function []=nonunifgrid(itype) % Numerical experiments with finite volume solution of % convection-diffusion equation on uniform and non-uniform grids % Needs: convection_diffusion.m, exact_solution.m % [norminf]=convection_diffusion(a,b,pe,m1,m2,refinement,pl) % Input parameters % a Left Dirichlet value % b Right Dirichlet value % pe Peclet number % m1 Number of cells outside refinement zone % m2 Number of cells inside refinement zone % refinement 1 local grid refinement (del = 8/Pe) % 0 uniform grid % pl = 1 Plot results % % Output parameter % norminf maximum error if itype==0 % Solve different examples (show zooms) convection_diffusion(0, 1, 40, 16, 0, 0, 1) % Nonuniform, 16 cells % convection_diffusion(0, 1, 40, 8, 8, 1, 1) % Uniform, 16 cells % convection_diffusion(0, 1, 40, 40, 0, 0, 1) % Same error as % % nonuniform (40 cells) % convection_diffusion(0, 1, 1000, 8, 8, 1, 1) % Same error, Pe = 1000 % convection_diffusion(0, 1, 1000, 16, 0, 0, 1) % Pe = 1000, uniform % convection_diffusion(0, 1, 1000, 8, 32, 1, 1) % Low error, > points \ % in BL only elseif itype==1 % Vary Pe for a fixed number of grid points on nonuniform grid for j = 1:6 pe(j) = 2^(j+4); norminf(j)=convection_diffusion(0,1,pe(j),8,8,1,0); end plot(pe,norminf,'o-');grid on; xlabel('Pe');ylabel('Error'); axis([0 1200 0 0.2]); elseif itype == 2 % Vary number of grid points for fixed Pe on nonuniform grid pe = 1e2; for j = 1:8 m1(j) = 8*2^j; m2(j) = 4*2^j; norminf(j)=convection_diffusion(0,1,pe,m1(j),m2(j),1,0); end loglog(m1+m2,norminf,'o');xlabel('J');ylabel('Error');hold on; loglog(m1+m2,2e1*(m1+m2).^(-2)*3.5); legend('Error','J^{-2}'); end