24#ifndef EWOMS_BLACK_OIL_PRIMARY_VARIABLES_HH
25#define EWOMS_BLACK_OIL_PRIMARY_VARIABLES_HH
27#include <dune/common/fvector.hh>
29#include <opm/common/OpmLog/OpmLog.hpp>
30#include <opm/common/utility/gpuDecorators.hpp>
32#include <opm/material/common/MathToolbox.hpp>
33#include <opm/material/common/Valgrind.hpp>
34#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
35#include <opm/material/fluidstates/SimpleModularFluidState.hpp>
52#include <fmt/format.h>
58{
static constexpr Scalar
value = 1.0; };
67 { fluidSystem.enableDissolvedGas() } -> std::convertible_to<bool>;
68 { fluidSystem.enableDissolvedGasInWater() } -> std::convertible_to<bool>;
69 { fluidSystem.enableVaporizedOil() } -> std::convertible_to<bool>;
70 { fluidSystem.enableVaporizedWater() } -> std::convertible_to<bool>;
73 fluidSystem.waterPvt();
85template <
class TypeTag,
template<
class,
int>
class VectorType = Dune::FieldVector>
100 enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
103 static constexpr unsigned waterSwitchIdx = Indices::waterSwitchIdx;
104 static constexpr unsigned pressureSwitchIdx = Indices::pressureSwitchIdx;
105 static constexpr unsigned compositionSwitchIdx = Indices::compositionSwitchIdx;
106 static constexpr unsigned saltConcentrationIdx = Indices::saltConcentrationIdx;
107 static constexpr unsigned solventSaturationIdx = Indices::solventSaturationIdx;
109 static constexpr bool compositionSwitchEnabled =
110 Indices::compositionSwitchIdx != std::numeric_limits<unsigned>::max();
111 static constexpr bool waterEnabled = Indices::waterEnabled;
112 static constexpr bool gasEnabled = Indices::gasEnabled;
113 static constexpr bool oilEnabled = Indices::oilEnabled;
116 enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
117 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
118 enum { waterPhaseIdx = FluidSystem::waterPhaseIdx };
119 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
122 enum { numComponents = getPropValue<TypeTag, Properties::NumComponents>() };
124 static constexpr EnergyModules energyModuleType = getPropValue<TypeTag, Properties::EnergyModuleType>();
126 static constexpr bool enableBioeffects = getPropValue<TypeTag, Properties::EnableBioeffects>();
127 static constexpr bool enableBrine = getPropValue<TypeTag, Properties::EnableBrine>();
128 static constexpr bool enableExtbo = getPropValue<TypeTag, Properties::EnableExtbo>();
129 static constexpr bool enableFoam = getPropValue<TypeTag, Properties::EnableFoam>();
130 static constexpr bool enableFullyImplicitThermal = energyModuleType == EnergyModules::FullyImplicitThermal;
131 static constexpr bool enablePolymer = getPropValue<TypeTag, Properties::EnablePolymer>();
132 static constexpr bool enableSolvent = getPropValue<TypeTag, Properties::EnableSolvent>();
134 enum { enableSaltPrecipitation = getPropValue<TypeTag, Properties::EnableSaltPrecipitation>() };
135 enum { enableVapwat = getPropValue<TypeTag, Properties::EnableVapwat>() };
136 enum { enableMICP = Indices::enableMICP };
137 enum { gasCompIdx = FluidSystem::gasCompIdx };
138 enum { waterCompIdx = FluidSystem::waterCompIdx };
139 enum { oilCompIdx = FluidSystem::oilCompIdx };
141 using Toolbox = MathToolbox<Evaluation>;
142 using ComponentVector = Dune::FieldVector<Scalar, numComponents>;
143 using SolventModule = BlackOilSolventModule<TypeTag, enableSolvent>;
144 using ExtboModule = BlackOilExtboModule<TypeTag, enableExtbo>;
146 using BrineModule = BlackOilBrineModule<TypeTag, enableBrine>;
147 using BioeffectsModule = BlackOilBioeffectsModule<TypeTag, enableBioeffects>;
149 static_assert(numPhases == 3,
"The black-oil model assumes three phases!");
150 static_assert(numComponents == 3,
"The black-oil model assumes three components!");
163 template<
class OtherTypeTag,
template<
class,
int>
class OtherVectorType>
169 template <
class OtherTypeTag,
template <
class,
int>
class OtherVectorType>
170 explicit OPM_HOST_DEVICE
173 , primaryVarsMeaningWater_(other.primaryVarsMeaningWater_)
174 , primaryVarsMeaningPressure_(other.primaryVarsMeaningPressure_)
175 , primaryVarsMeaningGas_(other.primaryVarsMeaningGas_)
176 , primaryVarsMeaningBrine_(other.primaryVarsMeaningBrine_)
177 , primaryVarsMeaningSolvent_(other.primaryVarsMeaningSolvent_)
178 , pvtRegionIdx_(other.pvtRegionIdx_)
179 , pcFactor_(other.pcFactor_)
185 Valgrind::SetUndefined(*
this);
197 result.pvtRegionIdx_ = 1;
198 result.primaryVarsMeaningBrine_ = BrineMeaning::Sp;
200 result.primaryVarsMeaningPressure_ = PressureMeaning::Pg;
201 result.primaryVarsMeaningWater_ = WaterMeaning::Rsw;
202 result.primaryVarsMeaningSolvent_ = SolventMeaning::Ss;
203 for (std::size_t i = 0; i < result.size(); ++i) {
213 pressureScale_ = Parameters::Get<Parameters::PressureScale<Scalar>>();
221 if (pressureScale_ != Scalar {1.0}) {
222 OpmLog::warning(fmt::format(
223 "Using a pressure scaling different from 1.0 is not supported "
224 "when running with GPU support. We have detected that you are compiling with GPU support, but we can "
225 "not detect whether you are running with GPU support for the assembly or property evaluation. If you "
226 "are doing property evaluation or assembly on the GPU, pressure scaling will be ignored."
227 "Read value of pressure scale: {}",
235 Parameters::Register<Parameters::PressureScale<Scalar>>
236 (
"Scaling of pressure primary variable");
239 OPM_HOST_DEVICE Evaluation
243 const Scalar scale = varIdx == pressureSwitchIdx ? this->getPressureScale() : Scalar{1.0};
244 if (std::is_same_v<Evaluation, Scalar>) {
245 return (*
this)[varIdx] * scale;
249 if (timeIdx == linearizationType.time) {
250 return Toolbox::createVariable((*
this)[varIdx], varIdx) * scale;
253 return Toolbox::createConstant((*
this)[varIdx]) * scale;
266 { pvtRegionIdx_ =
static_cast<unsigned short>(value); }
272 {
return pvtRegionIdx_; }
279 {
return primaryVarsMeaningWater_; }
286 { primaryVarsMeaningWater_ = newMeaning; }
293 {
return primaryVarsMeaningPressure_; }
300 { primaryVarsMeaningPressure_ = newMeaning; }
307 {
return primaryVarsMeaningGas_; }
314 { primaryVarsMeaningGas_ = newMeaning; }
317 {
return primaryVarsMeaningBrine_; }
324 { primaryVarsMeaningBrine_ = newMeaning; }
327 {
return primaryVarsMeaningSolvent_; }
334 { primaryVarsMeaningSolvent_ = newMeaning; }
339 template <
class Flu
idState>
342 using ConstEvaluation = std::remove_reference_t<typename FluidState::ValueType>;
343 using FsEvaluation = std::remove_const_t<ConstEvaluation>;
344 using FsToolbox = MathToolbox<FsEvaluation>;
346 const bool gasPresent =
347 fluidState.fluidSystem().phaseIsActive(gasPhaseIdx)
348 ? fluidState.saturation(gasPhaseIdx) > 0.0
350 const bool oilPresent =
351 fluidState.fluidSystem().phaseIsActive(oilPhaseIdx)
352 ? fluidState.saturation(oilPhaseIdx) > 0.0
354 const bool waterPresent =
355 fluidState.fluidSystem().phaseIsActive(waterPhaseIdx)
356 ? fluidState.saturation(waterPhaseIdx) > 0.0
358 const auto& saltSaturation =
359 BlackOil::getSaltSaturation_<FluidSystem, FluidState, Scalar>(fluidState, pvtRegionIdx_);
360 const bool precipitatedSaltPresent = enableSaltPrecipitation ? saltSaturation > 0.0 :
false;
361 const bool oneActivePhases = fluidState.fluidSystem().numActivePhases() == 1;
363 if constexpr (enableFullyImplicitThermal) {
364 EnergyModule::assignPrimaryVars(*
this, fluidState);
370 if (gasPresent && fluidState.fluidSystem().enableVaporizedOil() && !oilPresent) {
371 primaryVarsMeaningPressure_ = PressureMeaning::Pg;
373 else if (fluidState.fluidSystem().phaseIsActive(oilPhaseIdx)) {
374 primaryVarsMeaningPressure_ = PressureMeaning::Po;
376 else if (waterPresent && fluidState.fluidSystem().enableDissolvedGasInWater() && !gasPresent) {
377 primaryVarsMeaningPressure_ = PressureMeaning::Pw;
379 else if (fluidState.fluidSystem().phaseIsActive(gasPhaseIdx)) {
380 primaryVarsMeaningPressure_ = PressureMeaning::Pg;
383 assert(fluidState.fluidSystem().phaseIsActive(waterPhaseIdx));
384 primaryVarsMeaningPressure_ = PressureMeaning::Pw;
391 if (waterPresent && gasPresent) {
394 else if (gasPresent && fluidState.fluidSystem().enableVaporizedWater()) {
395 primaryVarsMeaningWater_ = WaterMeaning::Rvw;
397 else if (waterPresent && fluidState.fluidSystem().enableDissolvedGasInWater()) {
398 primaryVarsMeaningWater_ = WaterMeaning::Rsw;
400 else if (fluidState.fluidSystem().phaseIsActive(waterPhaseIdx) && !oneActivePhases) {
412 if (gasPresent && oilPresent) {
415 else if (oilPresent && fluidState.fluidSystem().enableDissolvedGas()) {
418 else if (gasPresent && fluidState.fluidSystem().enableVaporizedOil()) {
421 else if (fluidState.fluidSystem().phaseIsActive(gasPhaseIdx) && fluidState.fluidSystem().phaseIsActive(oilPhaseIdx)) {
429 if constexpr (enableSaltPrecipitation) {
430 if (precipitatedSaltPresent) {
431 primaryVarsMeaningBrine_ = BrineMeaning::Sp;
434 primaryVarsMeaningBrine_ = BrineMeaning::Cs;
443 case PressureMeaning::Po:
444 this->setScaledPressure_(FsToolbox::value(fluidState.pressure(oilPhaseIdx)));
446 case PressureMeaning::Pg:
447 this->setScaledPressure_(FsToolbox::value(fluidState.pressure(gasPhaseIdx)));
449 case PressureMeaning::Pw:
450 this->setScaledPressure_(FsToolbox::value(fluidState.pressure(waterPhaseIdx)));
453 OPM_THROW(std::logic_error,
"No valid primary variable selected for pressure");
459 (*this)[waterSwitchIdx] = FsToolbox::value(fluidState.saturation(waterPhaseIdx));
462 case WaterMeaning::Rvw:
464 const auto& rvw = BlackOil::getRvw_<FluidSystem, FluidState, Scalar>(fluidState, pvtRegionIdx_);
465 (*this)[waterSwitchIdx] = rvw;
468 case WaterMeaning::Rsw:
470 const auto& Rsw = BlackOil::getRsw_<FluidSystem, FluidState, Scalar>(fluidState, pvtRegionIdx_);
471 (*this)[waterSwitchIdx] = Rsw;
477 OPM_THROW(std::logic_error,
"No valid primary variable selected for water");
481 (*this)[compositionSwitchIdx] = FsToolbox::value(fluidState.saturation(gasPhaseIdx));
485 const auto& rs = BlackOil::getRs_<FluidSystem, FluidState, Scalar>(fluidState, pvtRegionIdx_);
486 (*this)[compositionSwitchIdx] = rs;
491 const auto& rv = BlackOil::getRv_<FluidSystem, FluidState, Scalar>(fluidState, pvtRegionIdx_);
492 (*this)[compositionSwitchIdx] = rv;
498 OPM_THROW(std::logic_error,
"No valid primary variable selected for composision");
514 unsigned globalDofIdx,
516 Scalar thresholdWaterFilledCell, Scalar eps = 0.0)
519 swMaximum, thresholdWaterFilledCell, eps);
522 template<Concepts::BlackOilPhaseSwitchingFlu
idSystem Flu
idSystemInstance>
524 const FluidSystemInstance& fluidSystem,
525 unsigned globalDofIdx,
526 [[maybe_unused]] Scalar swMaximum,
527 Scalar thresholdWaterFilledCell, Scalar eps = 0.0)
546 Scalar saltConcentration = 0.0;
547 const Scalar& T = asImp_().temperature_(problem, globalDofIdx, fluidSystem);
549 sw = (*this)[waterSwitchIdx];
552 sg = (*this)[compositionSwitchIdx];
564 if constexpr (enableSaltPrecipitation) {
565 const Scalar saltSolubility = BrineModule::saltSol(
pvtRegionIndex());
567 saltConcentration = saltSolubility;
568 const Scalar saltSat = (*this)[saltConcentrationIdx];
569 if (saltSat < -eps) {
571 (*this)[saltConcentrationIdx] = saltSolubility;
575 saltConcentration = (*this)[saltConcentrationIdx];
576 if (saltConcentration > saltSolubility + eps) {
578 (*this)[saltConcentrationIdx] = 0.0;
586 if constexpr (enableSolvent) {
587 if (SolventModule::isSolubleInWater()) {
588 const Scalar p = (*this)[pressureSwitchIdx];
589 const Scalar solLimit =
590 SolventModule::solubilityLimit(
pvtRegionIndex(), T , p, saltConcentration);
592 const Scalar solSat = (*this)[solventSaturationIdx];
595 (*this)[solventSaturationIdx] = solLimit;
599 const Scalar rsolw = (*this)[solventSaturationIdx];
600 if (rsolw > solLimit + eps) {
602 (*this)[solventSaturationIdx] = 0.0;
609 bool changed =
false;
617 if (sw >= thresholdWaterFilledCell && !fluidSystem.enableDissolvedGasInWater()) {
619 if constexpr (waterEnabled) {
620 (*this)[Indices::waterSwitchIdx] = std::min(swMaximum, sw);
624 if constexpr (compositionSwitchEnabled) {
625 (*this)[Indices::compositionSwitchIdx] = 0.0;
630 if constexpr (compositionSwitchEnabled) {
640 if constexpr (enableBrine) {
642 unsigned satnumRegionIdx = problem.satnumRegionIndex(globalDofIdx);
643 Scalar Sp = saltConcentration_();
644 Scalar porosityFactor = std::min(1.0 - Sp, 1.0);
645 const auto& pcfactTable = BrineModule::pcfactTable(satnumRegionIdx);
646 pcFactor_ = pcfactTable.eval(porosityFactor,
true);
649 else if constexpr (enableBioeffects) {
650 if (BioeffectsModule::hasPcfactTables() && problem.referencePorosity(globalDofIdx, 0) > 0) {
651 unsigned satnumRegionIdx = problem.satnumRegionIndex(globalDofIdx);
652 Scalar Sb = biofilmVolumeFraction_() /
653 problem.referencePorosity(globalDofIdx, 0);
654 Scalar porosityFactor = std::min(1.0 - Sb, 1.0);
655 const auto& pcfactTable = BioeffectsModule::pcfactTable(satnumRegionIdx);
656 pcFactor_ = pcfactTable.eval(porosityFactor,
true);
664 if (sw < -eps && sg > eps && fluidSystem.enableVaporizedWater()) {
665 Scalar p = this->pressure_();
667 std::array<Scalar, numPhases> pC{};
668 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
669 const Scalar so = 1.0 - sg - solventSaturation_();
670 computeCapillaryPressures_(pC, so, sg + solventSaturation_(), 0.0, matParams);
671 p += pcFactor_ * (pC[gasPhaseIdx] - pC[oilPhaseIdx]);
673 const Scalar rvwSat =
674 fluidSystem.gasPvt().saturatedWaterVaporizationFactor(pvtRegionIdx_,
679 (*this)[Indices::waterSwitchIdx] = rvwSat;
685 if (sg < -eps && sw > eps && fluidSystem.enableDissolvedGasInWater()) {
686 const Scalar pg = this->pressure_();
688 std::array<Scalar, numPhases> pC = { 0.0 };
689 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
690 const Scalar so = 1.0 - sw - solventSaturation_();
691 computeCapillaryPressures_(pC, so, 0.0, sw, matParams);
692 const Scalar pw = pg + pcFactor_ * (pC[waterPhaseIdx] - pC[gasPhaseIdx]);
693 const Scalar rswSat =
694 fluidSystem.waterPvt().saturatedGasDissolutionFactor(pvtRegionIdx_,
699 const Scalar rswMax = problem.maxGasDissolutionFactor(0, globalDofIdx);
700 (*this)[Indices::waterSwitchIdx] = std::min(rswSat, rswMax);
702 this->setScaledPressure_(pw);
708 case WaterMeaning::Rvw:
710 const Scalar& rvw = (*this)[waterSwitchIdx];
711 Scalar p = this->pressure_();
713 std::array<Scalar, numPhases> pC{};
714 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
715 const Scalar so = 1.0 - sg - solventSaturation_();
716 computeCapillaryPressures_(pC, so, sg + solventSaturation_(), 0.0, matParams);
717 p += pcFactor_ * (pC[gasPhaseIdx] - pC[oilPhaseIdx]);
719 const Scalar rvwSat =
720 fluidSystem.gasPvt().saturatedWaterVaporizationFactor(pvtRegionIdx_,
725 if (rvw > rvwSat * (1.0 + eps)) {
727 (*this)[Indices::waterSwitchIdx] = 0.0;
732 case WaterMeaning::Rsw:
737 const Scalar& pw = this->pressure_();
739 const Scalar rswSat =
740 fluidSystem.waterPvt().saturatedGasDissolutionFactor(pvtRegionIdx_,
745 const Scalar rsw = (*this)[Indices::waterSwitchIdx];
746 const Scalar rswMax = problem.maxGasDissolutionFactor(0, globalDofIdx);
747 if (rsw > std::min(rswSat, rswMax)) {
750 (*this)[Indices::waterSwitchIdx] = 1.0;
752 std::array<Scalar, numPhases> pC{};
753 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
754 computeCapillaryPressures_(pC, 0.0, 0.0, 1.0, matParams);
755 const Scalar pg = pw + pcFactor_ * (pC[gasPhaseIdx] - pC[waterPhaseIdx]);
756 this->setScaledPressure_(pg);
764 OPM_THROW(std::logic_error,
"No valid primary variable selected for water");
774 if constexpr (compositionSwitchEnabled) {
778 const Scalar s = 1.0 - sw - solventSaturation_();
779 if (sg < -eps && s > 0.0 && fluidSystem.enableDissolvedGas()) {
780 const Scalar po = this->pressure_();
782 const Scalar soMax = std::max(s, problem.maxOilSaturation(globalDofIdx));
783 const Scalar rsMax = problem.maxGasDissolutionFactor(0, globalDofIdx);
785 if constexpr (enableExtbo) {
789 rsSat = fluidSystem.oilPvt().saturatedGasDissolutionFactor(pvtRegionIdx_,
795 Scalar rs = std::min(rsMax, rsSat);
796 if constexpr (!enableExtbo) {
797 const Scalar so = s - sg;
798 if (so < maxOilSaturationForComponentRs_) {
799 rs = gasOilRatioOfPresentComponents_(problem, globalDofIdx, T, po, so, sg, rs, fluidSystem);
802 (*this)[Indices::compositionSwitchIdx] = rs;
806 const Scalar so = 1.0 - sw - solventSaturation_() - sg;
807 if (so < -eps && sg > 0.0 && fluidSystem.enableVaporizedOil()) {
812 const Scalar po = this->pressure_();
813 std::array<Scalar, numPhases> pC{};
814 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
815 computeCapillaryPressures_(pC, 0.0, sg + solventSaturation_(), sw, matParams);
816 const Scalar pg = po + pcFactor_ * (pC[gasPhaseIdx] - pC[oilPhaseIdx]);
821 this->setScaledPressure_(pg);
822 const Scalar soMax = problem.maxOilSaturation(globalDofIdx);
823 const Scalar rvMax = problem.maxOilVaporizationFactor(0, globalDofIdx);
825 if constexpr (enableExtbo) {
829 rvSat = fluidSystem.gasPvt().saturatedOilVaporizationFactor(pvtRegionIdx_,
836 (*this)[Indices::compositionSwitchIdx] = std::min(rvMax, rvSat);
846 const Scalar po = this->pressure_();
847 const Scalar so = 1.0 - sw - solventSaturation_();
848 const Scalar soMax = std::max(so, problem.maxOilSaturation(globalDofIdx));
849 const Scalar rsMax = problem.maxGasDissolutionFactor(0, globalDofIdx);
851 if constexpr (enableExtbo) {
855 rsSat = fluidSystem.oilPvt().saturatedGasDissolutionFactor(pvtRegionIdx_,
861 const Scalar rs = (*this)[Indices::compositionSwitchIdx];
862 if (rs > std::min(rsMax, rsSat * (Scalar{1.0} + eps))) {
865 (*this)[Indices::compositionSwitchIdx] = 0.0;
876 const Scalar pg = this->pressure_();
877 const Scalar soMax = problem.maxOilSaturation(globalDofIdx);
878 const Scalar rvMax = problem.maxOilVaporizationFactor(0, globalDofIdx);
880 if constexpr (enableExtbo) {
884 rvSat = fluidSystem.gasPvt().saturatedOilVaporizationFactor(pvtRegionIdx_,
890 const Scalar rv = (*this)[Indices::compositionSwitchIdx];
891 if (rv > std::min(rvMax, rvSat * (Scalar{1.0} + eps))) {
895 const Scalar sg2 = 1.0 - sw - solventSaturation_();
896 std::array<Scalar, numPhases> pC{};
897 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
898 computeCapillaryPressures_(pC,
900 sg2 + solventSaturation_(),
903 const Scalar po = pg + pcFactor_ * (pC[oilPhaseIdx] - pC[gasPhaseIdx]);
907 this->setScaledPressure_(po);
908 (*this)[Indices::compositionSwitchIdx] = sg2;
916 OPM_THROW(std::logic_error,
"No valid primary variable selected for gas");
931 sw = (*this)[Indices::waterSwitchIdx];
935 sg = (*this)[Indices::compositionSwitchIdx];
940 ssol =(*this) [Indices::solventSaturationIdx];
943 Scalar so = 1.0 - sw - sg - ssol;
944 sw = std::min(std::max(sw, Scalar{0.0}), Scalar{1.0});
945 so = std::min(std::max(so, Scalar{0.0}), Scalar{1.0});
946 sg = std::min(std::max(sg, Scalar{0.0}), Scalar{1.0});
947 ssol = std::min(std::max(ssol, Scalar{0.0}), Scalar{1.0});
948 const Scalar st = sw + so + sg + ssol;
954 (*this)[Indices::waterSwitchIdx] = sw;
957 (*this)[Indices::compositionSwitchIdx] = sg;
960 (*this) [Indices::solventSaturationIdx] = ssol;
968 using ParentType::operator=;
981 for (
unsigned i = 0; i < this->size(); ++i) {
982 Valgrind::CheckDefined((*
this)[i]);
986 Valgrind::CheckDefined(primaryVarsMeaningWater_);
987 Valgrind::CheckDefined(primaryVarsMeaningGas_);
988 Valgrind::CheckDefined(primaryVarsMeaningPressure_);
989 Valgrind::CheckDefined(primaryVarsMeaningBrine_);
990 Valgrind::CheckDefined(primaryVarsMeaningSolvent_);
992 Valgrind::CheckDefined(pvtRegionIdx_);
996 template<
class Serializer>
999 using FV = Dune::FieldVector<Scalar, getPropValue<TypeTag, Properties::NumEq>()>;
1000 serializer(
static_cast<FV&
>(*
this));
1001 serializer(primaryVarsMeaningWater_);
1002 serializer(primaryVarsMeaningPressure_);
1003 serializer(primaryVarsMeaningGas_);
1004 serializer(primaryVarsMeaningBrine_);
1005 serializer(primaryVarsMeaningSolvent_);
1006 serializer(pvtRegionIdx_);
1013 && this->primaryVarsMeaningWater_ == rhs.primaryVarsMeaningWater_
1014 && this->primaryVarsMeaningPressure_ == rhs.primaryVarsMeaningPressure_
1015 && this->primaryVarsMeaningGas_ == rhs.primaryVarsMeaningGas_
1016 && this->primaryVarsMeaningBrine_ == rhs.primaryVarsMeaningBrine_
1017 && this->primaryVarsMeaningSolvent_ == rhs.primaryVarsMeaningSolvent_
1018 && this->pvtRegionIdx_ == rhs.pvtRegionIdx_;
1022 OPM_HOST_DEVICE Implementation& asImp_()
1023 {
return *
static_cast<Implementation*
>(
this); }
1025 OPM_HOST_DEVICE
const Implementation& asImp_()
const
1026 {
return *
static_cast<const Implementation*
>(
this); }
1028 OPM_HOST_DEVICE Scalar solventSaturation_()
const
1030 if constexpr (enableSolvent) {
1032 return (*
this)[Indices::solventSaturationIdx];
1038 OPM_HOST_DEVICE Scalar zFraction_()
const
1040 if constexpr (enableExtbo) {
1041 return (*
this)[Indices::zFractionIdx];
1048 OPM_HOST_DEVICE Scalar saltConcentration_()
const
1050 if constexpr (enableBrine) {
1051 return (*
this)[Indices::saltConcentrationIdx];
1058 Scalar biofilmVolumeFraction_()
const
1060 if constexpr (enableBioeffects)
1061 return (*
this)[Indices::biofilmVolumeFractionIdx];
1066 template<
class Flu
idSystemInstance = Flu
idSystem>
1067 OPM_HOST_DEVICE Scalar temperature_(
const Problem& problem,
1068 [[maybe_unused]]
unsigned globalDofIdx,
1069 [[maybe_unused]]
const FluidSystemInstance& fluidSystem = FluidSystem{})
const
1071 if constexpr (energyModuleType == EnergyModules::FullyImplicitThermal) {
1072 return (*
this)[Indices::temperatureIdx];
1074 else if (energyModuleType == EnergyModules::NoTemperature) {
1075 return fluidSystem.reservoirTemperature(pvtRegionIdx_);
1077 return problem.temperature(globalDofIdx, 0);
1081 template <
class Container>
1082 OPM_HOST_DEVICE
void computeCapillaryPressures_(Container& result,
1086 const MaterialLawParams& matParams)
const
1101 fluidState.setSaturation(waterPhaseIdx, sw);
1102 fluidState.setSaturation(oilPhaseIdx, so);
1103 fluidState.setSaturation(gasPhaseIdx, sg);
1105 MaterialLaw::capillaryPressures(result, matParams, fluidState);
1138 template<
class Flu
idSystemInstance>
1139 OPM_HOST_DEVICE Scalar gasOilRatioOfPresentComponents_(
const Problem& problem,
1140 unsigned globalDofIdx,
1146 const FluidSystemInstance& fluidSystem)
const
1148 const Scalar soMax = std::max(so,
static_cast<Scalar
>(problem.maxOilSaturation(globalDofIdx)));
1150 const Scalar rsMax = problem.maxGasDissolutionFactor(0, globalDofIdx);
1151 const Scalar rsSat = fluidSystem.oilPvt().saturatedGasDissolutionFactor(pvtRegionIdx_, T, po,
1153 const Scalar rs = std::min(rsMax, rsSat);
1156 if (fluidSystem.enableVaporizedOil()) {
1157 const Scalar rvMax = problem.maxOilVaporizationFactor(0, globalDofIdx);
1158 const Scalar rvSat = fluidSystem.gasPvt().saturatedOilVaporizationFactor(pvtRegionIdx_, T, po,
1160 rv = std::min(rvMax, rvSat);
1163 const Scalar bo = fluidSystem.oilPvt().inverseFormationVolumeFactor(pvtRegionIdx_, T, po, rs);
1164 const Scalar bg = fluidSystem.gasPvt().inverseFormationVolumeFactor(pvtRegionIdx_, T, po, rv,
1166 const Scalar gasComponent = rs * bo * so + bg * sg;
1167 const Scalar oilComponent = bo * so + rv * bg * sg;
1168 if (!(oilComponent > 0.0)) {
1171 return std::clamp(gasComponent / oilComponent, Scalar{0.0}, rsSwitch);
1174 OPM_HOST_DEVICE Scalar pressure_()
const
1176 return (*
this)[Indices::pressureSwitchIdx] * this->getPressureScale();
1179 OPM_HOST_DEVICE
constexpr Scalar getPressureScale()
const
1183 #if OPM_IS_INSIDE_DEVICE_FUNCTION
1186 return this->pressureScale_;
1190 OPM_HOST_DEVICE
void setScaledPressure_(Scalar pressure)
1191 { (*this)[Indices::pressureSwitchIdx] = pressure / (this->getPressureScale()); }
1199 unsigned short pvtRegionIdx_{};
1201 inline static Scalar pressureScale_ = 1.0;
1208 static constexpr Scalar maxOilSaturationForComponentRs_ = 0.1;
Contains classes extending the black-oil model. \detail This file holds dummy definitions,...
Declares the properties required by the black oil model.
Definition: blackoilmodules.hpp:63
Represents the primary variables used by the black-oil model.
Definition: blackoilprimaryvariables.hh:87
::Opm::BlackOil::WaterMeaning WaterMeaning
Definition: blackoilprimaryvariables.hh:156
OPM_HOST_DEVICE void setPrimaryVarsMeaningPressure(PressureMeaning newMeaning)
Set the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:299
OPM_HOST_DEVICE void setPrimaryVarsMeaningBrine(BrineMeaning newMeaning)
Set the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:323
static void init()
Definition: blackoilprimaryvariables.hh:210
OPM_HOST_DEVICE BlackOilPrimaryVariables(const BlackOilPrimaryVariables< OtherTypeTag, OtherVectorType > &other)
Assignment from another primary variables object.
Definition: blackoilprimaryvariables.hh:171
::Opm::BlackOil::SolventMeaning SolventMeaning
Definition: blackoilprimaryvariables.hh:160
OPM_HOST_DEVICE bool adaptPrimaryVariables(const Problem &problem, const FluidSystemInstance &fluidSystem, unsigned globalDofIdx, Scalar swMaximum, Scalar thresholdWaterFilledCell, Scalar eps=0.0)
Definition: blackoilprimaryvariables.hh:523
OPM_HOST_DEVICE void checkDefined() const
< Import base class assignment operators.
Definition: blackoilprimaryvariables.hh:977
OPM_HOST_DEVICE PressureMeaning primaryVarsMeaningPressure() const
Return the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:292
::Opm::BlackOil::GasMeaning GasMeaning
Definition: blackoilprimaryvariables.hh:158
OPM_HOST_DEVICE BlackOilPrimaryVariables()
Definition: blackoilprimaryvariables.hh:183
OPM_HOST_DEVICE bool chopAndNormalizeSaturations()
Definition: blackoilprimaryvariables.hh:922
OPM_HOST_DEVICE unsigned pvtRegionIndex() const
Return the index of the region which should be used for PVT properties.
Definition: blackoilprimaryvariables.hh:271
OPM_HOST_DEVICE bool operator==(const BlackOilPrimaryVariables &rhs) const
Definition: blackoilprimaryvariables.hh:1009
void serializeOp(Serializer &serializer)
Definition: blackoilprimaryvariables.hh:997
OPM_HOST_DEVICE void setPrimaryVarsMeaningWater(WaterMeaning newMeaning)
Set the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:285
OPM_HOST_DEVICE void setPrimaryVarsMeaningGas(GasMeaning newMeaning)
Set the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:313
static void registerParameters()
Definition: blackoilprimaryvariables.hh:233
::Opm::BlackOil::BrineMeaning BrineMeaning
Definition: blackoilprimaryvariables.hh:159
BlackOilPrimaryVariables & operator=(const BlackOilPrimaryVariables &other)=default
BlackOilPrimaryVariables(const BlackOilPrimaryVariables &value)=default
Copy constructor.
::Opm::BlackOil::PressureMeaning PressureMeaning
Definition: blackoilprimaryvariables.hh:157
OPM_HOST_DEVICE GasMeaning primaryVarsMeaningGas() const
Return the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:306
OPM_HOST_DEVICE void setPvtRegionIndex(unsigned value)
Set the index of the region which should be used for PVT properties.
Definition: blackoilprimaryvariables.hh:265
bool adaptPrimaryVariables(const Problem &problem, unsigned globalDofIdx, Scalar swMaximum, Scalar thresholdWaterFilledCell, Scalar eps=0.0)
Adapt the interpretation of the switching variables to be physically meaningful.
Definition: blackoilprimaryvariables.hh:513
OPM_HOST_DEVICE void assignNaive(const FluidState &fluidState)
Directly retrieve the primary variables from an arbitrary fluid state.
Definition: blackoilprimaryvariables.hh:340
OPM_HOST_DEVICE BrineMeaning primaryVarsMeaningBrine() const
Definition: blackoilprimaryvariables.hh:316
OPM_HOST_DEVICE void setPrimaryVarsMeaningSolvent(SolventMeaning newMeaning)
Set the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:333
OPM_HOST_DEVICE WaterMeaning primaryVarsMeaningWater() const
Return the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:278
static BlackOilPrimaryVariables serializationTestObject()
Definition: blackoilprimaryvariables.hh:194
OPM_HOST_DEVICE Evaluation makeEvaluation(unsigned varIdx, unsigned timeIdx, LinearizationType linearizationType=LinearizationType()) const
Definition: blackoilprimaryvariables.hh:240
OPM_HOST_DEVICE SolventMeaning primaryVarsMeaningSolvent() const
Definition: blackoilprimaryvariables.hh:326
Represents the primary variables used by the a model.
Definition: fvbaseprimaryvariables.hh:54
Definition: blackoilprimaryvariables.hh:66
BrineMeaning
Definition: blackoilmeanings.hh:42
PressureMeaning
Definition: blackoilmeanings.hh:29
WaterMeaning
Definition: blackoilmeanings.hh:22
SolventMeaning
Definition: blackoilmeanings.hh:48
GasMeaning
Definition: blackoilmeanings.hh:35
Definition: blackoilprimaryvariables.hh:62
SimpleModularFluidState< double, 3, 3, FluidSystemSimple, false, false, false, false, true, false, false, false > SatOnlyFluidState
Definition: EquilibrationHelpers_impl.hpp:59
Definition: blackoilnewtonmethodparams.hpp:31
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
Definition: linearizationtype.hh:34
Definition: blackoilprimaryvariables.hh:58
static constexpr Scalar value
Definition: blackoilprimaryvariables.hh:58