GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/2p/nonisothermal/problem.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 32 41 78.0%
Functions: 6 12 50.0%
Branches: 56 98 57.1%

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 * \file
9 * \ingroup TwoPTests
10 * \brief Non-isothermal gas injection problem where a gas (e.g. air) is injected into a fully water saturated medium.
11 *
12 */
13
14 #ifndef DUMUX_INJECTION_PROBLEM_2PNI_HH
15 #define DUMUX_INJECTION_PROBLEM_2PNI_HH
16
17 #include <dumux/common/properties.hh>
18 #include <dumux/common/parameters.hh>
19 #include <dumux/common/boundarytypes.hh>
20 #include <dumux/common/numeqvector.hh>
21
22 #include <dumux/porousmediumflow/problem.hh>
23
24 namespace Dumux {
25
26 /*!
27 * \ingroup TwoPTests
28 * \brief Non-isothermal gas injection problem where a gas (e.g. air) is injected into a fully water saturated medium.
29 */
30 template<class TypeTag>
31 class InjectionProblem2PNI : public PorousMediumFlowProblem<TypeTag>
32 {
33 using ParentType = PorousMediumFlowProblem<TypeTag>;
34 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
35 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
36 using Element = typename GridView::template Codim<0>::Entity;
37 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
38
39 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
40 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
41 using Indices = typename ModelTraits::Indices;
42
43 enum
44 {
45 //! Primary variable indices
46 pressureIdx = Indices::pressureIdx,
47 saturationIdx = Indices::saturationIdx,
48 temperatureIdx = Indices::temperatureIdx,
49
50 //! Equation indices
51 contiN2EqIdx = Indices::conti0EqIdx + FluidSystem::N2Idx,
52 energyEqIdx = Indices::energyEqIdx,
53
54 //! Phase indices
55 wPhaseIdx = FluidSystem::H2OIdx,
56 nPhaseIdx = FluidSystem::N2Idx,
57
58 // world dimension
59 dimWorld = GridView::dimensionworld
60 };
61
62 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
63 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
64 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
65 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
66 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
67 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
68 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
69
70 public:
71 4 InjectionProblem2PNI(std::shared_ptr<const GridGeometry> gridGeometry)
72
7/20
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 4 times.
✓ Branch 15 taken 4 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 4 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
12 : ParentType(gridGeometry)
73 {
74 4 maxDepth_ = 2700.0; // [m]
75
76 // initialize the tables of the fluid system
77
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 FluidSystem::init(/*tempMin=*/273.15,
78 /*tempMax=*/423.15,
79 /*numTemp=*/50,
80 /*pMin=*/0.0,
81 /*pMax=*/30e6,
82 /*numP=*/300);
83
84
2/4
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 name_ = getParam<std::string>("Problem.Name");
85 4 }
86
87 /*!
88 * \brief Returns the problem name
89 *
90 * This is used as a prefix for files generated by the simulation.
91 */
92 const std::string name() const
93
2/6
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 { return name_; }
94
95 /*!
96 * \brief Returns the source term
97 *
98 * \param globalPos The global position
99 */
100 NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
101 {
102 1358592 NumEqVector values(0.0);
103 values = 0;
104 return values;
105 }
106
107
108 /*!
109 * \brief Specifies which kind of boundary condition should be
110 * used for which equation on a given boundary segment
111 *
112 * \param globalPos The global position
113 */
114 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
115 {
116 BoundaryTypes values;
117 if (globalPos[0] < eps_)
118 values.setAllDirichlet();
119 else
120 values.setAllNeumann();
121
122 return values;
123 }
124
125 /*!
126 * \brief Evaluates the boundary conditions for a Dirichlet boundary segment.
127 *
128 * \param globalPos The global position
129 */
130 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
131 {
132 6512 PrimaryVariables values;
133 6512 Scalar densityW = 1000.0;
134 13024 values[pressureIdx] = 1e5 + (maxDepth_ - globalPos[dimWorld-1])*densityW*9.81;
135 6512 values[saturationIdx] = 0.0;
136 19536 values[temperatureIdx] = 283.0 + (maxDepth_ - globalPos[dimWorld-1])*0.03;
137 return values;
138 }
139
140 /*!
141 * \brief Evaluates the boundary conditions for a Neumann boundary segment.
142 *
143 * \param globalPos The global position
144 *
145 * The \a values store the mass flux of each phase normal to the boundary.
146 * Negative values indicate an inflow.
147 */
148 99700 NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
149 {
150 99700 NumEqVector values(0.0);
151
152
8/8
✓ Branch 0 taken 46048 times.
✓ Branch 1 taken 53652 times.
✓ Branch 2 taken 46048 times.
✓ Branch 3 taken 53652 times.
✓ Branch 4 taken 4734 times.
✓ Branch 5 taken 41314 times.
✓ Branch 6 taken 4734 times.
✓ Branch 7 taken 41314 times.
199400 if (globalPos[1] < 13.75 + eps_ && globalPos[1] > 6.875 - eps_)
153 {
154 // inject air. negative values mean injection
155
1/2
✓ Branch 0 taken 4734 times.
✗ Branch 1 not taken.
4734 values[contiN2EqIdx] = -1e-3; // kg/(s*m^2)
156
157 // compute enthalpy flux associated with this injection [(J/(kg*s)]
158 using FluidState = GetPropType<TypeTag, Properties::FluidState>;
159 4734 FluidState fs;
160
161 9468 const auto initialValues = initialAtPos(globalPos);
162 9468 fs.setPressure(wPhaseIdx, initialValues[pressureIdx]);
163 9468 fs.setPressure(nPhaseIdx, initialValues[pressureIdx]); // assume pressure equality here
164 9468 fs.setTemperature(wPhaseIdx,initialValues[temperatureIdx]);
165 9468 fs.setTemperature(nPhaseIdx,initialValues[temperatureIdx]);
166
167 // energy flux is mass flux times specific enthalpy
168 9468 values[energyEqIdx] = values[contiN2EqIdx]*FluidSystem::enthalpy(fs, nPhaseIdx);
169 }
170
171 99700 return values;
172 }
173
174 /*!
175 * \brief Evaluates the initial values for a control volume.
176 *
177 * \param globalPos The global position
178 */
179 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
180 {
181 2002 PrimaryVariables values;
182 6736 Scalar densityW = 1000.0;
183
6/8
✓ Branch 0 taken 4734 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4734 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1296 times.
✓ Branch 5 taken 706 times.
✓ Branch 6 taken 1296 times.
✓ Branch 7 taken 706 times.
13472 values[pressureIdx] = 1e5 + (maxDepth_ - globalPos[1])*densityW*9.81;
184
3/4
✓ Branch 0 taken 4734 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1296 times.
✓ Branch 3 taken 706 times.
6736 values[saturationIdx] = 0.0;
185
6/8
✓ Branch 0 taken 4734 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4734 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1296 times.
✓ Branch 5 taken 706 times.
✓ Branch 6 taken 1296 times.
✓ Branch 7 taken 706 times.
13472 values[temperatureIdx] = 283.0 + (maxDepth_ - globalPos[1])*0.03;
186
187
20/32
✓ Branch 0 taken 4734 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4734 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4734 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4734 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1296 times.
✓ Branch 17 taken 706 times.
✓ Branch 18 taken 1296 times.
✓ Branch 19 taken 706 times.
✓ Branch 20 taken 262 times.
✓ Branch 21 taken 1034 times.
✓ Branch 22 taken 262 times.
✓ Branch 23 taken 1034 times.
✓ Branch 24 taken 221 times.
✓ Branch 25 taken 41 times.
✓ Branch 26 taken 221 times.
✓ Branch 27 taken 41 times.
✓ Branch 28 taken 180 times.
✓ Branch 29 taken 41 times.
✓ Branch 30 taken 180 times.
✓ Branch 31 taken 41 times.
13472 if (globalPos[0] > 21.25 - eps_ && globalPos[0] < 28.75 + eps_ && globalPos[1] > 6.25 - eps_ && globalPos[1] < 33.75 + eps_)
188 360 values[temperatureIdx] = 380;
189
190 return values;
191 }
192
193
194 private:
195 Scalar maxDepth_;
196 static constexpr Scalar eps_ = 1.5e-7;
197 std::string name_;
198 };
199
200 } // end namespace Dumux
201
202 #endif
203