28#ifndef EWOMS_RICHARDS_LENS_PROBLEM_HH
29#define EWOMS_RICHARDS_LENS_PROBLEM_HH
33#include <opm/material/components/SimpleH2O.hpp>
34#include <opm/material/fluidsystems/LiquidPhase.hpp>
35#include <opm/material/fluidmatrixinteractions/RegularizedVanGenuchten.hpp>
36#include <opm/material/fluidmatrixinteractions/LinearMaterial.hpp>
37#include <opm/material/fluidmatrixinteractions/EffToAbsLaw.hpp>
38#include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
42#include <dune/grid/yaspgrid.hh>
43#include <dune/grid/io/file/dgfparser/dgfyasp.hh>
45#include <dune/common/version.hh>
46#include <dune/common/fvector.hh>
47#include <dune/common/fmatrix.hh>
50template <
class TypeTag>
51class RichardsLensProblem;
63template<
class TypeTag>
67template<
class TypeTag>
71template<
class TypeTag>
78 using type = Opm::LiquidPhase<Scalar, Opm::SimpleH2O<Scalar> >;
82template<
class TypeTag>
87 enum { wettingPhaseIdx = FluidSystem::wettingPhaseIdx };
88 enum { nonWettingPhaseIdx = FluidSystem::nonWettingPhaseIdx };
91 using Traits = Opm::TwoPhaseMaterialTraits<Scalar,
92 FluidSystem::wettingPhaseIdx,
93 FluidSystem::nonWettingPhaseIdx>;
97 using EffectiveLaw = Opm::RegularizedVanGenuchten<Traits>;
101 using type = Opm::EffToAbsLaw<EffectiveLaw>;
124template <
class TypeTag>
143 pressureWIdx = Indices::pressureWIdx,
144 contiEqIdx = Indices::contiEqIdx,
145 wettingPhaseIdx = FluidSystem::wettingPhaseIdx,
146 nonWettingPhaseIdx = FluidSystem::nonWettingPhaseIdx,
147 numPhases = FluidSystem::numPhases,
150 dimWorld = GridView::dimensionworld
156 using MaterialLawParams =
typename MaterialLaw::Params;
158 using CoordScalar =
typename GridView::ctype;
159 using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
160 using PhaseVector = Dune::FieldVector<Scalar, numPhases>;
161 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
168 : ParentType(simulator)
171 dofIsInLens_.resize(simulator.model().numGridDof());
179 ParentType::finishInit();
184 lensLowerLeft_[0] = 1.0;
185 lensLowerLeft_[1] = 2.0;
187 lensUpperRight_[0] = 4.0;
188 lensUpperRight_[1] = 3.0;
192 lensMaterialParams_.setVgAlpha(0.00045);
193 lensMaterialParams_.setVgN(7.3);
194 lensMaterialParams_.finalize();
196 outerMaterialParams_.setVgAlpha(0.0037);
197 outerMaterialParams_.setVgN(4.7);
198 outerMaterialParams_.finalize();
207 lensK_ = this->toDimMatrix_(1e-12);
208 outerK_ = this->toDimMatrix_(5e-12);
211 Stencil stencil(this->gridView(), this->simulator().model().dofMapper() );
212 for (
const auto& elem : elements(this->gridView())) {
213 stencil.update(elem);
214 for (
unsigned dofIdx = 0; dofIdx < stencil.numPrimaryDof(); ++ dofIdx) {
215 unsigned globalDofIdx = stencil.globalSpaceIndex(dofIdx);
216 const auto& dofPos = stencil.subControlVolume(dofIdx).center();
217 dofIsInLens_[globalDofIdx] = isInLens_(dofPos);
227 ParentType::registerParameters();
229 Parameters::SetDefault<Parameters::GridFile>(
"./data/richardslens_24x16.dgf");
233 constexpr bool useFD = std::is_same_v<LLS, Properties::TTag::FiniteDifferenceLocalLinearizer>;
234 if constexpr (useFD) {
235 Parameters::SetDefault<Parameters::NumericDifferenceMethod>(0);
238 Parameters::SetDefault<Parameters::EndTime<Scalar>>(3000.0);
239 Parameters::SetDefault<Parameters::InitialTimeStepSize<Scalar>>(100.0);
240 Parameters::SetDefault<Parameters::NewtonMaxIterations>(28);
241 Parameters::SetDefault<Parameters::NewtonTargetIterations>(18);
242 Parameters::SetDefault<Parameters::EnableGravity>(
true);
255 std::ostringstream oss;
256 oss <<
"lens_richards_"
257 << Model::discretizationName();
267 this->model().checkConservativeness();
271 this->model().globalStorage(storage);
274 if (this->gridView().comm().rank() == 0) {
275 std::cout <<
"Storage: " << storage << std::endl << std::flush;
283 template <
class Context>
284 Scalar
temperature(
const Context& context,
unsigned spaceIdx,
unsigned timeIdx)
const
285 {
return temperature(context.globalSpaceIndex(spaceIdx, timeIdx), timeIdx); }
288 {
return 273.15 + 10; }
293 template <
class Context>
296 unsigned timeIdx)
const
298 const GlobalPosition& pos = context.pos(spaceIdx, timeIdx);
307 template <
class Context>
316 template <
class Context>
319 unsigned timeIdx)
const
321 unsigned globalSpaceIdx = context.globalSpaceIndex(spaceIdx, timeIdx);
328 if (dofIsInLens_[globalSpaceIdx])
329 return lensMaterialParams_;
330 return outerMaterialParams_;
338 template <
class Context>
341 unsigned timeIdx)
const
342 {
return referencePressure(context.globalSpaceIndex(spaceIdx, timeIdx), timeIdx); }
360 template <
class Context>
362 const Context& context,
364 unsigned timeIdx)
const
366 const auto& pos = context.pos(spaceIdx, timeIdx);
368 if (onLeftBoundary_(pos) || onRightBoundary_(pos)) {
369 const auto& materialParams = this->
materialLawParams(context, spaceIdx, timeIdx);
372 Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs;
373 fs.setSaturation(wettingPhaseIdx, Sw);
374 fs.setSaturation(nonWettingPhaseIdx, 1.0 - Sw);
377 MaterialLaw::capillaryPressures(pC, materialParams, fs);
378 fs.setPressure(wettingPhaseIdx, pnRef_ + pC[wettingPhaseIdx] - pC[nonWettingPhaseIdx]);
379 fs.setPressure(nonWettingPhaseIdx, pnRef_);
381 typename FluidSystem::template ParameterCache<Scalar> paramCache;
382 paramCache.updateAll(fs);
383 fs.setDensity(wettingPhaseIdx, FluidSystem::density(fs, paramCache, wettingPhaseIdx));
386 fs.setViscosity(wettingPhaseIdx, FluidSystem::viscosity(fs, paramCache, wettingPhaseIdx));
389 values.setFreeFlow(context, spaceIdx, timeIdx, fs);
391 else if (onInlet_(pos)) {
392 RateVector massRate(0.0);
395 massRate[contiEqIdx] = -0.04;
397 values.setMassRate(massRate);
413 template <
class Context>
415 const Context& context,
417 unsigned timeIdx)
const
419 const auto& materialParams = this->
materialLawParams(context, spaceIdx, timeIdx);
422 Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs;
423 fs.setSaturation(wettingPhaseIdx, Sw);
424 fs.setSaturation(nonWettingPhaseIdx, 1.0 - Sw);
427 MaterialLaw::capillaryPressures(pC, materialParams, fs);
428 values[pressureWIdx] = pnRef_ + (pC[wettingPhaseIdx] - pC[nonWettingPhaseIdx]);
437 template <
class Context>
442 { rate = Scalar(0.0); }
447 bool onLeftBoundary_(
const GlobalPosition& pos)
const
448 {
return pos[0] < this->boundingBoxMin()[0] + eps_; }
450 bool onRightBoundary_(
const GlobalPosition& pos)
const
451 {
return pos[0] > this->boundingBoxMax()[0] - eps_; }
453 bool onLowerBoundary_(
const GlobalPosition& pos)
const
454 {
return pos[1] < this->boundingBoxMin()[1] + eps_; }
456 bool onUpperBoundary_(
const GlobalPosition& pos)
const
457 {
return pos[1] > this->boundingBoxMax()[1] - eps_; }
459 bool onInlet_(
const GlobalPosition& pos)
const
461 Scalar width = this->boundingBoxMax()[0] - this->boundingBoxMin()[0];
462 Scalar lambda = (this->boundingBoxMax()[0] - pos[0]) / width;
463 return onUpperBoundary_(pos) && 0.5 < lambda && lambda < 2.0 / 3.0;
466 bool isInLens_(
const GlobalPosition& pos)
const
468 for (
unsigned i = 0; i < dimWorld; ++i) {
469 if (pos[i] < lensLowerLeft_[i] || pos[i] > lensUpperRight_[i])
475 GlobalPosition lensLowerLeft_;
476 GlobalPosition lensUpperRight_;
480 MaterialLawParams lensMaterialParams_;
481 MaterialLawParams outerMaterialParams_;
483 std::vector<bool> dofIsInLens_;
A water infiltration problem with a low-permeability lens embedded into a high-permeability domain.
Definition: richardslensproblem.hh:126
void finishInit()
Called by the Opm::Simulator in order to initialize the problem.
Definition: richardslensproblem.hh:177
static void registerParameters()
Definition: richardslensproblem.hh:225
std::string name() const
The problem name.
Definition: richardslensproblem.hh:253
const MaterialLawParams & materialLawParams(unsigned globalSpaceIdx, unsigned) const
Definition: richardslensproblem.hh:325
const MaterialLawParams & materialLawParams(const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Definition: richardslensproblem.hh:317
Scalar temperature(unsigned, unsigned) const
Definition: richardslensproblem.hh:287
Scalar referencePressure(const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Return the reference pressure [Pa] of the wetting phase.
Definition: richardslensproblem.hh:339
RichardsLensProblem(Simulator &simulator)
Definition: richardslensproblem.hh:167
const DimMatrix & intrinsicPermeability(const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Definition: richardslensproblem.hh:294
void source(RateVector &rate, const Context &, unsigned, unsigned) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: richardslensproblem.hh:438
Scalar referencePressure(unsigned, unsigned) const
Definition: richardslensproblem.hh:346
void boundary(BoundaryRateVector &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluate the boundary conditions for a boundary segment.
Definition: richardslensproblem.hh:361
void endTimeStep()
Called by the simulator after each time integration.
Definition: richardslensproblem.hh:264
Scalar temperature(const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Definition: richardslensproblem.hh:284
void initial(PrimaryVariables &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluate the initial value for a control volume.
Definition: richardslensproblem.hh:414
Scalar porosity(const Context &, unsigned, unsigned) const
Definition: richardslensproblem.hh:308
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
Dune::YaspGrid< 2 > type
Definition: richardslensproblem.hh:64
The type of the DUNE grid.
Definition: basicproperties.hh:104
Opm::EffToAbsLaw< EffectiveLaw > type
Definition: richardslensproblem.hh:101
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:86
Definition: richardslensproblem.hh:59
std::tuple< Richards > InheritsFrom
Definition: richardslensproblem.hh:59
Opm::LiquidPhase< Scalar, Opm::SimpleH2O< Scalar > > type
Definition: richardslensproblem.hh:78
Definition: richardsproperties.hh:40