diff --git a/slides/model.md b/slides/model.md index b0157c4344556c07a61f3885bdc7e00c24259d43..001fbd2800940c62e7050a9482a3d61f9872605f 100644 --- a/slides/model.md +++ b/slides/model.md @@ -1,11 +1,11 @@ --- -title: Models in DuMux +title: Models in DuMuX --- # Implementing a new DuMu<sup>X</sup> model ## What is a DuMu<sup>X</sup> model -A DuMu<sup>X</sup> model is an implementation of a **mathematical model**, generally given by partial differential equations, by using **discretization** schemes. +A DuMu<sup>X</sup> model is an implementation of a discretized **mathematical model**, generally given by partial differential equations. ## What is a DuMu<sup>X</sup> model Mathematical model (PDE): @@ -29,8 +29,8 @@ $\begin{equation*} |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*}$ -* $S_h$: storage calculation -* $F_{B,\sigma}$: flux over sub control volume face +* $S_h$: storage term +* $F_{B,\sigma}$: flux term over sub control volume face (scvf) * $q$ source term How to implement these terms in DuMu<sup>X</sup>? @@ -75,31 +75,22 @@ with $\begin{aligned} c_B^n: &\:\text{concentration at time $t_n$ and control volume $B$} \\ - c_h: &\:\text{global discrete solution, interpolation using \textbf{basis functions}} \\ + c^n_h: &\:\text{global discrete solution at time $t_n$, interpolated using \textbf{basis functions}} \\ \mathbf{n}: &\:\text{unit outer normal vector} \\ - \sigma: &\:\text{sub control volume face} \\ + \sigma: &\:\text{sub control volume face (scvf)} \\ \end{aligned}$ - ## Local residual The local residual of the diffusion model: ```cpp -namespace Dumux { -template<class TypeTag> -class DiffusionModelLocalResidual -: public GetPropType<TypeTag, Properties::BaseLocalResidual> -{ -``` - -## Local residual -```cpp -namespace Dumux { template<class TypeTag> class DiffusionModelLocalResidual : public GetPropType<TypeTag, Properties::BaseLocalResidual> { + ... +} ``` -Our class inherits from the class `BaseLocalResidual`, which has to be chosen depending on the discretization scheme, here *Box scheme*. +Inherits from the `BaseLocalResidual`, which is chosen depending on the discretization scheme, here *Box scheme*. ## Storage term ```cpp @@ -107,10 +98,10 @@ NumEqVector computeStorage(const Problem& problem, const SubControlVolume& scv, const VolumeVariables& volVars) const { - NumEqVector storage; - storage[Indices::massBalanceEqIdx] + NumEqVector storage; + storage[Indices::massBalanceEqIdx] = volVars.priVar(Indices::concentrationIdx); - return storage; + return storage; } ``` @@ -123,29 +114,29 @@ F_{B,\sigma} = -D \nabla c_h^{n+1} \cdot \boldsymbol{n}_{B,\sigma} \vert \sigma with $\begin{aligned} - c_h: &\:\text{discrete solution, interpolated using basis functions} \\ - \sigma: &\:\text{sub control volume face} \\ + c^n_h: &\:\text{global discrete solution at time $t_n$, interpolated using \textbf{basis functions}} \\ + \mathbf{n}: &\:\text{unit outer normal vector} \\ + \sigma: &\:\text{sub control volume face (scvf)} \\ \end{aligned}$ ## Flux term -Implementation takes place in the dedicated function `computeFlux`: ```cpp - NumEqVector computeFlux(const Problem& problem, - const Element& element, - const FVElementGeometry& fvGeometry, - const ElementVolumeVariables& elemVolVars, - const SubControlVolumeFace& scvf, - const ElementFluxVariablesCache& elemFluxVarsCache) const - { +NumEqVector computeFlux(const Problem& problem, + const Element& element, + const FVElementGeometry& fvGeometry, + const ElementVolumeVariables& elemVolVars, + const SubControlVolumeFace& scvf, + const ElementFluxVariablesCache& elemFluxVarsCache) const +{ ... +} ``` ## Flux term -Implementation takes place in the dedicated function `computeFlux`: ```cpp - NumEqVector computeFlux(...) const - { - // Compute ∇c +NumEqVector computeFlux(...) const +{ + // Compute ∇c const auto& fluxVarCache = elemFluxVarsCache[scvf]; Dune::FieldVector<Scalar, dimWorld> gradConcentration(0.0); for (const auto& scv : scvs(fvGeometry)) @@ -157,14 +148,13 @@ Implementation takes place in the dedicated function `computeFlux`: ); } ... - } +} ``` ## Flux term -Implementation takes place in the dedicated function `computeFlux`: ```cpp - NumEqVector computeFlux(...) const - { +NumEqVector computeFlux(...) const +{ ... NumEqVector flux; @@ -174,13 +164,12 @@ Implementation takes place in the dedicated function `computeFlux`: )*scvf.area(); return flux; - - } +} ``` ## Local Residual -A *local residual* implements the discretized mathematical model. +A **local residual** implements the discretized mathematical model. For its implementation different model-specific properties have to be set @@ -197,12 +186,12 @@ struct DiffusionModel {}; } // end namespace Dumux::Properties::TTag ``` ## Model properties -By specializing properties for the type tag `DiffusionModel`, every other class that knows about the type tag (this will be for example the assembler or the problem), can extract the type information that we specify here. +We can set nodel properties for the `DiffusionModel` type tag All properties are defined within the namespace `Dumux::Properties` ```cpp namespace Dumux::Properties { - //define all properties + //define all properties } // end namespace Dumux::Properties ```