3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test_mpfa2pproblem.hh
Go to the documentation of this file.
1/*****************************************************************************
2 * See the file COPYING for full copying permissions. *
3 * *
4 * This program is free software: you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation, either version 3 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
16 *****************************************************************************/
17
24#ifndef DUMUX_TEST_MPFA2P_PROBLEM_HH
25#define DUMUX_TEST_MPFA2P_PROBLEM_HH
26
27#if HAVE_UG
28#include <dune/grid/uggrid.hh>
29#endif
30#include <dune/grid/yaspgrid.hh>
31
36
44
45
48
52
53namespace Dumux
54{
55
56template<class TypeTag>
57class MPFATwoPTestProblem;
58
60// Specify the properties
62namespace Properties
63{
64
66
67// Set the grid type
68#if HAVE_UG
69SET_TYPE_PROP(MPFATwoPTest, Grid, Dune::UGGrid<2>);
70#else
71SET_TYPE_PROP(MPFATwoPTest, Grid, Dune::YaspGrid<2>);
72#endif
73
74// Set the problem property
76
77// Set the fluid system
78template<class TypeTag>
79struct FluidSystem<TypeTag, TTag::MPFATwoPTest>
80{
81 using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
83#if PROBLEM == 2
85#else
87#endif
89};
90
91#if PROBLEM == 1
93#endif
94
97
98NEW_TYPE_TAG(FVTwoPTest, INHERITS_FROM(FVPressureTwoP, FVTransportTwoP, IMPESTwoP, MPFATwoPTest));
99NEW_TYPE_TAG(FVAdaptiveTwoPTest, INHERITS_FROM(FVPressureTwoPAdaptive, FVTransportTwoP, IMPESTwoPAdaptive, MPFATwoPTest));
100NEW_TYPE_TAG(MPFAOTwoPTest, INHERITS_FROM(FvMpfaO2dPressureTwoP, FVTransportTwoP, IMPESTwoP, MPFATwoPTest));
101NEW_TYPE_TAG(MPFALTwoPTest, INHERITS_FROM(FvMpfaL2dPressureTwoP, FVTransportTwoP, IMPESTwoP, MPFATwoPTest));
102NEW_TYPE_TAG(MPFALAdaptiveTwoPTest, INHERITS_FROM(FvMpfaL2dPressureTwoPAdaptive, FVTransportTwoP, IMPESTwoPAdaptive, MPFATwoPTest));
103
104}
105
129template<class TypeTag>
131{
133using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
134using Grid = typename GridView::Grid;
135
136using Indices = typename GET_PROP_TYPE(TypeTag, ModelTraits)::Indices;
137
138using WettingPhase = typename GET_PROP(TypeTag, FluidSystem)::WettingPhase;
139
140using TimeManager = typename GET_PROP_TYPE(TypeTag, TimeManager);
141
142using BoundaryTypes = typename GET_PROP_TYPE(TypeTag, BoundaryTypes);
143using SolutionTypes = typename GET_PROP(TypeTag, SolutionTypes);
144using PrimaryVariables = typename SolutionTypes::PrimaryVariables;
145
146enum
147{
148 dim = GridView::dimension, dimWorld = GridView::dimensionworld
149};
150
151enum
152{
153 nPhaseIdx = Indices::nPhaseIdx,
154#if PROBLEM == 1
155 pnIdx = Indices::pnIdx,
156#else
157 pwIdx = Indices::pwIdx,
158#endif
159 swIdx = Indices::swIdx,
160 eqIdxPress = Indices::pressureEqIdx,
161 eqIdxSat = Indices::satEqIdx
162};
163
164using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
165
166using Element = typename GridView::Traits::template Codim<0>::Entity;
167using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
168
169public:
172#if PROBLEM != 2
173, analyticSolution_(*this)
174#endif
175{
176 int refinementFactor = getParam<Scalar>("Grid.RefinementFactor", 0);
177 this->grid().globalRefine(refinementFactor);
178
179 Scalar inletWidth = getParam<Scalar>("Problem.InletWidth", 1.0);
180 GlobalPosition inletCenter = this->bBoxMax();
181 inletCenter[0] *= 0.5;
182
183 inletLeftCoord_ = inletCenter;
184 inletLeftCoord_[0] -=0.5*inletWidth;
185 inletRightCoord_ = inletCenter;
186 inletRightCoord_[0] +=0.5*inletWidth;
187
188 inFlux_ = getParam<Scalar>("Problem.InjectionFlux", 1e-4);
189
190 int outputInterval = getParam<int>("Problem.OutputInterval", 0);
191 this->setOutputInterval(outputInterval);
192
193 Scalar outputTimeInterval = getParam<Scalar>("Problem.OutputTimeInterval", 1e6);
194 this->setOutputTimeInterval(outputTimeInterval);
195}
196
197#if PROBLEM != 2
198void init()
199{
201
202#if PROBLEM == 0
203 Scalar vTot = 3e-6;
204 analyticSolution_.initialize(vTot);
205#endif
206#if PROBLEM == 1
207 analyticSolution_.initialize();
208#endif
209}
210
212{
213 analyticSolution_.calculateAnalyticSolution();
214
216 analyticSolution_.addOutputVtkFields(this->resultWriter());
217}
218#endif
219
223// \{
224
230std::string name() const
231{
232 return getParam<std::string>("Problem.Name");
233}
234
236{
237 return false;
238}
239
240
246Scalar temperatureAtPos(const GlobalPosition& globalPos) const
247{
248 return 273.15 + 10; // -> 10°C
249}
250
251// \}
252
254Scalar referencePressureAtPos(const GlobalPosition& globalPos) const
255{
256 return 1e5; // -> 10°C
257}
258
259void source(PrimaryVariables &values,const Element& element) const
260{
261 values = 0;
262}
263
271void boundaryTypesAtPos(BoundaryTypes &bcTypes, const GlobalPosition& globalPos) const
272{
273#if PROBLEM == 2
274 if (isInlet(globalPos))
275 {
276 bcTypes.setNeumann(eqIdxPress);
277 bcTypes.setDirichlet(swIdx);
278 }
279 else if (isBottom(globalPos) || isTop(globalPos))
280 {
281 bcTypes.setAllNeumann();
282 }
283 else
284 {
285 bcTypes.setDirichlet(pwIdx);
286 bcTypes.setOutflow(eqIdxSat);
287 }
288#elif PROBLEM == 0
289 if (globalPos[0] < eps_)
290 {
291 bcTypes.setAllDirichlet();
292 }
293 else if (globalPos[0] > this->bBoxMax()[0] - eps_)
294 {
295 bcTypes.setNeumann(eqIdxPress);
296 bcTypes.setOutflow(eqIdxSat);
297 }
298 else
299 {
300 bcTypes.setAllNeumann();
301 }
302#else
303 if (globalPos[0] < eps_)
304 {
305 bcTypes.setAllDirichlet();
306 }
307 else
308 {
309 bcTypes.setAllNeumann();
310 }
311#endif
312}
313
315void dirichletAtPos(PrimaryVariables &values, const GlobalPosition& globalPos) const
316{
317 values = 0;
318#if PROBLEM == 2
319 Scalar pRef = referencePressureAtPos(globalPos);
320 Scalar temp = temperatureAtPos(globalPos);
321
322 values[pwIdx] = (1e5 - (this->bBoxMax()- globalPos) * this->gravity() * WettingPhase::density(temp, pRef));
323 values[swIdx] = 1.0;
324
325 if (isInlet(globalPos))
326 {
327 values[swIdx] = 0.0;
328 }
329#elif PROBLEM == 0
330 if (globalPos[0] < eps_)
331 {
332 values[swIdx] = 0.8;
333 values[pwIdx] = 1;
334 }
335#else
336 if (globalPos[0] < eps_)
337 {
338 values[swIdx] = 1.0;
339 values[pnIdx] = 1e5;
340 }
341#endif
342}
343
345void neumannAtPos(PrimaryVariables &values, const GlobalPosition& globalPos) const
346{
347 values = 0;
348#if PROBLEM == 2
349 if (isInlet(globalPos))
350 {
351 values[nPhaseIdx] = -inFlux_;
352 }
353#elif PROBLEM == 0
354 if (globalPos[0] > this->bBoxMax()[0] - eps_)
355 {
356 values[nPhaseIdx] = 3e-3;
357 }
358#endif
359}
360
362void initialAtPos(PrimaryVariables &values,
363 const GlobalPosition& globalPos) const
364{
365#if PROBLEM == 2
366 values[pwIdx] = 0;
367 values[swIdx] = 1.0;
368#elif PROBLEM == 0
369 values[pwIdx] = 0;
370 values[swIdx] = 0.2;
371#else
372 values[pnIdx] = 0;
373 values[swIdx] = 0.0;
374#endif
375}
376
377private:
378
379bool isInlet(const GlobalPosition& globalPos) const
380{
381 if (!isTop(globalPos))
382 return false;
383
384 for (int i = 0; i < dim; i++)
385 {
386 if (globalPos[i] < inletLeftCoord_[i] - eps_)
387 return false;
388 if (globalPos[i] > inletRightCoord_[i] + eps_)
389 return false;
390 }
391 return true;
392}
393
394bool isTop(const GlobalPosition& globalPos) const
395{
396 if (dim == 2)
397 {
398 if (globalPos[1] > this->bBoxMax()[1] - eps_)
399 return true;
400 }
401 if (dim == 3)
402 {
403 if (globalPos[2] > this->bBoxMax()[2] - eps_)
404 return true;
405 }
406 return false;
407}
408
409bool isBottom(const GlobalPosition& globalPos) const
410{
411 if (dim == 2)
412 {
413 if (globalPos[1] < eps_)
414 return true;
415 }
416 if (dim == 3)
417 {
418 if (globalPos[2] < eps_)
419 return true;
420 }
421 return false;
422}
423
424Scalar inFlux_;
425GlobalPosition inletLeftCoord_;
426GlobalPosition inletRightCoord_;
427static constexpr Scalar eps_ = 1e-6;
428#if PROBLEM == 0
429BuckleyLeverettAnalytic<TypeTag> analyticSolution_;
430#endif
431#if PROBLEM == 1
432McWhorterAnalytic<TypeTag> analyticSolution_;
433#endif
434};
435} //end namespace
436
437#endif // DUMUX_TEST_MPFA2P_PROBLEM_HH
#define GET_PROP(TypeTag, PropTagName)
Definition: propertysystemmacros.hh:281
#define GET_PROP_TYPE(TypeTag, PropTagName)
Definition: propertysystemmacros.hh:283
#define NEW_TYPE_TAG(...)
Definition: propertysystemmacros.hh:130
A much simpler (and thus potentially less buggy) version of pure water.
A simple implementation of Trichloroethene (TCE), a DNAPL.
A liquid phase consisting of a single component.
A fluid system for two-phase models assuming immiscibility and thermodynamic equilibrium.
Properties for the adaptive MPFA-L method.
Class defining a standard, saturation dependent indicator for grid adaption.
Cfl-flux-function to evaluate a Cfl-Condition after Coats 2003.
Analytical solution of the buckley-leverett problem.
Analytic solution of the McWhorter problem.
#define PROBLEM
Definition: test_3d2p.cc:22
Test problem for the sequential 2p models.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
SET_INT_PROP(SequentialOneP, NumEq, 1)
Set number of equations to 1 for isothermal one-phase models.
Property tag AdaptionIndicator
Class defining the refinement/coarsening indicator.
Definition: gridadaptproperties.hh:55
SET_TYPE_PROP(FVPressureOneP, Velocity, FVVelocity1P< TypeTag >)
Set velocity reconstruction implementation standard cell centered finite volume schemes as default.
Type tag FVPressureOneP INHERITS_FROM(PressureOneP))
The type tag for the one-phase problems using a standard finite volume model.
Property tag EvalCflFluxFunction
Type of the evaluation of the CFL-condition.
Definition: transportproperties.hh:50
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
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 fluid system to use.
Definition: common/properties.hh:223
The formulation of the model.
Definition: common/properties.hh:237
A liquid phase consisting of a single component.
Definition: 1pliquid.hh:46
A fluid system for two-phase models assuming immiscibility and thermodynamic equilibrium.
Definition: 2pimmiscible.hh:59
Class defining a standard, saturation dependent indicator for grid adaption.
Definition: gridadaptionindicatorlocal.hh:40
Base class for all 2-phase problems which use an IMPES algorithm.
Definition: dumux/porousmediumflow/2p/sequential/impes/problem.hh:41
const GravityVector & gravity() const
Returns the acceleration due to gravity.
Definition: dumux/porousmediumflow/2p/sequential/impes/problem.hh:167
static const int pnsw
pn and sw as primary variables
Definition: porousmediumflow/2p/sequential/indices.hh:36
Cfl-flux-function to evaluate a Cfl-Condition after Coats 2003.
Definition: evalcflfluxcoats.hh:40
base class for problems using a sequential implicit-explicit strategy
Definition: impetproblem.hh:46
TimeManager & timeManager()
Returns TimeManager object used by the simulation.
Definition: impetproblem.hh:663
void setOutputTimeInterval(const Scalar timeInterval)
Sets a time interval for Output.
Definition: impetproblem.hh:481
void init()
Called by the TimeManager in order to initialize the problem.
Definition: impetproblem.hh:324
void addOutputVtkFields()
Definition: impetproblem.hh:785
void setOutputInterval(const int interval)
Sets the interval for Output.
Definition: impetproblem.hh:492
VtkMultiWriter & resultWriter()
Returns the applied VTK-writer for the output.
Definition: impetproblem.hh:818
const GlobalPosition & bBoxMax() const
The coordinate of the corner of the GridView's bounding box with the largest values.
Definition: impetproblem.hh:655
Grid & grid()
Returns the current grid which used by the problem.
Definition: impetproblem.hh:581
test problem for sequential 2p models
Definition: test_mpfa2pproblem.hh:131
void dirichletAtPos(PrimaryVariables &values, const GlobalPosition &globalPos) const
set dirichlet condition (pressure [Pa], saturation [-])
Definition: test_mpfa2pproblem.hh:315
Scalar referencePressureAtPos(const GlobalPosition &globalPos) const
Returns the reference pressure for evaluation of constitutive relations.
Definition: test_mpfa2pproblem.hh:254
std::string name() const
The problem name.
Definition: test_mpfa2pproblem.hh:230
void initialAtPos(PrimaryVariables &values, const GlobalPosition &globalPos) const
return initial solution -> only saturation values have to be given!
Definition: test_mpfa2pproblem.hh:362
void source(PrimaryVariables &values, const Element &element) const
Definition: test_mpfa2pproblem.hh:259
void init()
Definition: test_mpfa2pproblem.hh:198
void addOutputVtkFields()
Definition: test_mpfa2pproblem.hh:211
bool shouldWriteRestartFile() const
Definition: test_mpfa2pproblem.hh:235
void boundaryTypesAtPos(BoundaryTypes &bcTypes, const GlobalPosition &globalPos) const
Returns the type of boundary condition.
Definition: test_mpfa2pproblem.hh:271
MPFATwoPTestProblem(TimeManager &timeManager, Grid &grid)
Definition: test_mpfa2pproblem.hh:170
Scalar temperatureAtPos(const GlobalPosition &globalPos) const
Returns the temperature within the domain.
Definition: test_mpfa2pproblem.hh:246
void neumannAtPos(PrimaryVariables &values, const GlobalPosition &globalPos) const
set neumann condition for phases (flux, [kg/(m^2 s)])
Definition: test_mpfa2pproblem.hh:345
typename GET_PROP_TYPE(TypeTag, Scalar) Scalar
Definition: test_mpfa2pproblem.hh:81
Test problem for the sequential 2p models.
Definition: test_mpfa2pspatialparams.hh:63
Specifies the properties for immiscible 2p transport.
Base class for all 2-phase problems which use an IMPES algorithm.
Defines the properties required for finite volume pressure models in a two-phase sequential model.
Defines the properties required for finite volume pressure models in a two-phase sequential model.
Properties for the MPFA-L method.
Properties for the MPFA-O method.