28#ifndef EWOMS_FINGER_PROBLEM_HH
29#define EWOMS_FINGER_PROBLEM_HH
32#include <dune/alugrid/grid.hh>
35#include <dune/common/fmatrix.hh>
36#include <dune/common/fvector.hh>
37#include <dune/common/version.hh>
39#include <dune/grid/utility/persistentcontainer.hh>
41#include <opm/material/components/Air.hpp>
42#include <opm/material/components/SimpleH2O.hpp>
44#include <opm/material/fluidmatrixinteractions/EffToAbsLaw.hpp>
45#include <opm/material/fluidmatrixinteractions/LinearMaterial.hpp>
46#include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
47#include <opm/material/fluidmatrixinteractions/ParkerLenhard.hpp>
48#include <opm/material/fluidmatrixinteractions/RegularizedVanGenuchten.hpp>
50#include <opm/material/fluidstates/ImmiscibleFluidState.hpp>
52#include <opm/material/fluidsystems/TwoPhaseImmiscibleFluidSystem.hpp>
68template <
class TypeTag>
82template<
class TypeTag>
83struct Grid<TypeTag, TTag::FingerBaseProblem>
84{
using type = Dune::ALUGrid<2,
87 Dune::nonconforming>; };
91template<
class TypeTag>
95template<
class TypeTag>
102 using type = Opm::LiquidPhase<Scalar, Opm::SimpleH2O<Scalar> >;
106template<
class TypeTag>
113 using type = Opm::GasPhase<Scalar, Opm::Air<Scalar> >;
117template<
class TypeTag>
123 FluidSystem::wettingPhaseIdx,
124 FluidSystem::nonWettingPhaseIdx>;
132template<
class TypeTag>
133struct EnableConstraints<TypeTag, TTag::FingerBaseProblem> {
static constexpr int value =
true; };
139template<
class Scalar>
161template <
class TypeTag>
180 numPhases = FluidSystem::numPhases,
183 wettingPhaseIdx = FluidSystem::wettingPhaseIdx,
184 nonWettingPhaseIdx = FluidSystem::nonWettingPhaseIdx,
187 contiWettingEqIdx = Indices::conti0EqIdx + wettingPhaseIdx,
190 dim = GridView::dimension,
191 dimWorld = GridView::dimensionworld
196 enum { codim = Stencil::Entity::codimension };
205 using CoordScalar =
typename GridView::ctype;
206 using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
207 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
209 using Grid =
typename GridView :: Grid;
211 using MaterialLawParamsContainer = Dune::PersistentContainer< Grid, std::shared_ptr< MaterialLawParams > > ;
221 : ParentType(simulator),
222 materialParams_( simulator.vanguard().grid(), codim )
244 std::string(
"finger") +
245 "_" + Model::name() +
246 "_" + Model::discretizationName() +
247 (this->model().enableGridAdaptation()?
"_adaptive":
"");
255 ParentType::registerParameters();
257 Parameters::Register<Parameters::InitialWaterSaturation<Scalar>>
258 (
"The initial saturation in the domain [] of the wetting phase");
260 Parameters::SetDefault<Parameters::CellsX>(20);
261 Parameters::SetDefault<Parameters::DomainSizeX<Scalar>>(0.1);
263 if constexpr (
dim > 1) {
264 Parameters::SetDefault<Parameters::CellsY>(70);
265 Parameters::SetDefault<Parameters::DomainSizeY<Scalar>>(0.3);
267 if constexpr (
dim == 3) {
268 Parameters::SetDefault<Parameters::CellsZ>(1);
269 Parameters::SetDefault<Parameters::DomainSizeZ<Scalar>>(0.1);
273 Parameters::SetDefault<Parameters::NumericDifferenceMethod>(+1);
275 Parameters::SetDefault<Parameters::EndTime<Scalar>>(215);
276 Parameters::SetDefault<Parameters::InitialTimeStepSize<Scalar>>(10);
277 Parameters::SetDefault<Parameters::EnableGravity>(
true);
285 ParentType::finishInit();
289 temperature_ = 273.15 + 20;
295 micParams_.setVgAlpha(0.0037);
296 micParams_.setVgN(4.7);
297 micParams_.finalize();
299 mdcParams_.setVgAlpha(0.0037);
300 mdcParams_.setVgN(4.7);
301 mdcParams_.finalize();
305 materialParams_.resize();
307 for (
auto it = materialParams_.begin(),
308 end = materialParams_.end(); it != end; ++it ) {
309 std::shared_ptr< MaterialLawParams >& materialParams = *it ;
310 if( ! materialParams )
312 materialParams.reset(
new MaterialLawParams() );
313 materialParams->setMicParams(&micParams_);
314 materialParams->setMdcParams(&mdcParams_);
315 materialParams->setSwr(0.0);
316 materialParams->setSnr(0.1);
317 materialParams->finalize();
322 K_ = this->toDimMatrix_(4.6e-10);
324 setupInitialFluidState_();
339 this->model().globalStorage(storage);
342 if (this->gridView().comm().rank() == 0) {
343 std::cout <<
"Storage: " << storage << std::endl << std::flush;
348 ElementContext elemCtx(this->simulator());
350 for (
const auto& elem : elements(this->gridView())) {
351 elemCtx.updateAll(elem);
352 size_t numDofs = elemCtx.numDof(0);
353 for (
unsigned scvIdx = 0; scvIdx < numDofs; ++scvIdx)
356 const auto& fs = elemCtx.intensiveQuantities(scvIdx, 0).fluidState();
357 ParkerLenhard::update(materialParam, fs);
372 template <
class Context>
374 {
return temperature_; }
379 template <
class Context>
386 template <
class Context>
387 Scalar
porosity(
const Context& ,
unsigned ,
unsigned )
const
393 template <
class Context>
395 unsigned spaceIdx,
unsigned timeIdx)
397 const auto& entity = context.stencil(timeIdx).entity(spaceIdx);
398 assert(materialParams_[entity]);
399 return *materialParams_[entity];
405 template <
class Context>
407 unsigned spaceIdx,
unsigned timeIdx)
const
409 const auto& entity = context.stencil(timeIdx).entity( spaceIdx );
410 assert(materialParams_[entity]);
411 return *materialParams_[entity];
424 template <
class Context>
425 void boundary(BoundaryRateVector& values,
const Context& context,
426 unsigned spaceIdx,
unsigned timeIdx)
const
428 const GlobalPosition& pos = context.pos(spaceIdx, timeIdx);
430 if (onLeftBoundary_(pos) || onRightBoundary_(pos) || onLowerBoundary_(pos))
433 assert(onUpperBoundary_(pos));
435 values.setFreeFlow(context, spaceIdx, timeIdx, initialFluidState_);
441 values[contiWettingEqIdx] = -0.001;
455 template <
class Context>
456 void initial(PrimaryVariables& values,
const Context& ,
unsigned ,
unsigned )
const
459 values.assignNaive(initialFluidState_);
465 template <
class Context>
467 unsigned spaceIdx,
unsigned timeIdx)
const
469 const GlobalPosition& pos = context.pos(spaceIdx, timeIdx);
471 if (onUpperBoundary_(pos) && !onInlet_(pos)) {
475 else if (onLowerBoundary_(pos)) {
487 template <
class Context>
488 void source(RateVector& rate,
const Context& ,
489 unsigned ,
unsigned )
const
490 { rate = Scalar(0.0); }
494 bool onLeftBoundary_(
const GlobalPosition& pos)
const
495 {
return pos[0] < this->boundingBoxMin()[0] + eps_; }
497 bool onRightBoundary_(
const GlobalPosition& pos)
const
498 {
return pos[0] > this->boundingBoxMax()[0] - eps_; }
500 bool onLowerBoundary_(
const GlobalPosition& pos)
const
501 {
return pos[1] < this->boundingBoxMin()[1] + eps_; }
503 bool onUpperBoundary_(
const GlobalPosition& pos)
const
504 {
return pos[1] > this->boundingBoxMax()[1] - eps_; }
506 bool onInlet_(
const GlobalPosition& pos)
const
508 Scalar width = this->boundingBoxMax()[0] - this->boundingBoxMin()[0];
509 Scalar lambda = (this->boundingBoxMax()[0] - pos[0]) / width;
511 if (!onUpperBoundary_(pos))
514 const Scalar xInject[] = { 0.25, 0.75 };
515 const Scalar injectLen[] = { 0.1, 0.1 };
516 for (
unsigned i = 0; i <
sizeof(xInject) /
sizeof(Scalar); ++i) {
517 if (xInject[i] - injectLen[i] / 2 < lambda
518 && lambda < xInject[i] + injectLen[i] / 2)
524 void setupInitialFluidState_()
526 auto& fs = initialFluidState_;
527 fs.setPressure(wettingPhaseIdx, 1e5);
529 Scalar
Sw = Parameters::Get<Parameters::InitialWaterSaturation<Scalar>>();
530 fs.setSaturation(wettingPhaseIdx, Sw);
531 fs.setSaturation(nonWettingPhaseIdx, 1 - Sw);
533 fs.setTemperature(temperature_);
537 fs.setPressure(nonWettingPhaseIdx, pn);
538 fs.setPressure(wettingPhaseIdx, pn);
540 typename FluidSystem::template ParameterCache<Scalar> paramCache;
541 paramCache.updateAll(fs);
542 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
543 fs.setDensity(phaseIdx, FluidSystem::density(fs, paramCache, phaseIdx));
544 fs.setViscosity(phaseIdx, FluidSystem::viscosity(fs, paramCache, phaseIdx));
551 typename MaterialLawParams::VanGenuchtenParams micParams_;
552 typename MaterialLawParams::VanGenuchtenParams mdcParams_;
554 MaterialLawParamsContainer materialParams_;
556 Opm::ImmiscibleFluidState<Scalar, FluidSystem> initialFluidState_;
Definition: restrictprolong.hh:49
Two-phase problem featuring some gravity-driven saturation fingers.
Definition: fingerproblem.hh:163
MaterialLawParams & materialLawParams(const Context &context, unsigned spaceIdx, unsigned timeIdx)
Definition: fingerproblem.hh:394
void boundary(BoundaryRateVector &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluate the boundary conditions for a boundary segment.
Definition: fingerproblem.hh:425
const MaterialLawParams & materialLawParams(const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Definition: fingerproblem.hh:406
const DimMatrix & intrinsicPermeability(const Context &, unsigned, unsigned) const
Definition: fingerproblem.hh:380
Scalar porosity(const Context &, unsigned, unsigned) const
Definition: fingerproblem.hh:387
void source(RateVector &rate, const Context &, unsigned, unsigned) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: fingerproblem.hh:488
void constraints(Constraints &constraints, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluate the constraints for a control volume.
Definition: fingerproblem.hh:466
void finishInit()
Called by the Opm::Simulator in order to initialize the problem.
Definition: fingerproblem.hh:283
Scalar temperature(const Context &, unsigned, unsigned) const
Definition: fingerproblem.hh:373
void initial(PrimaryVariables &values, const Context &, unsigned, unsigned) const
Evaluate the initial value for a control volume.
Definition: fingerproblem.hh:456
void endTimeStep()
Called by the simulator after each time integration.
Definition: fingerproblem.hh:330
RestrictProlongOperator restrictProlongOperator()
return restriction and prolongation operator
Definition: fingerproblem.hh:234
static void registerParameters()
Definition: fingerproblem.hh:253
CopyRestrictProlong< Grid, MaterialLawParamsContainer > RestrictProlongOperator
Definition: fingerproblem.hh:215
std::string name() const
The problem name.
Definition: fingerproblem.hh:242
FingerProblem(Simulator &simulator)
Definition: fingerproblem.hh:220
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:84
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
void reset()
Reset parameter system.
Definition: blackoilmodel.hh:74
static constexpr int dim
Definition: structuredgridvanguard.hh:68
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
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type GetProp
get the type of a property (equivalent to old macro GET_PROP(...))
Definition: propertysystem.hh:224
The Opm property system, traits with inheritance.
Definition: fingerproblem.hh:140
static constexpr Scalar value
Definition: fingerproblem.hh:140
Specify whether the some degrees of fredom can be constraint.
Definition: fvbaseproperties.hh:213
The type of the DUNE grid.
Definition: basicproperties.hh:104
UndefinedProperty type
Definition: basicproperties.hh:104
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: fingerproblem.hh:120
Opm::ParkerLenhard< Traits > ParkerLenhard
Definition: fingerproblem.hh:127
ParkerLenhard type
Definition: fingerproblem.hh:128
GetPropType< TypeTag, Properties::FluidSystem > FluidSystem
Definition: fingerproblem.hh:121
Opm::TwoPhaseMaterialTraits< Scalar, FluidSystem::wettingPhaseIdx, FluidSystem::nonWettingPhaseIdx > Traits
Definition: fingerproblem.hh:124
The material law which ought to be used (extracted from the spatial parameters)
Definition: multiphasebaseproperties.hh:55
Opm::GasPhase< Scalar, Opm::Air< Scalar > > type
Definition: fingerproblem.hh:113
The non-wetting phase for two-phase models.
Definition: immiscibleproperties.hh:44
The type of the problem.
Definition: fvbaseproperties.hh:86
Definition: fingerproblem.hh:77
std::tuple< StructuredGridVanguard > InheritsFrom
Definition: fingerproblem.hh:77
Opm::LiquidPhase< Scalar, Opm::SimpleH2O< Scalar > > type
Definition: fingerproblem.hh:102
The wetting phase for two-phase models.
Definition: immiscibleproperties.hh:41