GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/2p2c/evaporation/problem.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 30 43 69.8%
Functions: 6 12 50.0%
Branches: 28 50 56.0%

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 TwoPTwoCTests
10 * \brief Evaporation problem where two components with constant properties mix and evaporate.
11 */
12
13 #ifndef DUMUX_EVAPORATION_CONSTANT_COMPONENT_PROBLEM_HH
14 #define DUMUX_EVAPORATION_CONSTANT_COMPONENT_PROBLEM_HH
15
16 #include <dumux/common/properties.hh>
17 #include <dumux/common/parameters.hh>
18 #include <dumux/common/boundarytypes.hh>
19 #include <dumux/common/numeqvector.hh>
20
21 #include <dumux/porousmediumflow/problem.hh>
22
23 namespace Dumux {
24
25 /*!
26 * \ingroup TwoPTwoCModel
27 * \brief Evaporation problem where two components with constant properties mix and evaporate.
28 *
29 */
30 template <class TypeTag >
31 class EvaporationConstantComponentProblem : public PorousMediumFlowProblem<TypeTag>
32 {
33 using ParentType = PorousMediumFlowProblem<TypeTag>;
34
35 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
36 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
37 using GridView = typename GridGeometry::GridView;
38 using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
39 using ElementVolumeVariables = typename GridVariables::GridVolumeVariables::LocalView;
40 using ElementFluxVariablesCache = typename GridVariables::GridFluxVariablesCache::LocalView;
41 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
42 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
43 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
44 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
45 using Indices = typename ModelTraits::Indices;
46
47 // primary variable indices
48 enum
49 {
50 pressureIdx = Indices::pressureIdx,
51 switchIdx = Indices::switchIdx,
52 temperatureIdx = Indices::temperatureIdx,
53 energyEqIdx = Indices::energyEqIdx
54 };
55
56 // equation indices
57 enum
58 {
59 contiH2OEqIdx = Indices::conti0EqIdx + FluidSystem::comp0Idx,
60 contiN2EqIdx = Indices::conti0EqIdx + FluidSystem::comp1Idx
61 };
62
63 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
64 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
65 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
66 using Element = typename GridView::template Codim<0>::Entity;
67 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
68
69 //! Property that defines whether mole or mass fractions are used
70 static constexpr bool useMoles = ModelTraits::useMoles();
71
72 public:
73 4 EvaporationConstantComponentProblem(std::shared_ptr<const GridGeometry> gridGeometry)
74
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)
75 {
76
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 FluidSystem::init();
77
78
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");
79
80 //stating in the console whether mole or mass fractions are used
81 if(useMoles)
82
1/2
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
8 std::cout << "The problem uses mole-fractions" << std::endl;
83 else
84 std::cout << "The problem uses mass-fractions" << std::endl;
85 4 }
86
87
88 /*!
89 * \brief The problem name.
90 *
91 * This is used as a prefix for files generated by the simulation.
92 */
93 const std::string& name() const
94
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 { return name_; }
95
96 /*!
97 * \brief Specifies which kind of boundary condition should be
98 * used for which equation on a given boundary segment.
99 *
100 * \param globalPos The position for which the bc type should be evaluated
101 */
102 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
103 {
104 BoundaryTypes bcTypes;
105 if(globalPos[0] < eps_)
106 bcTypes.setAllDirichlet();
107 else
108 bcTypes.setAllNeumann();
109
110 return bcTypes;
111 }
112
113 /*!
114 * \brief Evaluates the boundary conditions for a Neumann boundary segment.
115 *
116 * \param element The finite element
117 * \param fvGeometry The finite volume geometry of the element
118 * \param elemVolVars The element volume variables
119 * \param elemFluxVarsCache Flux variables caches for all faces in stencil
120 * \param scvf The sub-control volume face
121 *
122 * Negative values mean influx.
123 */
124 70960 NumEqVector neumann(const Element& element,
125 const FVElementGeometry& fvGeometry,
126 const ElementVolumeVariables& elemVolVars,
127 const ElementFluxVariablesCache& elemFluxVarsCache,
128 const SubControlVolumeFace& scvf) const
129 {
130 70960 NumEqVector values(0.0);
131
2/2
✓ Branch 0 taken 20800 times.
✓ Branch 1 taken 40560 times.
80560 const auto& globalPos = scvf.ipGlobal();
132
4/4
✓ Branch 0 taken 20800 times.
✓ Branch 1 taken 40560 times.
✓ Branch 2 taken 20800 times.
✓ Branch 3 taken 40560 times.
141920 const auto& volVars = elemVolVars[scvf.insideScvIdx()];
133 70960 Scalar boundaryLayerThickness = 0.0016;
134 //right side
135
10/10
✓ Branch 0 taken 24000 times.
✓ Branch 1 taken 46960 times.
✓ Branch 2 taken 24000 times.
✓ Branch 3 taken 46960 times.
✓ Branch 4 taken 24000 times.
✓ Branch 5 taken 46960 times.
✓ Branch 6 taken 24000 times.
✓ Branch 7 taken 46960 times.
✓ Branch 8 taken 24000 times.
✓ Branch 9 taken 46960 times.
354800 if (globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_)
136 {
137 24000 Scalar massFracInside = volVars.massFraction(FluidSystem::phase1Idx, FluidSystem::comp0Idx);
138 24000 Scalar massFracRef = 0.0;
139 24000 Scalar evaporationRate = volVars.diffusionCoefficient(FluidSystem::phase1Idx, FluidSystem::comp1Idx, FluidSystem::comp0Idx)
140 24000 * (massFracInside - massFracRef)
141 24000 / boundaryLayerThickness
142 24000 * volVars.density(FluidSystem::phase1Idx);
143 24000 values[Indices::conti0EqIdx] = evaporationRate;
144 24000 values[Indices::conti0EqIdx+1] = -evaporationRate;
145
146 24000 values[Indices::energyEqIdx] = FluidSystem::enthalpy(volVars.fluidState(), FluidSystem::phase1Idx) * evaporationRate;
147 48000 values[Indices::energyEqIdx] += FluidSystem::thermalConductivity(volVars.fluidState(), FluidSystem::phase1Idx)
148 48000 * (volVars.temperature() - 293.15)/boundaryLayerThickness;
149 }
150 70960 return values;
151 }
152
153 /*!
154 * \brief Evaluates the boundary conditions for a Dirichlet boundary segment.
155 *
156 * \param globalPos The position for which the Dirichlet condition should be evaluated
157 */
158 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
159 {
160 4040 PrimaryVariables priVars(0.0);
161 4040 priVars.setState(Indices::bothPhases);
162 4040 priVars[pressureIdx] = 1.e5;
163 4040 priVars[switchIdx] = 0.6; //sn
164 8080 priVars[temperatureIdx] = 298.15;
165
166 return priVars;
167
168 }
169
170
171
172 /*!
173 * \brief Evaluates the initial value for a control volume.
174 *
175 * \param globalPos The position for which the initial condition should be evaluated
176 *
177 * For this method, the \a values parameter stores primary
178 * variables.
179 */
180 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
181 {
182 PrimaryVariables priVars(0.0);
183 priVars.setState(Indices::bothPhases);
184 priVars[pressureIdx] = 1e5;
185 priVars[switchIdx] = 0.6; //sn
186 priVars[temperatureIdx] = 293.15;
187 return priVars;
188 }
189
190 private:
191
192 static constexpr Scalar eps_ = 1e-2;
193 std::string name_;
194 };
195
196 } // end namespace Dumux
197
198 #endif
199