A DuMux model is an implementation of a discretized mathematical model, generally given by partial differential equations.
Mathematical model (PDE): \(\begin{equation*} \small \frac{\partial S(u)}{\partial t} + \nabla \cdot \mathbf{F}(u) = q, \quad \forall (t,\mathbf{x}) \in (0,T] \times \Omega \end{equation*}\)
Discrete model, e.g. using finite volumes: \(\begin{equation*} \small |B| \frac{S_h(\mathbf{u}^{n+1}_h) - S_h(\mathbf{u}^{n}_h)}{\Delta t} + \sum_{\sigma \in \Sigma_B} F_{B,\sigma}(\mathbf{u}^{n+1}_h) = \int_{B} q^{n+1} \, dx, \quad \forall t_{n+1}\leq T, \; \forall B \end{equation*}\)
Discrete model, e.g. using finite volumes: \(\begin{equation*} \small |B| \frac{S_h(\mathbf{u}^{n+1}_h) - S_h(\mathbf{u}^{n}_h)}{\Delta t} + \sum_{\sigma \in \Sigma_B} F_{B,\sigma}(\mathbf{u}^{n+1}_h) = \int_{B} q \, dx, \quad \forall t_{n+1}\leq T, \; \forall B \end{equation*}\)
Where to implement these terms in DuMux?
LocalResidual
LocalResidual
LocalResidual
Implements terms of a PDE in the functions
computeStorage(...)
computeFlux(...)
computeSource(...)
Mathematical model (PDE):
\(\begin{equation} \frac{\partial c}{\partial t} - \nabla \cdot (D \nabla c) = 0 \:\: \mathrm{in}\; \Omega \times (0,T] \\ \end{equation}\)
with
Discrete model using the Box discretization:
\(\begin{equation} \vert B \vert \frac{c_B^{n+1}-c_B^{n}}{\Delta t} - \sum_{\sigma \in \Sigma_{B}} \left[ D \nabla c_h^{n+1} \cdot \boldsymbol{n}_{B,\sigma} \vert \sigma \vert \right] = 0, \end{equation}\)
with
Discrete model using the Box discretization:
\(\begin{equation} \vert B \vert \frac{c_B^{n+1}-c_B^{n}}{\Delta t} - \sum_{\sigma \in \Sigma_{B}} \left[ D \nabla c_h^{n+1} \cdot \boldsymbol{n}_{B,\sigma} \vert \sigma \vert \right] = 0, \end{equation}\)
LocalResidual
The local residual of the diffusion model:
template<class TypeTag>
class DiffusionModelLocalResidual
: public GetPropType<TypeTag, Properties::BaseLocalResidual>
{
...
}
Inherits from the BaseLocalResidual
, which is chosen
depending on the discretization scheme, here Box scheme.
\(\begin{equation} F_{B,\sigma} = -D \nabla c_h^{n+1} \cdot \boldsymbol{n}_{B,\sigma} \vert \sigma \vert \end{equation}\)
with
NumEqVector computeFlux(...) const
{
// Compute ∇c
const auto& fluxVarCache = elemFluxVarsCache[scvf];
Dune::FieldVector<Scalar, dimWorld> gradConcentration(0.0);
for (const auto& scv : scvs(fvGeometry))
{
const auto& volVars = elemVolVars[scv];
gradConcentration.axpy(
volVars.priVar(Indices::concentrationIdx),
fluxVarCache.gradN(scv.indexInElement())
);
}
...
}
LocalResidual
A LocalResidual
implements the discretized mathematical
model.
For its implementation different model-specific properties have to be set
The property tag is an empty struct with the respective name,
e.g. DiffusionModel
We can set nodel properties for the DiffusionModel
type
tag
All properties are defined within the namespace
Dumux::Properties
The type of the local residual is the class
DiffusionModelLocalResidual
defined from earlier
The model traits specify information about the model:
Further model specific properties can be set accordingly by using the
model property tag, i.e. TTag::DiffusionModel
Implementation of a nonlinear diffusion model for denoising of an MRI image