@@ -17,7 +17,7 @@ For this task we will edit the following files:
* And the shared __input file__: `exercise_runtimeparams.input`
Parameters can either be directly defined within your program, or specified
via the input file. Within every main file, (*.cc), the following function
via the input file. Within every main file, (`*.cc`), the following function
is called, which will read in the imput file parameters
```c++
...
...
@@ -26,7 +26,7 @@ Parameters::init(argc, argv);
```
This input file should either be named the same as the executable file, with a
trailing ".input", as is standard in our CMake system, or be explicitly written
trailing `*.input`, as is standard in our CMake system, or be explicitly written
as the first shell argument after the executable file is called.
```bash
...
...
@@ -54,7 +54,7 @@ When a parameter is defined directly within your program, you'll need to recompi
### Task 2: Setting a variable to collect a runtime parameter
<hr>
Let's free one of the variables in this exercise. Within the class `injection2p2cproblem.hh`, in the first line of the neumann boundary condition definition function neumannAtPos(-), the injection rate is defined as $`1e-4 kg/(s m^2)`$.
Let's free one of the variables in this exercise. Within the class `injection2p2cproblem.hh`, in the first line of the neumann boundary condition definition function `neumannAtPos(...)`, the injection rate is defined as $`1e-4 kg/(s m^2)`$.
```c++
// inject nitrogen. negative values mean injection
*`<PARAMNAME>` is the name of the parameter in the input file
An example of this is already performed in the problem constructor. The Injection Duration (injectionDuration_) is defined via the imput file, and can then be used later in the problem.
An example of this is already performed in the problem constructor. The Injection Duration (`injectionDuration_`) is defined via the imput file, and can then be used later in the problem.
with a runtime variable. (2a) Develop a new variable called totalAreaSpecificInflow_, (2b) record a value to this variable from a path in the input file, and (2c) incorporate this variable into the injection boundary condition.
with a runtime variable. (2a) Develop a new variable called `totalAreaSpecificInflow_`, (2b) record a value to this variable from a path in the input file, and (2c) incorporate this variable into the injection boundary condition.
When your problem file and the input file are edited, compile and run the exercise.
...
...
@@ -122,7 +122,7 @@ make exercise_runtimeparams && ./exercise_runtimeparams exercise_runtimeparams.i
### Task 3: Default Values for Runtime Parameters
<hr>
In the case that no path to a required runtime parameter is provided in the input file, the program will no longer run. You can try this if you like by removing the TotalAreaSpecificInflow from the input file. The resulting error message should look like this:
In the case that no path to a required runtime parameter is provided in the input file, the program will no longer run. You can try this if you like by removing the `TotalAreaSpecificInflow` from the input file. The resulting error message should look like this:
Setting default values for variables defined with runtime parameters can also lead to problems. If one runtime parameter from the input file is set to multiple different variables, each with a different Default value, changing the variable in one location can lead to unexpected changes elsewhere. On top of this, in DUMUX, there are a few base variables that are set with default values for all dumux simulations. These can be found in the header file `dumux/common/parameters.hh` in the function `globalDefaultParameters`.
Setting default values for variables defined with runtime parameters can also lead to problems. If one runtime parameter from the input file is set to multiple different variables, each with a different Default value, changing the variable in one location can lead to unexpected changes elsewhere. On top of this, in DuMu<sup>x</sup>, there are a few base variables that are set with default values for all DuMu<sup>x</sup> simulations. These can be found in the header file `dumux/common/parameters.hh` in the function `globalDefaultParameters`.
One way to check this is to use either the `hasParam()` or the `hasParamInGroup()` function. These bool functions will check to see if a parameter is read in via the input file. These functions are also both defined in the `dumux/dumux/common/parameters.hh` class, and follow a similar format to that of `getParam` and `getParamFromGroup`
One way to check this is to use either the `hasParam()` or the `hasParamInGroup()` function. These functions returning `bool`s will check to see if a parameter is read in via the input file. These functions are also both defined in the `dumux/dumux/common/parameters.hh` class, and follow a similar format to that of `getParam()` and `getParamFromGroup()`