This tutorial shows a very easy example how to solve a 2-D advection-diffusion-reaction problem on a rectangular geometry at high Peclet numbers. It is intended to give basic introduction to using SUPG stabilization of advection diffusion problems in QuickerSim CFD Toolbox.
Let us solve the following problem
on a rectangle with source term everywhere and the following natural and essential boundary conditions:
Note that the above problem definition makes it identical to the corresponding 1-D advection-diffusion problem and the solution of our 2-D problem is constant with respect to y-coordinate and identical to the 1-D problem solution with respect to x-axis. We make this choice on purpose to be able to compute error norms of the numerical solution with respect to the analytical 1-D solution given in the following form:
Let us also define mesh Peclet number as . Mesh Peclet number expresses the ratio of total strength of convection on the mesh with given elemnt size h to the diffusion strength, adenotes advection velocity (in our 2-D case we will simply choose everywhere).
The Figure below shows ids of the left, right, bottom and top boundary, which we will need to use, when specifying boundary conditions.
% Clear MATLAB Command Window and Workspace clc; clear; % Define problem parameters a = 1; nu = 0.1; f = 1; % Read and dispaly mesh [p,e,t] = importMeshGmsh('rectangleDomain.msh'); [p,e,t,nVnodes,nPnodes,indices] = convertMeshToSecondOrder(p,e,t); displayMesh2D(p,t);
% Create advection velocity vectors with ax = a and ay = 0 ax = a*ones(nVnodes,1); ay = zeros(nVnodes,1); % Assemble advection and diffusion matrix and compute right hand side D = assembleDiffusionMatrix2D(p,t,nu); C = assembleScalarConvectionMatrix2D(p,t,nu,ax,ay,'nosupg'); F = assembleScalarSourceTerm2D(p,t,f); % We test now solving advection diffusion problem without SUPG ('nosupg' % flag above). Final problem matrix is a sum of D and C M = D + C; % Apply boundary conditions % % Let us impose essential (Dirichlet) boundary conditions on left (id = 10) % and right (id = 8) boundary. Since, bottom and top boundaries have % homogenous Neumann conditions (natural in finite element formulation) % we do not need to modify anything for the top and bottom walls. [M,F] = imposeScalarBoundaryCondition2D(p,e,M,F,10,'value',0); [M,F] = imposeScalarBoundaryCondition2D(p,e,M,F,8,'value',0); % Solve equations u = M\F; % Display solution figure(2) displaySolution2D(p,t,u,'u-values');
% Display 1-D solution figure(3) scatter(p(1,:), u); title('u-values'); xlabel('x') ylabel('u')
% Compute analytical solution x = p(1,:); ua = 1+(1/a)*(x-(1-exp(a/nu*x)/(1-exp(a/nu)))); % Plot both numerical and analytical 1-D solution figure(4) scatter(p(1,:),u); hold on; scatter(p(1,:),ua); legend('Numerical solution','Analytical solution','location','NorthWest'); title('u-values'); xlabel('x'); ylabel('u'); hold off;