28 #ifndef EWOMS_POWER_INJECTION_PROBLEM_HH
29 #define EWOMS_POWER_INJECTION_PROBLEM_HH
31 #include <opm/models/immiscible/immisciblemodel.hh>
32 #include <opm/models/io/cubegridvanguard.hh>
34 #include <opm/material/fluidmatrixinteractions/RegularizedVanGenuchten.hpp>
35 #include <opm/material/fluidmatrixinteractions/LinearMaterial.hpp>
36 #include <opm/material/fluidmatrixinteractions/EffToAbsLaw.hpp>
37 #include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
38 #include <opm/material/fluidsystems/TwoPhaseImmiscibleFluidSystem.hpp>
39 #include <opm/material/fluidstates/ImmiscibleFluidState.hpp>
40 #include <opm/material/components/SimpleH2O.hpp>
41 #include <opm/material/components/Air.hpp>
42 #include <opm/material/common/Unused.hpp>
44 #include <dune/grid/yaspgrid.hh>
46 #include <dune/common/version.hh>
47 #include <dune/common/fvector.hh>
48 #include <dune/common/fmatrix.hh>
52 #include <type_traits>
56 template <
class TypeTag>
57 class PowerInjectionProblem;
60 namespace Opm::Properties {
67 template<
class TypeTag>
68 struct Grid<TypeTag, TTag::PowerInjectionBaseProblem> {
using type = Dune::YaspGrid<1>; };
71 template<
class TypeTag>
72 struct Vanguard<TypeTag, TTag::PowerInjectionBaseProblem> {
using type = Opm::CubeGridVanguard<TypeTag>; };
75 template<
class TypeTag>
79 template<
class TypeTag>
80 struct WettingPhase<TypeTag, TTag::PowerInjectionBaseProblem>
83 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
86 using type = Opm::LiquidPhase<Scalar, Opm::SimpleH2O<Scalar> >;
90 template<
class TypeTag>
91 struct NonwettingPhase<TypeTag, TTag::PowerInjectionBaseProblem>
94 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
97 using type = Opm::GasPhase<Scalar, Opm::Air<Scalar> >;
101 template<
class TypeTag>
102 struct MaterialLaw<TypeTag, TTag::PowerInjectionBaseProblem>
105 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
106 enum { wettingPhaseIdx = FluidSystem::wettingPhaseIdx };
107 enum { nonWettingPhaseIdx = FluidSystem::nonWettingPhaseIdx };
109 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
110 using Traits = Opm::TwoPhaseMaterialTraits<Scalar,
111 FluidSystem::wettingPhaseIdx,
112 FluidSystem::nonWettingPhaseIdx>;
116 using EffectiveLaw = Opm::RegularizedVanGenuchten<Traits>;
120 using type = Opm::EffToAbsLaw<EffectiveLaw>;
124 template<
class TypeTag>
125 struct VtkWriteFilterVelocities<TypeTag, TTag::PowerInjectionBaseProblem> {
static constexpr
bool value =
true; };
128 template<
class TypeTag>
129 struct EnableGravity<TypeTag, TTag::PowerInjectionBaseProblem> {
static constexpr
bool value =
false; };
132 template<
class TypeTag>
133 struct DomainSizeX<TypeTag, TTag::PowerInjectionBaseProblem>
135 using type = GetPropType<TypeTag, Scalar>;
136 static constexpr type value = 100.0;
138 template<
class TypeTag>
139 struct DomainSizeY<TypeTag, TTag::PowerInjectionBaseProblem>
141 using type = GetPropType<TypeTag, Scalar>;
142 static constexpr type value = 1.0;
144 template<
class TypeTag>
145 struct DomainSizeZ<TypeTag, TTag::PowerInjectionBaseProblem>
147 using type = GetPropType<TypeTag, Scalar>;
148 static constexpr type value = 1.0;
151 template<
class TypeTag>
152 struct CellsX<TypeTag, TTag::PowerInjectionBaseProblem> {
static constexpr
int value = 250; };
153 template<
class TypeTag>
154 struct CellsY<TypeTag, TTag::PowerInjectionBaseProblem> {
static constexpr
int value = 1; };
155 template<
class TypeTag>
156 struct CellsZ<TypeTag, TTag::PowerInjectionBaseProblem> {
static constexpr
int value = 1; };
159 template<
class TypeTag>
160 struct EndTime<TypeTag, TTag::PowerInjectionBaseProblem>
162 using type = GetPropType<TypeTag, Scalar>;
163 static constexpr type value = 100;
167 template<
class TypeTag>
168 struct InitialTimeStepSize<TypeTag, TTag::PowerInjectionBaseProblem>
170 using type = GetPropType<TypeTag, Scalar>;
171 static constexpr type value = 1e-3;
189 template <
class TypeTag>
192 using ParentType = GetPropType<TypeTag, Properties::BaseProblem>;
194 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
195 using GridView = GetPropType<TypeTag, Properties::GridView>;
196 using Indices = GetPropType<TypeTag, Properties::Indices>;
197 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
198 using WettingPhase = GetPropType<TypeTag, Properties::WettingPhase>;
199 using NonwettingPhase = GetPropType<TypeTag, Properties::NonwettingPhase>;
200 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
201 using EqVector = GetPropType<TypeTag, Properties::EqVector>;
202 using RateVector = GetPropType<TypeTag, Properties::RateVector>;
203 using BoundaryRateVector = GetPropType<TypeTag, Properties::BoundaryRateVector>;
204 using Simulator = GetPropType<TypeTag, Properties::Simulator>;
208 numPhases = FluidSystem::numPhases,
211 wettingPhaseIdx = FluidSystem::wettingPhaseIdx,
212 nonWettingPhaseIdx = FluidSystem::nonWettingPhaseIdx,
215 contiNEqIdx = Indices::conti0EqIdx + nonWettingPhaseIdx,
218 dim = GridView::dimension,
219 dimWorld = GridView::dimensionworld
222 using MaterialLaw = GetPropType<TypeTag, Properties::MaterialLaw>;
223 using MaterialLawParams = GetPropType<TypeTag, Properties::MaterialLawParams>;
225 using CoordScalar =
typename GridView::ctype;
226 using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
228 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
235 : ParentType(simulator)
243 ParentType::finishInit();
248 temperature_ = 273.15 + 26.6;
252 materialParams_.setVgAlpha(0.00045);
253 materialParams_.setVgN(7.3);
254 materialParams_.finalize();
256 K_ = this->toDimMatrix_(5.73e-08);
258 setupInitialFluidState_();
271 std::ostringstream oss;
272 oss <<
"powerinjection_";
273 if (std::is_same<GetPropType<TypeTag, Properties::FluxModule>,
274 Opm::DarcyFluxModule<TypeTag> >::value)
277 oss <<
"forchheimer";
279 if (std::is_same<GetPropType<TypeTag, Properties::LocalLinearizerSplice>,
280 Properties::TTag::AutoDiffLocalLinearizer>::value)
294 this->model().checkConservativeness();
298 this->model().globalStorage(storage);
301 if (this->gridView().comm().rank() == 0) {
302 std::cout <<
"Storage: " << storage << std::endl << std::flush;
316 template <
class Context>
318 unsigned spaceIdx OPM_UNUSED,
319 unsigned timeIdx OPM_UNUSED)
const
325 template <
class Context>
327 unsigned spaceIdx OPM_UNUSED,
328 unsigned timeIdx OPM_UNUSED)
const
334 template <
class Context>
336 unsigned spaceIdx OPM_UNUSED,
337 unsigned timeIdx OPM_UNUSED)
const
343 template <
class Context>
344 const MaterialLawParams&
346 unsigned spaceIdx OPM_UNUSED,
347 unsigned timeIdx OPM_UNUSED)
const
348 {
return materialParams_; }
353 template <
class Context>
355 unsigned spaceIdx OPM_UNUSED,
356 unsigned timeIdx OPM_UNUSED)
const
357 {
return temperature_; }
372 template <
class Context>
374 const Context& context,
376 unsigned timeIdx)
const
378 const GlobalPosition& pos = context.pos(spaceIdx, timeIdx);
380 if (onLeftBoundary_(pos)) {
381 RateVector massRate(0.0);
383 massRate[contiNEqIdx] = -1.00;
386 values.setMassRate(massRate);
388 else if (onRightBoundary_(pos))
390 values.setFreeFlow(context, spaceIdx, timeIdx, initialFluidState_);
405 template <
class Context>
407 const Context& context OPM_UNUSED,
408 unsigned spaceIdx OPM_UNUSED,
409 unsigned timeIdx OPM_UNUSED)
const
412 values.assignNaive(initialFluidState_);
421 template <
class Context>
423 const Context& context OPM_UNUSED,
424 unsigned spaceIdx OPM_UNUSED,
425 unsigned timeIdx OPM_UNUSED)
const
426 { rate = Scalar(0.0); }
431 bool onLeftBoundary_(
const GlobalPosition& pos)
const
432 {
return pos[0] < this->boundingBoxMin()[0] + eps_; }
434 bool onRightBoundary_(
const GlobalPosition& pos)
const
435 {
return pos[0] > this->boundingBoxMax()[0] - eps_; }
437 void setupInitialFluidState_()
439 initialFluidState_.setTemperature(temperature_);
442 initialFluidState_.setSaturation(wettingPhaseIdx, Sw);
443 initialFluidState_.setSaturation(nonWettingPhaseIdx, 1 - Sw);
446 initialFluidState_.setPressure(wettingPhaseIdx, p);
447 initialFluidState_.setPressure(nonWettingPhaseIdx, p);
449 typename FluidSystem::template ParameterCache<Scalar> paramCache;
450 paramCache.updateAll(initialFluidState_);
451 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
452 initialFluidState_.setDensity(phaseIdx,
453 FluidSystem::density(initialFluidState_, paramCache, phaseIdx));
454 initialFluidState_.setViscosity(phaseIdx,
455 FluidSystem::viscosity(initialFluidState_, paramCache, phaseIdx));
460 MaterialLawParams materialParams_;
462 Opm::ImmiscibleFluidState<Scalar, FluidSystem> initialFluidState_;
1D Problem with very fast injection of gas on the left.
Definition: powerinjectionproblem.hh:191
void source(RateVector &rate, const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: powerinjectionproblem.hh:422
void finishInit()
Definition: powerinjectionproblem.hh:241
void initial(PrimaryVariables &values, const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: powerinjectionproblem.hh:406
Scalar porosity(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: powerinjectionproblem.hh:335
const DimMatrix & intrinsicPermeability(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: powerinjectionproblem.hh:317
void endTimeStep()
Definition: powerinjectionproblem.hh:291
Scalar ergunCoefficient(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: powerinjectionproblem.hh:326
Scalar temperature(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: powerinjectionproblem.hh:354
const MaterialLawParams & materialLawParams(const Context &context OPM_UNUSED, unsigned spaceIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED) const
Definition: powerinjectionproblem.hh:345
std::string name() const
Definition: powerinjectionproblem.hh:269
PowerInjectionProblem(Simulator &simulator)
Definition: powerinjectionproblem.hh:234
void boundary(BoundaryRateVector &values, const Context &context, unsigned spaceIdx, unsigned timeIdx) const
Definition: powerinjectionproblem.hh:373
Definition: powerinjectionproblem.hh:63