|
From: | c. |
Subject: | Re: [Octave forge] [bim package] bim1a_advection* |
Date: | Sat, 11 Jan 2020 09:28:40 +0100 |
Hi JPi, The convention being adopted in BIM is that Diffusion Advection equations be written in the form: - (a * (u'(x) - b u(x)))' = f if the system you intend to solve is - A u'' + B u = f with A and B constant, you have to set a = A b = B/A Here is an example showing the correct convergence rate (order 1 for upwind, independent of the peclet number) on a steady state problem : nn = 20 * 2.^ (1:5); for ii = 1 : numel (nn) n = nn(ii); mesh = linspace(0,1,n+1)'; uex = @(r) - r.^2 + 1; Nnodes = numel(mesh); Nelements = Nnodes-1; D = 1; v = 1; sigma = 0; alpha = D*ones(Nelements,1); gamma = ones(Nnodes,1); eta = ones(Nnodes,1); beta = 1/D*v*ones(Nelements,1); delta = ones(Nelements,1); zeta = sigma*ones(Nnodes,1); f = @(r) 2*D - 2*v.*r + sigma*uex(r); rhs = bim1a_rhs(mesh, ones(Nelements,1), f(mesh)); S = bim1a_laplacian(mesh,alpha,gamma); A = bim1a_advection_upwind(mesh, beta); R = bim1a_reaction(mesh, delta, zeta); S += (A+R); u = zeros(Nnodes,1); u([1 end]) = uex(mesh([1 end])); u(2:end-1) = S(2:end-1,2:end-1)\(rhs(2:end-1) - S(2:end-1,[1 end])*u([1 end])); err(ii) = norm (u - uex(mesh), inf); endfor loglog (nn, err, nn, 1./nn) In your example, if I understand correctly what you want to do, I suggest changing the following : Diff = bim1a_laplacian (msh{i}, 1, a); Conv = bim1a_advection_upwind (msh{i}, b * msh{i});to Diff = bim1a_laplacian (msh{i}, a, 1); Conv = bim1a_advection_upwind (msh{i}, (b/a) * ones (size (msh{i}))); (why did you multiply b by the mesh node coordinates? was that intentional?) c. |
[Prev in Thread] | Current Thread | [Next in Thread] |