16. Solver Framework Reference#
16.1. 1 Solver#
Thermo / species update – solves energy and species equations ↳ updates density
ρand conductivityk.Velocity predictor - momentum equation in Patankar implicit form
Assemble momentum coefficients
Solve for provisional velocity v*.
Pressure correction
Build RHS from mass-flux imbalance
Solve Poisson system for pressure correction p′
Correct velocity & pressure:
(16.1.1)#\[\vec{v} \leftarrow \vec{v}^* - d_f \nabla p', \qquad p \leftarrow p + \alpha_p p'\]
Sparse matrix assembly & linear solve – update all coupled fields.
16.2. 2 Mesh & connectivity cheat‑sheet#
Name |
Type |
Meaning |
|---|---|---|
|
|
Cartesian coordinates of grid nodes $\vec{x}_i$ |
|
|
Ordered nodes defining each face (RH‑rule) |
|
|
Cell indices left / right of face, so $\hat{\vec{n}}$ points $cl \rightarrow cr$ |
|
|
Non‑zero structure of sparse matrix (transpose of |
|
|
Set of actual physical cells (excludes ghost) |
16.3. 2.5 Math-to-Code Naming Map#
The theory guide uses conventional mathematical symbols, while the implementation uses compact store names. The naming is not perfectly one-to-one, but there is enough overlap that a reader can usually use the following rules.
Code pattern |
Typical mathematical meaning |
Example |
|---|---|---|
|
provisional / predictor / pre-correction state |
|
|
correction quantity |
|
|
post-correction field before iteration advance |
|
|
diagonal, lower, upper, RHS of an assembled linear system |
|
|
central coefficient (a_P) |
|
The most common solver-variable correspondences are:
Mathematical meaning |
Theory notation |
Common code name(s) |
Notes |
|---|---|---|---|
Cell-centered velocity vector |
chapter-dependent (\vec{u}), (\vec{v}), or (\vec{V}) |
|
The code uses |
Provisional velocity after the momentum predictor |
(\vec{v}^{*}) |
|
Output of the momentum predictor solve. |
Corrected velocity after pressure correction |
(\vec{v}^{k+1}), (\vec{v}^{new}) |
|
Starts from |
Pressure correction |
(p’) |
|
Solution of the pressure-correction equation. |
Effective pressure correction actually used in updates |
(p’) |
|
Solution of the pressure-correction equation and value used in downstream updates. |
SIMPLER preliminary pressure |
(\tilde{p}) or the separate pressure-equation unknown |
|
Distinct from |
Central momentum coefficient |
(a_P) |
|
Raw diagonal of the discretized momentum equation. |
Under-relaxed predictor diagonal |
(a_P/\alpha_v) |
|
Diagonal used in the |
Pressure-free part of the momentum row |
(\mathcal{H}_u) |
|
Code-level analogue of the non-pressure momentum RHS. |
Face pressure-correction coefficient |
(d_f) or face correction coefficient |
|
Face-based pressure-velocity coupling coefficient. |
Provisional face volumetric flux |
(\dot V_f^{*}) |
|
The code stores a volumetric flux here, not a mass flux. |
Corrected face volumetric flux |
(\dot V_f^{corr}) |
|
Used after pressure correction in subsequent transport assembly. |
Face mass flux |
(\dot m_f) |
|
Usually formed from density times volumetric flux rather than stored as a primary variable. |
Velocity under-relaxation |
(\alpha_v) |
|
Relaxation used in the velocity predictor. |
Pressure-correction relaxation |
(\alpha_p) |
|
Used in the update (p \leftarrow p + \alpha_p p’). |
SIMPLER pressure-equation relaxation |
pressure-equation relaxation |
|
Separate from |
The important caveat is that the theory guide usually writes mass flux as (\dot m_f), whereas large parts of the code store volumetric flux as volFlux* and only multiply by density when a mass flux is needed.
16.4. 3 Momentum block (velocity predictor)#
vMainCoefficient#Raw diagonal \(a_P\) from discretised momentum equation.
vStar_D#\(a_P/\alpha_v\) – under‑relaxed diagonal used in the velocity predictor solve.
vStar_RelaxationFactor#Relaxation \(\alpha_v\;(0<\alpha\le1)\).
vStar_L,vStar_U#Off‑diagonal coefficients \(a_N\) stored through
loweranduppermaps.H(v)#Source vector \(b\) without \(a_P v_P\) term.
16.4.1. Key rule snippet#
$vStar_D = vMainCoefficient / vStar_RelaxationFactor$
If a cell is iblanked ($iblank>1$) we force the diagonal to 1 to decouple it.
16.5. 4 Pressure‑correction block#
Anything that ends in
_D,_L,_U,_Bis part of the sparse matrix \(\Matrix{A}_p p' = b_p\):Suffix
Meaning
_Ddiagonal \(a_P\)
_Llower neighbour coeff
_Uupper neighbour coeff
_BRHS / source term
The face coefficient
pPrimeCoefficientis the Rhie–Chow term \(d_f\). Every other pressure variable is assembled from this face value.
pPrimeCoefficient#Face factor (d_f = \rho_f,\alpha_v,F/\Delta x) used in Rhie–Chow interpolation. Computed per–face.
pPrime_RelaxationFactor#Pressure under-relaxation \(\alpha_p\).
pStar_RelaxationFactor#Relaxation used by the separate SIMPLER pressure equation (
pStar), not by the main pressure-correction update.pPrime_D#Under-relaxed diagonal \(a_P^{(p)}/\alpha_p\) for the Poisson matrix.
pPrime_L,pPrime_U#Lower / upper off-diagonals for sparse matrix \(\Matrix{A}_p\). Assembed from
pPrimeCoefficient.pPrime_B#Right-hand side \(b_p\): mass-flux imbalance + relaxation terms.
pPrime#Pressure correction \(p'\). At convergence \(p=p+\alpha_p p'\).
16.5.1. Matrix assembly snapshot#
Equation per cell \(P\):
// inside the pPrime_L/pPrime_U rule
pPrime_L = -pPrimeCoefficient / α_p # coefficient to right cell
pPrime_U = -pPrimeCoefficient / α_p # coefficient to left cell
pPrime_D += pPrimeCoefficient / α_p # accumulate diagonal
for every face f:
d_f = (ρ_f α_v) * (V_L/a_P_L + V_R/a_P_R)/2 * D_f
pStar_D[L] += d_f/α_p
pStar_D[R] += d_f/α_p
pStar_L = -d_f
pStar_U = -d_f
The pStar_* names in this sketch refer to the separate SIMPLER pressure-equation system. The directly corresponding pressure-correction system uses the pPrime_* names listed in the glossary above.
16.5.2. RHS build logic#
Add temporal \(Δ(\rho V)/Δt\) (
BDF/BDF2blocks).Subtract net mass flux (
tempMassFlux,faceMassFlux).Add relaxation \(\;(1-α_p)a_Pp\) and convert to delta form.
At solve completion:
16.6. 5 Life‑cycle of the pPrime variables#
Stage |
Variable |
Triggering rule tag |
|---|---|---|
Initialisation (it = 0) |
|
|
Assemble RHS |
|
|
Assemble coefficients |
|
rules containing |
Linear solve |
|
|
Out‑of‑loop update |
|
|