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>
51#include <fmt/format.h>
57{
static constexpr Scalar
value = 1.0; };
68template <
class TypeTag,
template<
class,
int>
class VectorType = Dune::FieldVector>
83 enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
86 static constexpr unsigned waterSwitchIdx = Indices::waterSwitchIdx;
87 static constexpr unsigned pressureSwitchIdx = Indices::pressureSwitchIdx;
88 static constexpr unsigned compositionSwitchIdx = Indices::compositionSwitchIdx;
89 static constexpr unsigned saltConcentrationIdx = Indices::saltConcentrationIdx;
90 static constexpr unsigned solventSaturationIdx = Indices::solventSaturationIdx;
92 static constexpr bool compositionSwitchEnabled =
93 Indices::compositionSwitchIdx != std::numeric_limits<unsigned>::max();
94 static constexpr bool waterEnabled = Indices::waterEnabled;
95 static constexpr bool gasEnabled = Indices::gasEnabled;
96 static constexpr bool oilEnabled = Indices::oilEnabled;
99 enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
100 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
101 enum { waterPhaseIdx = FluidSystem::waterPhaseIdx };
102 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
105 enum { numComponents = getPropValue<TypeTag, Properties::NumComponents>() };
107 static constexpr EnergyModules energyModuleType = getPropValue<TypeTag, Properties::EnergyModuleType>();
109 static constexpr bool enableBioeffects = getPropValue<TypeTag, Properties::EnableBioeffects>();
110 static constexpr bool enableBrine = getPropValue<TypeTag, Properties::EnableBrine>();
111 static constexpr bool enableExtbo = getPropValue<TypeTag, Properties::EnableExtbo>();
112 static constexpr bool enableFoam = getPropValue<TypeTag, Properties::EnableFoam>();
113 static constexpr bool enableFullyImplicitThermal = energyModuleType == EnergyModules::FullyImplicitThermal;
114 static constexpr bool enablePolymer = getPropValue<TypeTag, Properties::EnablePolymer>();
115 static constexpr bool enableSolvent = getPropValue<TypeTag, Properties::EnableSolvent>();
117 enum { enableSaltPrecipitation = getPropValue<TypeTag, Properties::EnableSaltPrecipitation>() };
118 enum { enableVapwat = getPropValue<TypeTag, Properties::EnableVapwat>() };
119 enum { enableMICP = Indices::enableMICP };
120 enum { gasCompIdx = FluidSystem::gasCompIdx };
121 enum { waterCompIdx = FluidSystem::waterCompIdx };
122 enum { oilCompIdx = FluidSystem::oilCompIdx };
124 using Toolbox = MathToolbox<Evaluation>;
125 using ComponentVector = Dune::FieldVector<Scalar, numComponents>;
126 using SolventModule = BlackOilSolventModule<TypeTag, enableSolvent>;
127 using ExtboModule = BlackOilExtboModule<TypeTag, enableExtbo>;
129 using BrineModule = BlackOilBrineModule<TypeTag, enableBrine>;
130 using BioeffectsModule = BlackOilBioeffectsModule<TypeTag, enableBioeffects>;
132 static_assert(numPhases == 3,
"The black-oil model assumes three phases!");
133 static_assert(numComponents == 3,
"The black-oil model assumes three components!");
146 template<
class OtherTypeTag,
template<
class,
int>
class OtherVectorType>
152 template <
class OtherTypeTag,
template <
class,
int>
class OtherVectorType>
153 explicit OPM_HOST_DEVICE
156 , primaryVarsMeaningWater_(other.primaryVarsMeaningWater_)
157 , primaryVarsMeaningPressure_(other.primaryVarsMeaningPressure_)
158 , primaryVarsMeaningGas_(other.primaryVarsMeaningGas_)
159 , primaryVarsMeaningBrine_(other.primaryVarsMeaningBrine_)
160 , primaryVarsMeaningSolvent_(other.primaryVarsMeaningSolvent_)
161 , pvtRegionIdx_(other.pvtRegionIdx_)
162 , pcFactor_(other.pcFactor_)
168 Valgrind::SetUndefined(*
this);
180 result.pvtRegionIdx_ = 1;
181 result.primaryVarsMeaningBrine_ = BrineMeaning::Sp;
183 result.primaryVarsMeaningPressure_ = PressureMeaning::Pg;
184 result.primaryVarsMeaningWater_ = WaterMeaning::Rsw;
185 result.primaryVarsMeaningSolvent_ = SolventMeaning::Ss;
186 for (std::size_t i = 0; i < result.size(); ++i) {
196 pressureScale_ = Parameters::Get<Parameters::PressureScale<Scalar>>();
204 if (pressureScale_ != Scalar {1.0}) {
205 OpmLog::warning(fmt::format(
206 "Using a pressure scaling different from 1.0 is not supported "
207 "when running with GPU support. We have detected that you are compiling with GPU support, but we can "
208 "not detect whether you are running with GPU support for the assembly or property evaluation. If you "
209 "are doing property evaluation or assembly on the GPU, pressure scaling will be ignored."
210 "Read value of pressure scale: {}",
218 Parameters::Register<Parameters::PressureScale<Scalar>>
219 (
"Scaling of pressure primary variable");
222 OPM_HOST_DEVICE Evaluation
226 const Scalar scale = varIdx == pressureSwitchIdx ? this->getPressureScale() : Scalar{1.0};
227 if (std::is_same_v<Evaluation, Scalar>) {
228 return (*
this)[varIdx] * scale;
232 if (timeIdx == linearizationType.time) {
233 return Toolbox::createVariable((*
this)[varIdx], varIdx) * scale;
236 return Toolbox::createConstant((*
this)[varIdx]) * scale;
249 { pvtRegionIdx_ =
static_cast<unsigned short>(value); }
255 {
return pvtRegionIdx_; }
262 {
return primaryVarsMeaningWater_; }
269 { primaryVarsMeaningWater_ = newMeaning; }
276 {
return primaryVarsMeaningPressure_; }
283 { primaryVarsMeaningPressure_ = newMeaning; }
290 {
return primaryVarsMeaningGas_; }
297 { primaryVarsMeaningGas_ = newMeaning; }
300 {
return primaryVarsMeaningBrine_; }
307 { primaryVarsMeaningBrine_ = newMeaning; }
310 {
return primaryVarsMeaningSolvent_; }
317 { primaryVarsMeaningSolvent_ = newMeaning; }
322 template <
class Flu
idState>
325 using ConstEvaluation = std::remove_reference_t<typename FluidState::ValueType>;
326 using FsEvaluation = std::remove_const_t<ConstEvaluation>;
327 using FsToolbox = MathToolbox<FsEvaluation>;
329 const bool gasPresent =
330 fluidState.fluidSystem().phaseIsActive(gasPhaseIdx)
331 ? fluidState.saturation(gasPhaseIdx) > 0.0
333 const bool oilPresent =
334 fluidState.fluidSystem().phaseIsActive(oilPhaseIdx)
335 ? fluidState.saturation(oilPhaseIdx) > 0.0
337 const bool waterPresent =
338 fluidState.fluidSystem().phaseIsActive(waterPhaseIdx)
339 ? fluidState.saturation(waterPhaseIdx) > 0.0
341 const auto& saltSaturation =
342 BlackOil::getSaltSaturation_<FluidSystem, FluidState, Scalar>(fluidState, pvtRegionIdx_);
343 const bool precipitatedSaltPresent = enableSaltPrecipitation ? saltSaturation > 0.0 :
false;
344 const bool oneActivePhases = fluidState.fluidSystem().numActivePhases() == 1;
346 if constexpr (enableFullyImplicitThermal) {
347 EnergyModule::assignPrimaryVars(*
this, fluidState);
353 if (gasPresent && fluidState.fluidSystem().enableVaporizedOil() && !oilPresent) {
354 primaryVarsMeaningPressure_ = PressureMeaning::Pg;
356 else if (fluidState.fluidSystem().phaseIsActive(oilPhaseIdx)) {
357 primaryVarsMeaningPressure_ = PressureMeaning::Po;
359 else if (waterPresent && fluidState.fluidSystem().enableDissolvedGasInWater() && !gasPresent) {
360 primaryVarsMeaningPressure_ = PressureMeaning::Pw;
362 else if (fluidState.fluidSystem().phaseIsActive(gasPhaseIdx)) {
363 primaryVarsMeaningPressure_ = PressureMeaning::Pg;
366 assert(fluidState.fluidSystem().phaseIsActive(waterPhaseIdx));
367 primaryVarsMeaningPressure_ = PressureMeaning::Pw;
374 if (waterPresent && gasPresent) {
377 else if (gasPresent && fluidState.fluidSystem().enableVaporizedWater()) {
378 primaryVarsMeaningWater_ = WaterMeaning::Rvw;
380 else if (waterPresent && fluidState.fluidSystem().enableDissolvedGasInWater()) {
381 primaryVarsMeaningWater_ = WaterMeaning::Rsw;
383 else if (fluidState.fluidSystem().phaseIsActive(waterPhaseIdx) && !oneActivePhases) {
387 primaryVarsMeaningWater_ = WaterMeaning::Disabled;
395 if (gasPresent && oilPresent) {
398 else if (oilPresent && fluidState.fluidSystem().enableDissolvedGas()) {
401 else if (gasPresent && fluidState.fluidSystem().enableVaporizedOil()) {
404 else if (fluidState.fluidSystem().phaseIsActive(gasPhaseIdx) && fluidState.fluidSystem().phaseIsActive(oilPhaseIdx)) {
408 primaryVarsMeaningGas_ = GasMeaning::Disabled;
412 if constexpr (enableSaltPrecipitation) {
413 if (precipitatedSaltPresent) {
414 primaryVarsMeaningBrine_ = BrineMeaning::Sp;
417 primaryVarsMeaningBrine_ = BrineMeaning::Cs;
421 primaryVarsMeaningBrine_ = BrineMeaning::Disabled;
426 case PressureMeaning::Po:
427 this->setScaledPressure_(FsToolbox::value(fluidState.pressure(oilPhaseIdx)));
429 case PressureMeaning::Pg:
430 this->setScaledPressure_(FsToolbox::value(fluidState.pressure(gasPhaseIdx)));
432 case PressureMeaning::Pw:
433 this->setScaledPressure_(FsToolbox::value(fluidState.pressure(waterPhaseIdx)));
436 OPM_THROW(std::logic_error,
"No valid primary variable selected for pressure");
442 (*this)[waterSwitchIdx] = FsToolbox::value(fluidState.saturation(waterPhaseIdx));
445 case WaterMeaning::Rvw:
447 const auto& rvw = BlackOil::getRvw_<FluidSystem, FluidState, Scalar>(fluidState, pvtRegionIdx_);
448 (*this)[waterSwitchIdx] = rvw;
451 case WaterMeaning::Rsw:
453 const auto& Rsw = BlackOil::getRsw_<FluidSystem, FluidState, Scalar>(fluidState, pvtRegionIdx_);
454 (*this)[waterSwitchIdx] = Rsw;
457 case WaterMeaning::Disabled:
460 OPM_THROW(std::logic_error,
"No valid primary variable selected for water");
464 (*this)[compositionSwitchIdx] = FsToolbox::value(fluidState.saturation(gasPhaseIdx));
468 const auto& rs = BlackOil::getRs_<FluidSystem, FluidState, Scalar>(fluidState, pvtRegionIdx_);
469 (*this)[compositionSwitchIdx] = rs;
474 const auto& rv = BlackOil::getRv_<FluidSystem, FluidState, Scalar>(fluidState, pvtRegionIdx_);
475 (*this)[compositionSwitchIdx] = rv;
478 case GasMeaning::Disabled:
481 OPM_THROW(std::logic_error,
"No valid primary variable selected for composision");
497 unsigned globalDofIdx,
498 [[maybe_unused]] Scalar swMaximum,
499 Scalar thresholdWaterFilledCell, Scalar eps = 0.0)
518 Scalar saltConcentration = 0.0;
519 const Scalar& T = asImp_().temperature_(problem, globalDofIdx);
521 sw = (*this)[waterSwitchIdx];
524 sg = (*this)[compositionSwitchIdx];
536 if constexpr (enableSaltPrecipitation) {
537 const Scalar saltSolubility = BrineModule::saltSol(
pvtRegionIndex());
539 saltConcentration = saltSolubility;
540 const Scalar saltSat = (*this)[saltConcentrationIdx];
541 if (saltSat < -eps) {
543 (*this)[saltConcentrationIdx] = saltSolubility;
547 saltConcentration = (*this)[saltConcentrationIdx];
548 if (saltConcentration > saltSolubility + eps) {
550 (*this)[saltConcentrationIdx] = 0.0;
558 if constexpr (enableSolvent) {
559 if (SolventModule::isSolubleInWater()) {
560 const Scalar p = (*this)[pressureSwitchIdx];
561 const Scalar solLimit =
562 SolventModule::solubilityLimit(
pvtRegionIndex(), T , p, saltConcentration);
564 const Scalar solSat = (*this)[solventSaturationIdx];
567 (*this)[solventSaturationIdx] = solLimit;
571 const Scalar rsolw = (*this)[solventSaturationIdx];
572 if (rsolw > solLimit + eps) {
574 (*this)[solventSaturationIdx] = 0.0;
581 bool changed =
false;
589 if (sw >= thresholdWaterFilledCell && !FluidSystem::enableDissolvedGasInWater()) {
591 if constexpr (waterEnabled) {
592 (*this)[Indices::waterSwitchIdx] = std::min(swMaximum, sw);
596 if constexpr (compositionSwitchEnabled) {
597 (*this)[Indices::compositionSwitchIdx] = 0.0;
602 if constexpr (compositionSwitchEnabled) {
612 if constexpr (enableBrine) {
614 unsigned satnumRegionIdx = problem.satnumRegionIndex(globalDofIdx);
615 Scalar Sp = saltConcentration_();
616 Scalar porosityFactor = std::min(1.0 - Sp, 1.0);
617 const auto& pcfactTable = BrineModule::pcfactTable(satnumRegionIdx);
618 pcFactor_ = pcfactTable.eval(porosityFactor,
true);
621 else if constexpr (enableBioeffects) {
622 if (BioeffectsModule::hasPcfactTables() && problem.referencePorosity(globalDofIdx, 0) > 0) {
623 unsigned satnumRegionIdx = problem.satnumRegionIndex(globalDofIdx);
624 Scalar Sb = biofilmVolumeFraction_() /
625 problem.referencePorosity(globalDofIdx, 0);
626 Scalar porosityFactor = std::min(1.0 - Sb, 1.0);
627 const auto& pcfactTable = BioeffectsModule::pcfactTable(satnumRegionIdx);
628 pcFactor_ = pcfactTable.eval(porosityFactor,
true);
636 if (sw < -eps && sg > eps && FluidSystem::enableVaporizedWater()) {
637 Scalar p = this->pressure_();
639 std::array<Scalar, numPhases> pC{};
640 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
641 const Scalar so = 1.0 - sg - solventSaturation_();
642 computeCapillaryPressures_(pC, so, sg + solventSaturation_(), 0.0, matParams);
643 p += pcFactor_ * (pC[gasPhaseIdx] - pC[oilPhaseIdx]);
645 const Scalar rvwSat =
646 FluidSystem::gasPvt().saturatedWaterVaporizationFactor(pvtRegionIdx_,
651 (*this)[Indices::waterSwitchIdx] = rvwSat;
657 if (sg < -eps && sw > eps && FluidSystem::enableDissolvedGasInWater()) {
658 const Scalar pg = this->pressure_();
660 std::array<Scalar, numPhases> pC = { 0.0 };
661 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
662 const Scalar so = 1.0 - sw - solventSaturation_();
663 computeCapillaryPressures_(pC, so, 0.0, sw, matParams);
664 const Scalar pw = pg + pcFactor_ * (pC[waterPhaseIdx] - pC[gasPhaseIdx]);
665 const Scalar rswSat =
666 FluidSystem::waterPvt().saturatedGasDissolutionFactor(pvtRegionIdx_,
671 const Scalar rswMax = problem.maxGasDissolutionFactor(0, globalDofIdx);
672 (*this)[Indices::waterSwitchIdx] = std::min(rswSat, rswMax);
674 this->setScaledPressure_(pw);
680 case WaterMeaning::Rvw:
682 const Scalar& rvw = (*this)[waterSwitchIdx];
683 Scalar p = this->pressure_();
685 std::array<Scalar, numPhases> pC{};
686 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
687 const Scalar so = 1.0 - sg - solventSaturation_();
688 computeCapillaryPressures_(pC, so, sg + solventSaturation_(), 0.0, matParams);
689 p += pcFactor_ * (pC[gasPhaseIdx] - pC[oilPhaseIdx]);
691 const Scalar rvwSat =
692 FluidSystem::gasPvt().saturatedWaterVaporizationFactor(pvtRegionIdx_,
697 if (rvw > rvwSat * (1.0 + eps)) {
699 (*this)[Indices::waterSwitchIdx] = 0.0;
704 case WaterMeaning::Rsw:
709 const Scalar& pw = this->pressure_();
711 const Scalar rswSat =
712 FluidSystem::waterPvt().saturatedGasDissolutionFactor(pvtRegionIdx_,
717 const Scalar rsw = (*this)[Indices::waterSwitchIdx];
718 const Scalar rswMax = problem.maxGasDissolutionFactor(0, globalDofIdx);
719 if (rsw > std::min(rswSat, rswMax)) {
722 (*this)[Indices::waterSwitchIdx] = 1.0;
724 std::array<Scalar, numPhases> pC{};
725 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
726 computeCapillaryPressures_(pC, 0.0, 0.0, 1.0, matParams);
727 const Scalar pg = pw + pcFactor_ * (pC[gasPhaseIdx] - pC[waterPhaseIdx]);
728 this->setScaledPressure_(pg);
733 case WaterMeaning::Disabled:
736 throw std::logic_error(
"No valid primary variable selected for water");
749 const Scalar s = 1.0 - sw - solventSaturation_();
750 if (sg < -eps && s > 0.0 && FluidSystem::enableDissolvedGas()) {
751 const Scalar po = this->pressure_();
753 const Scalar soMax = std::max(s, problem.maxOilSaturation(globalDofIdx));
754 const Scalar rsMax = problem.maxGasDissolutionFactor(0, globalDofIdx);
756 if constexpr (enableExtbo) {
760 rsSat = FluidSystem::oilPvt().saturatedGasDissolutionFactor(pvtRegionIdx_,
766 (*this)[Indices::compositionSwitchIdx] = std::min(rsMax, rsSat);
769 const Scalar so = 1.0 - sw - solventSaturation_() - sg;
770 if (so < -eps && sg > 0.0 && FluidSystem::enableVaporizedOil()) {
775 const Scalar po = this->pressure_();
776 std::array<Scalar, numPhases> pC{};
777 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
778 computeCapillaryPressures_(pC, 0.0, sg + solventSaturation_(), sw, matParams);
779 const Scalar pg = po + pcFactor_ * (pC[gasPhaseIdx] - pC[oilPhaseIdx]);
784 this->setScaledPressure_(pg);
785 const Scalar soMax = problem.maxOilSaturation(globalDofIdx);
786 const Scalar rvMax = problem.maxOilVaporizationFactor(0, globalDofIdx);
788 if constexpr (enableExtbo) {
792 rvSat = FluidSystem::gasPvt().saturatedOilVaporizationFactor(pvtRegionIdx_,
799 (*this)[Indices::compositionSwitchIdx] = std::min(rvMax, rvSat);
809 const Scalar po = this->pressure_();
810 const Scalar so = 1.0 - sw - solventSaturation_();
811 const Scalar soMax = std::max(so, problem.maxOilSaturation(globalDofIdx));
812 const Scalar rsMax = problem.maxGasDissolutionFactor(0, globalDofIdx);
814 if constexpr (enableExtbo) {
818 rsSat = FluidSystem::oilPvt().saturatedGasDissolutionFactor(pvtRegionIdx_,
824 const Scalar rs = (*this)[Indices::compositionSwitchIdx];
825 if (rs > std::min(rsMax, rsSat * (Scalar{1.0} + eps))) {
828 (*this)[Indices::compositionSwitchIdx] = 0.0;
839 const Scalar pg = this->pressure_();
840 const Scalar soMax = problem.maxOilSaturation(globalDofIdx);
841 const Scalar rvMax = problem.maxOilVaporizationFactor(0, globalDofIdx);
843 if constexpr (enableExtbo) {
847 rvSat = FluidSystem::gasPvt().saturatedOilVaporizationFactor(pvtRegionIdx_,
853 const Scalar rv = (*this)[Indices::compositionSwitchIdx];
854 if (rv > std::min(rvMax, rvSat * (Scalar{1.0} + eps))) {
858 const Scalar sg2 = 1.0 - sw - solventSaturation_();
859 std::array<Scalar, numPhases> pC{};
860 const MaterialLawParams& matParams = problem.materialLawParams(globalDofIdx);
861 computeCapillaryPressures_(pC,
863 sg2 + solventSaturation_(),
866 const Scalar po = pg + pcFactor_ * (pC[oilPhaseIdx] - pC[gasPhaseIdx]);
870 this->setScaledPressure_(po);
871 (*this)[Indices::compositionSwitchIdx] = sg2;
876 case GasMeaning::Disabled:
879 throw std::logic_error(
"No valid primary variable selected for water");
893 sw = (*this)[Indices::waterSwitchIdx];
897 sg = (*this)[Indices::compositionSwitchIdx];
902 ssol =(*this) [Indices::solventSaturationIdx];
905 Scalar so = 1.0 - sw - sg - ssol;
906 sw = std::min(std::max(sw, Scalar{0.0}), Scalar{1.0});
907 so = std::min(std::max(so, Scalar{0.0}), Scalar{1.0});
908 sg = std::min(std::max(sg, Scalar{0.0}), Scalar{1.0});
909 ssol = std::min(std::max(ssol, Scalar{0.0}), Scalar{1.0});
910 const Scalar st = sw + so + sg + ssol;
916 (*this)[Indices::waterSwitchIdx] = sw;
919 (*this)[Indices::compositionSwitchIdx] = sg;
922 (*this) [Indices::solventSaturationIdx] = ssol;
930 using ParentType::operator=;
943 for (
unsigned i = 0; i < this->size(); ++i) {
944 Valgrind::CheckDefined((*
this)[i]);
948 Valgrind::CheckDefined(primaryVarsMeaningWater_);
949 Valgrind::CheckDefined(primaryVarsMeaningGas_);
950 Valgrind::CheckDefined(primaryVarsMeaningPressure_);
951 Valgrind::CheckDefined(primaryVarsMeaningBrine_);
952 Valgrind::CheckDefined(primaryVarsMeaningSolvent_);
954 Valgrind::CheckDefined(pvtRegionIdx_);
958 template<
class Serializer>
961 using FV = Dune::FieldVector<Scalar, getPropValue<TypeTag, Properties::NumEq>()>;
962 serializer(
static_cast<FV&
>(*
this));
963 serializer(primaryVarsMeaningWater_);
964 serializer(primaryVarsMeaningPressure_);
965 serializer(primaryVarsMeaningGas_);
966 serializer(primaryVarsMeaningBrine_);
967 serializer(primaryVarsMeaningSolvent_);
968 serializer(pvtRegionIdx_);
975 && this->primaryVarsMeaningWater_ == rhs.primaryVarsMeaningWater_
976 && this->primaryVarsMeaningPressure_ == rhs.primaryVarsMeaningPressure_
977 && this->primaryVarsMeaningGas_ == rhs.primaryVarsMeaningGas_
978 && this->primaryVarsMeaningBrine_ == rhs.primaryVarsMeaningBrine_
979 && this->primaryVarsMeaningSolvent_ == rhs.primaryVarsMeaningSolvent_
980 && this->pvtRegionIdx_ == rhs.pvtRegionIdx_;
984 OPM_HOST_DEVICE Implementation& asImp_()
985 {
return *
static_cast<Implementation*
>(
this); }
987 OPM_HOST_DEVICE
const Implementation& asImp_()
const
988 {
return *
static_cast<const Implementation*
>(
this); }
990 OPM_HOST_DEVICE Scalar solventSaturation_()
const
992 if constexpr (enableSolvent) {
994 return (*
this)[Indices::solventSaturationIdx];
1000 OPM_HOST_DEVICE Scalar zFraction_()
const
1002 if constexpr (enableExtbo) {
1003 return (*
this)[Indices::zFractionIdx];
1010 OPM_HOST_DEVICE Scalar saltConcentration_()
const
1012 if constexpr (enableBrine) {
1013 return (*
this)[Indices::saltConcentrationIdx];
1020 Scalar biofilmVolumeFraction_()
const
1022 if constexpr (enableBioeffects)
1023 return (*
this)[Indices::biofilmVolumeFractionIdx];
1028 OPM_HOST_DEVICE Scalar temperature_(
const Problem& problem, [[maybe_unused]]
unsigned globalDofIdx)
const
1030 if constexpr (energyModuleType == EnergyModules::FullyImplicitThermal) {
1031 return (*
this)[Indices::temperatureIdx];
1033 else if (energyModuleType == EnergyModules::NoTemperature) {
1034 return FluidSystem::reservoirTemperature();
1036 return problem.temperature(globalDofIdx, 0);
1040 template <
class Container>
1041 OPM_HOST_DEVICE
void computeCapillaryPressures_(Container& result,
1045 const MaterialLawParams& matParams)
const
1060 fluidState.setSaturation(waterPhaseIdx, sw);
1061 fluidState.setSaturation(oilPhaseIdx, so);
1062 fluidState.setSaturation(gasPhaseIdx, sg);
1064 MaterialLaw::capillaryPressures(result, matParams, fluidState);
1067 OPM_HOST_DEVICE Scalar pressure_()
const
1069 return (*
this)[Indices::pressureSwitchIdx] * this->getPressureScale();
1072 OPM_HOST_DEVICE
constexpr Scalar getPressureScale()
const
1076 #if OPM_IS_INSIDE_DEVICE_FUNCTION
1079 return this->pressureScale_;
1083 OPM_HOST_DEVICE
void setScaledPressure_(Scalar pressure)
1084 { (*this)[Indices::pressureSwitchIdx] = pressure / (this->getPressureScale()); }
1087 WaterMeaning primaryVarsMeaningWater_{WaterMeaning::Disabled};
1089 GasMeaning primaryVarsMeaningGas_{GasMeaning::Disabled};
1090 BrineMeaning primaryVarsMeaningBrine_{BrineMeaning::Disabled};
1091 SolventMeaning primaryVarsMeaningSolvent_{SolventMeaning::Disabled};
1092 unsigned short pvtRegionIdx_{};
1094 inline static Scalar pressureScale_ = 1.0;
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:70
::Opm::BlackOil::WaterMeaning WaterMeaning
Definition: blackoilprimaryvariables.hh:139
OPM_HOST_DEVICE void setPrimaryVarsMeaningPressure(PressureMeaning newMeaning)
Set the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:282
OPM_HOST_DEVICE void setPrimaryVarsMeaningBrine(BrineMeaning newMeaning)
Set the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:306
static void init()
Definition: blackoilprimaryvariables.hh:193
OPM_HOST_DEVICE BlackOilPrimaryVariables(const BlackOilPrimaryVariables< OtherTypeTag, OtherVectorType > &other)
Assignment from another primary variables object.
Definition: blackoilprimaryvariables.hh:154
::Opm::BlackOil::SolventMeaning SolventMeaning
Definition: blackoilprimaryvariables.hh:143
OPM_HOST_DEVICE void checkDefined() const
< Import base class assignment operators.
Definition: blackoilprimaryvariables.hh:939
OPM_HOST_DEVICE PressureMeaning primaryVarsMeaningPressure() const
Return the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:275
::Opm::BlackOil::GasMeaning GasMeaning
Definition: blackoilprimaryvariables.hh:141
OPM_HOST_DEVICE BlackOilPrimaryVariables()
Definition: blackoilprimaryvariables.hh:166
OPM_HOST_DEVICE bool chopAndNormalizeSaturations()
Definition: blackoilprimaryvariables.hh:884
OPM_HOST_DEVICE unsigned pvtRegionIndex() const
Return the index of the region which should be used for PVT properties.
Definition: blackoilprimaryvariables.hh:254
OPM_HOST_DEVICE bool operator==(const BlackOilPrimaryVariables &rhs) const
Definition: blackoilprimaryvariables.hh:971
void serializeOp(Serializer &serializer)
Definition: blackoilprimaryvariables.hh:959
OPM_HOST_DEVICE void setPrimaryVarsMeaningWater(WaterMeaning newMeaning)
Set the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:268
OPM_HOST_DEVICE void setPrimaryVarsMeaningGas(GasMeaning newMeaning)
Set the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:296
static void registerParameters()
Definition: blackoilprimaryvariables.hh:216
::Opm::BlackOil::BrineMeaning BrineMeaning
Definition: blackoilprimaryvariables.hh:142
BlackOilPrimaryVariables & operator=(const BlackOilPrimaryVariables &other)=default
BlackOilPrimaryVariables(const BlackOilPrimaryVariables &value)=default
Copy constructor.
::Opm::BlackOil::PressureMeaning PressureMeaning
Definition: blackoilprimaryvariables.hh:140
OPM_HOST_DEVICE GasMeaning primaryVarsMeaningGas() const
Return the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:289
OPM_HOST_DEVICE void setPvtRegionIndex(unsigned value)
Set the index of the region which should be used for PVT properties.
Definition: blackoilprimaryvariables.hh:248
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:496
OPM_HOST_DEVICE void assignNaive(const FluidState &fluidState)
Directly retrieve the primary variables from an arbitrary fluid state.
Definition: blackoilprimaryvariables.hh:323
OPM_HOST_DEVICE BrineMeaning primaryVarsMeaningBrine() const
Definition: blackoilprimaryvariables.hh:299
OPM_HOST_DEVICE void setPrimaryVarsMeaningSolvent(SolventMeaning newMeaning)
Set the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:316
OPM_HOST_DEVICE WaterMeaning primaryVarsMeaningWater() const
Return the interpretation which should be applied to the switching primary variables.
Definition: blackoilprimaryvariables.hh:261
static BlackOilPrimaryVariables serializationTestObject()
Definition: blackoilprimaryvariables.hh:177
OPM_HOST_DEVICE Evaluation makeEvaluation(unsigned varIdx, unsigned timeIdx, LinearizationType linearizationType=LinearizationType()) const
Definition: blackoilprimaryvariables.hh:223
OPM_HOST_DEVICE SolventMeaning primaryVarsMeaningSolvent() const
Definition: blackoilprimaryvariables.hh:309
Represents the primary variables used by the a model.
Definition: fvbaseprimaryvariables.hh:54
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
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:57
static constexpr Scalar value
Definition: blackoilprimaryvariables.hh:57