Navigation

Operators and Keywords

Function List:

C++ API

Function File: [A] = bim2a_advection_diffusion(mesh,alpha,gamma,eta,beta)

Build the Scharfetter-Gummel stabilized stiffness matrix for a diffusion-advection problem.

The equation taken into account is:

- div (alpha * gamma (eta grad (u) - beta u )) = f

where alpha is an element-wise constant scalar function, eta and gamma are piecewise linear conforming scalar functions, beta is an element-wise constant vector function.

Instead of passing the vector field beta directly one can pass a piecewise linear conforming scalar function phi as the last input. In such case beta = grad phi is assumed.

If phi is a single scalar value beta is assumed to be 0 in the whole domain.

Example:

 mesh = msh2m_structured_mesh([0:1/3:1],[0:1/3:1],1,1:4);
 mesh = bim2c_mesh_properties(mesh);
 x    = mesh.p(1,:)';

 Dnodes    = bim2c_unknowns_on_side(mesh,[2,4]);
 Nnodes    = columns(mesh.p);
 Nelements = columns(mesh.t);
 Varnodes  = setdiff(1:Nnodes,Dnodes);

 alpha  = ones(Nelements,1);
 eta    = .1*ones(Nnodes,1);
 beta   = [ones(1,Nelements);zeros(1,Nelements)];
 gamma  = ones(Nnodes,1);
 f      = bim2a_rhs(mesh,ones(Nnodes,1),ones(Nelements,1));

 S   = bim2a_advection_diffusion(mesh,alpha,gamma,eta,beta);
 u   = zeros(Nnodes,1);
 uex = x - (exp(10*x)-1)/(exp(10)-1);
 
 u(Varnodes) = S(Varnodes,Varnodes)\f(Varnodes);
 
 assert(u,uex,1e-7)
 

See also: bim2a_rhs, bim2a_reaction, bim2c_mesh_properties.

Package: bim