28 #ifndef EWOMS_TUTORIAL1_PROBLEM_HH
29 #define EWOMS_TUTORIAL1_PROBLEM_HH
32 #include <opm/models/immiscible/immisciblemodel.hh>
35 #include <opm/models/discretization/vcfv/vcfvdiscretization.hh>
38 #include <opm/material/components/SimpleH2O.hpp>
39 #include <opm/material/components/Lnapl.hpp>
42 #include <opm/material/fluidmatrixinteractions/RegularizedBrooksCorey.hpp>
43 #include <opm/material/fluidmatrixinteractions/EffToAbsLaw.hpp>
44 #include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
47 #include <dune/grid/yaspgrid.hh>
48 #include <opm/models/io/cubegridvanguard.hh>
51 #include <dune/common/fmatrix.hh>
52 #include <dune/common/version.hh>
56 template <
class TypeTag>
57 class Tutorial1Problem;
60 namespace Opm::Properties {
69 template<
class TypeTag>
71 {
using type = TTag::VcfvDiscretization; };
74 template<
class TypeTag>
79 template<
class TypeTag>
81 template<
class TypeTag>
82 struct Vanguard<TypeTag, TTag::
Tutorial1Problem> {
using type = Opm::CubeGridVanguard<TypeTag>; };
85 template<
class TypeTag>
88 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
89 using type = Opm::LiquidPhase<Scalar, Opm::SimpleH2O<Scalar> >;
93 template<
class TypeTag>
96 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
97 using type = Opm::LiquidPhase<Scalar, Opm::LNAPL<Scalar> >;
101 template<
class TypeTag>
107 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
108 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
109 enum { wettingPhaseIdx = FluidSystem::wettingPhaseIdx };
110 enum { nonWettingPhaseIdx = FluidSystem::nonWettingPhaseIdx };
111 using Traits = Opm::TwoPhaseMaterialTraits<Scalar, wettingPhaseIdx, nonWettingPhaseIdx>;
115 using RawMaterialLaw = Opm::RegularizedBrooksCorey<Traits>;
120 using type = Opm::EffToAbsLaw<RawMaterialLaw>;
124 template<
class TypeTag>
125 struct EnableGravity<TypeTag, TTag::
Tutorial1Problem> {
static constexpr
bool value =
false; };
128 template<
class TypeTag>
131 using type = GetPropType<TypeTag, Scalar>;
132 static constexpr type value = 100e3;
136 template<
class TypeTag>
139 using type = GetPropType<TypeTag, Scalar>;
140 static constexpr type value = 125.0;
144 template<
class TypeTag>
147 using type = GetPropType<TypeTag, Scalar>;
148 static constexpr type value = 300.0;
150 template<
class TypeTag>
153 using type = GetPropType<TypeTag, Scalar>;
154 static constexpr type value = 60.0;
156 template<
class TypeTag>
159 using type = GetPropType<TypeTag, Scalar>;
160 static constexpr type value = 0.0;
164 template<
class TypeTag>
166 template<
class TypeTag>
168 template<
class TypeTag>
175 template <
class TypeTag>
177 :
public GetPropType<TypeTag, Properties::BaseProblem>
179 using ParentType = GetPropType<TypeTag, Properties::BaseProblem>;
180 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
181 using GridView = GetPropType<TypeTag, Properties::GridView>;
184 enum { dimWorld = GridView::dimensionworld };
187 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
190 using Simulator = GetPropType<TypeTag, Properties::Simulator>;
191 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
192 using RateVector = GetPropType<TypeTag, Properties::RateVector>;
193 using BoundaryRateVector = GetPropType<TypeTag, Properties::BoundaryRateVector>;
194 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
195 using Indices = GetPropType<TypeTag, Properties::Indices>;
196 using MaterialLaw = GetPropType<TypeTag, Properties::MaterialLaw>;
197 using MaterialLawParams = GetPropType<TypeTag, Properties::MaterialLawParams>;
200 enum { numPhases = FluidSystem::numPhases };
201 enum { wettingPhaseIdx = FluidSystem::wettingPhaseIdx };
202 enum { nonWettingPhaseIdx = FluidSystem::nonWettingPhaseIdx };
205 enum { contiWettingEqIdx = Indices::conti0EqIdx + wettingPhaseIdx };
206 enum { contiNonWettingEqIdx = Indices::conti0EqIdx + nonWettingPhaseIdx };
212 : ParentType(simulator)
221 ParentType::finishInit();
224 K_ = this->toDimMatrix_(1e-7);
227 materialParams_.setEntryPressure(500.0 );
228 materialParams_.setLambda(2);
231 materialParams_.setResidualSaturation(wettingPhaseIdx, 0.0);
232 materialParams_.setResidualSaturation(nonWettingPhaseIdx, 0.0);
235 materialParams_.finalize();
240 {
return "tutorial1"; }
243 template <
class Context>
245 unsigned ,
unsigned )
const
249 template <
class Context>
251 unsigned ,
unsigned )
const
255 template <
class Context>
257 unsigned ,
unsigned )
const
261 template <
class Context>
263 unsigned ,
unsigned )
const
264 {
return materialParams_; }
267 template <
class Context>
268 void boundary(BoundaryRateVector& values,
const Context& context,
269 unsigned spaceIdx,
unsigned timeIdx)
const
271 const auto& pos = context.pos(spaceIdx, timeIdx);
274 const auto& materialParams = this->
materialLawParams(context, spaceIdx, timeIdx);
276 Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs;
278 fs.setSaturation(wettingPhaseIdx, Sw);
279 fs.setSaturation(nonWettingPhaseIdx, 1.0 - Sw);
280 fs.setTemperature(
temperature(context, spaceIdx, timeIdx));
282 Scalar pC[numPhases];
283 MaterialLaw::capillaryPressures(pC, materialParams, fs);
284 fs.setPressure(wettingPhaseIdx, 200e3);
285 fs.setPressure(nonWettingPhaseIdx, 200e3 + pC[nonWettingPhaseIdx] - pC[nonWettingPhaseIdx]);
287 typename FluidSystem::template ParameterCache<Scalar> paramCache;
288 paramCache.updateAll(fs);
289 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
290 fs.setDensity(phaseIdx, FluidSystem::density(fs, paramCache, phaseIdx));
291 fs.setViscosity(phaseIdx, FluidSystem::viscosity(fs, paramCache, phaseIdx));
294 values.setFreeFlow(context, spaceIdx, timeIdx, fs);
296 else if (pos[0] > this->boundingBoxMax()[0] - eps_) {
298 RateVector massRate(0.0);
300 massRate[contiWettingEqIdx] = 0.0;
301 massRate[contiNonWettingEqIdx] = 3e-2;
303 values.setMassRate(massRate);
312 template <
class Context>
313 void source(RateVector& sourceRate,
const Context& ,
314 unsigned ,
unsigned )
const
316 sourceRate[contiWettingEqIdx] = 0.0;
317 sourceRate[contiNonWettingEqIdx] = 0.0;
321 template <
class Context>
322 void initial(PrimaryVariables& values,
const Context& context,
323 unsigned spaceIdx,
unsigned timeIdx)
const
325 Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs;
329 fs.setSaturation(wettingPhaseIdx, Sw);
330 fs.setSaturation(nonWettingPhaseIdx, 1.0 - Sw);
333 fs.setTemperature(
temperature(context, spaceIdx, timeIdx));
336 Scalar pC[numPhases];
337 MaterialLaw::capillaryPressures(pC,
materialLawParams(context, spaceIdx, timeIdx),
339 fs.setPressure(wettingPhaseIdx, 200e3);
340 fs.setPressure(nonWettingPhaseIdx, 200e3 + pC[nonWettingPhaseIdx] - pC[nonWettingPhaseIdx]);
342 values.assignNaive(fs);
348 MaterialLawParams materialParams_;
Tutorial problem using the "immiscible" model.
Definition: tutorial1problem.hh:178
const DimMatrix & intrinsicPermeability(const Context &, unsigned, unsigned) const
Returns the intrinsic permeability tensor [m^2] at a position.
Definition: tutorial1problem.hh:250
Scalar porosity(const Context &, unsigned, unsigned) const
Defines the porosity [-] of the medium at a given position.
Definition: tutorial1problem.hh:256
void initial(PrimaryVariables &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluates the initial value at a given position in the domain.
Definition: tutorial1problem.hh:322
void finishInit()
This method initializes the data structures allocated by the problem constructor.
Definition: tutorial1problem.hh:219
Tutorial1Problem(Simulator &simulator)
The constructor of the problem.
Definition: tutorial1problem.hh:211
void boundary(BoundaryRateVector &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Evaluates the boundary conditions.
Definition: tutorial1problem.hh:268
void source(RateVector &sourceRate, const Context &, unsigned, unsigned) const
Evaluates the source term for all conserved quantities at a given position of the domain [kg/(m^3 * s...
Definition: tutorial1problem.hh:313
std::string name() const
Specifies the problem name. This is used for files generated by the simulation.
Definition: tutorial1problem.hh:239
const MaterialLawParams & materialLawParams(const Context &, unsigned, unsigned) const
Returns the parameter object for the material law at a given position.
Definition: tutorial1problem.hh:262
Scalar temperature(const Context &, unsigned, unsigned) const
Returns the temperature at a given position.
Definition: tutorial1problem.hh:244
Definition: tutorial1problem.hh:65