The Advection-Diffusion Equation¶
Advection-diffusion equations describe how a quantity is transported through a medium by two competing mechanisms: advection (bulk transport carried along by a flow) and diffusion (spreading down a concentration gradient). In this work the quantity of interest is a species concentration in a fluid, specifically hydrogen, but the same equation governs heat transport, pollutant dispersion, and many other physical problems.
We consider the steady-state form for a scalar quantity (m):
where is a prescribed advective velocity field (ms), is the diffusion coefficient (ms), is a volumetric source term (ms), and is the computational domain.
The relative importance of the two transport mechanisms is captured by the cell Péclet number:
where is the local mesh element size. The Péclet number is a dimensionless ratio: large or small pushes it up, and small or large pushes it down.
When , diffusion dominates. The solution is smooth and the problem behaves like a standard Poisson (diffusion) equation. This type of problem is called elliptic, meaning the solution at any point is influenced smoothly by conditions everywhere in the domain, rather than being driven by information propagating in a particular direction.
When , advection dominates. The solution can develop sharp layers, which are thin regions of rapid concentration change near inflow boundaries or obstacles. These are physically real but numerically difficult to resolve accurately.
Numerical Challenges and the Case for DG¶
Standard continuous Galerkin (CG) finite element methods work well when diffusion dominates, but as the Péclet number grows the solution develops oscillations that are entirely numerical in origin and have no physical meaning. To understand why, it helps to think about how information travels in an advection-dominated problem. If a fluid is moving to the right, the concentration at a point is determined by what is upstream, not downstream. A numerical scheme that respects this directionality is said to have upwinding: it biases the treatment of the advection term towards information coming from the upstream direction. Standard CG treats information from both sides of an element face symmetrically, which is appropriate for diffusion but wrong for advection, and this mismatch is what produces the spurious oscillations.
Several stabilisation strategies have been developed to recover stability within the CG framework:
Isotropic artificial diffusion adds an extra diffusion term uniformly in all directions, where is a dimensionless tuning parameter and is the local mesh size. It is simple to implement but inconsistent: the added term does not vanish even when the exact solution is substituted, meaning it permanently modifies the problem being solved. This introduces cross-stream smearing and reduces accuracy, particularly near sharp layers (COMSOL, 2020).
Streamline-upwind Petrov–Galerkin (SUPG) and Galerkin least-squares (GLS) are smarter approaches that add numerical diffusion only along the flow direction, not across it. They are consistent stabilisations, meaning the extra terms vanish exactly when the true solution is substituted into the equations, so the formal accuracy of the method is preserved. These are generally preferred over isotropic diffusion.
These methods can be effective, but all require tuning parameters, add complexity to the formulation, and are fundamentally workarounds for a framework not designed with advection-dominated transport in mind.
DG methods address the root cause rather than patching the symptom. In DG the approximate solution is allowed to be discontinuous across element boundaries, and information is passed between elements through numerical flux functions defined on each shared face. The choice of flux naturally encodes upwinding for the advection term, without any add-on stabilisation. This gives DG several structural advantages:
Natural upwinding: upwind information transfer is built directly into the flux formulation, so no stabilisation parameter needs to be tuned for the advection term.
Local conservation: the flux balance is satisfied element by element, which is important for transport quantities.
Flexible boundary conditions: all conditions are imposed weakly through face integrals, giving a consistent treatment across different condition types.
High-order accuracy: high-degree polynomial spaces can be used on unstructured meshes without additional complications.
The trade-off is a larger global system (DG has more degrees of freedom than CG for the same mesh) and the need to choose a penalty parameter for the diffusion term carefully. Both are manageable in practice.
Derivation of the DG Weak Form¶
Notation¶
The domain is divided into a mesh : a collection of non-overlapping elements , triangles in 2D or tetrahedra in 3D, that together cover . The subscript refers to the typical element size.
Within this mesh, every shared boundary between two adjacent elements is an interior face. The set of all interior faces is , and the set of faces on the outer boundary of is .
In DG, the approximate solution is allowed to be a different polynomial on each element and may be discontinuous across element boundaries. The function space that encodes this is:
This says: contains all functions that, when restricted to any element , are a polynomial of degree at most , with no continuity requirement between elements.
Because solutions in can be discontinuous, each interior face has two values, one from each neighbouring element and . Let be the outward unit normal from (pointing into ). For a quantity with values and on each side, we define the average and jump operators:
The average is the mean value across the face; the jump measures the size of the discontinuity, which is zero if the solution is continuous at that face. For a vector :
where is the scalar normal jump. On a boundary face there is only one element, so and .
From Strong Form to Weak Form¶
The strong form of the PDE is an equation that must hold pointwise everywhere in , requiring to be smooth enough to be differentiated twice. On a mesh where the solution can be discontinuous, this is too strict.
The weak form relaxes this by multiplying the PDE by a test function and integrating over the domain. Rather than demanding the equation hold at every point, we demand it holds in an average sense against every possible . The test function is chosen from the same space as the solution, which is called the Galerkin approach.
We derive the weak form element by element. Multiplying by and integrating over a single element gives:
Applying the divergence theorem (the multi-dimensional analogue of integration by parts) moves one derivative off and onto , reducing the smoothness requirement on . It also produces boundary integrals on , which represent the flux of information through the faces of element :
To form the global problem we sum over all elements . The face integrals on are shared between neighbouring elements and must be assembled carefully using the average and jump operators. The treatment of the advection and diffusion face terms differs, and is described in the two sections below.
Diffusion Term: SIPG¶
When we sum the diffusion face integrals over all elements, each interior face is counted twice, once from each side. Using the average and jump operators this collapses to:
For a smooth exact solution, the normal gradient is the same on both sides of every face, so and the second interior term vanishes. We can drop it without changing which solutions satisfy the equations, a property called consistency. After dropping it, however, the resulting form is not symmetric and is not yet stable. The Symmetric Interior Penalty Galerkin (SIPG) method adds two further face terms to fix both issues:
The role of each term:
Bulk diffusion: the standard integral, identical to standard Galerkin for pure diffusion.
Consistency: the face flux term from integration by parts. It vanishes when the exact solution is substituted, so it does not change which solutions the equations accept.
Symmetry: the consistency term with and swapped. It is also zero for the exact solution, but its presence symmetrises the formulation, which is needed for a well-posed system.
Penalty: penalises the size of the jump across interior faces. This prevents the solution from becoming arbitrarily discontinuous and ensures the method is coercive, meaning the residual is bounded away from zero, which guarantees stability. The penalty parameter is (with and the polynomial degree); it must be chosen large enough for stability, but not so large that it over-constrains the solution.
Advection Term: Upwind Flux¶
When the advection face integrals are summed over all elements, each interior face produces a term involving evaluated from both sides. Since is discontinuous, we must choose which value to use, and this is where upwinding is applied.
The upwind value of on face is:
Always take from the element the flow is coming from. This is the DG implementation of the upwinding principle, and it can be written compactly as:
The interior advection contribution is then:
The bulk advection term moves information within each element; the interior upwind flux passes information between elements using the upstream value. Together they give DG its natural stability for advection without any additional tuning parameter.
Note: the compact identity for assumes is single-valued on . This holds when is prescribed analytically or lives in a continuous FE space, but requires care when the velocity is interpolated from an external solver, as discussed in the section on coupling with an external velocity field.
Boundary contributions depend on the flow direction and are treated in the next section.
Boundary Conditions¶
Each type of boundary condition enters the formulation by modifying the face integrals on that appeared during integration by parts. On a boundary face there is only one element, so there is no “other side” to take values from. Instead, the boundary data closes the equations.
Diffusion¶
Dirichlet ( on ):
A Dirichlet condition prescribes the solution value directly. In a classical finite element method this would mean enforcing at shared nodes. In DG, where there are no shared nodes between elements, the condition is instead imposed weakly through the face integrals, by treating the boundary face exactly like an interior SIPG face but with playing the role of the solution on the outside. Written as a residual contribution in terms of the error :
When exactly, the symmetry and penalty terms vanish and only the flux consistency term remains, confirming the condition is satisfied.
Neumann ( on ):
A Neumann condition prescribes the flux through the boundary rather than the value. The diffusion face flux integral that arose from integration by parts is simply replaced by the prescribed value:
No penalty term is needed because we are specifying the gradient, not enforcing a value of . The homogeneous case (zero flux, such as an insulating or symmetry boundary) is the natural boundary condition for this formulation: it requires no additional terms at all, and is automatically satisfied if the boundary face integrals are simply omitted.
Robin ( on , ):
A Robin condition is a linear combination of the flux and the solution value. It arises in heat transfer (convective cooling at a surface) and in mass transfer (surface recombination of species). Substituting the Robin condition into the flux integral splits it into one term depending on and one depending on the data :
Advection¶
The advection term also produces boundary face integrals, and their treatment depends on whether flow is entering or leaving the domain at each face.
Inflow ( on ):
The flow is entering the domain, so the upwind value lies outside the domain. We prescribe it as , which moves the term to the right-hand side:
The minus sign and the fact that on mean this contributes positively for positive inflow data, which is physically correct: inflow adds concentration to the domain.
Outflow ( on ):
The flow is leaving the domain, so the upwind value is the interior trace . No data needs to be prescribed; the term is -dependent and enters the residual as:
Wall / Symmetry ( on ):
No advective flux crosses the boundary. The face integral is identically zero, so no term needs to be added.
The Complete Weak Formulation¶
In practice, FESTIM uses a nonlinear solver (Newton/SNES) even for problems that are formally linear, so the formulation is assembled as a single residual rather than as separate bilinear and linear forms. This has the added benefit that the same formulation extends directly to nonlinear problems, for example with a concentration-dependent diffusivity or a nonlinear boundary flux, without any structural change.
The residual form of the problem is: find such that for all , where is the sum of all contributions derived above:
On interior faces the jump since there; on faces it reduces to , penalising the departure from the prescribed value.
Coupling with an External Velocity Field¶
The formulation above assumes the velocity field is either prescribed analytically or lives in a continuous finite element space, is divergence-free (i.e. ) in the discrete sense, and has exactly zero normal component on walls. When is supplied by an external solver such as OpenFOAM, each of these assumptions requires care. The issues divide into three groups.
Single-valued face flux¶
In the interior advection term, we used the compact identity
which assumes is the same on both sides of every interior face, i.e. . OpenFOAM satisfies this naturally: it stores face-normal mass fluxes that are single-valued per face by construction. However, if the cell-centred velocity is interpolated into a DG space on the transport mesh and is reconstructed from it, the two sides of each interior face will in general give different values, breaking the identity. Two fixes are available:
Replace the compact identity with an explicit upwind flux that does not assume single-valuedness:
Transfer the face-flux field directly from OpenFOAM and use it as the advective transport coefficient on each face, replacing by (or by for a volumetric flux). The upwind branch is selected on the sign of . This option preserves OpenFOAM’s flux conservation exactly and is generally preferred.
In either case the boundary face integrals on and must use the same face flux consistently, not a reconstructed , so that the inflow and outflow classification remains consistent with the interior treatment.
Discrete divergence¶
A divergence-free velocity field satisfies , meaning there is no net creation or destruction of fluid volume at any point. The physical flow is divergence-free, but an interpolated velocity field on the transport mesh generally is not. This matters because the two advection forms
differ by , which is zero in the continuous problem but acts as a spurious source when . Two options are available:
Use the non-conservative form when deriving the weak form. This reduces sensitivity to interpolation error in at the cost of losing element-by-element conservation, and is the pragmatic choice when the velocity is known only approximately.
Project onto a divergence-conforming finite element space (such as Raviart-Thomas or BDM), which enforces exactly at the discrete level. This keeps the conservative form valid but adds a projection step and couples the transport mesh more tightly to the flow discretisation.
When the face-flux form (option 2 above) is used, conservation is enforced through directly and this divergence issue does not arise in the same way.
Wall boundary flux¶
On no-slip or symmetry walls the physical condition is , and the corresponding advection face integral vanishes. An interpolated velocity field rarely satisfies this exactly, and a small residual normal component acts as a spurious inflow or outflow. The safest fix is to enforce explicitly on wall faces, either by zeroing the integrand or by using the face-flux field , which is identically zero on OpenFOAM wall patches and therefore introduces no spurious flux.
Mesh transfer¶
All of the above assumes that velocity data defined on the OpenFOAM mesh has already been transferred to the transport mesh. Mesh-to-mesh interpolation is itself a source of error, particularly near boundaries and in regions with large velocity gradients, and its treatment is outside the scope of this document. We assume that either a face-flux field or a cell-centred velocity field has been made available on the transport mesh by an appropriate interpolation method.