GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/test/porousmediumflow/richards/lens/problem.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 34 34 100.0%
Functions: 13 13 100.0%
Branches: 39 46 84.8%

Line Branch Exec Source
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 //
4 // SPDX-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 /*!
8 * \file
9 * \ingroup RichardsTests
10 * \brief A water infiltration problem with a low-permeability lens
11 * embedded into a high-permeability domain which uses the
12 * Richards box model.
13 */
14
15 #ifndef DUMUX_RICHARDS_LENSPROBLEM_HH
16 #define DUMUX_RICHARDS_LENSPROBLEM_HH
17
18 #include <dumux/common/properties.hh>
19 #include <dumux/common/parameters.hh>
20 #include <dumux/common/boundarytypes.hh>
21 #include <dumux/common/numeqvector.hh>
22
23 #include <dumux/porousmediumflow/problem.hh>
24
25 namespace Dumux {
26
27 /*!
28 * \ingroup RichardsTests
29 *
30 * \brief A water infiltration problem with a low-permeability lens
31 * embedded into a high-permeability domain which uses the
32 * Richards model.
33 *
34 * The domain is box shaped. Left and right boundaries are Dirichlet
35 * boundaries with fixed water pressure (fixed Saturation \f$S_w = 0\f$),
36 * bottom boundary is closed (Neumann 0 boundary), the top boundary
37 * (Neumann 0 boundary) is also closed except for infiltration
38 * section, where water is infiltrating into an initially unsaturated
39 * porous medium. This problem is very similar to the LensProblem
40 * which uses the TwoPBoxModel, with the main difference being that
41 * the domain is initially fully saturated by gas instead of water and
42 * water instead of a %DNAPL infiltrates from the top.
43 *
44 * This problem uses the \ref RichardsModel
45 */
46 template <class TypeTag>
47 25 class RichardsLensProblem : public PorousMediumFlowProblem<TypeTag>
48 {
49 using ParentType = PorousMediumFlowProblem<TypeTag>;
50 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
51 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
52 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
53 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
54 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
55 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
56 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
57 enum {
58 // copy some indices for convenience
59 pressureIdx = Indices::pressureIdx,
60 conti0EqIdx = Indices::conti0EqIdx,
61
62 // world dimension
63 dimWorld = GridView::dimensionworld
64 };
65 using Element = typename GridView::template Codim<0>::Entity;
66
67 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
68
69 public:
70 25 RichardsLensProblem(std::shared_ptr<const GridGeometry> gridGeometry)
71
3/6
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 25 times.
✗ Branch 9 not taken.
75 : ParentType(gridGeometry)
72 {
73
1/2
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
25 name_ = getParam<std::string>("Problem.Name");
74 25 }
75
76 /*!
77 * \name Problem parameters
78 */
79 // \{
80
81 /*!
82 * \brief The problem name
83 *
84 * This is used as a prefix for files generated by the simulation.
85 */
86 25 const std::string& name() const
87
1/2
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
25 { return name_; }
88
89 /*!
90 * \brief Returns the reference pressure [Pa] of the nonwetting
91 * fluid phase within a finite volume
92 *
93 * This problem assumes a constant reference pressure of 1 bar.
94 */
95 Scalar nonwettingReferencePressure() const
96 { return 1.0e5; };
97
98 // \}
99
100 /*!
101 * \name Boundary conditions
102 */
103 // \{
104
105 /*!
106 * \brief Specifies which kind of boundary condition should be
107 * used for which equation on a given boundary segment.
108 *
109 * \param globalPos The position for which the boundary type is set
110 */
111
2/2
✓ Branch 0 taken 139408 times.
✓ Branch 1 taken 34280 times.
173688 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
112 {
113 173688 BoundaryTypes bcTypes;
114
6/6
✓ Branch 0 taken 139408 times.
✓ Branch 1 taken 34280 times.
✓ Branch 2 taken 34280 times.
✓ Branch 3 taken 105128 times.
✓ Branch 4 taken 68560 times.
✓ Branch 5 taken 105128 times.
242248 if (onLeftBoundary_(globalPos) || onRightBoundary_(globalPos))
115 bcTypes.setAllDirichlet();
116 else
117 bcTypes.setAllNeumann();
118 173688 return bcTypes;
119 }
120
121 /*!
122 * \brief Evaluates the boundary conditions for a Dirichlet boundary segment.
123 *
124 * \param globalPos The position for which the Dirichlet value is set
125 *
126 * For this method, the \a values parameter stores primary variables.
127 */
128 34444 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
129 {
130 34444 return initial_(globalPos);
131 }
132
133 /*!
134 * \brief Evaluates the boundary conditions for a Neumann boundary segment.
135 *
136 * For this method, the \a values parameter stores the mass flux
137 * in normal direction of each phase. Negative values mean influx.
138 *
139 * \param globalPos The position for which the Neumann value is set
140 */
141 154968 NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
142 {
143 154968 NumEqVector values(0.0);
144
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 36624 times.
✓ Branch 3 taken 7104 times.
154968 if (onInlet_(globalPos))
145 values[conti0EqIdx] = -0.04; // kg/(m*s)
146 return values;
147 }
148
149 /*!
150 * \name Volume terms
151 */
152 // \{
153
154 /*!
155 * \brief Evaluates the initial values for a control volume.
156 *
157 * For this method, the \a values parameter stores primary
158 * variables.
159 *
160 * \param globalPos The position for which the boundary type is set
161 */
162 6424 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
163 6424 { return initial_(globalPos); };
164
165 // \}
166
167 private:
168 40868 PrimaryVariables initial_(const GlobalPosition &globalPos) const
169 {
170 40868 PrimaryVariables values(0.0);
171 40868 const Scalar sw = 0.0;
172 81736 const Scalar pc = this->spatialParams().fluidMatrixInteractionAtPos(globalPos).pc(sw);
173 40868 values[pressureIdx] = nonwettingReferencePressure() - pc;
174 40868 return values;
175 }
176
177
2/2
✓ Branch 0 taken 139408 times.
✓ Branch 1 taken 34280 times.
173688 bool onLeftBoundary_(const GlobalPosition &globalPos) const
178 {
179
2/2
✓ Branch 0 taken 139408 times.
✓ Branch 1 taken 34280 times.
173688 return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_;
180 }
181
182
2/2
✓ Branch 0 taken 34280 times.
✓ Branch 1 taken 105128 times.
139408 bool onRightBoundary_(const GlobalPosition &globalPos) const
183 {
184
2/2
✓ Branch 0 taken 34280 times.
✓ Branch 1 taken 105128 times.
139408 return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_;
185 }
186
187 bool onLowerBoundary_(const GlobalPosition &globalPos) const
188 {
189 return globalPos[1] < this->gridGeometry().bBoxMin()[1] + eps_;
190 }
191
192 154968 bool onUpperBoundary_(const GlobalPosition &globalPos) const
193 {
194 154968 return globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_;
195 }
196
197 154968 bool onInlet_(const GlobalPosition &globalPos) const
198 {
199
4/4
✓ Branch 0 taken 55620 times.
✓ Branch 1 taken 55620 times.
✓ Branch 2 taken 21864 times.
✓ Branch 3 taken 21864 times.
154968 Scalar width = this->gridGeometry().bBoxMax()[0] - this->gridGeometry().bBoxMin()[0];
200 154968 Scalar lambda = (this->gridGeometry().bBoxMax()[0] - globalPos[0])/width;
201
12/12
✓ Branch 0 taken 55620 times.
✓ Branch 1 taken 55620 times.
✓ Branch 2 taken 27810 times.
✓ Branch 3 taken 27810 times.
✓ Branch 4 taken 17550 times.
✓ Branch 5 taken 10260 times.
✓ Branch 6 taken 21864 times.
✓ Branch 7 taken 21864 times.
✓ Branch 8 taken 10932 times.
✓ Branch 9 taken 10932 times.
✓ Branch 10 taken 7086 times.
✓ Branch 11 taken 3846 times.
154968 return onUpperBoundary_(globalPos) && 0.5 < lambda + eps_ && lambda < 2.0/3.0 + eps_;
202 }
203
204 static constexpr Scalar eps_ = 1.5e-7;
205
206 GlobalPosition lensLowerLeft_;
207 GlobalPosition lensUpperRight_;
208 std::string name_;
209 };
210
211 } // end namespace Dumux
212
213 #endif
214