Skip to content
Snippets Groups Projects
Commit 88b1a77c authored by Timo Koch's avatar Timo Koch
Browse files

Merge branch 'exercise/model' into 'master'

[ex][model] Minor improvements

See merge request !167
parents ccf3bb0d 1573276d
No related branches found
No related tags found
1 merge request!167[ex][model] Minor improvements
Pipeline #30407 passed
# Exercise Model (DuMuX course)
The aim of this exercise is it to learn how to set up a new model (new system of equations).
As an example, we implement a nonlinear diffusion equation mode and apply it for image denoising.
As an example, we implement a nonlinear diffusion equation model and apply it for image denoising.
In this exercise, we will only consider the bare minimum of classes to successfully assemble
and solve such a problem with DuMux. We also implement the model for a specific discretization method
(the Box method: a vertex-centered finite volume method also known as control-volume finite element method with piece-wise linear basis functions).
......@@ -38,17 +38,17 @@ The diffusion example also derives the discrete equations using the Box method a
:arrow_right: Copy the `model.hh` file from the diffusion example into `dumux-course/exercises/exercise-model` and choose appropriate class names.
In the local residual, you can start with a hard-coded diffusion coefficient of `1.0` (linear diffusion coefficient function).
(Replace `problem.diffusionCoefficient()` by `1.0` because our problem class in `main.cc` does not have a `diffusionCoefficient()` interface.)
The goal is to get the simulation running first and then add improvements. For this, it is important to have a
compiling test such that new changes can continuously be tested.
Do also not forget to change the [include guards](https://en.wikipedia.org/wiki/Include_guard)
at the beginning of header files (`DUMUX_EXAMPLES_DIFFUSION_MODEL_HH`).
Include guards have to be unique in the entire application that you compile. (Otherwise some
code will not be included.) An alternative is using [`#pragma once`](https://en.wikipedia.org/wiki/Pragma_once)
which is widely supported but not specified by the C++ standard.
First, the goal is to get the simulation running and then add improvements. For this, it is important to have a
compiling test such that new changes can continuously be tested.
Thus, in the `computeFlux(...)` function of the local residual, you can start with a hard-coded diffusion coefficient of `1.0` (linear diffusion coefficient function).
(Replace `problem.diffusionCoefficient()` by `1.0` because our problem class in `main.cc` does not have a `diffusionCoefficient()` interface.)
Each model also needs to define a model type tag for setting model-specific properties.
:arrow_right: Rename the one of the diffusion model (`struct DiffusionModel {};`) to `NonlinearDiffusionModel`.
......@@ -81,9 +81,9 @@ const auto imageFileName = getParam<std::string>("ImageFile");
const auto imageData = NetPBMReader::readPGM(imageFileName);
```
### 3.1: Make Test type tag inherit properties from model type tag
### 3.1: Make test type tag inherit properties from model type tag
:arrow_right: Include the header `model.hh`
:arrow_right: Include the header `model.hh` <br>
:arrow_right: To use the new model for this test case, make
the test type tag inherit properties from the model type tag
......@@ -137,7 +137,7 @@ You can get the conductance $K$ via the problem interface `conductance`.
:arrow_right: Compare the `main.cc` with the `main.cc` of the diffusion example. Notice that we
use a Newton solver as we want to solve nonlinear equations.
As the DuMux assembler uses numeric differentation to approximate the Jacobian matrix, you do not have to implement
As the DuMux assembler uses numeric differentiation to approximate the Jacobian matrix, you do not have to implement
the derivatives of your residual by hand and implement them. This greatly simplifies implementing
nonlinear equations.
......@@ -155,7 +155,7 @@ __The final result should look like this:__
<figure>
<center>
<img src="../extradoc/exercisemodel_mri_denoise.gif" alt="denoising"/>
<figcaption> <b> Fig.1 </b> - Denosing og MRI image using nonlinear diffusion model.</figcaption>
<figcaption> <b> Fig.1 </b> - Denosing of MRI image using nonlinear diffusion model.</figcaption>
</center>
</figure>
......@@ -192,7 +192,7 @@ struct VolumeVariables<TypeTag, TTag::NonlinearDiffusionModel>
};
```
you can now use the interface `imageIntensity` in your local residual instead of the generic `priVar` interface.
You can now use the interface `imageIntensity` in your local residual instead of the generic `priVar` interface.
In order to simplify the implementation of your custom volume variables, you can
also inherit from `BasicVolumeVariables` and only implement the additional interface.
......@@ -202,7 +202,7 @@ To this end, we typically add an `Indices` struct to the `ModelTraits` in which
and equation indices are named (e.g. `static constexpr int imageIntensityIdx = 0;`).
The model traits can be passed to the volume variables class via the Traits class.
:arrow_right: Have a look a the solution to the exercise to see how this is usually implemented.
:arrow_right: Have a look at the solution of the exercise to see how this is usually implemented.
Names indices allow to address the entries of the local residual vector or the primary variables vector.
You will see names indices in every DuMux model.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment