24 #ifndef EWOMS_BLACK_OIL_PRIMARY_VARIABLES_HH 25 #define EWOMS_BLACK_OIL_PRIMARY_VARIABLES_HH 27 #include <dune/common/fvector.hh> 28 #include <opm/common/OpmLog/OpmLog.hpp> 29 #include <opm/common/utility/gpuDecorators.hpp> 31 #include <opm/material/common/MathToolbox.hpp> 32 #include <opm/material/common/Valgrind.hpp> 33 #include <opm/material/fluidsystems/BlackOilFluidSystem.hpp> 34 #include <opm/material/fluidstates/SimpleModularFluidState.hpp> 40 #include <opm/models/blackoil/blackoilmeanings.hh> 46 #include <fmt/format.h> 53 #include <type_traits> 57 template<
class Scalar>
59 {
static constexpr Scalar value = 1.0; };
70 template <
class TypeTag,
template<
class,
int>
class VectorType = Dune::FieldVector>
85 enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
88 enum { waterSwitchIdx = Indices::waterSwitchIdx };
89 enum { pressureSwitchIdx = Indices::pressureSwitchIdx };
90 enum { compositionSwitchIdx = Indices::compositionSwitchIdx };
91 enum { saltConcentrationIdx = Indices::saltConcentrationIdx };
92 enum { solventSaturationIdx = Indices::solventSaturationIdx };
94 static constexpr
bool compositionSwitchEnabled = Indices::compositionSwitchIdx >= 0;
95 static constexpr
bool waterEnabled = Indices::waterEnabled;
96 static constexpr
bool gasEnabled = Indices::gasEnabled;
97 static constexpr
bool oilEnabled = Indices::oilEnabled;
100 enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
101 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
102 enum { waterPhaseIdx = FluidSystem::waterPhaseIdx };
103 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
106 enum { numComponents = getPropValue<TypeTag, Properties::NumComponents>() };
107 enum { enableSolvent = getPropValue<TypeTag, Properties::EnableSolvent>() };
108 enum { enableExtbo = getPropValue<TypeTag, Properties::EnableExtbo>() };
109 enum { enablePolymer = getPropValue<TypeTag, Properties::EnablePolymer>() };
110 enum { enableFoam = getPropValue<TypeTag, Properties::EnableFoam>() };
111 enum { enableBrine = getPropValue<TypeTag, Properties::EnableBrine>() };
112 enum { enableSaltPrecipitation = getPropValue<TypeTag, Properties::EnableSaltPrecipitation>() };
113 enum { enableVapwat = getPropValue<TypeTag, Properties::EnableVapwat>() };
114 static constexpr EnergyModules energyModuleType = getPropValue<TypeTag, Properties::EnergyModuleType>();
115 enum { enableBioeffects = getPropValue<TypeTag, Properties::EnableBioeffects>() };
116 enum { enableMICP = Indices::enableMICP };
117 enum { gasCompIdx = FluidSystem::gasCompIdx };
118 enum { waterCompIdx = FluidSystem::waterCompIdx };
119 enum { oilCompIdx = FluidSystem::oilCompIdx };
121 using Toolbox = MathToolbox<Evaluation>;
122 using ComponentVector = Dune::FieldVector<Scalar, numComponents>;
129 static_assert(numPhases == 3,
"The black-oil model assumes three phases!");
130 static_assert(numComponents == 3,
"The black-oil model assumes three components!");
136 using WaterMeaning = ::Opm::BlackOil::WaterMeaning;
137 using PressureMeaning = ::Opm::BlackOil::PressureMeaning;
138 using GasMeaning = ::Opm::BlackOil::GasMeaning;
139 using BrineMeaning = ::Opm::BlackOil::BrineMeaning;
140 using SolventMeaning = ::Opm::BlackOil::SolventMeaning;
143 template<
class OtherTypeTag,
template<
class,
int>
class OtherVectorType>
149 template <
class OtherTypeTag,
template <
class,
int>
class OtherVectorType>
150 explicit OPM_HOST_DEVICE
153 , primaryVarsMeaningWater_(other.primaryVarsMeaningWater_)
154 , primaryVarsMeaningPressure_(other.primaryVarsMeaningPressure_)
155 , primaryVarsMeaningGas_(other.primaryVarsMeaningGas_)
156 , primaryVarsMeaningBrine_(other.primaryVarsMeaningBrine_)
157 , primaryVarsMeaningSolvent_(other.primaryVarsMeaningSolvent_)
158 , pvtRegionIdx_(other.pvtRegionIdx_)
159 , pcFactor_(other.pcFactor_)
165 Valgrind::SetUndefined(*
this);
172 BlackOilPrimaryVariables(
const BlackOilPrimaryVariables& value) =
default;
174 static BlackOilPrimaryVariables serializationTestObject()
176 BlackOilPrimaryVariables result;
177 result.pvtRegionIdx_ = 1;
178 result.primaryVarsMeaningBrine_ = BrineMeaning::Sp;
179 result.primaryVarsMeaningGas_ = GasMeaning::Rv;
180 result.primaryVarsMeaningPressure_ = PressureMeaning::Pg;
181 result.primaryVarsMeaningWater_ = WaterMeaning::Rsw;
182 result.primaryVarsMeaningSolvent_ = SolventMeaning::Ss;
183 for (std::size_t i = 0; i < result.size(); ++i) {
193 pressureScale_ = Parameters::Get<Parameters::PressureScale<Scalar>>();
201 if (pressureScale_ != Scalar {1.0}) {
202 OpmLog::warning(fmt::format(
203 "Using a pressure scaling different from 1.0 is not supported " 204 "when running with GPU support. We have detected that you are compiling with GPU support, but we can " 205 "not detect whether you are running with GPU support for the assembly or property evaluation. If you " 206 "are doing property evaluation or assembly on the GPU, pressure scaling will be ignored." 207 "Read value of pressure scale: {}",
213 static void registerParameters()
215 Parameters::Register<Parameters::PressureScale<Scalar>>
216 (
"Scaling of pressure primary variable");
219 OPM_HOST_DEVICE Evaluation
220 makeEvaluation(
unsigned varIdx,
unsigned timeIdx,
221 LinearizationType linearizationType = LinearizationType())
const 223 const Scalar scale = varIdx == pressureSwitchIdx ? this->getPressureScale() : Scalar{1.0};
224 if (std::is_same_v<Evaluation, Scalar>) {
225 return (*
this)[varIdx] * scale;
229 if (timeIdx == linearizationType.time) {
230 return Toolbox::createVariable((*
this)[varIdx], varIdx) * scale;
233 return Toolbox::createConstant((*
this)[varIdx]) * scale;
246 { pvtRegionIdx_ =
static_cast<unsigned short>(value); }
252 {
return pvtRegionIdx_; }
259 {
return primaryVarsMeaningWater_; }
266 { primaryVarsMeaningWater_ = newMeaning; }
273 {
return primaryVarsMeaningPressure_; }
280 { primaryVarsMeaningPressure_ = newMeaning; }
287 {
return primaryVarsMeaningGas_; }
294 { primaryVarsMeaningGas_ = newMeaning; }
296 OPM_HOST_DEVICE BrineMeaning primaryVarsMeaningBrine()
const 297 {
return primaryVarsMeaningBrine_; }
304 { primaryVarsMeaningBrine_ = newMeaning; }
306 OPM_HOST_DEVICE SolventMeaning primaryVarsMeaningSolvent()
const 307 {
return primaryVarsMeaningSolvent_; }
314 { primaryVarsMeaningSolvent_ = newMeaning; }
319 template <
class Flu
idState>
322 using ConstEvaluation = std::remove_reference_t<typename FluidState::ValueType>;
323 using FsEvaluation = std::remove_const_t<ConstEvaluation>;
324 using FsToolbox = MathToolbox<FsEvaluation>;
326 const bool gasPresent =
327 fluidState.fluidSystem().phaseIsActive(gasPhaseIdx)
328 ? fluidState.saturation(gasPhaseIdx) > 0.0
330 const bool oilPresent =
331 fluidState.fluidSystem().phaseIsActive(oilPhaseIdx)
332 ? fluidState.saturation(oilPhaseIdx) > 0.0
334 const bool waterPresent =
335 fluidState.fluidSystem().phaseIsActive(waterPhaseIdx)
336 ? fluidState.saturation(waterPhaseIdx) > 0.0
338 const auto& saltSaturation =
339 BlackOil::getSaltSaturation_<FluidSystem, FluidState, Scalar>(fluidState, pvtRegionIdx_);
340 const bool precipitatedSaltPresent = enableSaltPrecipitation ? saltSaturation > 0.0 :
false;
341 const bool oneActivePhases = fluidState.fluidSystem().numActivePhases() == 1;
348 if (gasPresent && fluidState.fluidSystem().enableVaporizedOil() && !oilPresent) {
349 primaryVarsMeaningPressure_ = PressureMeaning::Pg;
351 else if (fluidState.fluidSystem().phaseIsActive(oilPhaseIdx)) {
352 primaryVarsMeaningPressure_ = PressureMeaning::Po;
354 else if (waterPresent && fluidState.fluidSystem().enableDissolvedGasInWater() && !gasPresent) {
355 primaryVarsMeaningPressure_ = PressureMeaning::Pw;
357 else if (fluidState.fluidSystem().phaseIsActive(gasPhaseIdx)) {
358 primaryVarsMeaningPressure_ = PressureMeaning::Pg;
361 assert(fluidState.fluidSystem().phaseIsActive(waterPhaseIdx));
362 primaryVarsMeaningPressure_ = PressureMeaning::Pw;
369 if (waterPresent && gasPresent) {
370 primaryVarsMeaningWater_ = WaterMeaning::Sw;
372 else if (gasPresent && fluidState.fluidSystem().enableVaporizedWater()) {
373 primaryVarsMeaningWater_ = WaterMeaning::Rvw;
375 else if (waterPresent && fluidState.fluidSystem().enableDissolvedGasInWater()) {
376 primaryVarsMeaningWater_ = WaterMeaning::Rsw;
378 else if (fluidState.fluidSystem().phaseIsActive(waterPhaseIdx) && !oneActivePhases) {
379 primaryVarsMeaningWater_ = WaterMeaning::Sw;
382 primaryVarsMeaningWater_ = WaterMeaning::Disabled;
390 if (gasPresent && oilPresent) {
391 primaryVarsMeaningGas_ = GasMeaning::Sg;
393 else if (oilPresent && fluidState.fluidSystem().enableDissolvedGas()) {
394 primaryVarsMeaningGas_ = GasMeaning::Rs;
396 else if (gasPresent && fluidState.fluidSystem().enableVaporizedOil()) {
397 primaryVarsMeaningGas_ = GasMeaning::Rv;
399 else if (fluidState.fluidSystem().phaseIsActive(gasPhaseIdx) && fluidState.fluidSystem().phaseIsActive(oilPhaseIdx)) {
400 primaryVarsMeaningGas_ = GasMeaning::Sg;
403 primaryVarsMeaningGas_ = GasMeaning::Disabled;
407 if constexpr (enableSaltPrecipitation) {
408 if (precipitatedSaltPresent) {
409 primaryVarsMeaningBrine_ = BrineMeaning::Sp;
412 primaryVarsMeaningBrine_ = BrineMeaning::Cs;
416 primaryVarsMeaningBrine_ = BrineMeaning::Disabled;
421 case PressureMeaning::Po:
422 this->setScaledPressure_(FsToolbox::value(fluidState.pressure(oilPhaseIdx)));
424 case PressureMeaning::Pg:
425 this->setScaledPressure_(FsToolbox::value(fluidState.pressure(gasPhaseIdx)));
427 case PressureMeaning::Pw:
428 this->setScaledPressure_(FsToolbox::value(fluidState.pressure(waterPhaseIdx)));
431 OPM_THROW(std::logic_error,
"No valid primary variable selected for pressure");
435 case WaterMeaning::Sw:
437 (*this)[waterSwitchIdx] = FsToolbox::value(fluidState.saturation(waterPhaseIdx));
440 case WaterMeaning::Rvw:
442 const auto& rvw = BlackOil::getRvw_<FluidSystem, FluidState, Scalar>(fluidState, pvtRegionIdx_);
443 (*this)[waterSwitchIdx] = rvw;
446 case WaterMeaning::Rsw:
448 const auto& Rsw = BlackOil::getRsw_<FluidSystem, FluidState, Scalar>(fluidState, pvtRegionIdx_);
449 (*this)[waterSwitchIdx] = Rsw;
452 case WaterMeaning::Disabled:
455 OPM_THROW(std::logic_error,
"No valid primary variable selected for water");
459 (*this)[compositionSwitchIdx] = FsToolbox::value(fluidState.saturation(gasPhaseIdx));
463 const auto& rs = BlackOil::getRs_<FluidSystem, FluidState, Scalar>(fluidState, pvtRegionIdx_);
464 (*this)[compositionSwitchIdx] = rs;
469 const auto& rv = BlackOil::getRv_<FluidSystem, FluidState, Scalar>(fluidState, pvtRegionIdx_);
470 (*this)[compositionSwitchIdx] = rv;
473 case GasMeaning::Disabled:
476 OPM_THROW(std::logic_error,
"No valid primary variable selected for composision");
492 unsigned globalDofIdx,
493 [[maybe_unused]] Scalar swMaximum,
494 Scalar thresholdWaterFilledCell, Scalar eps = 0.0)
513 Scalar saltConcentration = 0.0;
514 const Scalar& T = asImp_().temperature_(problem, globalDofIdx);
516 sw = (*this)[waterSwitchIdx];
519 sg = (*this)[compositionSwitchIdx];
531 if constexpr (enableSaltPrecipitation) {
532 const Scalar saltSolubility = BrineModule::saltSol(
pvtRegionIndex());
533 if (primaryVarsMeaningBrine() == BrineMeaning::Sp) {
534 saltConcentration = saltSolubility;
535 const Scalar saltSat = (*this)[saltConcentrationIdx];
536 if (saltSat < -eps) {
538 (*this)[saltConcentrationIdx] = saltSolubility;
541 else if (primaryVarsMeaningBrine() == BrineMeaning::Cs) {
542 saltConcentration = (*this)[saltConcentrationIdx];
543 if (saltConcentration > saltSolubility + eps) {
545 (*this)[saltConcentrationIdx] = 0.0;
553 if constexpr (enableSolvent) {
554 if (SolventModule::isSolubleInWater()) {
555 const Scalar p = (*this)[pressureSwitchIdx];
556 const Scalar solLimit =
557 SolventModule::solubilityLimit(
pvtRegionIndex(), T , p, saltConcentration);
558 if (primaryVarsMeaningSolvent() == SolventMeaning::Ss) {
559 const Scalar solSat = (*this)[solventSaturationIdx];
562 (*this)[solventSaturationIdx] = solLimit;
565 else if (primaryVarsMeaningSolvent() == SolventMeaning::Rsolw) {
566 const Scalar rsolw = (*this)[solventSaturationIdx];
567 if (rsolw > solLimit + eps) {
569 (*this)[solventSaturationIdx] = 0.0;
576 bool changed =
false;
584 if (sw >= thresholdWaterFilledCell && !FluidSystem::enableDissolvedGasInWater()) {
586 if constexpr (waterEnabled) {
587 (*this)[Indices::waterSwitchIdx] = std::min(swMaximum, sw);
591 if constexpr (compositionSwitchEnabled) {
592 (*this)[Indices::compositionSwitchIdx] = 0.0;
597 if constexpr (compositionSwitchEnabled) {
607 if constexpr (enableBrine) {
608 if (BrineModule::hasPcfactTables() && primaryVarsMeaningBrine() == BrineMeaning::Sp) {
609 unsigned satnumRegionIdx = problem.satnumRegionIndex(globalDofIdx);
610 Scalar Sp = saltConcentration_();
611 Scalar porosityFactor = std::min(1.0 - Sp, 1.0);
612 const auto& pcfactTable = BrineModule::pcfactTable(satnumRegionIdx);
613 pcFactor_ = pcfactTable.eval(porosityFactor,
true);
616 else if constexpr (enableBioeffects) {
617 if (BioeffectsModule::hasPcfactTables() && problem.referencePorosity(globalDofIdx, 0) > 0) {
618 unsigned satnumRegionIdx = problem.satnumRegionIndex(globalDofIdx);
619 Scalar Sb = biofilmVolumeFraction_() /
620 problem.referencePorosity(globalDofIdx, 0);
621 Scalar porosityFactor = std::min(1.0 - Sb, 1.0);
622 const auto& pcfactTable = BioeffectsModule::pcfactTable(satnumRegionIdx);
623 pcFactor_ = pcfactTable.eval(porosityFactor,
true);
628 case WaterMeaning::Sw:
631 if (sw < -eps && sg > eps && FluidSystem::enableVaporizedWater()) {
632 Scalar p = this->pressure_();
634 std::array<Scalar, numPhases> pC{};
635 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
636 const Scalar so = 1.0 - sg - solventSaturation_();
637 computeCapillaryPressures_(pC, so, sg + solventSaturation_(), 0.0, matParams);
638 p += pcFactor_ * (pC[gasPhaseIdx] - pC[oilPhaseIdx]);
640 const Scalar rvwSat =
641 FluidSystem::gasPvt().saturatedWaterVaporizationFactor(pvtRegionIdx_,
646 (*this)[Indices::waterSwitchIdx] = rvwSat;
652 if (sg < -eps && sw > eps && FluidSystem::enableDissolvedGasInWater()) {
653 const Scalar pg = this->pressure_();
655 std::array<Scalar, numPhases> pC = { 0.0 };
656 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
657 const Scalar so = 1.0 - sw - solventSaturation_();
658 computeCapillaryPressures_(pC, so, 0.0, sw, matParams);
659 const Scalar pw = pg + pcFactor_ * (pC[waterPhaseIdx] - pC[gasPhaseIdx]);
660 const Scalar rswSat =
661 FluidSystem::waterPvt().saturatedGasDissolutionFactor(pvtRegionIdx_,
666 const Scalar rswMax = problem.maxGasDissolutionFactor(0, globalDofIdx);
667 (*this)[Indices::waterSwitchIdx] = std::min(rswSat, rswMax);
669 this->setScaledPressure_(pw);
675 case WaterMeaning::Rvw:
677 const Scalar& rvw = (*this)[waterSwitchIdx];
678 Scalar p = this->pressure_();
680 std::array<Scalar, numPhases> pC{};
681 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
682 const Scalar so = 1.0 - sg - solventSaturation_();
683 computeCapillaryPressures_(pC, so, sg + solventSaturation_(), 0.0, matParams);
684 p += pcFactor_ * (pC[gasPhaseIdx] - pC[oilPhaseIdx]);
686 const Scalar rvwSat =
687 FluidSystem::gasPvt().saturatedWaterVaporizationFactor(pvtRegionIdx_,
692 if (rvw > rvwSat * (1.0 + eps)) {
694 (*this)[Indices::waterSwitchIdx] = 0.0;
699 case WaterMeaning::Rsw:
704 const Scalar& pw = this->pressure_();
706 const Scalar rswSat =
707 FluidSystem::waterPvt().saturatedGasDissolutionFactor(pvtRegionIdx_,
712 const Scalar rsw = (*this)[Indices::waterSwitchIdx];
713 const Scalar rswMax = problem.maxGasDissolutionFactor(0, globalDofIdx);
714 if (rsw > std::min(rswSat, rswMax)) {
717 (*this)[Indices::waterSwitchIdx] = 1.0;
719 std::array<Scalar, numPhases> pC{};
720 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
721 computeCapillaryPressures_(pC, 0.0, 0.0, 1.0, matParams);
722 const Scalar pg = pw + pcFactor_ * (pC[gasPhaseIdx] - pC[waterPhaseIdx]);
723 this->setScaledPressure_(pg);
728 case WaterMeaning::Disabled:
731 throw std::logic_error(
"No valid primary variable selected for water");
744 const Scalar s = 1.0 - sw - solventSaturation_();
745 if (sg < -eps && s > 0.0 && FluidSystem::enableDissolvedGas()) {
746 const Scalar po = this->pressure_();
748 const Scalar soMax = std::max(s, problem.maxOilSaturation(globalDofIdx));
749 const Scalar rsMax = problem.maxGasDissolutionFactor(0, globalDofIdx);
753 : FluidSystem::oilPvt().saturatedGasDissolutionFactor(pvtRegionIdx_,
758 (*this)[Indices::compositionSwitchIdx] = std::min(rsMax, rsSat);
761 const Scalar so = 1.0 - sw - solventSaturation_() - sg;
762 if (so < -eps && sg > 0.0 && FluidSystem::enableVaporizedOil()) {
767 const Scalar po = this->pressure_();
768 std::array<Scalar, numPhases> pC{};
769 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
770 computeCapillaryPressures_(pC, 0.0, sg + solventSaturation_(), sw, matParams);
771 const Scalar pg = po + pcFactor_ * (pC[gasPhaseIdx] - pC[oilPhaseIdx]);
776 this->setScaledPressure_(pg);
777 const Scalar soMax = problem.maxOilSaturation(globalDofIdx);
778 const Scalar rvMax = problem.maxOilVaporizationFactor(0, globalDofIdx);
782 : FluidSystem::gasPvt().saturatedOilVaporizationFactor(pvtRegionIdx_,
788 (*this)[Indices::compositionSwitchIdx] = std::min(rvMax, rvSat);
798 const Scalar po = this->pressure_();
799 const Scalar so = 1.0 - sw - solventSaturation_();
800 const Scalar soMax = std::max(so, problem.maxOilSaturation(globalDofIdx));
801 const Scalar rsMax = problem.maxGasDissolutionFactor(0, globalDofIdx);
805 : FluidSystem::oilPvt().saturatedGasDissolutionFactor(pvtRegionIdx_,
811 const Scalar rs = (*this)[Indices::compositionSwitchIdx];
812 if (rs > std::min(rsMax, rsSat * (Scalar{1.0} + eps))) {
815 (*this)[Indices::compositionSwitchIdx] = 0.0;
826 const Scalar pg = this->pressure_();
827 const Scalar soMax = problem.maxOilSaturation(globalDofIdx);
828 const Scalar rvMax = problem.maxOilVaporizationFactor(0, globalDofIdx);
832 : FluidSystem::gasPvt().saturatedOilVaporizationFactor(pvtRegionIdx_,
838 const Scalar rv = (*this)[Indices::compositionSwitchIdx];
839 if (rv > std::min(rvMax, rvSat * (Scalar{1.0} + eps))) {
843 const Scalar sg2 = 1.0 - sw - solventSaturation_();
844 std::array<Scalar, numPhases> pC{};
845 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
846 computeCapillaryPressures_(pC,
848 sg2 + solventSaturation_(),
851 const Scalar po = pg + pcFactor_ * (pC[oilPhaseIdx] - pC[gasPhaseIdx]);
855 this->setScaledPressure_(po);
856 (*this)[Indices::compositionSwitchIdx] = sg2;
861 case GasMeaning::Disabled:
864 throw std::logic_error(
"No valid primary variable selected for water");
869 OPM_HOST_DEVICE
bool chopAndNormalizeSaturations()
878 sw = (*this)[Indices::waterSwitchIdx];
882 sg = (*this)[Indices::compositionSwitchIdx];
886 if (primaryVarsMeaningSolvent() == SolventMeaning::Ss) {
887 ssol =(*this) [Indices::solventSaturationIdx];
890 Scalar so = 1.0 - sw - sg - ssol;
891 sw = std::min(std::max(sw, Scalar{0.0}), Scalar{1.0});
892 so = std::min(std::max(so, Scalar{0.0}), Scalar{1.0});
893 sg = std::min(std::max(sg, Scalar{0.0}), Scalar{1.0});
894 ssol = std::min(std::max(ssol, Scalar{0.0}), Scalar{1.0});
895 const Scalar st = sw + so + sg + ssol;
901 (*this)[Indices::waterSwitchIdx] = sw;
904 (*this)[Indices::compositionSwitchIdx] = sg;
906 if (primaryVarsMeaningSolvent() == SolventMeaning::Ss) {
907 (*this) [Indices::solventSaturationIdx] = ssol;
913 BlackOilPrimaryVariables& operator=(
const BlackOilPrimaryVariables& other) =
default;
915 using ParentType::operator=;
928 for (
unsigned i = 0; i < this->size(); ++i) {
929 Valgrind::CheckDefined((*
this)[i]);
933 Valgrind::CheckDefined(primaryVarsMeaningWater_);
934 Valgrind::CheckDefined(primaryVarsMeaningGas_);
935 Valgrind::CheckDefined(primaryVarsMeaningPressure_);
936 Valgrind::CheckDefined(primaryVarsMeaningBrine_);
937 Valgrind::CheckDefined(primaryVarsMeaningSolvent_);
939 Valgrind::CheckDefined(pvtRegionIdx_);
943 template<
class Serializer>
944 void serializeOp(Serializer& serializer)
946 using FV = Dune::FieldVector<Scalar, getPropValue<TypeTag, Properties::NumEq>()>;
947 serializer(static_cast<FV&>(*
this));
948 serializer(primaryVarsMeaningWater_);
949 serializer(primaryVarsMeaningPressure_);
950 serializer(primaryVarsMeaningGas_);
951 serializer(primaryVarsMeaningBrine_);
952 serializer(primaryVarsMeaningSolvent_);
953 serializer(pvtRegionIdx_);
956 OPM_HOST_DEVICE
bool operator==(
const BlackOilPrimaryVariables& rhs)
const 959 static_cast<const FvBasePrimaryVariables<TypeTag>&
>(*this) == rhs
960 && this->primaryVarsMeaningWater_ == rhs.primaryVarsMeaningWater_
961 && this->primaryVarsMeaningPressure_ == rhs.primaryVarsMeaningPressure_
962 && this->primaryVarsMeaningGas_ == rhs.primaryVarsMeaningGas_
963 && this->primaryVarsMeaningBrine_ == rhs.primaryVarsMeaningBrine_
964 && this->primaryVarsMeaningSolvent_ == rhs.primaryVarsMeaningSolvent_
965 && this->pvtRegionIdx_ == rhs.pvtRegionIdx_;
969 OPM_HOST_DEVICE Implementation& asImp_()
970 {
return *
static_cast<Implementation*
>(
this); }
972 OPM_HOST_DEVICE
const Implementation& asImp_()
const 973 {
return *
static_cast<const Implementation*
>(
this); }
975 OPM_HOST_DEVICE Scalar solventSaturation_()
const 977 if constexpr (enableSolvent) {
978 if (primaryVarsMeaningSolvent() == SolventMeaning::Ss) {
979 return (*
this)[Indices::solventSaturationIdx];
985 OPM_HOST_DEVICE Scalar zFraction_()
const 987 if constexpr (enableExtbo) {
988 return (*
this)[Indices::zFractionIdx];
995 OPM_HOST_DEVICE Scalar saltConcentration_()
const 997 if constexpr (enableBrine) {
998 return (*
this)[Indices::saltConcentrationIdx];
1005 Scalar biofilmVolumeFraction_()
const 1007 if constexpr (enableBioeffects)
1008 return (*
this)[Indices::biofilmVolumeFractionIdx];
1013 OPM_HOST_DEVICE Scalar temperature_(
const Problem& problem, [[maybe_unused]]
unsigned globalDofIdx)
const 1015 if constexpr (energyModuleType == EnergyModules::FullyImplicitThermal) {
1016 return (*
this)[Indices::temperatureIdx];
1018 else if (energyModuleType == EnergyModules::NoTemperature) {
1019 return FluidSystem::reservoirTemperature();
1021 return problem.temperature(globalDofIdx, 0);
1025 template <
class Container>
1026 OPM_HOST_DEVICE
void computeCapillaryPressures_(Container& result,
1030 const MaterialLawParams& matParams)
const 1032 using SatOnlyFluidState = SimpleModularFluidState<Scalar,
1044 SatOnlyFluidState fluidState;
1045 fluidState.setSaturation(waterPhaseIdx, sw);
1046 fluidState.setSaturation(oilPhaseIdx, so);
1047 fluidState.setSaturation(gasPhaseIdx, sg);
1049 MaterialLaw::capillaryPressures(result, matParams, fluidState);
1052 OPM_HOST_DEVICE Scalar pressure_()
const 1054 return (*
this)[Indices::pressureSwitchIdx] * this->getPressureScale();
1057 OPM_HOST_DEVICE constexpr Scalar getPressureScale()
const 1061 #if OPM_IS_INSIDE_DEVICE_FUNCTION 1064 return this->pressureScale_;
1068 void setScaledPressure_(Scalar pressure)
1069 { (*this)[Indices::pressureSwitchIdx] = pressure / (this->getPressureScale()); }
1072 WaterMeaning primaryVarsMeaningWater_{WaterMeaning::Disabled};
1073 PressureMeaning primaryVarsMeaningPressure_{PressureMeaning::Po};
1074 GasMeaning primaryVarsMeaningGas_{GasMeaning::Disabled};
1075 BrineMeaning primaryVarsMeaningBrine_{BrineMeaning::Disabled};
1076 SolventMeaning primaryVarsMeaningSolvent_{SolventMeaning::Disabled};
1077 unsigned short pvtRegionIdx_{};
1079 inline static Scalar pressureScale_ = 1.0;
OPM_HOST_DEVICE void setPrimaryVarsMeaningGas(GasMeaning newMeaning)
Set the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:293
Contains the high level supplements required to extend the black oil model by solvents.
Definition: blackoilsolventmodules.hh:68
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
Contains the classes required to extend the black-oil model by solvent component. ...
Definition: blackoilprimaryvariables.hh:58
OPM_HOST_DEVICE GasMeaning primaryVarsMeaningGas() const
Return the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:286
bool adaptPrimaryVariables(const Problem &problem, unsigned globalDofIdx, [[maybe_unused]] Scalar swMaximum, Scalar thresholdWaterFilledCell, Scalar eps=0.0)
Adapt the interpretation of the switching variables to be physically meaningful.
Definition: blackoilprimaryvariables.hh:491
Contains the classes required to extend the black-oil model by solvents.
OPM_HOST_DEVICE void setPrimaryVarsMeaningPressure(PressureMeaning newMeaning)
Set the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:279
Contains the high level supplements required to extend the black oil model by brine.
Definition: blackoilbrinemodules.hh:57
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
Definition: blackoilnewtonmethodparams.hpp:31
Contains the high level supplements required to extend the black oil model by energy.
Definition: blackoilenergymodules.hh:62
OPM_HOST_DEVICE void setPrimaryVarsMeaningSolvent(SolventMeaning newMeaning)
Set the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:313
Declares the properties required by the black oil model.
Represents the primary variables used by the a model.
Definition: fvbaseprimaryvariables.hh:51
OPM_HOST_DEVICE unsigned pvtRegionIndex() const
Return the index of the region which should be used for PVT properties.
Definition: blackoilprimaryvariables.hh:251
OPM_HOST_DEVICE BlackOilPrimaryVariables(const BlackOilPrimaryVariables< OtherTypeTag, OtherVectorType > &other)
Assignment from another primary variables object.
Definition: blackoilprimaryvariables.hh:151
Contains the classes required to extend the black-oil model by brine.
OPM_HOST_DEVICE void setPrimaryVarsMeaningWater(WaterMeaning newMeaning)
Set the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:265
OPM_HOST_DEVICE void setPvtRegionIndex(unsigned value)
Set the index of the region which should be used for PVT properties.
Definition: blackoilprimaryvariables.hh:245
Represents the primary variables used by the black-oil model.
Definition: blackoilprimaryvariables.hh:71
OPM_HOST_DEVICE PressureMeaning primaryVarsMeaningPressure() const
Return the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:272
OPM_HOST_DEVICE WaterMeaning primaryVarsMeaningWater() const
Return the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:258
static void assignPrimaryVars(PrimaryVariables &priVars, const FluidState &fluidState)
Assign the energy specific primary variables to a PrimaryVariables object.
Definition: blackoilenergymodules.hh:273
Represents the primary variables used by the a model.
Contains the high level supplements required to extend the black oil model.
Definition: blackoilextbomodules.hh:63
OPM_HOST_DEVICE void assignNaive(const FluidState &fluidState)
Directly retrieve the primary variables from an arbitrary fluid state.
Definition: blackoilprimaryvariables.hh:320
Contains the classes required to extend the black-oil model by bioeffects.
OPM_HOST_DEVICE void setPrimaryVarsMeaningBrine(BrineMeaning newMeaning)
Set the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:303
Contains the classes required to extend the black-oil model by energy.
OPM_HOST_DEVICE void checkDefined() const
< Import base class assignment operators.
Definition: blackoilprimaryvariables.hh:924
Contains the high level supplements required to extend the black oil model by bioeffects.
Definition: blackoilbioeffectsmodules.hh:94