28#ifndef EWOMS_LENS_PROBLEM_HH
29#define EWOMS_LENS_PROBLEM_HH
31#include <dune/common/fmatrix.hh>
32#include <dune/common/fvector.hh>
33#include <dune/common/version.hh>
35#include <opm/material/components/Dnapl.hpp>
36#include <opm/material/components/SimpleH2O.hpp>
37#include <opm/material/fluidmatrixinteractions/RegularizedVanGenuchten.hpp>
38#include <opm/material/fluidmatrixinteractions/LinearMaterial.hpp>
39#include <opm/material/fluidmatrixinteractions/EffToAbsLaw.hpp>
40#include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
41#include <opm/material/fluidstates/ImmiscibleFluidState.hpp>
42#include <opm/material/fluidsystems/TwoPhaseImmiscibleFluidSystem.hpp>
61template <
class TypeTag>
73template<
class TypeTag>
77template<
class TypeTag>
78struct Grid<TypeTag, TTag::LensBaseProblem> {
using type = Dune::YaspGrid<2>; };
81template<
class TypeTag>
88 using type = Opm::LiquidPhase<Scalar, Opm::SimpleH2O<Scalar> >;
92template<
class TypeTag>
99 using type = Opm::LiquidPhase<Scalar, Opm::DNAPL<Scalar> >;
103template<
class TypeTag>
108 enum { wettingPhaseIdx = FluidSystem::wettingPhaseIdx };
109 enum { nonWettingPhaseIdx = FluidSystem::nonWettingPhaseIdx };
112 using Traits = Opm::TwoPhaseMaterialTraits<Scalar,
113 FluidSystem::wettingPhaseIdx,
114 FluidSystem::nonWettingPhaseIdx>;
118 using EffectiveLaw = Opm::RegularizedVanGenuchten<Traits>;
122 using type = Opm::EffToAbsLaw<EffectiveLaw>;
130template<
class Scalar>
131struct LensLowerLeftX {
static constexpr Scalar
value = 1.0; };
133template<
class Scalar>
134struct LensLowerLeftY {
static constexpr Scalar
value = 2.0; };
136template<
class Scalar>
137struct LensLowerLeftZ {
static constexpr Scalar
value = 0.0; };
139template<
class Scalar>
140struct LensUpperRightX {
static constexpr Scalar
value = 4.0; };
142template<
class Scalar>
143struct LensUpperRightY {
static constexpr Scalar
value = 3.0; };
145template<
class Scalar>
146struct LensUpperRightZ {
static constexpr Scalar
value = 1.0; };
175template <
class TypeTag>
192 numPhases = FluidSystem::numPhases,
195 wettingPhaseIdx = FluidSystem::wettingPhaseIdx,
196 nonWettingPhaseIdx = FluidSystem::nonWettingPhaseIdx,
199 contiNEqIdx = Indices::conti0EqIdx + nonWettingPhaseIdx,
202 dim = GridView::dimension,
203 dimWorld = GridView::dimensionworld
212 using CoordScalar =
typename GridView::ctype;
213 using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
215 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
222 : ParentType(simulator)
230 ParentType::finishInit();
235 temperature_ = 273.15 + 20;
236 lensLowerLeft_[0] = Parameters::Get<Parameters::LensLowerLeftX<Scalar>>();
237 lensLowerLeft_[1] = Parameters::Get<Parameters::LensLowerLeftY<Scalar>>();
238 lensUpperRight_[0] = Parameters::Get<Parameters::LensUpperRightX<Scalar>>();
239 lensUpperRight_[1] = Parameters::Get<Parameters::LensUpperRightY<Scalar>>();
241 if constexpr (dim == 3) {
242 lensLowerLeft_[2] = Parameters::Get<Parameters::LensLowerLeftZ<Scalar>>();
243 lensUpperRight_[2] = Parameters::Get<Parameters::LensUpperRightZ<Scalar>>();
247 lensMaterialParams_.setResidualSaturation(wettingPhaseIdx, 0.18);
248 lensMaterialParams_.setResidualSaturation(nonWettingPhaseIdx, 0.0);
249 outerMaterialParams_.setResidualSaturation(wettingPhaseIdx, 0.05);
250 outerMaterialParams_.setResidualSaturation(nonWettingPhaseIdx, 0.0);
253 lensMaterialParams_.setVgAlpha(0.00045);
254 lensMaterialParams_.setVgN(7.3);
255 outerMaterialParams_.setVgAlpha(0.0037);
256 outerMaterialParams_.setVgN(4.7);
258 lensMaterialParams_.finalize();
259 outerMaterialParams_.finalize();
261 lensK_ = this->toDimMatrix_(9.05e-12);
262 outerK_ = this->toDimMatrix_(4.6e-10);
266 this->gravity_[1] = -9.81;
275 ParentType::registerParameters();
277 Parameters::Register<Parameters::LensLowerLeftX<Scalar>>
278 (
"The x-coordinate of the lens' lower-left corner [m].");
279 Parameters::Register<Parameters::LensLowerLeftY<Scalar>>
280 (
"The y-coordinate of the lens' lower-left corner [m].");
281 Parameters::Register<Parameters::LensUpperRightX<Scalar>>
282 (
"The x-coordinate of the lens' upper-right corner [m].");
283 Parameters::Register<Parameters::LensUpperRightY<Scalar>>
284 (
"The y-coordinate of the lens' upper-right corner [m].");
286 if constexpr (dim == 3) {
287 Parameters::Register<Parameters::LensLowerLeftZ<Scalar>>
288 (
"The z-coordinate of the lens' lower-left corner [m].");
289 Parameters::Register<Parameters::LensUpperRightZ<Scalar>>
290 (
"The z-coordinate of the lens' upper-right corner [m].");
293 Parameters::SetDefault<Parameters::CellsX>(48);
294 Parameters::SetDefault<Parameters::CellsY>(32);
295 Parameters::SetDefault<Parameters::DomainSizeX<Scalar>>(6.0);
296 Parameters::SetDefault<Parameters::DomainSizeY<Scalar>>(4.0);
298 if constexpr (dim == 3) {
299 Parameters::SetDefault<Parameters::CellsZ>(16);
300 Parameters::SetDefault<Parameters::DomainSizeZ<Scalar>>(1.0);
305 constexpr bool useFD = std::is_same_v<LLS, Properties::TTag::FiniteDifferenceLocalLinearizer>;
306 if constexpr (useFD) {
307 Parameters::SetDefault<Parameters::NumericDifferenceMethod>(+1);
310 Parameters::SetDefault<Parameters::EndTime<Scalar>>(30e3);
311 Parameters::SetDefault<Parameters::EnableIntensiveQuantityCache>(
true);
312 Parameters::SetDefault<Parameters::EnableStorageCache>(
true);
313 Parameters::SetDefault<Parameters::InitialTimeStepSize<Scalar>>(250.0);
314 Parameters::SetDefault<Parameters::VtkWriteIntrinsicPermeabilities>(
true);
315 Parameters::SetDefault<Parameters::EnableGravity>(
true);
323 std::string thermal =
"isothermal";
324 constexpr bool enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>();
325 if constexpr (enableEnergy)
326 thermal =
"non-isothermal";
328 std::string deriv =
"finite difference";
330 constexpr bool useAutoDiff = std::is_same_v<LLS, Properties::TTag::AutoDiffLocalLinearizer>;
331 if constexpr (useAutoDiff) {
332 deriv =
"automatic differentiation";
335 std::string disc =
"vertex centered finite volume";
337 constexpr bool useEcfv = std::is_same<D, Opm::EcfvDiscretization<TypeTag>>::value;
338 if constexpr (useEcfv)
339 disc =
"element centered finite volume";
341 return std::string(
"")+
342 "Ground remediation problem where a dense oil infiltrates "+
343 "an aquifer with an embedded low-permability lens. " +
344 "This is the binary for the "+thermal+
" variant using "+deriv+
345 "and the "+disc+
" discretization";
356 template <
class Context>
358 unsigned timeIdx)
const
360 const GlobalPosition& globalPos = context.pos(spaceIdx, timeIdx);
362 if (isInLens_(globalPos))
370 template <
class Context>
379 template <
class Context>
381 unsigned spaceIdx,
unsigned timeIdx)
const
383 const GlobalPosition& globalPos = context.pos(spaceIdx, timeIdx);
385 if (isInLens_(globalPos))
386 return lensMaterialParams_;
387 return outerMaterialParams_;
393 template <
class Context>
397 {
return temperature_; }
413 constexpr bool useAutoDiff = std::is_same_v<LLS, Properties::TTag::AutoDiffLocalLinearizer>;
416 constexpr bool useTrans = std::is_same_v<FM, Opm::TransFluxModule<TypeTag>>;
418 std::ostringstream oss;
419 oss <<
"lens_" << Model::name()
420 <<
"_" << Model::discretizationName()
421 <<
"_" << (useAutoDiff?
"ad":
"fd");
450 this->model().globalStorage(storage);
453 if (this->gridView().comm().rank() == 0) {
454 std::cout <<
"Storage: " << storage << std::endl << std::flush;
469 template <
class Context>
471 const Context& context,
473 unsigned timeIdx)
const
475 const GlobalPosition& pos = context.pos(spaceIdx, timeIdx);
477 if (onLeftBoundary_(pos) || onRightBoundary_(pos)) {
479 Scalar densityW = WettingPhase::density(temperature_, Scalar(1e5));
480 Scalar densityN = NonwettingPhase::density(temperature_, Scalar(1e5));
482 Scalar T =
temperature(context, spaceIdx, timeIdx);
486 if (onLeftBoundary_(pos)) {
487 Scalar height = this->boundingBoxMax()[1] - this->boundingBoxMin()[1];
488 Scalar depth = this->boundingBoxMax()[1] - pos[1];
489 Scalar alpha = (1 + 1.5 / height);
492 pw = 1e5 - alpha * densityW * this->gravity()[1] * depth;
496 Scalar depth = this->boundingBoxMax()[1] - pos[1];
499 pw = 1e5 - densityW * this->gravity()[1] * depth;
504 const MaterialLawParams& matParams = this->
materialLawParams(context, spaceIdx, timeIdx);
506 Opm::ImmiscibleFluidState<Scalar, FluidSystem,
508 fs.setSaturation(wettingPhaseIdx, Sw);
509 fs.setSaturation(nonWettingPhaseIdx, 1 - Sw);
510 fs.setTemperature(T);
512 Scalar pC[numPhases];
513 MaterialLaw::capillaryPressures(pC, matParams, fs);
514 fs.setPressure(wettingPhaseIdx, pw);
515 fs.setPressure(nonWettingPhaseIdx, pw + pC[nonWettingPhaseIdx] - pC[wettingPhaseIdx]);
517 fs.setDensity(wettingPhaseIdx, densityW);
518 fs.setDensity(nonWettingPhaseIdx, densityN);
520 fs.setViscosity(wettingPhaseIdx, WettingPhase::viscosity(temperature_, fs.pressure(wettingPhaseIdx)));
521 fs.setViscosity(nonWettingPhaseIdx, NonwettingPhase::viscosity(temperature_, fs.pressure(nonWettingPhaseIdx)));
524 values.setFreeFlow(context, spaceIdx, timeIdx, fs);
526 else if (onInlet_(pos)) {
527 RateVector massRate(0.0);
529 massRate[contiNEqIdx] = -0.04;
532 values.setMassRate(massRate);
550 template <
class Context>
551 void initial(PrimaryVariables& values,
const Context& context,
unsigned spaceIdx,
unsigned timeIdx)
const
553 const GlobalPosition& pos = context.pos(spaceIdx, timeIdx);
554 Scalar depth = this->boundingBoxMax()[1] - pos[1];
556 Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs;
557 fs.setPressure(wettingPhaseIdx, 1e5);
560 fs.setSaturation(wettingPhaseIdx, Sw);
561 fs.setSaturation(nonWettingPhaseIdx, 1 - Sw);
563 fs.setTemperature(temperature_);
565 typename FluidSystem::template ParameterCache<Scalar> paramCache;
566 paramCache.updatePhase(fs, wettingPhaseIdx);
567 Scalar densityW = FluidSystem::density(fs, paramCache, wettingPhaseIdx);
570 Scalar pw = 1e5 - densityW * this->gravity()[1] * depth;
573 const MaterialLawParams& matParams = this->
materialLawParams(context, spaceIdx, timeIdx);
574 Scalar pC[numPhases];
575 MaterialLaw::capillaryPressures(pC, matParams, fs);
578 fs.setPressure(wettingPhaseIdx, pw);
579 fs.setPressure(nonWettingPhaseIdx, pw + (pC[wettingPhaseIdx] - pC[nonWettingPhaseIdx]));
582 values.assignNaive(fs);
591 template <
class Context>
596 { rate = Scalar(0.0); }
601 bool isInLens_(
const GlobalPosition& pos)
const
603 for (
unsigned i = 0; i < dim; ++i) {
604 if (pos[i] < lensLowerLeft_[i] - eps_ || pos[i] > lensUpperRight_[i]
611 bool onLeftBoundary_(
const GlobalPosition& pos)
const
612 {
return pos[0] < this->boundingBoxMin()[0] + eps_; }
614 bool onRightBoundary_(
const GlobalPosition& pos)
const
615 {
return pos[0] > this->boundingBoxMax()[0] - eps_; }
617 bool onLowerBoundary_(
const GlobalPosition& pos)
const
618 {
return pos[1] < this->boundingBoxMin()[1] + eps_; }
620 bool onUpperBoundary_(
const GlobalPosition& pos)
const
621 {
return pos[1] > this->boundingBoxMax()[1] - eps_; }
623 bool onInlet_(
const GlobalPosition& pos)
const
625 Scalar width = this->boundingBoxMax()[0] - this->boundingBoxMin()[0];
626 Scalar lambda = (this->boundingBoxMax()[0] - pos[0]) / width;
627 return onUpperBoundary_(pos) && 0.5 < lambda && lambda < 2.0 / 3.0;
630 GlobalPosition lensLowerLeft_;
631 GlobalPosition lensUpperRight_;
635 MaterialLawParams lensMaterialParams_;
636 MaterialLawParams outerMaterialParams_;
Soil contamination problem where DNAPL infiltrates a fully water saturated medium.
Definition: lensproblem.hh:177
Scalar temperature(const Context &, unsigned, unsigned) const
Definition: lensproblem.hh:394
static void registerParameters()
Definition: lensproblem.hh:273
void beginTimeStep()
Called by the simulator before each time integration.
Definition: lensproblem.hh:431
static std::string briefDescription()
Returns a human readable description of the problem for the help message.
Definition: lensproblem.hh:321
const MaterialLawParams & materialLawParams(const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Definition: lensproblem.hh:380
void initial(PrimaryVariables &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluate the initial value for a control volume.
Definition: lensproblem.hh:551
Scalar porosity(const Context &, unsigned, unsigned) const
Definition: lensproblem.hh:371
LensProblem(Simulator &simulator)
Definition: lensproblem.hh:221
void finishInit()
Called by the Opm::Simulator in order to initialize the problem.
Definition: lensproblem.hh:228
void boundary(BoundaryRateVector &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluate the boundary conditions for a boundary segment.
Definition: lensproblem.hh:470
const DimMatrix & intrinsicPermeability(const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Definition: lensproblem.hh:357
std::string name() const
The problem name.
Definition: lensproblem.hh:409
void endTimeStep()
Called by the simulator after each time integration.
Definition: lensproblem.hh:443
void beginIteration()
Called by the simulator before each Newton-Raphson iteration.
Definition: lensproblem.hh:437
void source(RateVector &rate, const Context &, unsigned, unsigned) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: lensproblem.hh:592
Defines the properties required for the immiscible multi-phase model.
Defines the common parameters for the porous medium multi-phase models.
Definition: blackoilnewtonmethodparams.hpp:31
Definition: blackoilmodel.hh:74
Definition: blackoilbioeffectsmodules.hh:45
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
static constexpr Scalar value
Definition: groundwaterproblem.hh:95
static constexpr Scalar value
Definition: groundwaterproblem.hh:98
static constexpr Scalar value
Definition: groundwaterproblem.hh:101
static constexpr Scalar value
Definition: groundwaterproblem.hh:104
static constexpr Scalar value
Definition: groundwaterproblem.hh:107
static constexpr Scalar value
Definition: groundwaterproblem.hh:110
Dune::YaspGrid< 2 > type
Definition: lensproblem.hh:78
The type of the DUNE grid.
Definition: basicproperties.hh:104
Opm::EffToAbsLaw< EffectiveLaw > type
Definition: lensproblem.hh:122
The material law which ought to be used (extracted from the spatial parameters)
Definition: multiphasebaseproperties.hh:55
Opm::LiquidPhase< Scalar, Opm::DNAPL< Scalar > > type
Definition: lensproblem.hh:99
The non-wetting phase for two-phase models.
Definition: immiscibleproperties.hh:44
The type of the problem.
Definition: fvbaseproperties.hh:86
Definition: lensproblem.hh:69
std::tuple< StructuredGridVanguard > InheritsFrom
Definition: lensproblem.hh:69
Opm::LiquidPhase< Scalar, Opm::SimpleH2O< Scalar > > type
Definition: lensproblem.hh:88
The wetting phase for two-phase models.
Definition: immiscibleproperties.hh:41
This file contains the flux module that uses transmissibilities.