3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/porousmediumflow/mpnc/implicit/2p2ccomparison/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_MPNC_TWOPTWOC_COMPARISON_OBSTACLEPROBLEM_HH
27#define DUMUX_MPNC_TWOPTWOC_COMPARISON_OBSTACLEPROBLEM_HH
28
29#include <dune/common/parametertreeparser.hh>
30#include <dune/grid/yaspgrid.hh>
31
34
38
42
43#include "spatialparams.hh"
44
45namespace Dumux {
46
53template <class TypeTag>
54class MPNCComparisonProblem;
55
56namespace Properties {
57// Create new type tags
58namespace TTag {
59struct MPNCComparison { using InheritsFrom = std::tuple<MPNC>; };
60struct MPNCComparisonBox { using InheritsFrom = std::tuple<MPNCComparison, BoxModel>; };
61struct MPNCComparisonCC { using InheritsFrom = std::tuple<MPNCComparison, CCTpfaModel>; };
62} // end namespace TTag
63
64// Set the grid type
65template<class TypeTag>
66struct Grid<TypeTag, TTag::MPNCComparison> { using type = Dune::YaspGrid<2>; };
67
68// Set the problem property
69template<class TypeTag>
70struct Problem<TypeTag, TTag::MPNCComparison> { using type = MPNCComparisonProblem<TypeTag>; };
71
72// Set the spatial parameters
73template<class TypeTag>
74struct SpatialParams<TypeTag, TTag::MPNCComparison>
75{
79};
80
81// Set fluid configuration
82template<class TypeTag>
83struct FluidSystem<TypeTag, TTag::MPNCComparison>
84{
86 FluidSystems::H2ON2DefaultPolicy</*fastButSimplifiedRelations=*/true>>;
87};
88
89// decide which type to use for floating values (double / quad)
90template<class TypeTag>
91struct Scalar<TypeTag, TTag::MPNCComparison> { using type = double; };
92template<class TypeTag>
93struct UseMoles<TypeTag, TTag::MPNCComparison> { static constexpr bool value = true; };
94template<class TypeTag>
95struct IOFields<TypeTag, TTag::MPNCComparison> { using type = TwoPTwoCMPNCIOFields; };
96} // end namespace Dumux
97
105template <class TypeTag>
107 : public PorousMediumFlowProblem<TypeTag>
108{
116 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
117 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
118 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
120 using Element = typename GridView::template Codim<0>::Entity;
123 using ParameterCache = typename FluidSystem::ParameterCache;
124
125 static constexpr auto numPhases = GetPropType<TypeTag, Properties::ModelTraits>::numFluidPhases();
126 static constexpr auto numComponents = GetPropType<TypeTag, Properties::ModelTraits>::numFluidComponents();
127 static constexpr auto gasPhaseIdx = FluidSystem::gasPhaseIdx;
128 static constexpr auto liquidPhaseIdx = FluidSystem::liquidPhaseIdx;
129 static constexpr auto wCompIdx = FluidSystem::H2OIdx;
130 static constexpr auto nCompIdx = FluidSystem::N2Idx;
131 static constexpr auto fug0Idx = Indices::fug0Idx;
132 static constexpr auto s0Idx = Indices::s0Idx;
133 static constexpr auto p0Idx = Indices::p0Idx;
134
135 using GlobalPosition = typename SubControlVolumeFace::GlobalPosition;
136 using PhaseVector = Dune::FieldVector<Scalar, numPhases>;
138
139public:
140 MPNCComparisonProblem(std::shared_ptr<const GridGeometry> gridGeometry)
142 {
143 temperature_ = 273.15 + 25; // -> 25°C
144
145 // initialize the tables of the fluid system
146 Scalar Tmin = temperature_ - 1.0;
147 Scalar Tmax = temperature_ + 1.0;
148 int nT = 3;
149
150 Scalar pmin = 1.0e5 * 0.75;
151 Scalar pmax = 2.0e5 * 1.25;
152 int np = 1000;
153
154 FluidSystem::init(Tmin, Tmax, nT, pmin, pmax, np);
155 name_ = getParam<std::string>("Problem.Name");
156 }
157
161 // \{
162
168 const std::string name() const
169 { return name_; }
170
175 Scalar temperature() const
176 { return temperature_; }
177
178 // \}
179
183 // \{
190 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
191 {
192 BoundaryTypes bcTypes;
193 if (onOutlet_(globalPos))
194 bcTypes.setAllDirichlet();
195 else
196 bcTypes.setAllNeumann();
197 return bcTypes;
198 }
199
205 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
206 {
207 return initial_(globalPos);
208 }
209
214 NeumannFluxes neumannAtPos(const GlobalPosition& globalPos) const
215 {
216 NeumannFluxes values(0.0);
217 Scalar injectedAirMass = -1e-3;
218 Scalar injectedAirMolarMass = injectedAirMass/FluidSystem::molarMass(FluidSystem::N2Idx);
219 if (onInlet_(globalPos))
220 values[Indices::conti0EqIdx + FluidSystem::N2Idx] = injectedAirMolarMass;
221 return values;
222 }
223
224 // \}
225
229 // \{
230
239 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
240 {
241 return initial_(globalPos);
242 }
243
244 // \}
245
246private:
247 // the internal method for the initial condition
248 PrimaryVariables initial_(const GlobalPosition &globalPos) const
249 {
250 PrimaryVariables values(0.0);
251 FluidState fs;
252
253 // set the fluid temperatures
254 fs.setTemperature(this->temperatureAtPos(globalPos));
255
256 // set water saturation
257 fs.setSaturation(liquidPhaseIdx, 0.8);
258 fs.setSaturation(gasPhaseIdx, 1.0 - fs.saturation(liquidPhaseIdx));
259 // set pressure of the gas phase
260 fs.setPressure(gasPhaseIdx, 1e5);
261 // calulate the capillary pressure
262 const auto& matParams =
263 this->spatialParams().materialLawParamsAtPos(globalPos);
264 PhaseVector pc;
265 using MaterialLaw = typename ParentType::SpatialParams::MaterialLaw;
267
268 const int wPhaseIdx = this->spatialParams().template wettingPhaseAtPos<FluidSystem>(globalPos);
269 MPAdapter::capillaryPressures(pc, matParams, fs, wPhaseIdx);
270 fs.setPressure(liquidPhaseIdx,
271 fs.pressure(gasPhaseIdx) + pc[liquidPhaseIdx] - pc[gasPhaseIdx]);
272
273 // make the fluid state consistent with local thermodynamic
274 // equilibrium
276
277 ParameterCache paramCache;
279
281 // assign the primary variables
283
284 // all N component fugacities
285 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
286 values[fug0Idx + compIdx] = fs.fugacity(gasPhaseIdx, compIdx);
287
288 // first M - 1 saturations
289 for (int phaseIdx = 0; phaseIdx < numPhases - 1; ++phaseIdx)
290 values[s0Idx + phaseIdx] = fs.saturation(phaseIdx);
291
292 // first pressure
293 values[p0Idx] = fs.pressure(/*phaseIdx=*/0);
294 return values;
295 }
296
297 bool onInlet_(const GlobalPosition &globalPos) const
298 {
299 Scalar x = globalPos[0];
300 Scalar y = globalPos[1];
301 return x >= 60 - eps_ && y <= 10 + eps_;
302 }
303
304 bool onOutlet_(const GlobalPosition &globalPos) const
305 {
306 Scalar x = globalPos[0];
307 Scalar y = globalPos[1];
308 return x < eps_ && y <= 10 + eps_;
309 }
310
311 Scalar temperature_;
312 static constexpr Scalar eps_ = 1e-6;
313 std::string name_;
314};
315} // end namespace
316
317#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.
Computes the composition of all phases of a N-phase, N-component fluid system assuming that all N pha...
Represents all relevant thermodynamic quantities of a multi-phase, multi-component fluid system assum...
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
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
Property to specify the type of scalar values.
Definition: common/properties.hh:53
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
A class helping models to define input and output fields.
Definition: common/properties.hh:78
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
Computes the composition of all phases of a N-phase, N-component fluid system assuming that all N pha...
Definition: misciblemultiphasecomposition.hh:60
static void solve(FluidState &fluidState, ParameterCache &paramCache, int knownPhaseIdx=0)
Computes the composition of all phases of a N-phase, N-component fluid system assuming that all N pha...
Definition: misciblemultiphasecomposition.hh:82
An adapter for mpnc to use the capillary pressure-saturation relationships.
Definition: mpadapter.hh:42
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
Scalar temperatureAtPos(const GlobalPosition &globalPos) const
Returns the temperature at a given global position.
Definition: dumux/porousmediumflow/problem.hh:105
SpatialParams & spatialParams()
Returns the spatial parameters object.
Definition: dumux/porousmediumflow/problem.hh:146
Adds I/O fields specific to the two-phase two-component model.
Definition: test/porousmediumflow/2p2c/implicit/mpnccomparison/iofields.hh:36
Problem where air is injected in a unsaturated porous medium.
Definition: test/porousmediumflow/mpnc/implicit/2p2ccomparison/problem.hh:108
MPNCComparisonProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/mpnc/implicit/2p2ccomparison/problem.hh:140
NeumannFluxes neumannAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Neumann boundary segment.
Definition: test/porousmediumflow/mpnc/implicit/2p2ccomparison/problem.hh:214
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/mpnc/implicit/2p2ccomparison/problem.hh:190
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/mpnc/implicit/2p2ccomparison/problem.hh:205
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/porousmediumflow/mpnc/implicit/2p2ccomparison/problem.hh:239
Scalar temperature() const
Returns the temperature .
Definition: test/porousmediumflow/mpnc/implicit/2p2ccomparison/problem.hh:175
const std::string name() const
Returns the problem name.
Definition: test/porousmediumflow/mpnc/implicit/2p2ccomparison/problem.hh:168
Definition: test/porousmediumflow/mpnc/implicit/2p2ccomparison/problem.hh:59
std::tuple< MPNC > InheritsFrom
Definition: test/porousmediumflow/mpnc/implicit/2p2ccomparison/problem.hh:59
Definition: test/porousmediumflow/mpnc/implicit/2p2ccomparison/problem.hh:60
std::tuple< MPNCComparison, BoxModel > InheritsFrom
Definition: test/porousmediumflow/mpnc/implicit/2p2ccomparison/problem.hh:60
Definition: test/porousmediumflow/mpnc/implicit/2p2ccomparison/problem.hh:61
std::tuple< MPNCComparison, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/mpnc/implicit/2p2ccomparison/problem.hh:61
Dune::YaspGrid< 2 > type
Definition: test/porousmediumflow/mpnc/implicit/2p2ccomparison/problem.hh:66
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/mpnc/implicit/2p2ccomparison/problem.hh:77
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/mpnc/implicit/2p2ccomparison/problem.hh:76
double type
Definition: test/porousmediumflow/mpnc/implicit/2p2ccomparison/problem.hh:91
Definition of the spatial params properties for the obstacle problem.
Definition: porousmediumflow/mpnc/implicit/2p2ccomparison/spatialparams.hh:46
A fully implicit model for MpNc flow using vertex centered finite volumes.
Adds I/O fields specific to the twop model.
Base class for all porous media problems.
Definition of the spatial parameters for the MaxwellStefan problem.