PDE Solver using a Finite Element/Finite Volume approach: bim2a_advection_diffusion

### Categories &

#### Functions List

###### Matrix assembly

- bim1a_advection_diffusion
- bim1a_advection_upwind
- bim1a_axisymmetric_advection_diffusion
- bim1a_axisymmetric_advection_upwind
- bim2a_advection_diffusion
- bim2a_advection_upwind
- bim2a_axisymmetric_advection_diffusion
- bim2a_axisymmetric_advection_upwind
- bim3a_advection_diffusion
- bim3a_osc_advection_diffusion
- bim1a_laplacian
- bim1a_axisymmetric_laplacian
- bim2a_laplacian
- bim2a_axisymmetric_laplacian
- bim3a_laplacian
- bim3a_osc_laplacian
- bim1a_reaction
- bim1a_axisymmetric_reaction
- bim2a_reaction
- bim2a_axisymmetric_reaction
- bim3a_reaction
- bim1a_rhs
- bim1a_axisymmetric_rhs
- bim2a_rhs
- bim2a_axisymmetric_rhs
- bim3a_rhs
- bim2a_boundary_mass
- bim2a_axisymmetric_boundary_mass
- bim3a_boundary_mass

###### Pre-processing and Post-processing computations

- bim2c_mesh_properties
- bim3c_mesh_properties
- bim2c_unknowns_on_side
- bim3c_unknowns_on_faces
- bim2c_pde_gradient
- bim3c_pde_gradient
- bim2c_global_flux
- bim3c_global_flux
- bim1c_elem_to_nodes
- bim2c_tri_to_nodes
- bim3c_tri_to_nodes
- bim2c_intrp
- bim3c_intrp
- bim1c_norm
- bim2c_norm
- bim3c_norm

###### Utilities

- bimu_bernoulli
- bimu_logm

### Function Reference: `bim2a_advection_diffusion`

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

Source Code: bim2a_advection_diffusion