GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/2p/incompressible/problem.hh
Date: 2024-09-21 20:52:54
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 8 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 12 TwoPTestProblem(std::shared_ptr<const GridGeometry> gridGeometry)
51
5/14
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 12 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
36 : 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 495682 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
60 {
61 495682 BoundaryTypes values;
62 1800808 if (onLeftBoundary_(globalPos) || onRightBoundary_(globalPos))
63 values.setAllDirichlet();
64 else
65 values.setAllNeumann();
66 495682 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 87464 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
75 {
76 87464 PrimaryVariables values;
77 87464 GetPropType<TypeTag, Properties::FluidState> fluidState;
78 174928 fluidState.setTemperature(this->spatialParams().temperatureAtPos(globalPos));
79 174928 fluidState.setPressure(waterPhaseIdx, /*pressure=*/1e5);
80 174928 fluidState.setPressure(dnaplPhaseIdx, /*pressure=*/1e5);
81
82 174928 Scalar densityW = FluidSystem::density(fluidState, waterPhaseIdx);
83
84 612248 Scalar height = this->gridGeometry().bBoxMax()[1] - this->gridGeometry().bBoxMin()[1];
85 437320 Scalar depth = this->gridGeometry().bBoxMax()[1] - globalPos[1];
86 87464 Scalar alpha = 1 + 1.5/height;
87 612248 Scalar width = this->gridGeometry().bBoxMax()[0] - this->gridGeometry().bBoxMin()[0];
88 174928 Scalar factor = (width*alpha + (1.0 - alpha)*globalPos[0])/width;
89
90 // hydrostatic pressure scaled by alpha
91 437320 values[pressureH2OIdx] = 1e5 - factor*densityW*this->spatialParams().gravity(globalPos)[1]*depth;
92 174928 values[saturationDNAPLIdx] = 0.0;
93
94 87464 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 441705 NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
106 {
107 441705 NumEqVector values(0.0);
108 489749 if (onInlet_(globalPos))
109 96088 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 428107 times.
✓ Branch 2 taken 13598 times.
✓ Branch 3 taken 428107 times.
883410 if (this->spatialParams().lensIsOilWet())
113 27196 values[contiDNAPLEqIdx] *= 10;
114
115 441705 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 404722 times.
✓ Branch 1 taken 90960 times.
✓ Branch 2 taken 404722 times.
✓ Branch 3 taken 90960 times.
✓ Branch 4 taken 404722 times.
✓ Branch 5 taken 90960 times.
✓ Branch 6 taken 404722 times.
✓ Branch 7 taken 90960 times.
✓ Branch 8 taken 404722 times.
✓ Branch 9 taken 90960 times.
2478410 return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_;
146 }
147
148 bool onRightBoundary_(const GlobalPosition &globalPos) const
149 {
150
10/10
✓ Branch 0 taken 312165 times.
✓ Branch 1 taken 92557 times.
✓ Branch 2 taken 312165 times.
✓ Branch 3 taken 92557 times.
✓ Branch 4 taken 312165 times.
✓ Branch 5 taken 92557 times.
✓ Branch 6 taken 312165 times.
✓ Branch 7 taken 92557 times.
✓ Branch 8 taken 312165 times.
✓ Branch 9 taken 92557 times.
2023610 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 249505 times.
✓ Branch 1 taken 192200 times.
✓ Branch 2 taken 249505 times.
✓ Branch 3 taken 192200 times.
✓ Branch 4 taken 249505 times.
✓ Branch 5 taken 192200 times.
1325115 return globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_;
161 }
162
163 bool onInlet_(const GlobalPosition &globalPos) const
164 {
165
12/12
✓ Branch 0 taken 249505 times.
✓ Branch 1 taken 192200 times.
✓ Branch 2 taken 249505 times.
✓ Branch 3 taken 192200 times.
✓ Branch 4 taken 249505 times.
✓ Branch 5 taken 192200 times.
✓ Branch 6 taken 249505 times.
✓ Branch 7 taken 192200 times.
✓ Branch 8 taken 249505 times.
✓ Branch 9 taken 192200 times.
✓ Branch 10 taken 249505 times.
✓ Branch 11 taken 192200 times.
2650230 Scalar width = this->gridGeometry().bBoxMax()[0] - this->gridGeometry().bBoxMin()[0];
166
8/8
✓ Branch 0 taken 249505 times.
✓ Branch 1 taken 192200 times.
✓ Branch 2 taken 249505 times.
✓ Branch 3 taken 192200 times.
✓ Branch 4 taken 249505 times.
✓ Branch 5 taken 192200 times.
✓ Branch 6 taken 249505 times.
✓ Branch 7 taken 192200 times.
1766820 Scalar lambda = (this->gridGeometry().bBoxMax()[0] - globalPos[0])/width;
167
8/8
✓ Branch 0 taken 249505 times.
✓ Branch 1 taken 192200 times.
✓ Branch 2 taken 249505 times.
✓ Branch 3 taken 192200 times.
✓ Branch 4 taken 127130 times.
✓ Branch 5 taken 122375 times.
✓ Branch 6 taken 48044 times.
✓ Branch 7 taken 79086 times.
883410 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