27#ifndef EWOMS_INFILTRATION_PROBLEM_HH
28#define EWOMS_INFILTRATION_PROBLEM_HH
30#include <dune/common/fmatrix.hh>
31#include <dune/common/fvector.hh>
32#include <dune/common/version.hh>
34#include <dune/grid/yaspgrid.hh>
35#include <dune/grid/io/file/dgfparser/dgfyasp.hh>
37#include <opm/material/common/Valgrind.hpp>
38#include <opm/material/constraintsolvers/ComputeFromReferencePhase.hpp>
39#include <opm/material/fluidmatrixinteractions/ThreePhaseParkerVanGenuchten.hpp>
40#include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
41#include <opm/material/fluidstates/CompositionalFluidState.hpp>
42#include <opm/material/fluidsystems/H2OAirMesityleneFluidSystem.hpp>
54template <
class TypeTag>
55class InfiltrationProblem;
65template<
class TypeTag>
66struct Grid<TypeTag, TTag::InfiltrationBaseProblem> {
using type = Dune::YaspGrid<2>; };
69template<
class TypeTag>
73template<
class TypeTag>
75{
using type = Opm::H2OAirMesityleneFluidSystem<GetPropType<TypeTag, Properties::Scalar>>; };
78template<
class TypeTag>
85 using Traits= Opm::ThreePhaseMaterialTraits<
87 FluidSystem::waterPhaseIdx,
88 FluidSystem::naplPhaseIdx,
89 FluidSystem::gasPhaseIdx,
94 using type = Opm::ThreePhaseParkerVanGenuchten<Traits>;
122template <
class TypeTag>
143 conti0EqIdx = Indices::conti0EqIdx,
146 numPhases = FluidSystem::numPhases,
149 NAPLIdx = FluidSystem::NAPLIdx,
150 H2OIdx = FluidSystem::H2OIdx,
151 airIdx = FluidSystem::airIdx,
154 waterPhaseIdx = FluidSystem::waterPhaseIdx,
155 gasPhaseIdx = FluidSystem::gasPhaseIdx,
156 naplPhaseIdx = FluidSystem::naplPhaseIdx,
159 dim = GridView::dimension,
160 dimWorld = GridView::dimensionworld
163 using CoordScalar =
typename GridView::ctype;
164 using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
165 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
172 : ParentType(simulator)
181 ParentType::finishInit();
183 temperature_ = 273.15 + 10.0;
184 FluidSystem::init(temperature_ - 1,
192 fineK_ = this->toDimMatrix_(1e-11);
193 coarseK_ = this->toDimMatrix_(1e-11);
199 materialParams_.setSwr(0.12);
200 materialParams_.setSwrx(0.12);
201 materialParams_.setSnr(0.07);
202 materialParams_.setSgr(0.03);
205 materialParams_.setVgAlpha(0.0005);
206 materialParams_.setVgN(4.);
207 materialParams_.setkrRegardsSnr(
false);
209 materialParams_.finalize();
210 materialParams_.checkDefined();
218 ParentType::registerParameters();
220 Parameters::SetDefault<Parameters::GridFile>(
"./data/infiltration_50x3.dgf");
221 Parameters::SetDefault<Parameters::NumericDifferenceMethod>(1);
222 Parameters::SetDefault<Parameters::EndTime<Scalar>>(6e3);
223 Parameters::SetDefault<Parameters::InitialTimeStepSize<Scalar>>(60.0);
224 Parameters::SetDefault<Parameters::EnableGravity>(
true);
245 std::ostringstream oss;
246 oss <<
"infiltration_" << Model::name();
256 this->model().checkConservativeness();
260 this->model().globalStorage(storage);
263 if (this->gridView().comm().rank() == 0) {
264 std::cout <<
"Storage: " << storage << std::endl << std::flush;
272 template <
class Context>
276 {
return temperature_; }
281 template <
class Context>
285 unsigned timeIdx)
const
287 const GlobalPosition& pos = context.pos(spaceIdx, timeIdx);
288 if (isFineMaterial_(pos))
296 template <
class Context>
300 {
return porosity_; }
305 template <
class Context>
306 const MaterialLawParams&
310 {
return materialParams_; }
322 template <
class Context>
324 const Context& context,
326 unsigned timeIdx)
const
328 const auto& pos = context.pos(spaceIdx, timeIdx);
330 if (onLeftBoundary_(pos) || onRightBoundary_(pos)) {
331 Opm::CompositionalFluidState<Scalar, FluidSystem> fs;
333 initialFluidState_(fs, context, spaceIdx, timeIdx);
335 values.setFreeFlow(context, spaceIdx, timeIdx, fs);
337 else if (onInlet_(pos)) {
338 RateVector molarRate(0.0);
339 molarRate[conti0EqIdx + NAPLIdx] = -0.001;
341 values.setMolarRate(molarRate);
342 Opm::Valgrind::CheckDefined(values);
358 template <
class Context>
360 const Context& context,
362 unsigned timeIdx)
const
364 Opm::CompositionalFluidState<Scalar, FluidSystem> fs;
366 initialFluidState_(fs, context, spaceIdx, timeIdx);
369 values.assignMassConservative(fs, matParams,
true);
370 Opm::Valgrind::CheckDefined(values);
379 template <
class Context>
384 { rate = Scalar(0.0); }
389 bool onLeftBoundary_(
const GlobalPosition& pos)
const
390 {
return pos[0] < eps_; }
392 bool onRightBoundary_(
const GlobalPosition& pos)
const
393 {
return pos[0] > this->boundingBoxMax()[0] - eps_; }
395 bool onLowerBoundary_(
const GlobalPosition& pos)
const
396 {
return pos[1] < eps_; }
398 bool onUpperBoundary_(
const GlobalPosition& pos)
const
399 {
return pos[1] > this->boundingBoxMax()[1] - eps_; }
401 bool onInlet_(
const GlobalPosition& pos)
const
402 {
return onUpperBoundary_(pos) && 50 < pos[0] && pos[0] < 75; }
404 template <
class Flu
idState,
class Context>
405 void initialFluidState_(FluidState& fs,
const Context& context,
406 unsigned spaceIdx,
unsigned timeIdx)
const
408 const GlobalPosition pos = context.pos(spaceIdx, timeIdx);
412 Scalar densityW = 1000.0;
413 Scalar pc = 9.81 * densityW * (y - (5 - 5e-4 * x));
419 Scalar Sw = matParams.Swr();
420 Scalar Swr = matParams.Swr();
421 Scalar Sgr = matParams.Sgr();
428 Opm::Valgrind::CheckDefined(Sw);
429 Opm::Valgrind::CheckDefined(Sg);
431 fs.setSaturation(waterPhaseIdx, Sw);
432 fs.setSaturation(gasPhaseIdx, Sg);
433 fs.setSaturation(naplPhaseIdx, 0);
436 fs.setTemperature(temperature_);
439 Scalar pcAll[numPhases];
441 if (onLeftBoundary_(pos))
443 MaterialLaw::capillaryPressures(pcAll, matParams, fs);
444 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
445 fs.setPressure(phaseIdx, pg + (pcAll[phaseIdx] - pcAll[gasPhaseIdx]));
448 fs.setMoleFraction(gasPhaseIdx, H2OIdx, 1e-6);
449 fs.setMoleFraction(gasPhaseIdx, airIdx,
450 1 - fs.moleFraction(gasPhaseIdx, H2OIdx));
451 fs.setMoleFraction(gasPhaseIdx, NAPLIdx, 0);
453 using CFRP = Opm::ComputeFromReferencePhase<Scalar, FluidSystem>;
454 typename FluidSystem::template ParameterCache<Scalar> paramCache;
455 CFRP::solve(fs, paramCache, gasPhaseIdx,
459 fs.setMoleFraction(waterPhaseIdx, H2OIdx,
460 1 - fs.moleFraction(waterPhaseIdx, H2OIdx));
463 bool isFineMaterial_(
const GlobalPosition& pos)
const
464 {
return 70. <= pos[0] && pos[0] <= 85. && 7.0 <= pos[1] && pos[1] <= 7.50; }
471 MaterialLawParams materialParams_;
Isothermal NAPL infiltration problem where LNAPL contaminates the unsaturated and the saturated groun...
Definition: infiltrationproblem.hh:124
void source(RateVector &rate, const Context &, unsigned, unsigned) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: infiltrationproblem.hh:380
Scalar temperature(const Context &, unsigned, unsigned) const
Definition: infiltrationproblem.hh:273
const DimMatrix & intrinsicPermeability(const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Definition: infiltrationproblem.hh:283
std::string name() const
The problem name.
Definition: infiltrationproblem.hh:243
Scalar porosity(const Context &, unsigned, unsigned) const
Definition: infiltrationproblem.hh:297
void boundary(BoundaryRateVector &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluate the boundary conditions for a boundary segment.
Definition: infiltrationproblem.hh:323
const MaterialLawParams & materialLawParams(const Context &, unsigned, unsigned) const
Definition: infiltrationproblem.hh:307
void endTimeStep()
Called by the simulator after each time integration.
Definition: infiltrationproblem.hh:253
InfiltrationProblem(Simulator &simulator)
Definition: infiltrationproblem.hh:171
bool shouldWriteRestartFile() const
Returns true if a restart file should be written to disk.
Definition: infiltrationproblem.hh:237
static void registerParameters()
Definition: infiltrationproblem.hh:216
void initial(PrimaryVariables &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluate the initial value for a control volume.
Definition: infiltrationproblem.hh:359
void finishInit()
Called by the Opm::Simulator in order to initialize the problem.
Definition: infiltrationproblem.hh:179
Defines the common parameters for the porous medium multi-phase models.
Definition: blackoilmodel.hh:79
Definition: blackoilbioeffectsmodules.hh:43
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:233
Declares the properties required for the compositional multi-phase primary variable switching model.
Opm::H2OAirMesityleneFluidSystem< GetPropType< TypeTag, Properties::Scalar > > type
Definition: infiltrationproblem.hh:75
The fluid systems including the information about the phases.
Definition: multiphasebaseproperties.hh:79
Dune::YaspGrid< 2 > type
Definition: infiltrationproblem.hh:66
The type of the DUNE grid.
Definition: basicproperties.hh:100
Opm::ThreePhaseParkerVanGenuchten< Traits > type
Definition: infiltrationproblem.hh:94
The material law which ought to be used (extracted from the spatial parameters)
Definition: multiphasebaseproperties.hh:55
The type of the problem.
Definition: fvbaseproperties.hh:81
Definition: infiltrationproblem.hh:61