GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/test/porousmediumflow/2p/incompressible/problem.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 51 51 100.0%
Functions: 31 31 100.0%
Branches: 26 28 92.9%

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 * \ingroup TwoPTests
9 * \brief The properties for the incompressible 2p test.
10 */
11 #ifndef DUMUX_INCOMPRESSIBLE_TWOP_TEST_PROBLEM_HH
12 #define DUMUX_INCOMPRESSIBLE_TWOP_TEST_PROBLEM_HH
13
14 #include <dumux/common/properties.hh>
15 #include <dumux/common/parameters.hh>
16 #include <dumux/common/boundarytypes.hh>
17 #include <dumux/common/numeqvector.hh>
18
19 #include <dumux/porousmediumflow/problem.hh>
20
21 namespace Dumux {
22
23 /*!
24 * \ingroup TwoPTests
25 * \brief The incompressible 2p test problem.
26 */
27 template<class TypeTag>
28 9 class TwoPTestProblem : public PorousMediumFlowProblem<TypeTag>
29 {
30 using ParentType = PorousMediumFlowProblem<TypeTag>;
31 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
32 using Element = typename GridView::template Codim<0>::Entity;
33 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
34 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
35 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
36 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
37 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
38 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
39 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
40 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
41 enum {
42 pressureH2OIdx = Indices::pressureIdx,
43 saturationDNAPLIdx = Indices::saturationIdx,
44 contiDNAPLEqIdx = Indices::conti0EqIdx + FluidSystem::comp1Idx,
45 waterPhaseIdx = FluidSystem::phase0Idx,
46 dnaplPhaseIdx = FluidSystem::phase1Idx
47 };
48
49 public:
50 13 TwoPTestProblem(std::shared_ptr<const GridGeometry> gridGeometry)
51
2/4
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
39 : ParentType(gridGeometry) {}
52
53 /*!
54 * \brief Specifies which kind of boundary condition should be
55 * used for which equation on a given boundary segment
56 *
57 * \param globalPos The global position
58 */
59 503212 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
60 {
61 503212 BoundaryTypes values;
62
6/6
✓ Branch 0 taken 410920 times.
✓ Branch 1 taken 92292 times.
✓ Branch 2 taken 93949 times.
✓ Branch 3 taken 316971 times.
✓ Branch 4 taken 316971 times.
✓ Branch 5 taken 186241 times.
689453 if (onLeftBoundary_(globalPos) || onRightBoundary_(globalPos))
63 503212 values.setAllDirichlet();
64 else
65 503212 values.setAllNeumann();
66 503212 return values;
67 }
68
69 /*!
70 * \brief Evaluates the boundary conditions for a Dirichlet boundary segment.
71 *
72 * \param globalPos The global position
73 */
74 88424 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
75 {
76 88424 PrimaryVariables values;
77 88424 GetPropType<TypeTag, Properties::FluidState> fluidState;
78 88424 fluidState.setTemperature(this->spatialParams().temperatureAtPos(globalPos));
79 88424 fluidState.setPressure(waterPhaseIdx, /*pressure=*/1e5);
80 88424 fluidState.setPressure(dnaplPhaseIdx, /*pressure=*/1e5);
81
82 88424 Scalar densityW = FluidSystem::density(fluidState, waterPhaseIdx);
83
84 88424 Scalar height = this->gridGeometry().bBoxMax()[1] - this->gridGeometry().bBoxMin()[1];
85 88424 Scalar depth = this->gridGeometry().bBoxMax()[1] - globalPos[1];
86 88424 Scalar alpha = 1 + 1.5/height;
87 88424 Scalar width = this->gridGeometry().bBoxMax()[0] - this->gridGeometry().bBoxMin()[0];
88 88424 Scalar factor = (width*alpha + (1.0 - alpha)*globalPos[0])/width;
89
90 // hydrostatic pressure scaled by alpha
91 88424 values[pressureH2OIdx] = 1e5 - factor*densityW*this->spatialParams().gravity(globalPos)[1]*depth;
92 88424 values[saturationDNAPLIdx] = 0.0;
93
94 88424 return values;
95 }
96
97 /*!
98 * \brief Evaluates the boundary conditions for a Neumann boundary segment.
99 *
100 * \param globalPos The position of the integration point of the boundary segment.
101 *
102 * For this method, the \a values parameter stores the mass flux
103 * in normal direction of each phase. Negative values mean influx.
104 */
105 445087 NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
106 {
107 445087 NumEqVector values(0.0);
108 396731 if (onInlet_(globalPos))
109 values[contiDNAPLEqIdx] = -0.04; // kg / (m * s)
110
111 // in the test with the oil wet lens, use higher injection rate
112
2/2
✓ Branch 0 taken 13598 times.
✓ Branch 1 taken 431489 times.
445087 if (this->spatialParams().lensIsOilWet())
113 13598 values[contiDNAPLEqIdx] *= 10;
114
115 445087 return values;
116 }
117
118 /*!
119 * \brief Evaluates the initial values for a control volume.
120 *
121 * \param globalPos The global position
122 */
123 12531 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
124 {
125 12531 PrimaryVariables values;
126 12531 GetPropType<TypeTag, Properties::FluidState> fluidState;
127 12531 fluidState.setTemperature(this->spatialParams().temperatureAtPos(globalPos));
128 12531 fluidState.setPressure(waterPhaseIdx, /*pressure=*/1e5);
129 12531 fluidState.setPressure(dnaplPhaseIdx, /*pressure=*/1e5);
130
131 12531 Scalar densityW = FluidSystem::density(fluidState, waterPhaseIdx);
132
133 12531 Scalar depth = this->gridGeometry().bBoxMax()[1] - globalPos[1];
134
135 // hydrostatic pressure
136 12531 values[pressureH2OIdx] = 1e5 - densityW*this->spatialParams().gravity(globalPos)[1]*depth;
137 12531 values[saturationDNAPLIdx] = 0;
138 12531 return values;
139 }
140
141
142 private:
143
2/2
✓ Branch 0 taken 410920 times.
✓ Branch 1 taken 92292 times.
503212 bool onLeftBoundary_(const GlobalPosition &globalPos) const
144 {
145
2/2
✓ Branch 0 taken 410920 times.
✓ Branch 1 taken 92292 times.
503212 return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_;
146 }
147
148
2/2
✓ Branch 0 taken 93949 times.
✓ Branch 1 taken 316971 times.
410920 bool onRightBoundary_(const GlobalPosition &globalPos) const
149 {
150
2/2
✓ Branch 0 taken 93949 times.
✓ Branch 1 taken 316971 times.
410920 return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_;
151 }
152
153 bool onLowerBoundary_(const GlobalPosition &globalPos) const
154 {
155 return globalPos[1] < this->gridGeometry().bBoxMin()[1] + eps_;
156 }
157
158 445087 bool onUpperBoundary_(const GlobalPosition &globalPos) const
159 {
160 445087 return globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_;
161 }
162
163 445087 bool onInlet_(const GlobalPosition &globalPos) const
164 {
165
2/2
✓ Branch 0 taken 251251 times.
✓ Branch 1 taken 193836 times.
445087 Scalar width = this->gridGeometry().bBoxMax()[0] - this->gridGeometry().bBoxMin()[0];
166 445087 Scalar lambda = (this->gridGeometry().bBoxMax()[0] - globalPos[0])/width;
167
6/6
✓ Branch 0 taken 251251 times.
✓ Branch 1 taken 193836 times.
✓ Branch 2 taken 127998 times.
✓ Branch 3 taken 123253 times.
✓ Branch 4 taken 79642 times.
✓ Branch 5 taken 48356 times.
445087 return onUpperBoundary_(globalPos) && 0.5 < lambda && lambda < 2.0/3.0;
168 }
169
170 static constexpr Scalar eps_ = 1e-6;
171 };
172
173 } // end namespace Dumux
174
175 #endif
176