3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/porousmediumflow/2p2c/implicit/waterair/problem.hh
Go to the documentation of this file.
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
26#ifndef DUMUX_WATER_AIR_PROBLEM_HH
27#define DUMUX_WATER_AIR_PROBLEM_HH
28
29#include <dune/grid/yaspgrid.hh>
30
34
39
40#include "spatialparams.hh"
41
42namespace Dumux {
43
44template <class TypeTag>
45class WaterAirProblem;
46
47namespace Properties {
48// Create new type tags
49namespace TTag {
50struct WaterAir { using InheritsFrom = std::tuple<TwoPTwoCNI>; };
51struct WaterAirBox { using InheritsFrom = std::tuple<WaterAir, BoxModel>; };
52struct WaterAirCCTpfa { using InheritsFrom = std::tuple<WaterAir, CCTpfaModel>; };
53} // end namespace TTag
54
55// Set the grid type
56template<class TypeTag>
57struct Grid<TypeTag, TTag::WaterAir> { using type = Dune::YaspGrid<2>; };
58
59// Set the problem property
60template<class TypeTag>
61struct Problem<TypeTag, TTag::WaterAir> { using type = WaterAirProblem<TypeTag>; };
62
63// Set the wetting phase
64template<class TypeTag>
66
67// Set the spatial parameters
68template<class TypeTag>
69struct SpatialParams<TypeTag, TTag::WaterAir>
70{
74};
75
76// Define whether mole(true) or mass (false) fractions are used
77template<class TypeTag>
78struct UseMoles<TypeTag, TTag::WaterAir> { static constexpr bool value = true; };
79} // end namespace Dumux
80
115template <class TypeTag >
117{
119
124 using Indices = typename ModelTraits::Indices;
125
126 // primary variable indices
127 enum
128 {
129 pressureIdx = Indices::pressureIdx,
130 switchIdx = Indices::switchIdx,
131 temperatureIdx = Indices::temperatureIdx,
132 energyEqIdx = Indices::energyEqIdx
133 };
134
135 // equation indices
136 enum
137 {
138 contiH2OEqIdx = Indices::conti0EqIdx + FluidSystem::H2OIdx,
139 contiN2EqIdx = Indices::conti0EqIdx + FluidSystem::N2Idx
140 };
141
142 // phase presence
143 enum { wPhaseOnly = Indices::firstPhaseOnly };
144 // component index
145 enum { N2Idx = FluidSystem::N2Idx };
146
150 using Element = typename GridView::template Codim<0>::Entity;
151 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
152 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
154 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
155 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
156
158 static constexpr bool useMoles = ModelTraits::useMoles();
159
160public:
161 WaterAirProblem(std::shared_ptr<const GridGeometry> gridGeometry)
163 {
164 maxDepth_ = 1000.0; // [m]
165
166 FluidSystem::init();
167
168 name_ = getParam<std::string>("Problem.Name");
169 useDirichlet_ = name_.find("buoyancy") != std::string::npos;
170
171 //stating in the console whether mole or mass fractions are used
172 if(useMoles)
173 std::cout << "The problem uses mole-fractions" << std::endl;
174 else
175 std::cout << "The problem uses mass-fractions" << std::endl;
176
177 this->spatialParams().plotMaterialLaw();
178 }
179
183 // \{
184
190 const std::string& name() const
191 { return name_; }
192
193 // \}
194
198 // \{
199
206 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
207 {
208 BoundaryTypes bcTypes;
209 if(globalPos[0] > 40 - eps_ || globalPos[0] < eps_)
210 bcTypes.setAllDirichlet();
211 else
212 bcTypes.setAllNeumann();
213
214 if (useDirichlet_)
215 {
216 if (isInjectionArea_(globalPos))
217 bcTypes.setAllDirichlet();
218 }
219
220 return bcTypes;
221 }
222
228 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
229 {
230 PrimaryVariables priVars = initial_(globalPos);
231
232 if (useDirichlet_)
233 {
234 if (isInjectionArea_(globalPos))
235 {
236 priVars.setState(Indices::bothPhases);
237 priVars[switchIdx] = 0.2;
238 return priVars;
239 }
240 }
241
242 return priVars;
243 }
244
253 NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
254 {
255 NumEqVector values(0.0);
256
257 // we inject pure gasious nitrogen at the initial condition temperature and pressure from the bottom (negative values mean injection)
258 if (isInjectionArea_(globalPos))
259 {
260 values[contiN2EqIdx] = useMoles ? -1e-3/FluidSystem::molarMass(N2Idx) : -1e-3; // kg/(m^2*s) or mole/(m^2*s)
261
262 const auto initialValues = initial_(globalPos);
263 const auto& mParams = this->spatialParams().materialLawParamsAtPos(globalPos);
264 using MaterialLaw = typename ParentType::SpatialParams::MaterialLaw;
265 const auto pn = initialValues[pressureIdx] + MaterialLaw::endPointPc(mParams);
266 const auto t = initialValues[temperatureIdx];
267
268 // note: energy equation is always formulated in terms of mass specific quantities, not per mole
269 values[energyEqIdx] = -1e-3*Components::N2<Scalar>::gasEnthalpy(t, pn);
270 }
271
272 return values;
273 }
274
275 // \}
276
280 // \{
281
290 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
291 {
292 auto priVars = initial_(globalPos);
293 // initially there is a heated lens in the domain
294 if (globalPos[0] > 20 - eps_ && globalPos[0] < 30 + eps_ && globalPos[1] < 30 + eps_)
295 priVars[temperatureIdx] = 380.0;
296
297 return priVars;
298 }
299
300private:
301 // internal method for the initial condition (reused for the
302 // dirichlet conditions!)
303 PrimaryVariables initial_(const GlobalPosition &globalPos) const
304 {
305 PrimaryVariables priVars(0.0);
306 priVars.setState(wPhaseOnly);
307 Scalar densityW = 1000.0;
308 priVars[pressureIdx] = 1e5 + (maxDepth_ - globalPos[1])*densityW*9.81;
309 priVars[switchIdx] = 0.0;
310 priVars[temperatureIdx] = initialTemperatureProfile_(globalPos);
311 return priVars;
312 }
313
314 Scalar initialTemperatureProfile_(const GlobalPosition &globalPos) const
315 { return 283.0 + (maxDepth_ - globalPos[1])*0.03; }
316
317 bool isInjectionArea_(const GlobalPosition& globalPos) const
318 {
319 return globalPos[0] > 14.8 - eps_ && globalPos[0] < 25.2 + eps_ && globalPos[1] < eps_;
320 }
321
322 Scalar maxDepth_;
323 static constexpr Scalar eps_ = 1e-2;
324 std::string name_;
325 bool useDirichlet_;
326};
327
328} // end namespace Dumux
329
330#endif
Defines a type tag and some properties for models using the box scheme.
Properties for all models using cell-centered finite volume scheme with TPFA.
The available discretization methods in Dumux.
Properties of pure molecular nitrogen .
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
Property tag Indices
Definition: porousmediumflow/sequential/properties.hh:59
Base class for all finite-volume problems.
Definition: common/fvproblem.hh:50
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:588
The DUNE grid type.
Definition: common/properties.hh:57
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:69
Property whether to use moles or kg as amount unit for balance equations.
Definition: common/properties.hh:102
The type of the spatial parameters object.
Definition: common/properties.hh:221
The type of the fluid system to use.
Definition: common/properties.hh:223
static const Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of pure nitrogen gas.
Definition: n2.hh:176
A two-phase fluid system with two components water Nitrogen for non-equilibrium models.
Definition: h2on2.hh:69
Base class for all fully implicit porous media problems.
Definition: dumux/porousmediumflow/problem.hh:39
SpatialParams & spatialParams()
Returns the spatial parameters object.
Definition: dumux/porousmediumflow/problem.hh:146
Non-isothermal gas injection problem where a gas (e.g. air) is injected into a fully water saturated ...
Definition: test/porousmediumflow/2p2c/implicit/waterair/problem.hh:117
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/porousmediumflow/2p2c/implicit/waterair/problem.hh:290
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/2p2c/implicit/waterair/problem.hh:228
NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Neumann boundary segment.
Definition: test/porousmediumflow/2p2c/implicit/waterair/problem.hh:253
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: test/porousmediumflow/2p2c/implicit/waterair/problem.hh:206
WaterAirProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/2p2c/implicit/waterair/problem.hh:161
const std::string & name() const
The problem name.
Definition: test/porousmediumflow/2p2c/implicit/waterair/problem.hh:190
Definition: test/porousmediumflow/2p2c/implicit/waterair/problem.hh:50
std::tuple< TwoPTwoCNI > InheritsFrom
Definition: test/porousmediumflow/2p2c/implicit/waterair/problem.hh:50
Definition: test/porousmediumflow/2p2c/implicit/waterair/problem.hh:51
std::tuple< WaterAir, BoxModel > InheritsFrom
Definition: test/porousmediumflow/2p2c/implicit/waterair/problem.hh:51
Definition: test/porousmediumflow/2p2c/implicit/waterair/problem.hh:52
std::tuple< WaterAir, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/2p2c/implicit/waterair/problem.hh:52
Dune::YaspGrid< 2 > type
Definition: test/porousmediumflow/2p2c/implicit/waterair/problem.hh:57
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/2p2c/implicit/waterair/problem.hh:71
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/2p2c/implicit/waterair/problem.hh:72
Definition of the spatial parameters for the water-air problem.
Definition: porousmediumflow/2p2c/implicit/waterair/spatialparams.hh:46
Adaption of the fully implicit scheme to the two-phase two-component fully implicit model.
Base class for all porous media problems.
Definition of the spatial parameters for the MaxwellStefan problem.