Expand description
Layer 3 — optional source terms attached to finite-volume equations,
OpenFOAM’s fvOptions (Foundation fvModels) mechanism.
Optional source terms added to finite-volume equations — OpenFOAM’s
fvOptions mechanism.
§What this is for
A solver assembles a fixed equation — momentum, energy, a transported
scalar. Real cases then need extra terms in it that the solver itself
knows nothing about: a heat source in one region, a porous drag in another,
a phase-change latent heat, a momentum sink representing a fan. Editing the
solver for each is unworkable, so OpenFOAM lets a case attach source terms
to named equations from the outside. That is fvOptions.
The pattern is the same everywhere it appears:
solve( ddt(rho, U) + div(phi, U) - laplacian(mu, U) == fvModels.source(rho, U) );The solver names the equation; the case decides what, if anything, is added to it.
§A note on the name
What ESI OpenFOAM (openfoam.com) calls fvOptions, the OpenFOAM
Foundation (openfoam.org) split into fvModels — terms that add
sources to an equation — and fvConstraints — terms that constrain
a solution, such as fixing a value in a cell set. This port follows the
Foundation split, because the vendored reference tree is the Foundation
one, but the module is named fv_options because that is the name most
users will search for. FvModel is the source half; constraints are not
yet ported.
§Why this lives in outram-foam-basic-lib
It operates directly on FvMatrix, and every
solver crate needs it — the multiphase, turbulence and application layers
all assemble equations that a case may want to add to. Putting it in a
solver crate would make it unavailable to the others. This mirrors
OpenFOAM’s own dependency position, where fvOptions/fvModels sits
directly on finiteVolume.
§Sign convention, and the trap in it
Sources are added to the right-hand side, i.e. the equation reads
ddt(...) + div(...) == source. A positive scalar source therefore
increases the solved quantity.
Internally an FvMatrix stores the system as A·φ = b, so a right-hand
side contribution goes into source, while an implicit contribution
proportional to φ goes onto the diagonal with the opposite sign. That
asymmetry is the classic way to get a source term backwards, so
FvModel never asks a caller to place terms by hand:
add_source_scalar and
add_source_vector do the
placement, and the
individual models express themselves as an explicit part and an implicit
coefficient.
§Cell selection
Every model applies over a
CellSelection — the whole mesh, or a named
subset. This is upstream’s cellSetOption/fvCellZone. Selections hold
their cell list behind an Arc, per the workspace rule against lifetime
parameters, so sharing one selection between several models is free.
Structs§
- Equation
Field - Which equation a source term is being applied to.
- FvModels
- A collection of source terms, applied together to an equation.
- Semi
Implicit Source - A constant source term with an explicit and an implicit part.
- Solidification
Melting - Solidification and melting of a pure or eutectic material.
- Solidification
Melting Coefficients - Material and numerical coefficients of the melting model.
- Solidification
Porosity - Simple solidification as a porous blockage — upstream
porosityModels::solidification. - Source
Contribution - The explicit and implicit halves of a source term, per cell.
- Temperature
Table - A monotone-in-temperature lookup table with linear interpolation and end-clamping.
- VofSolidification
Melting - Solidification and melting of the condensed phase of a VoF simulation.
Enums§
- Cell
Selection - The set of cells a source term acts on.
- FvModel
- One optional source term.
- Momentum
Equation Form - Which momentum equation the drag is being added to.