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 OnePNCTests | ||
10 | * \brief Test for the OnePNCModel in combination with the NI model with transient boundary conditions. | ||
11 | * | ||
12 | * The simulation domain is a tube with an elevated temperature on the left hand side. | ||
13 | */ | ||
14 | #ifndef DUMUX_1P2CNI_TRANSIENT_BC_TEST_PROBLEM_HH | ||
15 | #define DUMUX_1P2CNI_TRANSIENT_BC_TEST_PROBLEM_HH | ||
16 | |||
17 | #include <dumux/common/properties.hh> | ||
18 | #include <dumux/common/parameters.hh> | ||
19 | |||
20 | #include <dumux/common/boundarytypes.hh> | ||
21 | #include <dumux/common/numeqvector.hh> | ||
22 | #include <dumux/porousmediumflow/problem.hh> | ||
23 | #include <dumux/material/components/h2o.hh> | ||
24 | |||
25 | namespace Dumux { | ||
26 | |||
27 | /*! | ||
28 | * \ingroup OnePNCTests | ||
29 | * \brief Test for the OnePTwoCModel in combination with the NI model for a convection problem. | ||
30 | * | ||
31 | * The simulation domain is a tube where water with an elevated temperature is injected | ||
32 | * at a constant rate on the left hand side. | ||
33 | * | ||
34 | * Initially, the domain is fully saturated with water at a constant temperature. | ||
35 | * On the left hand side water is injected at a constant rate and on the right hand side | ||
36 | * a Dirichlet boundary with constant pressure, saturation and temperature is applied. | ||
37 | * | ||
38 | * The results are compared to an analytical solution where a retarded front velocity is calculated as follows: | ||
39 | \f[ | ||
40 | v_{Front}=\frac{q S_{water}}{\phi S_{total}} | ||
41 | \f] | ||
42 | * | ||
43 | * The result of the analytical solution is written into the vtu files. | ||
44 | * | ||
45 | * This problem uses the \ref OnePModel and \ref NIModel model. | ||
46 | */ | ||
47 | |||
48 | template <class TypeTag> | ||
49 | 6 | class OnePTwoCNITransientBCProblem : public PorousMediumFlowProblem<TypeTag> | |
50 | { | ||
51 | using ParentType = PorousMediumFlowProblem<TypeTag>; | ||
52 | |||
53 | using Scalar = GetPropType<TypeTag, Properties::Scalar>; | ||
54 | using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; | ||
55 | using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView; | ||
56 | using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>; | ||
57 | using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>; | ||
58 | using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>; | ||
59 | using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; | ||
60 | using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView; | ||
61 | using NumEqVector = Dumux::NumEqVector<PrimaryVariables>; | ||
62 | using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView; | ||
63 | using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; | ||
64 | using Element = typename GridView::template Codim<0>::Entity; | ||
65 | using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>; | ||
66 | using VolumeVariables = GetPropType<TypeTag, Properties::VolumeVariables>; | ||
67 | using IapwsH2O = Components::H2O<Scalar>; | ||
68 | |||
69 | // copy some indices for convenience | ||
70 | enum | ||
71 | { | ||
72 | // indices of the primary variables | ||
73 | pressureIdx = Indices::pressureIdx, | ||
74 | temperatureIdx = Indices::temperatureIdx, | ||
75 | |||
76 | // component indices | ||
77 | H2OIdx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::H2OIdx), | ||
78 | N2Idx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::N2Idx), | ||
79 | |||
80 | // indices of the equations | ||
81 | contiH2OEqIdx = Indices::conti0EqIdx + H2OIdx, | ||
82 | contiN2EqIdx = Indices::conti0EqIdx + N2Idx, | ||
83 | energyEqIdx = Indices::energyEqIdx | ||
84 | }; | ||
85 | |||
86 | //! Property that defines whether mole or mass fractions are used | ||
87 | static constexpr bool useMoles = getPropValue<TypeTag, Properties::UseMoles>(); | ||
88 | static const int dimWorld = GridView::dimensionworld; | ||
89 | using GlobalPosition = typename SubControlVolumeFace::GlobalPosition; | ||
90 | |||
91 | public: | ||
92 | 6 | OnePTwoCNITransientBCProblem(std::shared_ptr<const GridGeometry> gridGeometry) | |
93 |
6/16✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 6 times.
✓ Branch 15 taken 6 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
|
18 | : ParentType(gridGeometry) |
94 | { | ||
95 | //initialize fluid system | ||
96 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | FluidSystem::init(); |
97 | |||
98 | // stating in the console whether mole or mass fractions are used | ||
99 | if(useMoles) | ||
100 |
1/2✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
12 | std::cout<<"problem uses mole fractions"<<std::endl; |
101 | else | ||
102 | std::cout<<"problem uses mass fractions"<<std::endl; | ||
103 | 6 | } | |
104 | |||
105 | /*! | ||
106 | * \name Boundary conditions | ||
107 | */ | ||
108 | // \{ | ||
109 | |||
110 | /*! | ||
111 | * \brief Specifies which kind of boundary condition should be | ||
112 | * used for which equation on a given boundary segment. | ||
113 | * | ||
114 | * \param globalPos The position for which the bc type should be evaluated | ||
115 | */ | ||
116 | 1789688 | BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const | |
117 | { | ||
118 | 1789688 | BoundaryTypes values; | |
119 | |||
120 |
20/20✓ Branch 0 taken 1783412 times.
✓ Branch 1 taken 6276 times.
✓ Branch 2 taken 1783412 times.
✓ Branch 3 taken 6276 times.
✓ Branch 4 taken 1783412 times.
✓ Branch 5 taken 6276 times.
✓ Branch 6 taken 1783412 times.
✓ Branch 7 taken 6276 times.
✓ Branch 8 taken 1783412 times.
✓ Branch 9 taken 6276 times.
✓ Branch 10 taken 1777136 times.
✓ Branch 11 taken 6276 times.
✓ Branch 12 taken 1777136 times.
✓ Branch 13 taken 6276 times.
✓ Branch 14 taken 1777136 times.
✓ Branch 15 taken 6276 times.
✓ Branch 16 taken 1777136 times.
✓ Branch 17 taken 6276 times.
✓ Branch 18 taken 1777136 times.
✓ Branch 19 taken 6276 times.
|
8948440 | if(globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_ || globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_) |
121 | values.setAllDirichlet(); | ||
122 | else | ||
123 | values.setAllNeumann(); | ||
124 | |||
125 | 1789688 | return values; | |
126 | } | ||
127 | |||
128 | /*! | ||
129 | * \brief Evaluates the boundary conditions for a Dirichlet boundary segment. | ||
130 | * | ||
131 | * \param globalPos The position for which the bc type should be evaluated | ||
132 | */ | ||
133 | 3984 | PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const | |
134 | { | ||
135 | 7968 | PrimaryVariables values = initial_(globalPos); | |
136 | |||
137 | // make the BCs on the left border time-dependent | ||
138 |
10/10✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 1992 times.
✓ Branch 2 taken 1992 times.
✓ Branch 3 taken 1992 times.
✓ Branch 4 taken 1992 times.
✓ Branch 5 taken 1992 times.
✓ Branch 6 taken 1992 times.
✓ Branch 7 taken 1992 times.
✓ Branch 8 taken 1992 times.
✓ Branch 9 taken 1992 times.
|
19920 | if (globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_) |
139 | { | ||
140 | 1992 | values[pressureIdx] += time_ * 1.0; | |
141 | 1992 | values[N2Idx] += time_ * 1e-8; | |
142 | 3984 | values[temperatureIdx] += time_ * 1e-3; | |
143 | } | ||
144 | |||
145 | 3984 | return values; | |
146 | } | ||
147 | |||
148 | /*! | ||
149 | * \brief Evaluates the boundary conditions for a Neumann boundary segment. | ||
150 | */ | ||
151 | ✗ | NumEqVector neumannAtPos(const GlobalPosition& globalPos) const | |
152 | { | ||
153 |
2/2✓ Branch 0 taken 293760 times.
✓ Branch 1 taken 193392 times.
|
4462704 | return NumEqVector(0.0); |
154 | } | ||
155 | |||
156 | // \} | ||
157 | |||
158 | /*! | ||
159 | * \name Volume terms | ||
160 | */ | ||
161 | // \{ | ||
162 | |||
163 | /*! | ||
164 | * \brief Evaluates the source term for all phases within a given | ||
165 | * sub-control volume. | ||
166 | * | ||
167 | * For this method, the \a priVars parameter stores the rate mass | ||
168 | * of a component is generated or annihilated per volume | ||
169 | * unit. Positive values mean that mass is created, negative ones | ||
170 | * mean that it vanishes. | ||
171 | * | ||
172 | * The units must be according to either using mole or mass fractions (mole/(m^3*s) or kg/(m^3*s)). | ||
173 | */ | ||
174 | ✗ | NumEqVector sourceAtPos(const GlobalPosition &globalPos) const | |
175 | 1468800 | { return NumEqVector(0.0); } | |
176 | |||
177 | /*! | ||
178 | * \brief Evaluates the initial value for a control volume. | ||
179 | * | ||
180 | * \param globalPos The position for which the initial condition should be evaluated | ||
181 | * | ||
182 | * For this method, the \a values parameter stores primary | ||
183 | * variables. | ||
184 | */ | ||
185 | PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const | ||
186 | 1288 | { return initial_(globalPos); } | |
187 | |||
188 | /*! | ||
189 | * \brief Set the simulation time. | ||
190 | * | ||
191 | * \param t The current time. | ||
192 | */ | ||
193 | ✗ | void setTime(Scalar t) | |
194 |
1/2✓ Branch 1 taken 258 times.
✗ Branch 2 not taken.
|
258 | { time_ = t; } |
195 | |||
196 | // \} | ||
197 | private: | ||
198 | |||
199 | // the internal method for the initial condition | ||
200 | PrimaryVariables initial_(const GlobalPosition& globalPos) const | ||
201 | { | ||
202 | 4628 | PrimaryVariables priVars; | |
203 | |||
204 |
20/20✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 1992 times.
✓ Branch 2 taken 1992 times.
✓ Branch 3 taken 1992 times.
✓ Branch 4 taken 1992 times.
✓ Branch 5 taken 1992 times.
✓ Branch 6 taken 1992 times.
✓ Branch 7 taken 1992 times.
✓ Branch 8 taken 1992 times.
✓ Branch 9 taken 1992 times.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 640 times.
✓ Branch 12 taken 4 times.
✓ Branch 13 taken 640 times.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 640 times.
✓ Branch 16 taken 4 times.
✓ Branch 17 taken 640 times.
✓ Branch 18 taken 4 times.
✓ Branch 19 taken 640 times.
|
23140 | if (globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_) |
205 | { | ||
206 | 1996 | priVars[pressureIdx] = 1.1e5; // initial condition for the pressure | |
207 | 1996 | priVars[N2Idx] = 2e-10; // initial condition for the N2 molefraction | |
208 | 3992 | priVars[temperatureIdx] = 300.00; | |
209 | } | ||
210 | else | ||
211 | { | ||
212 | 2632 | priVars[pressureIdx] = 1.0e5; | |
213 | 2632 | priVars[N2Idx] = 0.0; | |
214 | 5264 | priVars[temperatureIdx] = 285.00; | |
215 | } | ||
216 | return priVars; | ||
217 | } | ||
218 | |||
219 | static constexpr Scalar eps_ = 1e-6; | ||
220 | Scalar time_ = 0.0; | ||
221 | }; | ||
222 | |||
223 | } // end namespace Dumux | ||
224 | |||
225 | #endif | ||
226 |