GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/richards/nonisothermal/evaporation/problem.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 30 40 75.0%
Functions: 4 14 28.6%
Branches: 24 44 54.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 * \file
9 * \ingroup RichardsTests
10 * \brief Test for the extended richards problem:
11 * The simulation domain is a tube a constant evaporation rate is set at the top and the soil gradually dries out.
12 */
13
14 #ifndef DUMUX_RICHARDS_EVAPORATION_PROBLEM_HH
15 #define DUMUX_RICHARDS_EVAPORATION_PROBLEM_HH
16
17 #include <cmath>
18
19 #include <dumux/common/properties.hh>
20 #include <dumux/common/parameters.hh>
21 #include <dumux/common/boundarytypes.hh>
22 #include <dumux/common/numeqvector.hh>
23
24 #include <dumux/porousmediumflow/problem.hh>
25 #include <dumux/material/components/h2o.hh>
26
27 namespace Dumux {
28
29 /*!
30 * \ingroup RichardsTests
31 *
32 * \brief Test for the RichardsModel in combination with the NI model for evaporation
33 * The result of the analytical solution is written into the vtu files.
34 * This problem uses the \ref RichardsModel and \ref NIModel model.
35 */
36 template <class TypeTag>
37 class RichardsNIEvaporationProblem : public PorousMediumFlowProblem<TypeTag>
38 {
39 using ParentType = PorousMediumFlowProblem<TypeTag>;
40
41 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
42 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
43 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
44 using FVElementGeometry = typename GridGeometry::LocalView;
45 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
46 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
47 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
48 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
49 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
50 using ThermalConductivityModel = GetPropType<TypeTag, Properties::ThermalConductivityModel>;
51 using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
52 using ElementVolumeVariables = typename GridVariables::GridVolumeVariables::LocalView;
53 using ElementFluxVariablesCache = typename GridVariables::GridFluxVariablesCache::LocalView;
54 using VolumeVariables = typename GridVariables::GridVolumeVariables::VolumeVariables;
55 using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
56 using IapwsH2O = Components::H2O<Scalar>;
57
58 // copy some indices for convenience
59 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
60 enum { dimWorld = GridView::dimensionworld };
61
62 enum {
63 pressureIdx = Indices::pressureIdx,
64 conti0EqIdx = Indices::conti0EqIdx,
65 temperatureIdx = Indices::temperatureIdx,
66 energyEqIdx = Indices::energyEqIdx
67 };
68
69 using Element = typename GridView::template Codim<0>::Entity;
70 using GlobalPosition = typename SubControlVolumeFace::GlobalPosition;
71
72 public:
73 2 RichardsNIEvaporationProblem(std::shared_ptr<const GridGeometry> gridGeometry)
74
7/20
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✓ Branch 15 taken 2 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 2 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.
6 : ParentType(gridGeometry)
75 {
76 // initialize fluid system
77
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 FluidSystem::init();
78
79
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 name_ = getParam<std::string>("Problem.Name");
80 2 pressure_ = 9.9e4;
81 2 temperatureInitial_ = 291;
82 2 }
83
84 /*!
85 * \name Problem parameters
86 */
87 // \{
88
89 /*!
90 * \brief The problem name.
91 *
92 * This is used as a prefix for files generated by the simulation.
93 */
94 const std::string& name() const
95 {
96 return name_;
97 }
98
99 // \}
100
101 /*!
102 * \name Boundary conditions
103 */
104 // \{
105
106 /*!
107 * \brief Specifies which kind of boundary condition should be
108 * used for which equation on a given boundary segment.
109 *
110 * \param globalPos The position for which the boundary type is set
111 */
112 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
113 {
114 BoundaryTypes values;
115 if(globalPos[1] < eps_)
116 {
117 values.setAllDirichlet();
118 }
119 else
120 {
121 values.setAllNeumann();
122 }
123 return values;
124 }
125
126 /*!
127 * \brief Evaluates the boundary conditions for a Dirichlet boundary segment.
128 *
129 * \param globalPos The position for which the bc type should be evaluated
130 *
131 * For this method, the \a values parameter stores primary variables.
132 */
133 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
134 {
135 4080 return initial_(globalPos);
136 }
137
138 /*!
139 * \brief Evaluates the boundary conditions for a Neumann boundary segment.
140 *
141 * \param element The finite element
142 * \param fvGeometry The finite-volume geometry in the box scheme
143 * \param elemVolVars The element volume variables
144 * \param elemFluxVarsCache Flux variables caches for all faces in stencil
145 * \param scvf The subcontrolvolume face
146 * Negative values mean influx.
147 */
148 142038 NumEqVector neumann(const Element &element,
149 const FVElementGeometry& fvGeometry,
150 const ElementVolumeVariables& elemVolVars,
151 const ElementFluxVariablesCache& elemFluxVarsCache,
152 const SubControlVolumeFace& scvf) const
153 {
154 142038 NumEqVector values(0.0);
155 142038 const auto globalPos = scvf.ipGlobal();
156
4/4
✓ Branch 0 taken 9360 times.
✓ Branch 1 taken 110448 times.
✓ Branch 2 taken 9360 times.
✓ Branch 3 taken 110448 times.
284076 const auto& volVars = elemVolVars[scvf.insideScvIdx()];
157 142038 Scalar boundaryLayerThickness = 0.00016;
158
159
10/10
✓ Branch 0 taken 11070 times.
✓ Branch 1 taken 130968 times.
✓ Branch 2 taken 11070 times.
✓ Branch 3 taken 130968 times.
✓ Branch 4 taken 11070 times.
✓ Branch 5 taken 130968 times.
✓ Branch 6 taken 11070 times.
✓ Branch 7 taken 130968 times.
✓ Branch 8 taken 11070 times.
✓ Branch 9 taken 130968 times.
710190 if(globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_)
160 {
161 11070 Scalar massFracInside = volVars.massFraction(FluidSystem::phase1Idx, FluidSystem::comp0Idx);
162 11070 Scalar massFracRef = 0.0;
163 11070 Scalar evaporationRate = volVars.effectiveDiffusionCoefficient(FluidSystem::phase1Idx, FluidSystem::comp1Idx, FluidSystem::comp0Idx)
164 11070 * (massFracInside - massFracRef)
165 11070 / boundaryLayerThickness
166 11070 * volVars.density(FluidSystem::phase1Idx);
167 11070 values[conti0EqIdx] = evaporationRate;
168 22140 values[energyEqIdx] = FluidSystem::enthalpy( volVars.fluidState(), FluidSystem::gasPhaseIdx) * values[conti0EqIdx];
169 11070 values[energyEqIdx] += FluidSystem::thermalConductivity(volVars.fluidState(), FluidSystem::gasPhaseIdx)
170 22140 * (volVars.temperature() - temperatureInitial_)/boundaryLayerThickness;
171 }
172 142038 return values;
173 }
174
175 // \}
176
177 /*!
178 * \name Volume terms
179 */
180 // \{
181
182
183 /*!
184 * \brief Returns the reference pressure [Pa] of the nonwetting
185 * fluid phase within a finite volume.
186 *
187 * This problem assumes a constant reference pressure of 1 bar.
188 */
189 Scalar nonwettingReferencePressure() const
190 { return 1e5; };
191
192 /*!
193 * \brief Evaluates the initial value for a control volume.
194 *
195 * \param globalPos The position for which the initial condition should be evaluated
196 *
197 * For this method, the \a values parameter stores primary
198 * variables.
199 */
200 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
201 {
202 672 return initial_(globalPos);
203 }
204
205 // \}
206
207 private:
208 PrimaryVariables initial_(const GlobalPosition &globalPos) const
209 {
210 2376 PrimaryVariables priVars(0.0);
211 2376 priVars.setState(Indices::bothPhases);
212 2376 priVars[pressureIdx] = pressure_; // initial condition for the pressure
213 4752 priVars[temperatureIdx] = temperatureInitial_;
214 return priVars;
215 }
216
217 Scalar temperatureInitial_;
218 Scalar pressure_;
219 static constexpr Scalar eps_ = 1e-6;
220 std::string name_;
221 };
222
223 } // end namespace Dumux
224
225 #endif
226