95 using FluidState =
typename IntensiveQuantities::FluidState;
97 using Element =
typename GridView::template Codim<0>::Entity;
98 using ElementIterator =
typename GridView::template Codim<0>::Iterator;
101 using Dir = FaceDir::DirEnum;
108 static constexpr int conti0EqIdx = Indices::conti0EqIdx;
109 static constexpr int numPhases = FluidSystem::numPhases;
110 static constexpr int oilPhaseIdx = FluidSystem::oilPhaseIdx;
111 static constexpr int gasPhaseIdx = FluidSystem::gasPhaseIdx;
112 static constexpr int waterPhaseIdx = FluidSystem::waterPhaseIdx;
113 static constexpr int gasCompIdx = FluidSystem::gasCompIdx;
114 static constexpr int oilCompIdx = FluidSystem::oilCompIdx;
115 static constexpr int waterCompIdx = FluidSystem::waterCompIdx;
118 enum { enableMICP = Indices::enableMICP };
123 template<
class VectorType>
124 static Scalar value_or_zero(
int idx,
const VectorType&
v)
129 return v.empty() ? 0.0 :
v[
idx];
136 :
BaseType(simulator.vanguard().eclState(),
137 simulator.vanguard().schedule(),
139 simulator.vanguard().summaryState(),
141 [
this](
const int idx)
142 {
return simulator_.problem().eclWriter().collectOnIORank().localIdxToGlobalIdx(
idx); },
143 simulator.vanguard().grid().comm(),
154 , simulator_(simulator)
155 , collectOnIORank_(collectOnIORank)
161 auto isCartIdxOnThisRank = [&collectOnIORank](
const int idx) {
162 return collectOnIORank.isCartIdxOnThisRank(
idx);
165 this->setupBlockData(isCartIdxOnThisRank);
167 if (! Parameters::Get<Parameters::OwnerCellsFirst>()) {
168 const std::string
msg =
"The output code does not support --owner-cells-first=false.";
169 if (collectOnIORank.isIORank()) {
176 auto rset = this->eclState_.fieldProps().fip_regions();
177 rset.push_back(
"PVTNUM");
182 this->regionAvgDensity_
183 .emplace(this->simulator_.gridView().comm(),
184 FluidSystem::numPhases,
rset,
185 [
fp = std::cref(
this->eclState_.fieldProps())]
186 (
const std::string&
rsetName) ->
decltype(
auto)
187 { return fp.get().get_int(rsetName); });
197 const unsigned reportStepNum,
200 const bool isRestart)
206 const auto& problem = this->simulator_.problem();
213 &problem.materialLawManager()->hysteresisConfig(),
214 problem.eclWriter().getOutputNnc().size());
219 const int reportStepNum)
221 this->setupElementExtractors_();
222 this->setupBlockExtractors_(
isSubStep, reportStepNum);
228 this->extractors_.clear();
229 this->blockExtractors_.clear();
230 this->extraBlockExtractors_.clear();
244 if (this->extractors_.empty()) {
248 const auto&
matLawManager = simulator_.problem().materialLawManager();
251 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++dofIdx) {
252 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, 0);
253 const auto& fs = intQuants.fluidState();
256 elemCtx.globalSpaceIndex(dofIdx, 0),
257 elemCtx.primaryVars(dofIdx, 0).pvtRegionIndex(),
265 if (FluidSystem::phaseIsActive(oilPhaseIdx) && FluidSystem::phaseIsActive(waterPhaseIdx)) {
271 if (FluidSystem::phaseIsActive(oilPhaseIdx) && FluidSystem::phaseIsActive(gasPhaseIdx)) {
283 void processElementBlockData(
const ElementContext& elemCtx)
290 if (this->blockExtractors_.empty() &&
this->extraBlockExtractors_.empty()) {
294 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++dofIdx) {
296 const auto globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
297 const auto cartesianIdx = elemCtx.simulator().vanguard().cartesianIndex(globalDofIdx);
301 if (
be_it == this->blockExtractors_.end() &&
307 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, 0);
308 const auto& fs = intQuants.fluidState();
310 const typename BlockExtractor::Context
ectx{
318 if (
be_it != this->blockExtractors_.end()) {
321 if (
bee_it != this->extraBlockExtractors_.end()) {
328 const std::size_t reportStepNum,
332 const Parallel::Communication& comm)
335 if (comm.rank() != 0) {
340 std::unique_ptr<FIPConfig>
fipSched;
341 if (reportStepNum > 0) {
342 const auto&
rpt = this->schedule_[reportStepNum-1].rpt_config.get();
345 const FIPConfig&
fipc = reportStepNum == 0 ? this->eclState_.getEclipseConfig().fip()
348 if (!
substep && !this->forceDisableFipOutput_ &&
fipc.output(FIPConfig::OutputField::FIELD)) {
350 this->logOutput_.timeStamp(
"BALANCE", elapsed, reportStepNum,
currentDate);
355 if (
fipc.output(FIPConfig::OutputField::FIPNUM)) {
358 if (
fipc.output(FIPConfig::OutputField::RESV))
359 this->logOutput_.fipResv(
inplace,
"FIPNUM");
362 if (
fipc.output(FIPConfig::OutputField::FIP)) {
363 for (
const auto&
reg :
this->regions_) {
364 if (
reg.first !=
"FIPNUM") {
365 std::ostringstream
ss;
366 ss <<
"BAL" <<
reg.first.substr(3);
367 this->logOutput_.timeStamp(
ss.str(), elapsed, reportStepNum,
currentDate);
370 if (
fipc.output(FIPConfig::OutputField::RESV))
378 void outputFipAndResvLogToCSV(
const std::size_t reportStepNum,
380 const Parallel::Communication& comm)
382 if (comm.rank() != 0) {
386 if ((reportStepNum == 0) && (!
substep) &&
387 (this->schedule_.initialReportConfiguration().has_value()) &&
388 (
this->schedule_.initialReportConfiguration()->contains(
"CSVFIP"))) {
398 for (
const auto&
reg :
this->regions_) {
399 if (
reg.first !=
"FIPNUM") {
404 const IOConfig&
io = this->eclState_.getIOConfig();
405 auto csv_fname =
io.getOutputDir() +
"/" +
io.getBaseName() +
".CSV";
443 template <
class ActiveIndex,
class CartesianIndex>
449 const auto identifyCell = [&activeIndex, &cartesianIndex](
const Element&
elem)
457 elem.partitionType() == Dune::InteriorEntity
462 const auto& stencil = elemCtx.stencil(
timeIdx);
463 const auto numInteriorFaces = elemCtx.numInteriorFaces(
timeIdx);
470 const auto rates = this->
485 this->interRegionFlows_.
clear();
501 return this->interRegionFlows_;
504 template <
class Flu
idState>
505 void assignToFluidState(FluidState& fs,
unsigned elemIdx)
const
508 if (this->saturation_[
phaseIdx].empty())
514 if (!this->fluidPressure_.empty()) {
517 std::array<Scalar, numPhases>
pc = {0};
518 const MaterialLawParams&
matParams = simulator_.problem().materialLawParams(elemIdx);
519 MaterialLaw::capillaryPressures(
pc,
matParams, fs);
520 Valgrind::CheckDefined(this->fluidPressure_[elemIdx]);
521 Valgrind::CheckDefined(
pc);
522 const auto& pressure = this->fluidPressure_[elemIdx];
524 if (!FluidSystem::phaseIsActive(
phaseIdx))
527 if (Indices::oilEnabled)
529 else if (Indices::gasEnabled)
531 else if (Indices::waterEnabled)
537 if (!this->temperature_.empty())
538 fs.setTemperature(this->temperature_[elemIdx]);
540 if (!this->rs_.empty())
541 fs.setRs(
this->rs_[elemIdx]);
542 if (!this->rv_.empty())
543 fs.setRv(
this->rv_[elemIdx]);
545 if constexpr (enableDisgasInWater) {
546 if (!this->rsw_.empty())
547 fs.setRsw(
this->rsw_[elemIdx]);
549 if constexpr (enableVapwat) {
550 if (!this->rvw_.empty())
551 fs.setRvw(
this->rvw_[elemIdx]);
555 void initHysteresisParams(Simulator& simulator,
unsigned elemIdx)
const
557 if (!this->soMax_.empty())
558 simulator.problem().setMaxOilSaturation(elemIdx, this->soMax_[elemIdx]);
560 if (simulator.problem().materialLawManager()->enableHysteresis()) {
561 auto matLawManager = simulator.problem().materialLawManager();
563 if (FluidSystem::phaseIsActive(oilPhaseIdx)
564 && FluidSystem::phaseIsActive(waterPhaseIdx)) {
570 if (!this->soMax_.empty()) {
571 somax = this->soMax_[elemIdx];
575 if (!this->swMax_.empty()) {
576 swmax = this->swMax_[elemIdx];
580 if (!this->swmin_.empty()) {
581 swmin = this->swmin_[elemIdx];
585 somax, swmax, swmin, elemIdx);
587 if (FluidSystem::phaseIsActive(oilPhaseIdx)
588 && FluidSystem::phaseIsActive(gasPhaseIdx)) {
594 if (!this->sgmax_.empty()) {
595 sgmax = this->sgmax_[elemIdx];
599 if (!this->shmax_.empty()) {
600 shmax = this->shmax_[elemIdx];
604 if (!this->somin_.empty()) {
605 somin = this->somin_[elemIdx];
609 sgmax, shmax, somin, elemIdx);
614 if (simulator_.vanguard().eclState().fieldProps().has_double(
"SWATINIT")) {
615 simulator.problem().materialLawManager()
616 ->applyRestartSwatInit(elemIdx, this->ppcw_[elemIdx]);
620 void updateFluidInPlace(
const ElementContext& elemCtx)
622 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++dofIdx) {
623 updateFluidInPlace_(elemCtx, dofIdx);
627 void updateFluidInPlace(
const unsigned globalDofIdx,
628 const IntensiveQuantities& intQuants,
631 this->updateFluidInPlace_(globalDofIdx, intQuants,
totVolume);
635 template <
typename T>
636 using RemoveCVR = std::remove_cv_t<std::remove_reference_t<T>>;
638 template <
typename,
class =
void>
639 struct HasGeoMech :
public std::false_type {};
641 template <
typename Problem>
643 Problem, std::
void_t<decltype(std::declval<Problem>().geoMechModel())>
644 > :
public std::true_type {};
646 bool isDefunctParallelWell(
const std::string&
wname)
const override
648 if (simulator_.gridView().comm().size() == 1)
650 const auto& parallelWells = simulator_.vanguard().parallelWells();
651 std::pair<std::string, bool> value {
wname,
true};
652 auto candidate = std::lower_bound(parallelWells.begin(), parallelWells.end(), value);
656 bool isOwnedByCurrentRank(
const std::string&
wname)
const override
658 return this->simulator_.problem().wellModel().isOwner(
wname);
661 bool isOnCurrentRank(
const std::string&
wname)
const override
663 return this->simulator_.problem().wellModel().hasLocalCells(
wname);
666 void updateFluidInPlace_(
const ElementContext& elemCtx,
const unsigned dofIdx)
668 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, 0);
669 const unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
670 const auto totVolume = elemCtx.simulator().model().dofTotalVolume(globalDofIdx);
672 this->updateFluidInPlace_(globalDofIdx, intQuants,
totVolume);
675 void updateFluidInPlace_(
const unsigned globalDofIdx,
676 const IntensiveQuantities& intQuants,
681 this->updateTotalVolumesAndPressures_(globalDofIdx, intQuants,
totVolume);
683 if (this->computeFip_) {
684 this->updatePhaseInplaceVolumes_(globalDofIdx, intQuants,
totVolume);
688 void createLocalRegion_(std::vector<int>& region)
694 region.resize(simulator_.gridView().size(0));
695 std::size_t elemIdx = 0;
696 for (
const auto&
elem :
elements(simulator_.gridView())) {
697 if (
elem.partitionType() != Dune::InteriorEntity) {
705 template <
typename Flu
idState>
706 void aggregateAverageDensityContributions_(
const FluidState& fs,
707 const unsigned int globalDofIdx,
710 auto pvCellValue = RegionPhasePoreVolAverage::CellValue{};
713 for (
auto phaseIdx = 0*FluidSystem::numPhases;
716 if (! FluidSystem::phaseIsActive(
phaseIdx)) {
723 this->regionAvgDensity_
724 ->addCell(globalDofIdx,
725 RegionPhasePoreVolAverage::Phase {
phaseIdx },
745 data::InterRegFlowMap::FlowRates
746 getComponentSurfaceRates(
const ElementContext& elemCtx,
747 const Scalar faceArea,
749 const std::size_t
timeIdx)
const
751 using Component = data::InterRegFlowMap::Component;
753 auto rates = data::InterRegFlowMap::FlowRates {};
759 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
760 const auto&
up = elemCtx
763 const auto pvtReg =
up.pvtRegionIndex();
766 (
up.fluidState(), oilPhaseIdx,
pvtReg));
770 rates[Component::Oil] +=
qO;
772 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
774 BlackOil::getRs_<FluidSystem, FluidState, Scalar>
777 rates[Component::Gas] +=
qO * Rs;
778 rates[Component::Disgas] +=
qO * Rs;
782 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
783 const auto&
up = elemCtx
786 const auto pvtReg =
up.pvtRegionIndex();
789 (
up.fluidState(), gasPhaseIdx,
pvtReg));
793 rates[Component::Gas] +=
qG;
795 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
797 BlackOil::getRv_<FluidSystem, FluidState, Scalar>
800 rates[Component::Oil] +=
qG * Rv;
801 rates[Component::Vapoil] +=
qG * Rv;
805 if (FluidSystem::phaseIsActive(waterPhaseIdx)) {
806 const auto&
up = elemCtx
809 const auto pvtReg =
up.pvtRegionIndex();
812 (
up.fluidState(), waterPhaseIdx,
pvtReg));
814 rates[Component::Water] +=
821 template <
typename Flu
idState>
822 Scalar hydroCarbonFraction(
const FluidState& fs)
const
824 if (this->eclState_.runspec().co2Storage()) {
832 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
836 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
843 void updateTotalVolumesAndPressures_(
const unsigned globalDofIdx,
844 const IntensiveQuantities& intQuants,
847 const auto& fs = intQuants.fluidState();
849 const double pv =
totVolume * intQuants.porosity().value();
850 const auto hydrocarbon = this->hydroCarbonFraction(fs);
852 if (! this->hydrocarbonPoreVolume_.empty()) {
853 this->fipC_.assignPoreVolume(globalDofIdx,
854 totVolume * intQuants.referencePorosity());
856 this->dynamicPoreVolume_[globalDofIdx] = pv;
857 this->hydrocarbonPoreVolume_[globalDofIdx] = pv *
hydrocarbon;
860 if (!this->pressureTimesHydrocarbonVolume_.empty() &&
861 !
this->pressureTimesPoreVolume_.empty())
863 assert(this->hydrocarbonPoreVolume_.size() ==
this->pressureTimesHydrocarbonVolume_.size());
864 assert(this->fipC_.get(Inplace::Phase::PoreVolume).size() ==
this->pressureTimesPoreVolume_.size());
866 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
867 this->pressureTimesPoreVolume_[globalDofIdx] =
868 getValue(fs.pressure(oilPhaseIdx)) * pv;
870 this->pressureTimesHydrocarbonVolume_[globalDofIdx] =
871 this->pressureTimesPoreVolume_[globalDofIdx] *
hydrocarbon;
873 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
874 this->pressureTimesPoreVolume_[globalDofIdx] =
875 getValue(fs.pressure(gasPhaseIdx)) * pv;
877 this->pressureTimesHydrocarbonVolume_[globalDofIdx] =
878 this->pressureTimesPoreVolume_[globalDofIdx] *
hydrocarbon;
880 else if (FluidSystem::phaseIsActive(waterPhaseIdx)) {
881 this->pressureTimesPoreVolume_[globalDofIdx] =
882 getValue(fs.pressure(waterPhaseIdx)) * pv;
887 void updatePhaseInplaceVolumes_(
const unsigned globalDofIdx,
888 const IntensiveQuantities& intQuants,
891 std::array<Scalar, FluidSystem::numPhases> fip {};
892 std::array<Scalar, FluidSystem::numPhases>
fipr{};
894 const auto& fs = intQuants.fluidState();
895 const auto pv =
totVolume * intQuants.porosity().value();
898 if (!FluidSystem::phaseIsActive(
phaseIdx)) {
909 this->fipC_.assignVolumesSurface(globalDofIdx, fip);
910 this->fipC_.assignVolumesReservoir(globalDofIdx,
911 fs.saltConcentration().value(),
914 if (FluidSystem::phaseIsActive(oilPhaseIdx) &&
915 FluidSystem::phaseIsActive(gasPhaseIdx))
917 this->updateOilGasDistribution(globalDofIdx, fs, fip);
920 if (FluidSystem::phaseIsActive(waterPhaseIdx) &&
921 FluidSystem::phaseIsActive(gasPhaseIdx))
923 this->updateGasWaterDistribution(globalDofIdx, fs, fip);
926 if (FluidSystem::phaseIsActive(gasPhaseIdx) &&
927 this->fipC_.hasCo2InGas())
929 this->updateCO2InGas(globalDofIdx, pv, intQuants);
932 if (this->fipC_.hasCo2InWater() &&
933 (FluidSystem::phaseIsActive(waterPhaseIdx) ||
934 FluidSystem::phaseIsActive(oilPhaseIdx)))
936 this->updateCO2InWater(globalDofIdx, pv, fs);
939 if constexpr(enableBioeffects) {
942 if (this->fipC_.hasMicrobialMass()) {
943 this->updateMicrobialMass(globalDofIdx, intQuants,
surfVolWat);
945 if (this->fipC_.hasBiofilmMass()) {
946 this->updateBiofilmMass(globalDofIdx, intQuants,
totVolume);
948 if constexpr(enableMICP) {
949 if (this->fipC_.hasOxygenMass()) {
950 this->updateOxygenMass(globalDofIdx, intQuants,
surfVolWat);
952 if (this->fipC_.hasUreaMass()) {
953 this->updateUreaMass(globalDofIdx, intQuants,
surfVolWat);
955 if (this->fipC_.hasCalciteMass()) {
956 this->updateCalciteMass(globalDofIdx, intQuants,
totVolume);
961 if (this->fipC_.hasWaterMass() && FluidSystem::phaseIsActive(waterPhaseIdx))
963 this->updateWaterMass(globalDofIdx, fs, fip);
967 template <
typename Flu
idState,
typename FIPArray>
968 void updateOilGasDistribution(
const unsigned globalDofIdx,
969 const FluidState& fs,
979 template <
typename Flu
idState,
typename FIPArray>
980 void updateGasWaterDistribution(
const unsigned globalDofIdx,
981 const FluidState& fs,
991 template <
typename IntensiveQuantities>
992 void updateCO2InGas(
const unsigned globalDofIdx,
994 const IntensiveQuantities& intQuants)
997 ->oilWaterScaledEpsInfoDrainage(globalDofIdx);
999 const auto& fs = intQuants.fluidState();
1001 if (this->simulator_.problem().materialLawManager()->enableHysteresis()) {
1002 const auto&
matParams = simulator_.problem().materialLawParams(globalDofIdx);
1003 sgcr = MaterialLaw::trappedGasSaturation(
matParams,
false);
1007 if (this->fipC_.has(Inplace::Phase::CO2MassInGasPhaseMaximumTrapped) ||
1008 this->fipC_.has(Inplace::Phase::CO2MassInGasPhaseMaximumUnTrapped))
1010 if (this->simulator_.problem().materialLawManager()->enableHysteresis()) {
1011 const auto&
matParams = simulator_.problem().materialLawParams(globalDofIdx);
1017 const Scalar sg =
getValue(fs.saturation(gasPhaseIdx));
1019 if (this->fipC_.has(Inplace::Phase::CO2MassInGasPhaseEffectiveTrapped) ||
1020 this->fipC_.has(Inplace::Phase::CO2MassInGasPhaseEffectiveUnTrapped))
1022 if (this->simulator_.problem().materialLawManager()->enableHysteresis()) {
1023 const auto&
matParams = simulator_.problem().materialLawParams(globalDofIdx);
1024 const double krg =
getValue(intQuants.relativePermeability(gasPhaseIdx));
1029 const typename FIPContainer<FluidSystem>::Co2InGasInput
v{
1034 FluidSystem::phaseIsActive(waterPhaseIdx)
1035 ? FluidSystem::convertRvwToXgW(
getValue(fs.Rvw()), fs.pvtRegionIndex())
1037 FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex()),
1042 this->fipC_.assignCo2InGas(globalDofIdx,
v);
1045 template <
typename Flu
idState>
1046 void updateCO2InWater(
const unsigned globalDofIdx,
1048 const FluidState& fs)
1050 const auto co2InWater = FluidSystem::phaseIsActive(oilPhaseIdx)
1051 ? this->co2InWaterFromOil(fs, pv)
1052 :
this->co2InWaterFromWater(fs, pv);
1054 const Scalar mM = FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex());
1056 this->fipC_.assignCo2InWater(globalDofIdx,
co2InWater, mM);
1059 template <
typename Flu
idState>
1060 Scalar co2InWaterFromWater(
const FluidState& fs,
const double pv)
const
1062 const double rhow =
getValue(fs.density(waterPhaseIdx));
1063 const double sw =
getValue(fs.saturation(waterPhaseIdx));
1064 const double xwG = FluidSystem::convertRswToXwG(
getValue(fs.Rsw()), fs.pvtRegionIndex());
1066 const Scalar mM = FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex());
1071 template <
typename Flu
idState>
1072 Scalar co2InWaterFromOil(
const FluidState& fs,
const double pv)
const
1075 const double so =
getValue(fs.saturation(oilPhaseIdx));
1076 const double xoG = FluidSystem::convertRsToXoG(
getValue(fs.Rs()), fs.pvtRegionIndex());
1078 const Scalar mM = FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex());
1083 template <
typename Flu
idState,
typename FIPArray>
1084 void updateWaterMass(
const unsigned globalDofIdx,
1085 const FluidState& fs,
1089 const Scalar
rhoW = FluidSystem::referenceDensity(waterPhaseIdx, fs.pvtRegionIndex());
1091 this->fipC_.assignWaterMass(globalDofIdx, fip,
rhoW);
1094 template <
typename IntensiveQuantities>
1095 void updateMicrobialMass(
const unsigned globalDofIdx,
1096 const IntensiveQuantities& intQuants,
1099 const Scalar
mass =
surfVolWat * intQuants.microbialConcentration().value();
1101 this->fipC_.assignMicrobialMass(globalDofIdx,
mass);
1104 template <
typename IntensiveQuantities>
1105 void updateOxygenMass(
const unsigned globalDofIdx,
1106 const IntensiveQuantities& intQuants,
1109 const Scalar
mass =
surfVolWat * intQuants.oxygenConcentration().value();
1111 this->fipC_.assignOxygenMass(globalDofIdx,
mass);
1114 template <
typename IntensiveQuantities>
1115 void updateUreaMass(
const unsigned globalDofIdx,
1116 const IntensiveQuantities& intQuants,
1119 const Scalar
mass =
surfVolWat * intQuants.ureaConcentration().value();
1121 this->fipC_.assignUreaMass(globalDofIdx,
mass);
1124 template <
typename IntensiveQuantities>
1125 void updateBiofilmMass(
const unsigned globalDofIdx,
1126 const IntensiveQuantities& intQuants,
1129 const Scalar
mass =
totVolume * intQuants.biofilmMass().value();
1131 this->fipC_.assignBiofilmMass(globalDofIdx,
mass);
1134 template <
typename IntensiveQuantities>
1135 void updateCalciteMass(
const unsigned globalDofIdx,
1136 const IntensiveQuantities& intQuants,
1139 const Scalar
mass =
totVolume * intQuants.calciteMass().value();
1141 this->fipC_.assignCalciteMass(globalDofIdx,
mass);
1145 void setupElementExtractors_()
1147 using Entry =
typename Extractor::Entry;
1148 using Context =
typename Extractor::Context;
1149 using ScalarEntry =
typename Extractor::ScalarEntry;
1150 using PhaseEntry =
typename Extractor::PhaseEntry;
1152 const bool hasResidual = simulator_.model().linearizer().residual().size() > 0;
1153 const auto&
hysteresisConfig = simulator_.problem().materialLawManager()->hysteresisConfig();
1156 Entry{PhaseEntry{&this->saturation_,
1157 [](
const unsigned phase,
const Context&
ectx)
1161 Entry{PhaseEntry{&this->invB_,
1162 [](
const unsigned phase,
const Context&
ectx)
1166 Entry{PhaseEntry{&this->density_,
1167 [](
const unsigned phase,
const Context&
ectx)
1171 Entry{PhaseEntry{&this->relativePermeability_,
1172 [](
const unsigned phase,
const Context&
ectx)
1173 {
return getValue(
ectx.intQuants.relativePermeability(phase)); }
1176 Entry{PhaseEntry{&this->viscosity_,
1179 if (this->extboC_.allocated() &&
phaseIdx == oilPhaseIdx) {
1182 else if (this->extboC_.allocated() &&
phaseIdx == gasPhaseIdx) {
1191 Entry{PhaseEntry{&this->residual_,
1192 [&
modelResid = this->simulator_.model().linearizer().residual()]
1195 const unsigned sIdx = FluidSystem::solventComponentIndex(
phaseIdx);
1202 Entry{ScalarEntry{&this->rockCompPorvMultiplier_,
1203 [&problem = this->simulator_.problem()](
const Context&
ectx)
1205 return problem.template
1211 Entry{ScalarEntry{&this->rockCompTransMultiplier_,
1212 [&problem = this->simulator_.problem()](
const Context&
ectx)
1219 Entry{ScalarEntry{&this->minimumOilPressure_,
1220 [&problem = this->simulator_.problem()](
const Context&
ectx)
1222 return std::min(
getValue(
ectx.fs.pressure(oilPhaseIdx)),
1223 problem.minOilPressure(
ectx.globalDofIdx));
1227 Entry{ScalarEntry{&this->bubblePointPressure_,
1229 &vanguard = this->simulator_.vanguard()](
const Context&
ectx)
1233 FluidSystem::bubblePointPressure(
ectx.fs,
1234 ectx.intQuants.pvtRegionIndex())
1244 Entry{ScalarEntry{&this->dewPointPressure_,
1246 &vanguard = this->simulator_.vanguard()](
const Context&
ectx)
1250 FluidSystem::dewPointPressure(
ectx.fs,
1251 ectx.intQuants.pvtRegionIndex())
1261 Entry{ScalarEntry{&this->overburdenPressure_,
1262 [&problem = simulator_.problem()](
const Context&
ectx)
1263 {
return problem.overburdenPressure(
ectx.globalDofIdx); }
1266 Entry{ScalarEntry{&this->temperature_,
1267 [](
const Context&
ectx)
1271 Entry{ScalarEntry{&this->sSol_,
1272 [](
const Context&
ectx)
1273 {
return getValue(
ectx.intQuants.solventSaturation()); }
1276 Entry{ScalarEntry{&this->rswSol_,
1277 [](
const Context&
ectx)
1281 Entry{ScalarEntry{&this->cPolymer_,
1282 [](
const Context&
ectx)
1283 {
return getValue(
ectx.intQuants.polymerConcentration()); }
1286 Entry{ScalarEntry{&this->cFoam_,
1287 [](
const Context&
ectx)
1288 {
return getValue(
ectx.intQuants.foamConcentration()); }
1291 Entry{ScalarEntry{&this->cSalt_,
1292 [](
const Context&
ectx)
1296 Entry{ScalarEntry{&this->pSalt_,
1297 [](
const Context&
ectx)
1301 Entry{ScalarEntry{&this->permFact_,
1302 [](
const Context&
ectx)
1306 Entry{ScalarEntry{&this->rPorV_,
1307 [&model = this->simulator_.model()](
const Context&
ectx)
1309 const auto totVolume = model.dofTotalVolume(
ectx.globalDofIdx);
1314 Entry{ScalarEntry{&this->rs_,
1315 [](
const Context&
ectx)
1319 Entry{ScalarEntry{&this->rv_,
1320 [](
const Context&
ectx)
1324 Entry{ScalarEntry{&this->rsw_,
1325 [](
const Context&
ectx)
1329 Entry{ScalarEntry{&this->rvw_,
1330 [](
const Context&
ectx)
1334 Entry{ScalarEntry{&this->ppcw_,
1335 [&
matLawManager = *this->simulator_.problem().materialLawManager()]
1336 (
const Context&
ectx)
1343 Entry{ScalarEntry{&this->drsdtcon_,
1344 [&problem = this->simulator_.problem()](
const Context&
ectx)
1346 return problem.drsdtcon(
ectx.globalDofIdx,
1351 Entry{ScalarEntry{&this->pcgw_,
1352 [](
const Context&
ectx)
1359 Entry{ScalarEntry{&this->pcow_,
1360 [](
const Context&
ectx)
1367 Entry{ScalarEntry{&this->pcog_,
1368 [](
const Context&
ectx)
1375 Entry{ScalarEntry{&this->fluidPressure_,
1376 [](
const Context&
ectx)
1378 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1382 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1393 Entry{ScalarEntry{&this->gasDissolutionFactor_,
1394 [&problem = this->simulator_.problem()](
const Context&
ectx)
1396 const Scalar
SoMax = problem.maxOilSaturation(
ectx.globalDofIdx);
1397 return FluidSystem::template
1405 Entry{ScalarEntry{&this->oilVaporizationFactor_,
1406 [&problem = this->simulator_.problem()](
const Context&
ectx)
1408 const Scalar
SoMax = problem.maxOilSaturation(
ectx.globalDofIdx);
1409 return FluidSystem::template
1417 Entry{ScalarEntry{&this->gasDissolutionFactorInWater_,
1418 [&problem = this->simulator_.problem()](
const Context&
ectx)
1420 const Scalar
SwMax = problem.maxWaterSaturation(
ectx.globalDofIdx);
1421 return FluidSystem::template
1429 Entry{ScalarEntry{&this->waterVaporizationFactor_,
1430 [](
const Context&
ectx)
1432 return FluidSystem::template
1439 Entry{ScalarEntry{&this->gasFormationVolumeFactor_,
1440 [](
const Context&
ectx)
1442 return 1.0 / FluidSystem::template
1449 Entry{ScalarEntry{&this->saturatedOilFormationVolumeFactor_,
1450 [](
const Context&
ectx)
1452 return 1.0 / FluidSystem::template
1459 Entry{ScalarEntry{&this->oilSaturationPressure_,
1460 [](
const Context&
ectx)
1462 return FluidSystem::template
1469 Entry{ScalarEntry{&this->soMax_,
1470 [&problem = this->simulator_.problem()](
const Context&
ectx)
1472 return std::max(
getValue(
ectx.fs.saturation(oilPhaseIdx)),
1473 problem.maxOilSaturation(
ectx.globalDofIdx));
1478 Entry{ScalarEntry{&this->swMax_,
1479 [&problem = this->simulator_.problem()](
const Context&
ectx)
1481 return std::max(
getValue(
ectx.fs.saturation(waterPhaseIdx)),
1482 problem.maxWaterSaturation(
ectx.globalDofIdx));
1487 Entry{ScalarEntry{&this->soMax_,
1488 [](
const Context&
ectx)
1489 {
return ectx.hParams.somax; }
1493 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1494 FluidSystem::phaseIsActive(waterPhaseIdx)
1496 Entry{ScalarEntry{&this->swMax_,
1497 [](
const Context&
ectx)
1498 {
return ectx.hParams.swmax; }
1502 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1503 FluidSystem::phaseIsActive(waterPhaseIdx)
1505 Entry{ScalarEntry{&this->swmin_,
1506 [](
const Context&
ectx)
1507 {
return ectx.hParams.swmin; }
1511 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1512 FluidSystem::phaseIsActive(waterPhaseIdx)
1514 Entry{ScalarEntry{&this->sgmax_,
1515 [](
const Context&
ectx)
1516 {
return ectx.hParams.sgmax; }
1520 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1521 FluidSystem::phaseIsActive(gasPhaseIdx)
1523 Entry{ScalarEntry{&this->shmax_,
1524 [](
const Context&
ectx)
1525 {
return ectx.hParams.shmax; }
1529 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1530 FluidSystem::phaseIsActive(gasPhaseIdx)
1532 Entry{ScalarEntry{&this->somin_,
1533 [](
const Context&
ectx)
1534 {
return ectx.hParams.somin; }
1538 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1539 FluidSystem::phaseIsActive(gasPhaseIdx)
1541 Entry{[&model = this->simulator_.model(),
this](
const Context&
ectx)
1545 const auto porv =
ectx.intQuants.referencePorosity()
1546 * model.dofTotalVolume(
ectx.globalDofIdx);
1548 this->aggregateAverageDensityContributions_(
ectx.fs,
ectx.globalDofIdx,
1549 static_cast<double>(porv));
1550 }, this->regionAvgDensity_.has_value()
1552 Entry{[&
extboC = this->extboC_](
const Context&
ectx)
1555 ectx.intQuants.xVolume().value(),
1556 ectx.intQuants.yVolume().value());
1558 ectx.intQuants.zFraction().value());
1567 (1.0 -
ectx.intQuants.yVolume().value()) +
1571 (1.0 -
ectx.intQuants.xVolume().value());
1574 ectx.intQuants.yVolume().value() +
1578 ectx.intQuants.xVolume().value();
1579 const Scalar
rhoO = FluidSystem::referenceDensity(gasPhaseIdx,
ectx.pvtRegionIdx);
1580 const Scalar
rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
ectx.pvtRegionIdx);
1581 const Scalar
rhoCO2 =
ectx.intQuants.zRefDensity();
1583 extboC.assignMassFractions(
ectx.globalDofIdx,
1587 }, this->extboC_.allocated()
1592 ectx.intQuants.microbialConcentration().value(),
1593 ectx.intQuants.biofilmVolumeFraction().value());
1594 if (Indices::enableMICP) {
1596 ectx.intQuants.oxygenConcentration().value(),
1597 ectx.intQuants.ureaConcentration().value(),
1598 ectx.intQuants.calciteVolumeFraction().value());
1600 }, this->bioeffectsC_.allocated()
1602 Entry{[&
rftC = this->rftC_,
1603 &vanguard = this->simulator_.vanguard()](
const Context&
ectx)
1607 [&fs =
ectx.fs]() {
return getValue(fs.pressure(oilPhaseIdx)); },
1608 [&fs =
ectx.fs]() {
return getValue(fs.saturation(waterPhaseIdx)); },
1609 [&fs =
ectx.fs]() {
return getValue(fs.saturation(gasPhaseIdx)); });
1612 Entry{[&
tC = this->tracerC_,
1613 &
tM = this->simulator_.problem().tracerModel()](
const Context&
ectx)
1615 tC.assignFreeConcentrations(
ectx.globalDofIdx,
1618 tC.assignSolConcentrations(
ectx.globalDofIdx,
1623 Entry{[&
flowsInf = this->simulator_.problem().model().linearizer().getFlowsInfo(),
1624 &
flowsC = this->flowsC_](
const Context&
ectx)
1626 const auto gas_idx = Indices::gasEnabled ?
1627 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(gasCompIdx) : -1;
1628 const auto oil_idx = Indices::oilEnabled ?
1629 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(oilCompIdx) : -1;
1630 const auto water_idx = Indices::waterEnabled ?
1631 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(waterCompIdx) : -1;
1641 }, !this->simulator_.problem().model().linearizer().getFlowsInfo().empty()
1643 Entry{[&
floresInf = this->simulator_.problem().model().linearizer().getFloresInfo(),
1644 &
flowsC = this->flowsC_](
const Context&
ectx)
1646 const auto gas_idx = Indices::gasEnabled ?
1647 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(gasCompIdx) : -1;
1648 const auto oil_idx = Indices::oilEnabled ?
1649 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(oilCompIdx) : -1;
1650 const auto water_idx = Indices::waterEnabled ?
1651 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(waterCompIdx) : -1;
1661 }, !this->simulator_.problem().model().linearizer().getFloresInfo().empty()
1668 Entry{ScalarEntry{&this->rv_,
1669 [&problem = this->simulator_.problem()](
const Context&
ectx)
1670 {
return problem.initialFluidState(
ectx.globalDofIdx).Rv(); }
1672 simulator_.episodeIndex() < 0 &&
1673 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1674 FluidSystem::phaseIsActive(gasPhaseIdx)
1676 Entry{ScalarEntry{&this->rs_,
1677 [&problem = this->simulator_.problem()](
const Context&
ectx)
1678 {
return problem.initialFluidState(
ectx.globalDofIdx).Rs(); }
1680 simulator_.episodeIndex() < 0 &&
1681 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1682 FluidSystem::phaseIsActive(gasPhaseIdx)
1684 Entry{ScalarEntry{&this->rsw_,
1685 [&problem = this->simulator_.problem()](
const Context&
ectx)
1686 {
return problem.initialFluidState(
ectx.globalDofIdx).Rsw(); }
1688 simulator_.episodeIndex() < 0 &&
1689 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1690 FluidSystem::phaseIsActive(gasPhaseIdx)
1692 Entry{ScalarEntry{&this->rvw_,
1693 [&problem = this->simulator_.problem()](
const Context&
ectx)
1694 {
return problem.initialFluidState(
ectx.globalDofIdx).Rvw(); }
1696 simulator_.episodeIndex() < 0 &&
1697 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1698 FluidSystem::phaseIsActive(gasPhaseIdx)
1701 Entry{PhaseEntry{&this->density_,
1702 [&problem = this->simulator_.problem()](
const unsigned phase,
1703 const Context&
ectx)
1705 const auto&
fsInitial = problem.initialFluidState(
ectx.globalDofIdx);
1708 ectx.intQuants.pvtRegionIndex());
1711 simulator_.episodeIndex() < 0 &&
1712 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1713 FluidSystem::phaseIsActive(gasPhaseIdx)
1715 Entry{PhaseEntry{&this->invB_,
1716 [&problem = this->simulator_.problem()](
const unsigned phase,
1717 const Context&
ectx)
1719 const auto&
fsInitial = problem.initialFluidState(
ectx.globalDofIdx);
1720 return FluidSystem::inverseFormationVolumeFactor(
fsInitial,
1722 ectx.intQuants.pvtRegionIndex());
1725 simulator_.episodeIndex() < 0 &&
1726 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1727 FluidSystem::phaseIsActive(gasPhaseIdx)
1729 Entry{PhaseEntry{&this->viscosity_,
1730 [&problem = this->simulator_.problem()](
const unsigned phase,
1731 const Context&
ectx)
1733 const auto&
fsInitial = problem.initialFluidState(
ectx.globalDofIdx);
1734 return FluidSystem::viscosity(
fsInitial,
1736 ectx.intQuants.pvtRegionIndex());
1739 simulator_.episodeIndex() < 0 &&
1740 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1741 FluidSystem::phaseIsActive(gasPhaseIdx)
1749 if (this->mech_.allocated()) {
1750 this->extractors_.push_back(
1751 Entry{[&
mech = this->mech_,
1752 &model = simulator_.problem().geoMechModel()](
const Context&
ectx)
1754 mech.assignDelStress(
ectx.globalDofIdx,
1755 model.delstress(
ectx.globalDofIdx));
1757 mech.assignDisplacement(
ectx.globalDofIdx,
1758 model.disp(
ectx.globalDofIdx,
true));
1761 mech.assignFracStress(
ectx.globalDofIdx,
1762 model.fractureStress(
ectx.globalDofIdx));
1764 mech.assignLinStress(
ectx.globalDofIdx,
1765 model.linstress(
ectx.globalDofIdx));
1767 mech.assignPotentialForces(
ectx.globalDofIdx,
1768 model.mechPotentialForce(
ectx.globalDofIdx),
1769 model.mechPotentialPressForce(
ectx.globalDofIdx),
1770 model.mechPotentialTempForce(
ectx.globalDofIdx));
1772 mech.assignStrain(
ectx.globalDofIdx,
1773 model.strain(
ectx.globalDofIdx,
true));
1776 mech.assignStress(
ectx.globalDofIdx,
1777 model.stress(
ectx.globalDofIdx,
true));
1786 void setupBlockExtractors_(
const bool isSubStep,
1787 const int reportStepNum)
1790 using Context =
typename BlockExtractor::Context;
1791 using PhaseEntry =
typename BlockExtractor::PhaseEntry;
1792 using ScalarEntry =
typename BlockExtractor::ScalarEntry;
1794 using namespace std::string_view_literals;
1797 Entry{ScalarEntry{std::vector{
"BPR"sv,
"BPRESSUR"sv},
1798 [](
const Context&
ectx)
1800 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1803 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1815 Entry{PhaseEntry{std::array{
1816 std::array{
"BWSAT"sv,
"BOSAT"sv,
"BGSAT"sv},
1817 std::array{
"BSWAT"sv,
"BSOIL"sv,
"BSGAS"sv}
1825 Entry{ScalarEntry{
"BNSAT",
1826 [](
const Context&
ectx)
1828 return ectx.intQuants.solventSaturation().value();
1832 Entry{ScalarEntry{std::vector{
"BTCNFHEA"sv,
"BTEMP"sv},
1833 [](
const Context&
ectx)
1835 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1838 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1847 Entry{PhaseEntry{std::array{
1848 std::array{
"BWKR"sv,
"BOKR"sv,
"BGKR"sv},
1849 std::array{
"BKRW"sv,
"BKRO"sv,
"BKRG"sv}
1857 Entry{ScalarEntry{
"BKROG",
1858 [&problem = this->simulator_.problem()](
const Context&
ectx)
1861 problem.materialLawParams(
ectx.elemCtx,
1864 return getValue(MaterialLaw::template
1870 Entry{ScalarEntry{
"BKROW",
1871 [&problem = this->simulator_.problem()](
const Context&
ectx)
1876 return getValue(MaterialLaw::template
1882 Entry{ScalarEntry{
"BWPC",
1883 [](
const Context&
ectx)
1890 Entry{ScalarEntry{
"BGPC",
1891 [](
const Context&
ectx)
1898 Entry{ScalarEntry{
"BWPR",
1899 [](
const Context&
ectx)
1905 Entry{ScalarEntry{
"BGPR",
1906 [](
const Context&
ectx)
1912 Entry{PhaseEntry{std::array{
1913 std::array{
"BVWAT"sv,
"BVOIL"sv,
"BVGAS"sv},
1914 std::array{
"BWVIS"sv,
"BOVIS"sv,
"BGVIS"sv}
1922 Entry{PhaseEntry{std::array{
1923 std::array{
"BWDEN"sv,
"BODEN"sv,
"BGDEN"sv},
1924 std::array{
"BDENW"sv,
"BDENO"sv,
"BDENG"sv}
1932 Entry{ScalarEntry{
"BFLOWI",
1933 [&
flowsC = this->flowsC_](
const Context&
ectx)
1935 return flowsC.getFlow(
ectx.globalDofIdx, Dir::XPlus, waterCompIdx);
1939 Entry{ScalarEntry{
"BFLOWJ",
1940 [&
flowsC = this->flowsC_](
const Context&
ectx)
1942 return flowsC.getFlow(
ectx.globalDofIdx, Dir::YPlus, waterCompIdx);
1946 Entry{ScalarEntry{
"BFLOWK",
1947 [&
flowsC = this->flowsC_](
const Context&
ectx)
1949 return flowsC.getFlow(
ectx.globalDofIdx, Dir::ZPlus, waterCompIdx);
1953 Entry{ScalarEntry{
"BRPV",
1954 [&model = this->simulator_.model()](
const Context&
ectx)
1957 model.dofTotalVolume(
ectx.globalDofIdx);
1961 Entry{PhaseEntry{std::array{
"BWPV"sv,
"BOPV"sv,
"BGPV"sv},
1962 [&model = this->simulator_.model()](
const unsigned phaseIdx,
1963 const Context&
ectx)
1967 model.dofTotalVolume(
ectx.globalDofIdx);
1971 Entry{ScalarEntry{
"BRS",
1972 [](
const Context&
ectx)
1978 Entry{ScalarEntry{
"BRV",
1979 [](
const Context&
ectx)
1985 Entry{ScalarEntry{
"BOIP",
1986 [&model = this->simulator_.model()](
const Context&
ectx)
1993 model.dofTotalVolume(
ectx.globalDofIdx) *
1998 Entry{ScalarEntry{
"BGIP",
1999 [&model = this->simulator_.model()](
const Context&
ectx)
2004 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2016 model.dofTotalVolume(
ectx.globalDofIdx) *
2021 Entry{ScalarEntry{
"BWIP",
2022 [&model = this->simulator_.model()](
const Context&
ectx)
2026 model.dofTotalVolume(
ectx.globalDofIdx) *
2031 Entry{ScalarEntry{
"BOIPL",
2032 [&model = this->simulator_.model()](
const Context&
ectx)
2036 model.dofTotalVolume(
ectx.globalDofIdx) *
2041 Entry{ScalarEntry{
"BGIPL",
2042 [&model = this->simulator_.model()](
const Context&
ectx)
2045 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2056 model.dofTotalVolume(
ectx.globalDofIdx) *
2061 Entry{ScalarEntry{
"BGIPG",
2062 [&model = this->simulator_.model()](
const Context&
ectx)
2066 model.dofTotalVolume(
ectx.globalDofIdx) *
2071 Entry{ScalarEntry{
"BOIPG",
2072 [&model = this->simulator_.model()](
const Context&
ectx)
2077 model.dofTotalVolume(
ectx.globalDofIdx) *
2082 Entry{PhaseEntry{std::array{
"BPPW"sv,
"BPPO"sv,
"BPPG"sv},
2083 [&
simConfig = this->eclState_.getSimulationConfig(),
2084 &
grav = this->simulator_.problem().gravity(),
2086 &problem = this->simulator_.problem(),
2089 auto phase = RegionPhasePoreVolAverage::Phase{};
2102 const auto region = RegionPhasePoreVolAverage::Region {
2103 ectx.elemCtx.primaryVars(
ectx.dofIdx, 0).pvtRegionIndex() + 1
2108 const auto press =
getValue(
ectx.fs.pressure(phase.ix));
2109 const auto dz = problem.dofCenterDepth(
ectx.globalDofIdx) - datum;
2110 return press - density*
dz*
grav[GridView::dimensionworld - 1];
2114 Entry{ScalarEntry{
"BAMIP",
2115 [&model = this->simulator_.model()](
const Context&
ectx)
2117 const Scalar
rhoW = FluidSystem::referenceDensity(waterPhaseIdx,
2118 ectx.intQuants.pvtRegionIndex());
2122 model.dofTotalVolume(
ectx.globalDofIdx) *
2127 Entry{ScalarEntry{
"BMMIP",
2128 [&model = this->simulator_.model()](
const Context&
ectx)
2130 return getValue(
ectx.intQuants.microbialConcentration()) *
2133 model.dofTotalVolume(
ectx.globalDofIdx);
2137 Entry{ScalarEntry{
"BMOIP",
2138 [&model = this->simulator_.model()](
const Context&
ectx)
2140 return getValue(
ectx.intQuants.oxygenConcentration()) *
2142 model.dofTotalVolume(
ectx.globalDofIdx);
2146 Entry{ScalarEntry{
"BMUIP",
2147 [&model = this->simulator_.model()](
const Context&
ectx)
2151 model.dofTotalVolume(
ectx.globalDofIdx) * 1;
2155 Entry{ScalarEntry{
"BMBIP",
2156 [&model = this->simulator_.model()](
const Context&
ectx)
2158 return model.dofTotalVolume(
ectx.globalDofIdx) *
2163 Entry{ScalarEntry{
"BMCIP",
2164 [&model = this->simulator_.model()](
const Context&
ectx)
2166 return model.dofTotalVolume(
ectx.globalDofIdx) *
2171 Entry{ScalarEntry{
"BGMIP",
2172 [&model = this->simulator_.model()](
const Context&
ectx)
2177 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2187 const Scalar
rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
2188 ectx.intQuants.pvtRegionIndex());
2190 model.dofTotalVolume(
ectx.globalDofIdx) *
2196 Entry{ScalarEntry{
"BGMGP",
2197 [&model = this->simulator_.model()](
const Context&
ectx)
2199 const Scalar
rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
2200 ectx.intQuants.pvtRegionIndex());
2203 model.dofTotalVolume(
ectx.globalDofIdx) *
2209 Entry{ScalarEntry{
"BGMDS",
2210 [&model = this->simulator_.model()](
const Context&
ectx)
2213 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2223 const Scalar
rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
2224 ectx.intQuants.pvtRegionIndex());
2226 model.dofTotalVolume(
ectx.globalDofIdx) *
2232 Entry{ScalarEntry{
"BGMST",
2233 [&model = this->simulator_.model(),
2234 &problem = this->simulator_.problem()](
const Context&
ectx)
2237 ->oilWaterScaledEpsInfoDrainage(
ectx.dofIdx);
2238 const Scalar sg =
getValue(
ectx.fs.saturation(gasPhaseIdx));
2240 if (problem.materialLawManager()->enableHysteresis()) {
2241 const auto&
matParams = problem.materialLawParams(
ectx.dofIdx);
2242 const Scalar
krg =
getValue(
ectx.intQuants.relativePermeability(gasPhaseIdx));
2243 strandedGas = MaterialLaw::strandedGasSaturation(
matParams, sg,
krg);
2245 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
2246 FluidSystem::convertRvwToXgW(
getValue(
ectx.fs.Rvw()),
ectx.intQuants.pvtRegionIndex())
2248 return (1.0 - xgW) *
2249 model.dofTotalVolume(
ectx.globalDofIdx) *
2252 std::min(strandedGas, sg);
2256 Entry{ScalarEntry{
"BGMUS",
2257 [&model = this->simulator_.model(),
2258 &problem = this->simulator_.problem()](
const Context&
ectx)
2261 ->oilWaterScaledEpsInfoDrainage(
ectx.dofIdx);
2262 const Scalar sg =
getValue(
ectx.fs.saturation(gasPhaseIdx));
2264 if (problem.materialLawManager()->enableHysteresis()) {
2265 const auto&
matParams = problem.materialLawParams(
ectx.dofIdx);
2266 const Scalar
krg =
getValue(
ectx.intQuants.relativePermeability(gasPhaseIdx));
2267 strandedGas = MaterialLaw::strandedGasSaturation(
matParams, sg,
krg);
2269 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
2270 FluidSystem::convertRvwToXgW(
getValue(
ectx.fs.Rvw()),
ectx.intQuants.pvtRegionIndex())
2272 return (1.0 - xgW) *
2273 model.dofTotalVolume(
ectx.globalDofIdx) *
2276 std::max(Scalar{0.0}, sg - strandedGas);
2280 Entry{ScalarEntry{
"BGMTR",
2281 [&model = this->simulator_.model(),
2282 &problem = this->simulator_.problem()](
const Context&
ectx)
2285 ->oilWaterScaledEpsInfoDrainage(
ectx.dofIdx);
2287 if (problem.materialLawManager()->enableHysteresis()) {
2288 const auto&
matParams = problem.materialLawParams(
ectx.dofIdx);
2289 trappedGas = MaterialLaw::trappedGasSaturation(
matParams,
true);
2291 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
2292 FluidSystem::convertRvwToXgW(
getValue(
ectx.fs.Rvw()),
ectx.intQuants.pvtRegionIndex())
2294 return (1.0 - xgW) *
2295 model.dofTotalVolume(
ectx.globalDofIdx) *
2298 std::min(trappedGas,
getValue(
ectx.fs.saturation(gasPhaseIdx)));
2302 Entry{ScalarEntry{
"BGMMO",
2303 [&model = this->simulator_.model(),
2304 &problem = this->simulator_.problem()](
const Context&
ectx)
2307 ->oilWaterScaledEpsInfoDrainage(
ectx.dofIdx);
2309 if (problem.materialLawManager()->enableHysteresis()) {
2310 const auto&
matParams = problem.materialLawParams(
ectx.dofIdx);
2311 trappedGas = MaterialLaw::trappedGasSaturation(
matParams,
true);
2313 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
2314 FluidSystem::convertRvwToXgW(
getValue(
ectx.fs.Rvw()),
ectx.intQuants.pvtRegionIndex())
2316 return (1.0 - xgW) *
2317 model.dofTotalVolume(
ectx.globalDofIdx) *
2320 std::max(Scalar{0.0},
getValue(
ectx.fs.saturation(gasPhaseIdx)) - trappedGas);
2324 Entry{ScalarEntry{
"BGKTR",
2325 [&model = this->simulator_.model(),
2326 &problem = this->simulator_.problem()](
const Context&
ectx)
2329 ->oilWaterScaledEpsInfoDrainage(
ectx.dofIdx);
2330 const Scalar sg =
getValue(
ectx.fs.saturation(gasPhaseIdx));
2332 if (problem.materialLawManager()->enableHysteresis()) {
2333 const auto&
matParams = problem.materialLawParams(
ectx.dofIdx);
2334 sgcr = MaterialLaw::trappedGasSaturation(
matParams,
false);
2340 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
2341 FluidSystem::convertRvwToXgW(
getValue(
ectx.fs.Rvw()),
ectx.intQuants.pvtRegionIndex())
2343 return (1.0 - xgW) *
2344 model.dofTotalVolume(
ectx.globalDofIdx) *
2352 Entry{ScalarEntry{
"BGKMO",
2353 [&model = this->simulator_.model(),
2354 &problem = this->simulator_.problem()](
const Context&
ectx)
2357 ->oilWaterScaledEpsInfoDrainage(
ectx.dofIdx);
2358 const Scalar sg =
getValue(
ectx.fs.saturation(gasPhaseIdx));
2360 if (problem.materialLawManager()->enableHysteresis()) {
2361 const auto&
matParams = problem.materialLawParams(
ectx.dofIdx);
2362 sgcr = MaterialLaw::trappedGasSaturation(
matParams,
false);
2368 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
2369 FluidSystem::convertRvwToXgW(
getValue(
ectx.fs.Rvw()),
ectx.intQuants.pvtRegionIndex())
2371 return (1.0 - xgW) *
2372 model.dofTotalVolume(
ectx.globalDofIdx) *
2380 Entry{ScalarEntry{
"BGCDI",
2381 [&model = this->simulator_.model(),
2382 &problem = this->simulator_.problem()](
const Context&
ectx)
2385 ->oilWaterScaledEpsInfoDrainage(
ectx.dofIdx);
2387 if (problem.materialLawManager()->enableHysteresis()) {
2388 const auto&
matParams = problem.materialLawParams(
ectx.dofIdx);
2389 sgcr = MaterialLaw::trappedGasSaturation(
matParams,
false);
2391 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
2392 FluidSystem::convertRvwToXgW(
getValue(
ectx.fs.Rvw()),
ectx.intQuants.pvtRegionIndex())
2394 return (1.0 - xgW) *
2395 model.dofTotalVolume(
ectx.globalDofIdx) *
2398 std::min(sgcr,
getValue(
ectx.fs.saturation(gasPhaseIdx))) /
2399 FluidSystem::molarMass(gasCompIdx,
ectx.intQuants.pvtRegionIndex());
2403 Entry{ScalarEntry{
"BGCDM",
2404 [&model = this->simulator_.model(),
2405 &problem = this->simulator_.problem()](
const Context&
ectx)
2408 ->oilWaterScaledEpsInfoDrainage(
ectx.dofIdx);
2410 if (problem.materialLawManager()->enableHysteresis()) {
2411 const auto&
matParams = problem.materialLawParams(
ectx.dofIdx);
2412 sgcr = MaterialLaw::trappedGasSaturation(
matParams,
false);
2414 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
2415 FluidSystem::convertRvwToXgW(
getValue(
ectx.fs.Rvw()),
ectx.intQuants.pvtRegionIndex())
2417 return (1.0 - xgW) *
2418 model.dofTotalVolume(
ectx.globalDofIdx) *
2421 std::max(Scalar{0.0},
getValue(
ectx.fs.saturation(gasPhaseIdx)) - sgcr) /
2422 FluidSystem::molarMass(gasCompIdx,
ectx.intQuants.pvtRegionIndex());
2426 Entry{ScalarEntry{
"BGKDI",
2427 [&model = this->simulator_.model(),
2428 &problem = this->simulator_.problem()](
const Context&
ectx)
2431 ->oilWaterScaledEpsInfoDrainage(
ectx.dofIdx);
2432 const Scalar sg =
getValue(
ectx.fs.saturation(gasPhaseIdx));
2434 if (problem.materialLawManager()->enableHysteresis()) {
2435 const auto&
matParams = problem.materialLawParams(
ectx.dofIdx);
2436 sgcr = MaterialLaw::trappedGasSaturation(
matParams,
false);
2442 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
2443 FluidSystem::convertRvwToXgW(
getValue(
ectx.fs.Rvw()),
ectx.intQuants.pvtRegionIndex())
2445 return (1.0 - xgW) *
2446 model.dofTotalVolume(
ectx.globalDofIdx) *
2450 FluidSystem::molarMass(gasCompIdx,
ectx.intQuants.pvtRegionIndex());
2455 Entry{ScalarEntry{
"BGKDM",
2456 [&model = this->simulator_.model(),
2457 &problem = this->simulator_.problem()](
const Context&
ectx)
2460 ->oilWaterScaledEpsInfoDrainage(
ectx.dofIdx);
2461 const Scalar sg =
getValue(
ectx.fs.saturation(gasPhaseIdx));
2463 if (problem.materialLawManager()->enableHysteresis()) {
2464 const auto&
matParams = problem.materialLawParams(
ectx.dofIdx);
2465 sgcr = MaterialLaw::trappedGasSaturation(
matParams,
false);
2471 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
2472 FluidSystem::convertRvwToXgW(
getValue(
ectx.fs.Rvw()),
ectx.intQuants.pvtRegionIndex())
2474 return (1.0 - xgW) *
2475 model.dofTotalVolume(
ectx.globalDofIdx) *
2479 FluidSystem::molarMass(gasCompIdx,
ectx.intQuants.pvtRegionIndex());
2484 Entry{ScalarEntry{
"BWCD",
2485 [&model = this->simulator_.model()](
const Context&
ectx)
2488 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2498 const Scalar
rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
2499 ectx.intQuants.pvtRegionIndex());
2501 model.dofTotalVolume(
ectx.globalDofIdx) *
2504 FluidSystem::molarMass(gasCompIdx,
ectx.intQuants.pvtRegionIndex());
2508 Entry{ScalarEntry{
"BWIPG",
2509 [&model = this->simulator_.model()](
const Context&
ectx)
2512 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
2518 model.dofTotalVolume(
ectx.globalDofIdx) *
2523 Entry{ScalarEntry{
"BWIPL",
2524 [&model = this->simulator_.model()](
const Context&
ectx)
2528 model.dofTotalVolume(
ectx.globalDofIdx) *
2537 this->extraBlockData_.clear();
2540 const auto&
rpt = this->schedule_[reportStepNum - 1].rpt_config.get();
2541 if (
rpt.contains(
"WELLS") &&
rpt.at(
"WELLS") > 1) {
2542 this->setupExtraBlockData(reportStepNum,
2543 [&
c = this->collectOnIORank_](
const int idx)
2544 {
return c.isCartIdxOnThisRank(
idx); });
2555 const Simulator& simulator_;
2556 const CollectDataOnIORankType& collectOnIORank_;
2557 std::vector<typename Extractor::Entry> extractors_;