Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
diff -ruN exercises/exercise-properties/CMakeLists.txt exercises/solution/exercise-properties/CMakeLists.txt
--- exercises/exercise-properties/CMakeLists.txt 2023-06-01 14:31:33.153063018 +0200
+++ exercises/solution/exercise-properties/CMakeLists.txt 2023-04-26 14:37:49.797150837 +0200
@@ -1,5 +1,5 @@
-# the property exercise simulation program
-dumux_add_test(NAME exercise_properties
+# the solution to the properties exercise
+dumux_add_test(NAME exercise_properties_solution
SOURCES main.cc)
# add a symlink for each input file
diff -ruN exercises/exercise-properties/mylocalresidual.hh exercises/solution/exercise-properties/mylocalresidual.hh
--- exercises/exercise-properties/mylocalresidual.hh 2023-06-01 14:31:33.153063018 +0200
+++ exercises/solution/exercise-properties/mylocalresidual.hh 2023-04-26 14:37:49.797150837 +0200
@@ -71,8 +71,6 @@
* \note The volVars can be different to allow computing
* the implicit euler time derivative here
*/
- // TODO: dumux-course-task 3
- // Eliminate density from the storage term
NumEqVector computeStorage(const Problem& problem,
const SubControlVolume& scv,
const VolumeVariables& volVars) const
@@ -83,7 +81,6 @@
{
auto eqIdx = conti0EqIdx + phaseIdx;
storage[eqIdx] = volVars.porosity()
- * volVars.density(phaseIdx)
* volVars.saturation(phaseIdx);
//! The energy storage in the fluid phase with index phaseIdx
@@ -107,8 +104,6 @@
* \param scvf The sub control volume face to compute the flux on
* \param elemFluxVarsCache The cache related to flux computation
*/
- // TODO: dumux-course-task
- // Eliminate the density from the flux term
NumEqVector computeFlux(const Problem& problem,
const Element& element,
const FVElementGeometry& fvGeometry,
@@ -124,7 +119,7 @@
{
// the physical quantities for which we perform upwinding
auto upwindTerm = [phaseIdx](const auto& volVars)
- { return volVars.density(phaseIdx)*volVars.mobility(phaseIdx); };
+ { return volVars.mobility(phaseIdx); };
auto eqIdx = conti0EqIdx + phaseIdx;
flux[eqIdx] = fluxVars.advectiveFlux(phaseIdx, upwindTerm);
diff -ruN exercises/exercise-properties/problem.hh exercises/solution/exercise-properties/problem.hh
--- exercises/exercise-properties/problem.hh 2023-06-01 14:31:33.153063018 +0200
+++ exercises/solution/exercise-properties/problem.hh 2023-04-26 14:37:49.797150837 +0200
@@ -23,6 +23,7 @@
#ifndef DUMUX_INCOMPRESSIBLE_TWOP_TEST_PROBLEM_HH
#define DUMUX_INCOMPRESSIBLE_TWOP_TEST_PROBLEM_HH
+#include <dumux/material/components/trichloroethene.hh>
#include <dumux/porousmediumflow/problem.hh>
#include <dumux/common/properties.hh>
#include <dumux/common/boundarytypes.hh>
@@ -119,10 +120,12 @@
*/
NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
{
-// TODO: reformulate the neumann boundary condition's values in terms of volume instead of mass injected per meter and second
NumEqVector values(0.0);
if (onInlet_(globalPos))
- values[contiDNAPLEqIdx] = -0.04; // kg / (m * s)
+ {
+ using TCE = Components::Trichloroethene<Scalar>;
+ values[contiDNAPLEqIdx] = -0.04/TCE::liquidDensity(this->spatialParams().temperatureAtPos(globalPos), /*pressure=*/1e5);// m/s
+ }
return values;
}
diff -ruN exercises/exercise-properties/properties.hh exercises/solution/exercise-properties/properties.hh
--- exercises/exercise-properties/properties.hh 2023-06-01 14:31:33.157063038 +0200
+++ exercises/solution/exercise-properties/properties.hh 2023-04-26 14:37:49.797150837 +0200
@@ -39,9 +39,7 @@
#include "spatialparams.hh"
#include "problem.hh"
-
-// TODO: dumux-course-task 3
-// Include the local residual header
+#include "mylocalresidual.hh"
namespace Dumux::Properties {
@@ -59,9 +57,8 @@
template<class TypeTag>
struct Problem<TypeTag, TTag::TwoPIncompressible> { using type = TwoPTestProblem<TypeTag>; };
-// TODO: dumux-course-task 3
-// Use MyLocalResidual as LocalResidual
-
+template<class TypeTag>
+struct LocalResidual<TypeTag, TTag::TwoPIncompressible> { using type = MyLocalResidual<TypeTag>; };
// Set the fluid system
template<class TypeTag>
diff -ruN exercises/exercise-properties/README.md exercises/solution/exercise-properties/README.md
--- exercises/exercise-properties/README.md 2023-06-01 14:31:33.153063018 +0200
+++ exercises/solution/exercise-properties/README.md 1970-01-01 01:00:00.000000000 +0100
@@ -1,75 +0,0 @@
-# Exercise Properties (DuMuX course)
-<br>
-
-## Problem set-up
-
-The problem setup is identical to the two-phase incompressible test from DuMu<sup>x</sup>.
-
-## Preparing the exercise
-
-* Navigate to the directory `exercise-properties`
-
-_Exercise Properties_ deals with a two-phase immiscible incompressible problem (__2p__). The goal is to learn how to adapt compile-time parameters by employing the _DuMu<sup>x</sup> property system_.
-
-<br><br>
-### Task 1: Getting familiar with the code
-<hr>
-
-Locate all the files you will need for this exercise
-* The __main file__: `main.cc`
-* The __problem file__: `problem.hh`
-* The __properties file__: `properties.hh`
-* The __spatial parameters file__: `spatialparams.hh`
-* The __input file__: `params.input`
-* One header file containing:
- * a custom __local residual__ in: `mylocalresidual.hh`
-
-
-<br><br><br>
-### Task 2: Compiling and running the program
-<hr>
-
-* Change to the build-directory
-
-```bash
-cd ../../build-cmake/exercises/exercise-properties
-```
-
-* Compile the executable `exercise_properties`
-
-```bash
-make exercise_properties
-```
-
-* Run the problem and inspect the result
-
-```bash
-./exercise_properties
-```
-Note: Because the input file has the same name as the executable, DuMu<sup>x</sup> will find it automatically.
-
-
-<br><br><br>
-### Task 3: Implement a custom local residual
-<hr>
-
-Types that are properties can be changed on the problem level by using the property system. In the following task, we implement our own 2p local residual, i.e. the class that computes the element residual in every Newton iteration. The file `mylocalresidual.hh` contains a copy of the original local residual class used for all immiscible models renamed to `template<class TypeTag> class MyLocalResidual`.
-
-* Make DuMu<sup>x</sup> use this new local residual by including the header `mylocalresidual.hh` and setting the corresponding property in the `Properties` namespace in the file `properties.hh`
-
-```c++
-
-template<class TypeTag>
-struct LocalResidual<TypeTag, TTag::TwoPIncompressible>
-{
- using type = MyLocalResidual<TypeTag>;
-};
-```
-
-Simplify the original local residual by using the assumption that only incompressible fluid phases are present. As a consequence, one can balance phase volume instead of phase mass:
-
-* Eliminate the density from the `computeStorage` and the `computeFlux` methods.
-
-* Adapt the relevant routine in the problem file such that volume instead of mass is injected. The density of the employed NAPL is 1460 kg/m<sup>3</sup> . For a first try, you can use the hardcoded value.
-
-* Generalize your approach by using the component's `liquidDensity(t, p)` function instead of the hardcoded value.