Skip to content
Snippets Groups Projects
Commit 4f670e91 authored by Anna Mareike Kostelecky's avatar Anna Mareike Kostelecky
Browse files

[doc][slides] add md-file for runtimeparams-grids

parent cf5deb21
No related branches found
No related tags found
1 merge request!158[doc][slides] Add md-file for runtimeparams-grids
Pipeline #30394 waiting for manual action
slides/img/parameterlist.png

298 KiB

slides/img/params_grid.png

12.7 KiB

--- ---
title: DuMuX Course Slides title: DuMuX Course Slides
--- ---
- [Introduction to DuMu^x^](./intro.html) - [Introduction to DuMu^x^](./intro.html)
- [Runtime Parameters and Grids](./runtimeparams-grids.html)
- [Property System](./properties.html) - [Property System](./properties.html)
- [Model](./model.html) - [Model](./model.html)
- [Introduction to Multidomain](./multidomain.html) - [Introduction to Multidomain](./multidomain.html)
......
---
title: Runtime Parameters and Grids
subtitle: Introduction to DuMu$^\mathsf{X}$
---
# Runtime Parameters
## Runtime Parameters
* Avoid recompiling
* The same executable can be used to test different sets of parameters via shell script.
<p style="text-align: left;">Practical concern:</p>
* If the parameter can be set at compile time, it is often cleaner and faster to do so. Only use parameters, when it is needed.
## Input-file contents
* Input file syntax:
```ini
[MyGroup]
MyParameter = 2
```
* Examples:
| Groups | Parameters | | |
|-----------|---------------|---------------|------------|
| Component | GasDensity | LiquidDensity | MolarMass |
| Problem | EnableGravity | Name | |
| Grid | Cells | LowerLeft | UpperRight |
## Reading Runtime Parameters
* Use runtime parameters in any file in DuMu$^\mathsf{X}$
```cpp
paramname_ = getParam<TYPE>(GROUPNAME.PARAMNAME);
```
or
```cpp
paramname_ = getParamFromGroup<TYPE>("GROUPNAME", "PARAMNAME");
```
* You can also set a default value when calling a runtime parameter. In case that no parameter is set at runtime, the default value will be used. Be careful! Many parameters already have a default value.
```cpp
paramname_ = getParam<TYPE>(GROUPNAME.PARAMNAME, default);
```
## Reading Runtime Parameters
* Remark: If you need to read in a parameter multiple times in for one problem, use `static const` to reduce runtime. E.g.
```cpp
static const bool enableGravity = getParam<bool>("Problem.EnableGravity");
```
## Functions hasParam and hasParamInGroup
* Check: Parameter in input file?
```cpp
if (hasParam("GROUPNAME.PARAMNAME"))
std::cout << "GROUPNAME.PARAMNAME is read from the input file." << std::endl;
else
std::cout << "Using the default value for GROUPNAME.PARAMNAME." << std::endl;
```
* Another way of writing the upper
```cpp
if (hasParamInGroup("GROUPNAME","PARAMNAME"))
```
instead of
```cpp
if (hasParam("GROUPNAME.PARAMNAME"))
```
## Parameter list
An overview of all available parameters can be found in the [doxygen documentation](https://dumux.org/docs/doxygen/releases/3.6/a00008.html).
<img src=img/parameterlist.png>
# Grids
## Grid types
* **YASPGrid** (structured, n-dimensional, parallel tensorproduct grid)
* **UGGrid** (2D/3D, unstructured, parallel, multi-geometry)
* **ALUGrid** (2D/3D, unstructured, parallel, simplex/cube)
* **FOAMGrid** (1D-2D, Dynamic, Multi-dimension/Network Problems)
* **OPMGrid** (Cornerpoint grids)
## Create grid
* Set grid types in properties file:
```cpp
// Set the grid type
template<class TypeTag>
struct Grid<TypeTag, TTag::Injection2p>{
using type = Dune::YaspGrid<2>;
};
```
* Include the matching grid manager header files in main file.
```cpp
// grid manager for yasp grid
#include <dumux/io/grid/gridmanager_yasp.hh>
```
* Create grid in the main file
```cpp
// try to create a grid (from a grid file or the input file)
GridManager<GetPropType<TypeTag, Properties::Grid>> gridManager;
gridManager.init();
```
## Grid from file
* Read in grid from file (specified in input-file)
```ini
[Grid]
File = ./grids/heterogeneousSmall.dgf
# relative path to the grid file
```
* Supported grid file formats
* DGF (Dune grid format)
* Gmsh (gmsh.info)
* Cornerpoint grid format (.grdecl file, see opm)
## Grid from input
* Develop grid from basic spatial descriptions (specified in input-file)
```ini
[Grid]
LowerLeft = 0 0 # x, y entry (3 entries for 3D)
UpperRight = 1 1
Cells = 10 5
```
<img src=img/params_grid.png width="300">
# Excercises
## Exercises
<p style="text-align: left;">Exercise about runtime parameters:</p>
* Go to [https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/tree/master/exercises/exercise-runtimeparams](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/tree/master/exercises/exercise-runtimeparams) and check out the README
<p style="text-align: left;">Exercise about grids:</p>
* Go to [https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/tree/master/exercises/exercise-grids](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/tree/master/exercises/exercise-grids) and check out the README
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