3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/porousmediumflow/mpnc/implicit/obstacle/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 *****************************************************************************/
28#ifndef DUMUX_OBSTACLEPROBLEM_HH
29#define DUMUX_OBSTACLEPROBLEM_HH
30
31#include <dune/common/parametertreeparser.hh>
32#include <dune/grid/yaspgrid.hh>
33
36
39
43
44#include "spatialparams.hh"
45
46namespace Dumux {
47
56template <class TypeTag>
57class ObstacleProblem;
58
59namespace Properties {
60// Create new type tags
61namespace TTag {
62struct Obstacle { using InheritsFrom = std::tuple<MPNC>; };
63struct ObstacleBox { using InheritsFrom = std::tuple<Obstacle, BoxModel>; };
64struct ObstacleCC { using InheritsFrom = std::tuple<Obstacle, CCTpfaModel>; };
65} // end namespace TTag
66
67// Set the grid type
68template<class TypeTag>
69struct Grid<TypeTag, TTag::Obstacle> { using type = Dune::YaspGrid<2>; };
70
71// Set the problem property
72template<class TypeTag>
73struct Problem<TypeTag, TTag::Obstacle> { using type = ObstacleProblem<TypeTag>; };
74
75// Set the spatial parameters
76template<class TypeTag>
77struct SpatialParams<TypeTag, TTag::Obstacle>
78{
82};
83
84// Set fluid configuration
85template<class TypeTag>
86struct FluidSystem<TypeTag, TTag::Obstacle>
87{
89 FluidSystems::H2ON2DefaultPolicy</*fastButSimplifiedRelations=*/true>>;
90};
91
92// decide which type to use for floating values (double / quad)
93template<class TypeTag>
94struct Scalar<TypeTag, TTag::Obstacle> { using type = double; };
95
96}
97
126template <class TypeTag>
128 : public PorousMediumFlowProblem<TypeTag>
129{
136 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
137 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
138 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
139 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
141 using Element = typename GridView::template Codim<0>::Entity;
144 using ParameterCache = typename FluidSystem::ParameterCache;
145
147 using Indices = typename ModelTraits::Indices;
148
149 enum { dimWorld = GridView::dimensionworld };
150 enum { numPhases = ModelTraits::numFluidPhases() };
151 enum { numComponents = ModelTraits::numFluidComponents() };
152 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
153 enum { liquidPhaseIdx = FluidSystem::liquidPhaseIdx };
154 enum { H2OIdx = FluidSystem::H2OIdx };
155 enum { N2Idx = FluidSystem::N2Idx };
156 enum { fug0Idx = Indices::fug0Idx };
157 enum { s0Idx = Indices::s0Idx };
158 enum { p0Idx = Indices::p0Idx };
159
160 using GlobalPosition = typename SubControlVolume::GlobalPosition;
161 using PhaseVector = Dune::FieldVector<Scalar, numPhases>;
162
163public:
164 ObstacleProblem(std::shared_ptr<const GridGeometry> gridGeometry)
166 {
167 temperature_ = 273.15 + 25; // -> 25°C
168
169 // initialize the tables of the fluid system
170 Scalar Tmin = temperature_ - 1.0;
171 Scalar Tmax = temperature_ + 1.0;
172 int nT = 3;
173
174 Scalar pmin = 1.0e5 * 0.75;
175 Scalar pmax = 2.0e5 * 1.25;
176 int np = 1000;
177
178 FluidSystem::init(Tmin, Tmax, nT, pmin, pmax, np);
179 name_ = getParam<std::string>("Problem.Name");
180 }
181
185 // \{
186
192 const std::string name() const
193 { return name_; }
194
198 Scalar temperature() const
199 { return temperature_; }
200
205 {
206 return ParentType::shouldWriteRestartFile();
207 }
208
209 // \}
210
214 // \{
221 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
222 {
223 BoundaryTypes bcTypes;
224 if (onInlet_(globalPos) || onOutlet_(globalPos))
225 bcTypes.setAllDirichlet();
226 else
227 bcTypes.setAllNeumann();
228 return bcTypes;
229 }
230
236 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
237 {
238 return initial_(globalPos);
239 }
240
244 NumEqVector neumannAtPos(const GlobalPosition& globalPos) const
245 {
246 return NumEqVector(0.0);
247 }
248
249 // \}
250
254 // \{
255
267 NumEqVector source(const Element &element,
268 const FVElementGeometry& fvGeometry,
269 const ElementVolumeVariables& elemVolVars,
270 const SubControlVolume &scv) const
271 {
272 return NumEqVector(0.0);
273 }
274
283 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
284 {
285 return initial_(globalPos);
286 }
287
288 // \}
289
290private:
291 // the internal method for the initial condition
292 PrimaryVariables initial_(const GlobalPosition &globalPos) const
293 {
294 PrimaryVariables values(0.0);
295 FluidState fs;
296
297 int refPhaseIdx;
298 int otherPhaseIdx;
299
300 // set the fluid temperatures
301 fs.setTemperature(this->temperatureAtPos(globalPos));
302
303 if (onInlet_(globalPos))
304 {
305 // only liquid on inlet
306 refPhaseIdx = liquidPhaseIdx;
307 otherPhaseIdx = gasPhaseIdx;
308
309 // set liquid saturation
310 fs.setSaturation(liquidPhaseIdx, 1.0);
311
312 // set pressure of the liquid phase
313 fs.setPressure(liquidPhaseIdx, 2e5);
314
315 // set the liquid composition to pure water
316 fs.setMoleFraction(liquidPhaseIdx, N2Idx, 0.0);
317 fs.setMoleFraction(liquidPhaseIdx, H2OIdx, 1.0);
318 }
319 else {
320 // elsewhere, only gas
321 refPhaseIdx = gasPhaseIdx;
322 otherPhaseIdx = liquidPhaseIdx;
323
324 // set gas saturation
325 fs.setSaturation(gasPhaseIdx, 1.0);
326
327 // set pressure of the gas phase
328 fs.setPressure(gasPhaseIdx, 1e5);
329
330 // set the gas composition to 99% nitrogen and 1% steam
331 fs.setMoleFraction(gasPhaseIdx, N2Idx, 0.99);
332 fs.setMoleFraction(gasPhaseIdx, H2OIdx, 0.01);
333 }
334
335 // set the other saturation
336 fs.setSaturation(otherPhaseIdx, 1.0 - fs.saturation(refPhaseIdx));
337
338 // calulate the capillary pressure
339 const auto& matParams = this->spatialParams().materialLawParamsAtPos(globalPos);
340 PhaseVector pc;
341 using MaterialLaw = typename ParentType::SpatialParams::MaterialLaw;
342 using MPAdapter = MPAdapter<MaterialLaw, numPhases>;
343
344 const int wPhaseIdx = this->spatialParams().template wettingPhaseAtPos<FluidSystem>(globalPos);
345 MPAdapter::capillaryPressures(pc, matParams, fs, wPhaseIdx);
346 fs.setPressure(otherPhaseIdx,
347 fs.pressure(refPhaseIdx)
348 + (pc[otherPhaseIdx] - pc[refPhaseIdx]));
349
350 // make the fluid state consistent with local thermodynamic
351 // equilibrium
352 using ComputeFromReferencePhase = ComputeFromReferencePhase<Scalar, FluidSystem>;
353
354 ParameterCache paramCache;
356 paramCache,
357 refPhaseIdx);
358
360 // assign the primary variables
362
363 // all N component fugacities
364 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
365 values[fug0Idx + compIdx] = fs.fugacity(refPhaseIdx, compIdx);
366
367 // first M - 1 saturations
368 for (int phaseIdx = 0; phaseIdx < numPhases - 1; ++phaseIdx)
369 values[s0Idx + phaseIdx] = fs.saturation(phaseIdx);
370
371 // first pressure
372 values[p0Idx] = fs.pressure(/*phaseIdx=*/0);
373 return values;
374 }
375
376 bool onInlet_(const GlobalPosition &globalPos) const
377 {
378 Scalar x = globalPos[0];
379 Scalar y = globalPos[1];
380 return x >= 60 - eps_ && y <= 10 + eps_;
381 }
382
383 bool onOutlet_(const GlobalPosition &globalPos) const
384 {
385 Scalar x = globalPos[0];
386 Scalar y = globalPos[1];
387 return x < eps_ && y <= 10 + eps_;
388 }
389
390 Scalar temperature_;
391 static constexpr Scalar eps_ = 1e-6;
392 std::string name_;
393};
394} // end namespace Dumux
395
396#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 all quantities of a generic fluid state if a reference phase has been specified.
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
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
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
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 void solve(FluidState &fluidState, ParameterCache &paramCache, int refPhaseIdx)
Computes all quantities of a generic fluid state if a reference phase has been specified.
Definition: computefromreferencephase.hh:112
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
Problem where liquid water is injected which has to go around an obstacle with lower permeability.
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:129
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:236
bool shouldWriteRestartFile() const
Write a restart file?
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:204
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:283
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/obstacle/problem.hh:221
NumEqVector source(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Evaluates the source term for all balance equations within a given sub-control volume.
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:267
Scalar temperature() const
Returns the temperature .
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:198
const std::string name() const
Returns the problem name.
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:192
ObstacleProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:164
NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Neumann boundary segment.
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:244
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:62
std::tuple< MPNC > InheritsFrom
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:62
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:63
std::tuple< Obstacle, BoxModel > InheritsFrom
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:63
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:64
std::tuple< Obstacle, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:64
Dune::YaspGrid< 2 > type
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:69
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:79
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:80
double type
Definition: test/porousmediumflow/mpnc/implicit/obstacle/problem.hh:94
Definition of the spatial params properties for the obstacle problem.
Definition: porousmediumflow/mpnc/implicit/obstacle/spatialparams.hh:44
A fully implicit model for MpNc flow using vertex centered finite volumes.
Base class for all porous media problems.
Definition of the spatial parameters for the MaxwellStefan problem.