GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/2p/incompressible/problem.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 46 46 100.0%
Functions: 31 31 100.0%
Branches: 63 72 87.5%

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-FileCopyrightInfo: 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
5/14
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 13 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 13 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 13 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 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 1828264 if (onLeftBoundary_(globalPos) || onRightBoundary_(globalPos))
63 values.setAllDirichlet();
64 else
65 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 176848 fluidState.setTemperature(this->spatialParams().temperatureAtPos(globalPos));
79 176848 fluidState.setPressure(waterPhaseIdx, /*pressure=*/1e5);
80 176848 fluidState.setPressure(dnaplPhaseIdx, /*pressure=*/1e5);
81
82 176848 Scalar densityW = FluidSystem::density(fluidState, waterPhaseIdx);
83
84 618968 Scalar height = this->gridGeometry().bBoxMax()[1] - this->gridGeometry().bBoxMin()[1];
85 442120 Scalar depth = this->gridGeometry().bBoxMax()[1] - globalPos[1];
86 88424 Scalar alpha = 1 + 1.5/height;
87 618968 Scalar width = this->gridGeometry().bBoxMax()[0] - this->gridGeometry().bBoxMin()[0];
88 176848 Scalar factor = (width*alpha + (1.0 - alpha)*globalPos[0])/width;
89
90 // hydrostatic pressure scaled by alpha
91 442120 values[pressureH2OIdx] = 1e5 - factor*densityW*this->spatialParams().gravity(globalPos)[1]*depth;
92 176848 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 445071 NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
106 {
107 445071 NumEqVector values(0.0);
108 493411 if (onInlet_(globalPos))
109 96680 values[contiDNAPLEqIdx] = -0.04; // kg / (m * s)
110
111 // in the test with the oil wet lens, use higher injection rate
112
4/4
✓ Branch 0 taken 13598 times.
✓ Branch 1 taken 431473 times.
✓ Branch 2 taken 13598 times.
✓ Branch 3 taken 431473 times.
890142 if (this->spatialParams().lensIsOilWet())
113 27196 values[contiDNAPLEqIdx] *= 10;
114
115 445071 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 25062 fluidState.setTemperature(this->spatialParams().temperatureAtPos(globalPos));
128 25062 fluidState.setPressure(waterPhaseIdx, /*pressure=*/1e5);
129 25062 fluidState.setPressure(dnaplPhaseIdx, /*pressure=*/1e5);
130
131 25062 Scalar densityW = FluidSystem::density(fluidState, waterPhaseIdx);
132
133 62655 Scalar depth = this->gridGeometry().bBoxMax()[1] - globalPos[1];
134
135 // hydrostatic pressure
136 62655 values[pressureH2OIdx] = 1e5 - densityW*this->spatialParams().gravity(globalPos)[1]*depth;
137 25062 values[saturationDNAPLIdx] = 0;
138 12531 return values;
139 }
140
141
142 private:
143 bool onLeftBoundary_(const GlobalPosition &globalPos) const
144 {
145
10/10
✓ Branch 0 taken 410920 times.
✓ Branch 1 taken 92292 times.
✓ Branch 2 taken 410920 times.
✓ Branch 3 taken 92292 times.
✓ Branch 4 taken 410920 times.
✓ Branch 5 taken 92292 times.
✓ Branch 6 taken 410920 times.
✓ Branch 7 taken 92292 times.
✓ Branch 8 taken 410920 times.
✓ Branch 9 taken 92292 times.
2516060 return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_;
146 }
147
148 bool onRightBoundary_(const GlobalPosition &globalPos) const
149 {
150
10/10
✓ Branch 0 taken 316971 times.
✓ Branch 1 taken 93949 times.
✓ Branch 2 taken 316971 times.
✓ Branch 3 taken 93949 times.
✓ Branch 4 taken 316971 times.
✓ Branch 5 taken 93949 times.
✓ Branch 6 taken 316971 times.
✓ Branch 7 taken 93949 times.
✓ Branch 8 taken 316971 times.
✓ Branch 9 taken 93949 times.
2054600 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 bool onUpperBoundary_(const GlobalPosition &globalPos) const
159 {
160
6/6
✓ Branch 0 taken 251235 times.
✓ Branch 1 taken 193836 times.
✓ Branch 2 taken 251235 times.
✓ Branch 3 taken 193836 times.
✓ Branch 4 taken 251235 times.
✓ Branch 5 taken 193836 times.
1335213 return globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_;
161 }
162
163 bool onInlet_(const GlobalPosition &globalPos) const
164 {
165
12/12
✓ Branch 0 taken 251235 times.
✓ Branch 1 taken 193836 times.
✓ Branch 2 taken 251235 times.
✓ Branch 3 taken 193836 times.
✓ Branch 4 taken 251235 times.
✓ Branch 5 taken 193836 times.
✓ Branch 6 taken 251235 times.
✓ Branch 7 taken 193836 times.
✓ Branch 8 taken 251235 times.
✓ Branch 9 taken 193836 times.
✓ Branch 10 taken 251235 times.
✓ Branch 11 taken 193836 times.
2670426 Scalar width = this->gridGeometry().bBoxMax()[0] - this->gridGeometry().bBoxMin()[0];
166
8/8
✓ Branch 0 taken 251235 times.
✓ Branch 1 taken 193836 times.
✓ Branch 2 taken 251235 times.
✓ Branch 3 taken 193836 times.
✓ Branch 4 taken 251235 times.
✓ Branch 5 taken 193836 times.
✓ Branch 6 taken 251235 times.
✓ Branch 7 taken 193836 times.
1780284 Scalar lambda = (this->gridGeometry().bBoxMax()[0] - globalPos[0])/width;
167
8/8
✓ Branch 0 taken 251235 times.
✓ Branch 1 taken 193836 times.
✓ Branch 2 taken 251235 times.
✓ Branch 3 taken 193836 times.
✓ Branch 4 taken 127982 times.
✓ Branch 5 taken 123253 times.
✓ Branch 6 taken 48340 times.
✓ Branch 7 taken 79642 times.
890142 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