diff --git a/slides/img/parameterlist.png b/slides/img/parameterlist.png new file mode 100644 index 0000000000000000000000000000000000000000..e9fed1de96e4c9e391553aadb5a153a1956f4c1b Binary files /dev/null and b/slides/img/parameterlist.png differ diff --git a/slides/img/params_grid.png b/slides/img/params_grid.png new file mode 100644 index 0000000000000000000000000000000000000000..f7e98c75297ae3aa438ace8414c2b875605eccc9 Binary files /dev/null and b/slides/img/params_grid.png differ diff --git a/slides/index.md b/slides/index.md index f897d6a21cdcf1d0746e5593c735fca376565e94..7cc6ea7bd64d05875546244f24a2e6eded958b6f 100644 --- a/slides/index.md +++ b/slides/index.md @@ -1,8 +1,8 @@ --- title: DuMuX Course Slides --- - - [Introduction to DuMu^x^](./intro.html) +- [Runtime Parameters and Grids](./runtimeparams-grids.html) - [Property System](./properties.html) - [Model](./model.html) - [Introduction to Multidomain](./multidomain.html) diff --git a/slides/runtimeparams-grids.md b/slides/runtimeparams-grids.md new file mode 100644 index 0000000000000000000000000000000000000000..88f92372de3842a3b11e118568abbe3a6b0d1927 --- /dev/null +++ b/slides/runtimeparams-grids.md @@ -0,0 +1,146 @@ +--- +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