3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/porousmediumflow/2p2c/implicit/injection/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 *****************************************************************************/
25#ifndef DUMUX_INJECTION_PROBLEM_HH
26#define DUMUX_INJECTION_PROBLEM_HH
27
28#include <dune/grid/yaspgrid.hh>
29
34
38
39#include "spatialparams.hh"
40
41namespace Dumux {
42
43#ifndef ENABLECACHING
44#define ENABLECACHING 0
45#endif
46
47template <class TypeTag>
48class InjectionProblem;
49
50namespace Properties {
51// Create new type tags
52namespace TTag {
53struct Injection { using InheritsFrom = std::tuple<TwoPTwoC>; };
54struct InjectionBox { using InheritsFrom = std::tuple<Injection, BoxModel>; };
55struct InjectionCCTpfa { using InheritsFrom = std::tuple<Injection, CCTpfaModel>; };
56struct InjectionCCMpfa { using InheritsFrom = std::tuple<Injection, CCMpfaModel>; };
57} // end namespace TTag
58
59// Set the grid type
60template<class TypeTag>
61struct Grid<TypeTag, TTag::Injection> { using type = Dune::YaspGrid<2>; };
62
63// Set the problem property
64template<class TypeTag>
65struct Problem<TypeTag, TTag::Injection> { using type = InjectionProblem<TypeTag>; };
66
67// Set fluid configuration
68template<class TypeTag>
69struct FluidSystem<TypeTag, TTag::Injection>
70{
72 FluidSystems::H2ON2DefaultPolicy</*fastButSimplifiedRelations=*/true>>;
73};
74
75// Set the spatial parameters
76template<class TypeTag>
77struct SpatialParams<TypeTag, TTag::Injection>
78{
82};
83
84// Define whether mole(true) or mass (false) fractions are used
85template<class TypeTag>
86struct UseMoles<TypeTag, TTag::Injection> { static constexpr bool value = true; };
87
88// Enable caching or not (reference solutions created without caching)
89template<class TypeTag>
90struct EnableGridGeometryCache<TypeTag, TTag::Injection> { static constexpr bool value = ENABLECACHING; };
91template<class TypeTag>
92struct EnableGridVolumeVariablesCache<TypeTag, TTag::Injection> { static constexpr bool value = ENABLECACHING; };
93template<class TypeTag>
94struct EnableGridFluxVariablesCache<TypeTag, TTag::Injection> { static constexpr bool value = ENABLECACHING; };
95
96// use the static interaction volume around interior vertices in the mpfa test
97template<class TypeTag>
98struct PrimaryInteractionVolume<TypeTag, TTag::InjectionCCMpfa>
99{
100private:
103
104 // structured two-d grid
105 static constexpr int numIvScvs = 4;
106 static constexpr int numIvScvfs = 4;
107
108 // use the default traits
110public:
112};
113} // end namespace Properties
114
141template <class TypeTag>
143{
149
151 using Indices = typename ModelTraits::Indices;
152
153 // primary variable indices
154 enum
155 {
156 pressureIdx = Indices::pressureIdx,
157 switchIdx = Indices::switchIdx
158 };
159
160 // phase presence
161 enum { wPhaseOnly = Indices::firstPhaseOnly };
162
163 // equation indices
164 enum
165 {
166 contiH2OEqIdx = Indices::conti0EqIdx + FluidSystem::H2OIdx,
167 contiN2EqIdx = Indices::conti0EqIdx + FluidSystem::N2Idx,
168 };
169
170 // phase indices
171 enum
172 {
173 gasPhaseIdx = FluidSystem::N2Idx,
174 H2OIdx = FluidSystem::H2OIdx,
175 N2Idx = FluidSystem::N2Idx
176 };
177
181 using ElementVolumeVariables = typename GridVariables::GridVolumeVariables::LocalView;
182 using ElementFluxVariablesCache = typename GridVariables::GridFluxVariablesCache::LocalView;
184 using Element = typename GridView::template Codim<0>::Entity;
185 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
186 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
187 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
188
190 static constexpr bool useMoles = ModelTraits::useMoles();
191
192public:
193 InjectionProblem(std::shared_ptr<const GridGeometry> gridGeometry)
195 {
196 nTemperature_ = getParam<int>("Problem.NTemperature");
197 nPressure_ = getParam<int>("Problem.NPressure");
198 pressureLow_ = getParam<Scalar>("Problem.PressureLow");
199 pressureHigh_ = getParam<Scalar>("Problem.PressureHigh");
200 temperatureLow_ = getParam<Scalar>("Problem.TemperatureLow");
201 temperatureHigh_ = getParam<Scalar>("Problem.TemperatureHigh");
202 temperature_ = getParam<Scalar>("Problem.InitialTemperature");
203 depthBOR_ = getParam<Scalar>("Problem.DepthBOR");
204 name_ = getParam<std::string>("Problem.Name");
205
206 // initialize the tables of the fluid system
207 FluidSystem::init(/*Tmin=*/temperatureLow_,
208 /*Tmax=*/temperatureHigh_,
209 /*nT=*/nTemperature_,
210 /*pmin=*/pressureLow_,
211 /*pmax=*/pressureHigh_,
212 /*np=*/nPressure_);
213
214 // stating in the console whether mole or mass fractions are used
215 if(useMoles)
216 std::cout<<"problem uses mole-fractions"<<std::endl;
217 else
218 std::cout<<"problem uses mass-fractions"<<std::endl;
219 }
220
224 // \{
225
231 const std::string& name() const
232 { return name_; }
233
237 Scalar temperature() const
238 { return temperature_; }
239
240 // \}
241
245 // \{
246
253 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
254 {
255 BoundaryTypes bcTypes;
256 if (globalPos[0] < eps_)
257 bcTypes.setAllDirichlet();
258 else
259 bcTypes.setAllNeumann();
260 return bcTypes;
261 }
262
268 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
269 {
270 return initial_(globalPos);
271 }
272
288 NumEqVector neumann(const Element& element,
289 const FVElementGeometry& fvGeometry,
290 const ElementVolumeVariables& elemVolVars,
291 const ElementFluxVariablesCache& elemFluxVarsCache,
292 const SubControlVolumeFace& scvf) const
293 {
294 NumEqVector values(0.0);
295
296 const auto& globalPos = scvf.ipGlobal();
297
298 Scalar injectedPhaseMass = 1e-3;
299 Scalar moleFracW = elemVolVars[scvf.insideScvIdx()].moleFraction(gasPhaseIdx, H2OIdx);
300 if (globalPos[1] < 14 - eps_ && globalPos[1] > 6.5 - eps_)
301 {
302 values[contiN2EqIdx] = -(1-moleFracW)*injectedPhaseMass/FluidSystem::molarMass(N2Idx); //mole/(m^2*s) -> kg/(s*m^2)
303 values[contiH2OEqIdx] = -moleFracW*injectedPhaseMass/FluidSystem::molarMass(H2OIdx); //mole/(m^2*s) -> kg/(s*m^2)
304 }
305 return values;
306 }
307
308 // \}
309
313 // \{
314
320 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
321 { return initial_(globalPos); }
322
323 // \}
324
325private:
333 PrimaryVariables initial_(const GlobalPosition &globalPos) const
334 {
335 PrimaryVariables priVars(0.0);
336 priVars.setState(wPhaseOnly);
337
338 Scalar densityW = FluidSystem::H2O::liquidDensity(temperature_, 1e5);
339
340 Scalar pl = 1e5 - densityW*this->spatialParams().gravity(globalPos)[1]*(depthBOR_ - globalPos[1]);
341 Scalar moleFracLiquidN2 = pl*0.95/BinaryCoeff::H2O_N2::henry(temperature_);
342 Scalar moleFracLiquidH2O = 1.0 - moleFracLiquidN2;
343
344 Scalar meanM =
345 FluidSystem::molarMass(H2OIdx)*moleFracLiquidH2O +
346 FluidSystem::molarMass(N2Idx)*moleFracLiquidN2;
347 if(useMoles)
348 {
349 //mole-fraction formulation
350 priVars[switchIdx] = moleFracLiquidN2;
351 }
352 else
353 {
354 //mass fraction formulation
355 Scalar massFracLiquidN2 = moleFracLiquidN2*FluidSystem::molarMass(N2Idx)/meanM;
356 priVars[switchIdx] = massFracLiquidN2;
357 }
358 priVars[pressureIdx] = pl;
359 return priVars;
360 }
361
362 Scalar temperature_;
363 Scalar depthBOR_;
364 static constexpr Scalar eps_ = 1e-6;
365
366 int nTemperature_;
367 int nPressure_;
368 Scalar pressureLow_, pressureHigh_;
369 Scalar temperatureLow_, temperatureHigh_;
370
371 std::string name_;
372};
373
374} // end namespace Dumux
375
376#endif
Class for the interaction volume of the mpfa-o scheme to be used when the sizes are known at compile ...
Defines a type tag and some properties for models using the box scheme.
Properties for all models using cell-centered finite volume scheme with mpfa.
Properties for all models using cell-centered finite volume scheme with TPFA.
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
Definition: common/properties.hh:169
If disabled, the volume variables are not stored (reduces memory, but is slower)
Definition: common/properties.hh:178
specifies if data on flux vars should be saved (faster, but more memory consuming)
Definition: common/properties.hh:188
The primary interaction volume type.
Definition: common/properties.hh:196
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
Forward declaration of the o-method's static interaction volume.
Definition: staticinteractionvolume.hh:126
The default interaction volume traits class for the mpfa-o method with known size of the interaction ...
Definition: staticinteractionvolume.hh:65
static Scalar henry(Scalar temperature)
Henry coefficient for molecular nitrogen in liquid water.
Definition: h2o_n2.hh:48
Policy for the H2O-N2 fluid system.
Definition: h2on2.hh:52
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 2D problem where steam is injected on the lower left side of the domain.
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:143
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:268
Scalar temperature() const
Returns the temperature [K].
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:237
InjectionProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:193
const std::string & name() const
Returns the problem name.
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:231
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial values for a control volume.
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:320
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/injection/problem.hh:253
NumEqVector neumann(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
Evaluates the boundary conditions for a Neumann boundary segment in dependency on the current solutio...
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:288
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:53
std::tuple< TwoPTwoC > InheritsFrom
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:53
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:54
std::tuple< Injection, BoxModel > InheritsFrom
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:54
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:55
std::tuple< Injection, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:55
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:56
std::tuple< Injection, CCMpfaModel > InheritsFrom
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:56
Dune::YaspGrid< 2 > type
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:61
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:80
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:79
Definition of the spatial parameters for the injection problem which uses the isothermal two-phase tw...
Definition: porousmediumflow/2p2c/implicit/injection/spatialparams.hh:45
Adaption of the fully implicit scheme to the two-phase two-component fully implicit model.
Base class for all porous media problems.
#define ENABLECACHING
Definition: test/porousmediumflow/2p2c/implicit/injection/problem.hh:44
Definition of the spatial parameters for the MaxwellStefan problem.