27#ifndef OPM_OUTPUT_BLACK_OIL_MODULE_HPP
28#define OPM_OUTPUT_BLACK_OIL_MODULE_HPP
30#include <dune/common/fvector.hh>
32#include <opm/grid/CpGrid.hpp>
36#include <opm/common/Exceptions.hpp>
37#include <opm/common/TimingMacros.hpp>
38#include <opm/common/OpmLog/OpmLog.hpp>
39#include <opm/common/utility/Visitor.hpp>
41#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
43#include <opm/material/common/Valgrind.hpp>
44#include <opm/material/fluidmatrixinteractions/EclEpsScalingPoints.hpp>
45#include <opm/material/fluidstates/BlackOilFluidState.hpp>
46#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
53#include <opm/output/data/Cells.hpp>
54#include <opm/output/data/RegionVariableMapping.hpp>
56#include <opm/output/eclipse/EclipseIO.hpp>
57#include <opm/output/eclipse/Inplace.hpp>
58#include <opm/output/eclipse/RegionVariableCollection.hpp>
82template <
class TypeTag>
83class EcfvDiscretization;
87 template <
typename... T>
97template <
class TypeTag>
109 using FluidState =
typename IntensiveQuantities::FluidState;
111 using Element =
typename GridView::template Codim<0>::Entity;
112 using ElementIterator =
typename GridView::template Codim<0>::Iterator;
115 using Dir = FaceDir::DirEnum;
122 static constexpr int conti0EqIdx = Indices::conti0EqIdx;
123 static constexpr int numPhases = FluidSystem::numPhases;
124 static constexpr int oilPhaseIdx = FluidSystem::oilPhaseIdx;
125 static constexpr int gasPhaseIdx = FluidSystem::gasPhaseIdx;
126 static constexpr int waterPhaseIdx = FluidSystem::waterPhaseIdx;
127 static constexpr int gasCompIdx = FluidSystem::gasCompIdx;
128 static constexpr int oilCompIdx = FluidSystem::oilCompIdx;
129 static constexpr int waterCompIdx = FluidSystem::waterCompIdx;
130 static constexpr EnergyModules energyModuleType = getPropValue<TypeTag, Properties::EnergyModuleType>();
131 static constexpr bool enableBioeffects = getPropValue<TypeTag, Properties::EnableBioeffects>();
132 static constexpr bool enableExtbo = getPropValue<TypeTag, Properties::EnableExtbo>();
133 static constexpr bool enableFoam = getPropValue<TypeTag, Properties::EnableFoam>();
134 static constexpr bool enablePolymer = getPropValue<TypeTag, Properties::EnablePolymer>();
135 static constexpr bool enableSolvent = getPropValue<TypeTag, Properties::EnableSolvent>();
136 enum { enableMICP = Indices::enableMICP };
137 enum { enableVapwat = getPropValue<TypeTag, Properties::EnableVapwat>() };
138 enum { enableDisgasInWater = getPropValue<TypeTag, Properties::EnableDisgasInWater>() };
139 static constexpr bool enableDissolvedGas =
140 Indices::compositionSwitchIdx != std::numeric_limits<unsigned>::max();
142 template<
class VectorType>
143 static Scalar value_or_zero(
int idx,
const VectorType& v)
148 return v.empty() ? 0.0 : v[idx];
153 const SummaryConfig& smryCfg,
155 :
BaseType(simulator.vanguard().eclState(),
156 simulator.vanguard().schedule(),
158 simulator.vanguard().summaryState(),
160 [this](const int idx)
161 {
return simulator_.problem().eclWriter().collectOnIORank().localIdxToGlobalIdx(idx); },
162 [&collectOnIORank](
const int idx)
163 {
return collectOnIORank.isCartIdxOnThisRank(idx); },
164 simulator.vanguard().grid().comm(),
165 energyModuleType == EnergyModules::FullyImplicitThermal ||
166 energyModuleType == EnergyModules::SequentialImplicitThermal,
167 energyModuleType == EnergyModules::ConstantTemperature,
168 getPropValue<TypeTag, Properties::EnableMech>(),
169 getPropValue<TypeTag, Properties::EnableSolvent>(),
170 getPropValue<TypeTag, Properties::EnablePolymer>(),
171 getPropValue<TypeTag, Properties::EnableFoam>(),
172 getPropValue<TypeTag, Properties::EnableBrine>(),
173 getPropValue<TypeTag, Properties::EnableSaltPrecipitation>(),
174 getPropValue<TypeTag, Properties::EnableExtbo>(),
175 getPropValue<TypeTag, Properties::EnableBioeffects>(),
176 getPropValue<TypeTag, Properties::EnableGeochemistry>())
177 , simulator_(simulator)
178 , collectOnIORank_(collectOnIORank)
180 for (
auto& region_pair : this->
regions_) {
181 this->createLocalRegion_(region_pair.second);
184 auto isCartIdxOnThisRank = [&collectOnIORank](
const int idx) {
185 return collectOnIORank.isCartIdxOnThisRank(idx);
197 std::set<std::pair<int, int>> ownedLgrCells;
198 std::map<std::string, int> lgrNameToLevel;
199 if constexpr (std::is_same_v<Grid, Dune::CpGrid>) {
202 lgrNameToLevel = simulator.vanguard().grid().getLgrNameToLevel();
203 for (
const auto& element : elements(simulator.gridView())) {
204 const int level = element.level();
205 if (level > 0 && element.partitionType() == Dune::InteriorEntity) {
206 const int levelCompressed = element.getLevelElem().index();
207 const int levelCart = simulator.vanguard()
208 .levelCartesianIndexMapper()
209 .cartesianIndex(levelCompressed, level);
210 ownedLgrCells.emplace(level, levelCart);
216 [&ownedLgrCells](
const int level,
const int levelCart) {
217 return ownedLgrCells.count(std::make_pair(level, levelCart)) > 0;
220 if (! Parameters::Get<Parameters::OwnerCellsFirst>()) {
221 const std::string msg =
"The output code does not support --owner-cells-first=false.";
222 if (collectOnIORank.isIORank()) {
225 OPM_THROW_NOLOG(std::runtime_error, msg);
228 if (smryCfg.match(
"[FB]PP[OGW]") || smryCfg.match(
"RPP[OGW]*")) {
229 auto rset = this->
eclState_.fieldProps().fip_regions();
230 rset.push_back(
"PVTNUM");
236 .emplace(this->simulator_.gridView().comm(),
237 FluidSystem::numPhases, rset,
238 [fp = std::cref(this->eclState_.fieldProps())]
239 (
const std::string& rsetName) ->
decltype(
auto)
240 { return fp.get().get_int(rsetName); });
250 const unsigned reportStepNum,
253 const bool isRestart)
259 const auto& problem = this->simulator_.problem();
266 &problem.materialLawManager()->hysteresisConfig(),
267 problem.eclWriter().getOutputNnc().front().size());
272 const int reportStepNum)
274 this->setupElementExtractors_();
275 this->setupBlockExtractors_(isSubStep, reportStepNum);
281 this->extractors_.clear();
282 this->blockExtractors_.clear();
283 this->extraBlockExtractors_.clear();
284 this->lgrBlockExtractors_.clear();
295 using M = UnitSystem::measure;
296 this->
assignBuffer(sol,
"1OVERBO", M::oil_inverse_formation_volume_factor,
297 this->invB_[oilPhaseIdx], oilPhaseIdx);
298 this->
assignBuffer(sol,
"1OVERBG", M::gas_inverse_formation_volume_factor,
299 this->invB_[gasPhaseIdx], gasPhaseIdx);
301 this->relativePermeability_[oilPhaseIdx], oilPhaseIdx);
303 this->relativePermeability_[gasPhaseIdx], gasPhaseIdx);
304 this->
assignBuffer(sol,
"PBUB", M::pressure, this->bubblePointPressure_);
305 this->
assignBuffer(sol,
"PDEW", M::pressure, this->dewPointPressure_);
306 this->
assignBuffer(sol,
"RS", M::gas_oil_ratio, this->rs_);
307 this->
assignBuffer(sol,
"RV", M::oil_gas_ratio, this->rv_);
310 if constexpr (numPhases > 2) {
311 this->
assignBuffer(sol,
"1OVERBW", M::water_inverse_formation_volume_factor,
312 this->invB_[waterPhaseIdx], waterPhaseIdx);
314 this->relativePermeability_[waterPhaseIdx], waterPhaseIdx);
321 .gasDensity =
"GAS_DEN",
322 .waterDensity =
"WAT_DEN",
323 .oilViscosity =
"OIL_VISC",
324 .gasViscosity =
"GAS_VISC",
325 .waterViscosity =
"WAT_VISC",
340 if (this->extractors_.empty()) {
344 const auto& matLawManager = simulator_.problem().materialLawManager();
347 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++dofIdx) {
348 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, 0);
349 const auto& fs = intQuants.fluidState();
352 elemCtx.globalSpaceIndex(dofIdx, 0),
353 elemCtx.primaryVars(dofIdx, 0).pvtRegionIndex(),
360 if (matLawManager->enableHysteresis()) {
361 if (FluidSystem::phaseIsActive(oilPhaseIdx) && FluidSystem::phaseIsActive(waterPhaseIdx)) {
362 matLawManager->oilWaterHysteresisParams(hysterParams.
somax,
367 if (FluidSystem::phaseIsActive(oilPhaseIdx) && FluidSystem::phaseIsActive(gasPhaseIdx)) {
368 matLawManager->gasOilHysteresisParams(hysterParams.
sgmax,
386 if (this->blockExtractors_.empty() &&
387 this->extraBlockExtractors_.empty() &&
388 this->lgrBlockExtractors_.empty())
399 const auto& element = elemCtx.element();
400 const int level = element.level();
402 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++dofIdx) {
403 const auto globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
405 const std::vector<typename BlockExtractor::Exec>* be_extractors =
nullptr;
406 const std::vector<typename BlockExtractor::Exec>* bee_extractors =
nullptr;
407 const std::vector<typename BlockExtractor::Exec>* lgr_extractors =
nullptr;
410 const auto cartesianIdx = elemCtx.simulator().vanguard().cartesianIndex(globalDofIdx);
411 const auto be_it = this->blockExtractors_.find(cartesianIdx);
412 const auto bee_it = this->extraBlockExtractors_.find(cartesianIdx);
413 if (be_it != this->blockExtractors_.end()) { be_extractors = &be_it->second; }
414 if (bee_it != this->extraBlockExtractors_.end()) { bee_extractors = &bee_it->second; }
416 else if constexpr (std::is_same_v<Grid, Dune::CpGrid>) {
428 const auto level_it = this->lgrBlockExtractors_.find(level);
429 if (level_it != this->lgrBlockExtractors_.end() &&
430 element.partitionType() == Dune::InteriorEntity)
432 const int levelCompressed = element.getLevelElem().index();
433 const int levelCart = elemCtx.simulator().vanguard()
434 .levelCartesianIndexMapper()
435 .cartesianIndex(levelCompressed, level);
436 const auto cell_it = level_it->second.find(levelCart);
437 if (cell_it != level_it->second.end()) {
438 lgr_extractors = &cell_it->second;
443 if (be_extractors ==
nullptr &&
444 bee_extractors ==
nullptr &&
445 lgr_extractors ==
nullptr)
450 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, 0);
451 const auto& fs = intQuants.fluidState();
468 const std::size_t reportStepNum,
470 boost::posix_time::ptime currentDate,
475 if (comm.rank() != 0) {
480 std::unique_ptr<FIPConfig> fipSched;
481 if (reportStepNum > 0) {
482 const auto& rpt = this->
schedule_[reportStepNum-1].rpt_config.get();
483 fipSched = std::make_unique<FIPConfig>(rpt);
485 const FIPConfig& fipc = reportStepNum == 0 ? this->
eclState_.getEclipseConfig().fip()
490 this->
logOutput_.timeStamp(
"BALANCE", elapsed, reportStepNum, currentDate);
493 this->
logOutput_.fip(inplace, initial_inplace,
"");
495 if (fipc.output(FIPConfig::OutputField::FIPNUM)) {
496 this->
logOutput_.fip(inplace, initial_inplace,
"FIPNUM");
498 if (fipc.output(FIPConfig::OutputField::RESV))
502 if (fipc.output(FIPConfig::OutputField::FIP)) {
503 for (
const auto& reg : this->regions_) {
504 if (reg.first !=
"FIPNUM") {
505 std::ostringstream ss;
506 ss <<
"BAL" << reg.first.substr(3);
507 this->
logOutput_.timeStamp(ss.str(), elapsed, reportStepNum, currentDate);
508 this->
logOutput_.fip(inplace, initial_inplace, reg.first);
510 if (fipc.output(FIPConfig::OutputField::RESV))
522 if (comm.rank() != 0) {
526 if ((reportStepNum == 0) && (!substep) &&
527 (this->
schedule_.initialReportConfiguration().has_value()) &&
528 (this->schedule_.initialReportConfiguration()->contains(
"CSVFIP"))) {
530 std::ostringstream csv_stream;
536 this->
logOutput_.fip_csv(csv_stream, initial_inplace,
"FIPNUM");
538 for (
const auto& reg : this->regions_) {
539 if (reg.first !=
"FIPNUM") {
540 this->
logOutput_.fip_csv(csv_stream, initial_inplace, reg.first);
544 const IOConfig& io = this->
eclState_.getIOConfig();
545 auto csv_fname = io.getOutputDir() +
"/" + io.getBaseName() +
".CSV";
547 std::ofstream outputFile(csv_fname);
549 outputFile << csv_stream.str();
583 template <
class ActiveIndex,
class CartesianIndex>
585 ActiveIndex&& activeIndex,
586 CartesianIndex&& cartesianIndex)
589 const auto identifyCell = [&activeIndex, &cartesianIndex](
const Element& elem)
592 const auto cellIndex = activeIndex(elem);
595 static_cast<int>(cellIndex),
596 cartesianIndex(cellIndex),
597 elem.partitionType() == Dune::InteriorEntity
601 const auto timeIdx = 0u;
602 const auto& stencil = elemCtx.stencil(timeIdx);
603 const auto numInteriorFaces = elemCtx.numInteriorFaces(timeIdx);
605 for (
auto scvfIdx = 0 * numInteriorFaces; scvfIdx < numInteriorFaces; ++scvfIdx) {
606 const auto& face = stencil.interiorFace(scvfIdx);
607 const auto left = identifyCell(stencil.element(face.interiorIndex()));
608 const auto right = identifyCell(stencil.element(face.exteriorIndex()));
610 const auto rates = this->
611 getComponentSurfaceRates(elemCtx, face.area(), scvfIdx, timeIdx);
644 template <
class Flu
idState>
647 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
651 fs.setSaturation(phaseIdx, this->
saturation_[phaseIdx][elemIdx]);
657 std::array<Scalar, numPhases> pc = {0};
658 const MaterialLawParams& matParams = simulator_.problem().materialLawParams(elemIdx);
659 MaterialLaw::capillaryPressures(pc, matParams, fs);
661 Valgrind::CheckDefined(pc);
663 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
664 if (!FluidSystem::phaseIsActive(phaseIdx))
667 if (Indices::oilEnabled)
668 fs.setPressure(phaseIdx, pressure + (pc[phaseIdx] - pc[oilPhaseIdx]));
669 else if (Indices::gasEnabled)
670 fs.setPressure(phaseIdx, pressure + (pc[phaseIdx] - pc[gasPhaseIdx]));
671 else if (Indices::waterEnabled)
673 fs.setPressure(phaseIdx, pressure);
677 if constexpr (energyModuleType != EnergyModules::NoTemperature) {
679 fs.setTemperature(this->temperature_[elemIdx]);
681 if constexpr (enableDissolvedGas) {
682 if (!this->rs_.empty())
683 fs.setRs(this->rs_[elemIdx]);
684 if (!this->rv_.empty())
685 fs.setRv(this->rv_[elemIdx]);
687 if constexpr (enableDisgasInWater) {
688 if (!this->
rsw_.empty())
689 fs.setRsw(this->rsw_[elemIdx]);
691 if constexpr (enableVapwat) {
692 if (!this->
rvw_.empty())
693 fs.setRvw(this->rvw_[elemIdx]);
699 if (!this->
soMax_.empty())
700 simulator.problem().setMaxOilSaturation(elemIdx, this->
soMax_[elemIdx]);
702 if (simulator.problem().materialLawManager()->enableHysteresis()) {
703 auto matLawManager = simulator.problem().materialLawManager();
705 if (FluidSystem::phaseIsActive(oilPhaseIdx)
706 && FluidSystem::phaseIsActive(waterPhaseIdx)) {
711 if (matLawManager->enableNonWettingHysteresis()) {
712 if (!this->
soMax_.empty()) {
713 somax = this->
soMax_[elemIdx];
716 if (matLawManager->enableWettingHysteresis()) {
717 if (!this->
swMax_.empty()) {
718 swmax = this->
swMax_[elemIdx];
721 if (matLawManager->enablePCHysteresis()) {
722 if (!this->
swmin_.empty()) {
723 swmin = this->
swmin_[elemIdx];
726 matLawManager->setOilWaterHysteresisParams(
727 somax, swmax, swmin, elemIdx);
729 if (FluidSystem::phaseIsActive(oilPhaseIdx)
730 && FluidSystem::phaseIsActive(gasPhaseIdx)) {
735 if (matLawManager->enableNonWettingHysteresis()) {
736 if (!this->
sgmax_.empty()) {
737 sgmax = this->
sgmax_[elemIdx];
740 if (matLawManager->enableWettingHysteresis()) {
741 if (!this->
shmax_.empty()) {
742 shmax = this->
shmax_[elemIdx];
745 if (matLawManager->enablePCHysteresis()) {
746 if (!this->
somin_.empty()) {
747 somin = this->
somin_[elemIdx];
750 matLawManager->setGasOilHysteresisParams(
751 sgmax, shmax, somin, elemIdx);
756 if (simulator_.vanguard().eclState().fieldProps().has_double(
"SWATINIT")) {
757 simulator.problem().materialLawManager()
758 ->applyRestartSwatInit(elemIdx, this->
ppcw_[elemIdx]);
764 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++dofIdx) {
765 updateFluidInPlace_(elemCtx, dofIdx);
770 const IntensiveQuantities& intQuants,
771 const double totVolume)
773 this->updateFluidInPlace_(globalDofIdx, intQuants, totVolume);
778 const unsigned elemIdx,
779 const unsigned globalDofIndex)
override
783 auto assign = [&sol, elemIdx, globalDofIndex](
const std::string& name,
786 if (!data.empty() && sol.has(name)) {
787 data[elemIdx] = sol.data<
double>(name)[globalDofIndex];
799 const unsigned bufferSize)
override
804 FluidSystem::enableDissolvedGas(),
true);
806 FluidSystem::enableVaporizedOil(),
true);
810 bubblePointPressure_,
"PBPD",
true)) {
811 dewPointPressure_.resize(bufferSize, 0.0);
815 constexpr auto phaseChar = std::string_view{
"WOG"};
816 for (
unsigned phase = 0; phase < numPhases; ++phase) {
817 if (!FluidSystem::phaseIsActive(phase)) {
823 std::string(
"B") + phaseChar[phase],
true);
825 std::string(
"KR") + phaseChar[phase],
true);
835 ScalarBuffer bubblePointPressure_;
836 ScalarBuffer dewPointPressure_;
837 std::array<ScalarBuffer, numPhases> invB_;
838 std::array<ScalarBuffer, numPhases> relativePermeability_;
839 template <
typename T>
840 using RemoveCVR = std::remove_cv_t<std::remove_reference_t<T>>;
842 template <
typename,
class =
void>
843 struct HasGeoMech :
public std::false_type {};
845 template <
typename Problem>
847 Problem, std::void_t<decltype(std::declval<Problem>().geoMechModel())>
848 > :
public std::true_type {};
850 template <
typename,
class =
void>
851 struct HasGeochemistry :
public std::false_type {};
853 template <
typename Problem>
854 struct HasGeochemistry<
855 Problem, std::void_t<decltype(std::declval<Problem>().geochemistryModel())>
856 > :
public std::true_type {};
858 bool isDefunctParallelWell(
const std::string& wname)
const override
860 if (simulator_.gridView().comm().size() == 1)
862 const auto& parallelWells = simulator_.vanguard().parallelWells();
863 std::pair<std::string, bool> value {wname,
true};
864 auto candidate = std::lower_bound(parallelWells.begin(), parallelWells.end(), value);
865 return candidate == parallelWells.end() || *candidate != value;
868 bool isOwnedByCurrentRank(
const std::string& wname)
const override
870 return this->simulator_.problem().wellModel().isOwner(wname);
873 bool isOnCurrentRank(
const std::string& wname)
const override
875 return this->simulator_.problem().wellModel().hasLocalCells(wname);
878 void updateFluidInPlace_(
const ElementContext& elemCtx,
const unsigned dofIdx)
880 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, 0);
881 const unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
882 const auto totVolume = elemCtx.simulator().model().dofTotalVolume(globalDofIdx);
884 this->updateFluidInPlace_(globalDofIdx, intQuants, totVolume);
887 void updateFluidInPlace_(
const unsigned globalDofIdx,
888 const IntensiveQuantities& intQuants,
889 const double totVolume)
893 this->updateTotalVolumesAndPressures_(globalDofIdx, intQuants, totVolume);
896 this->updatePhaseInplaceVolumes_(globalDofIdx, intQuants, totVolume);
900 void createLocalRegion_(std::vector<int>& region)
906 region.resize(simulator_.gridView().size(0));
907 std::size_t elemIdx = 0;
908 for (
const auto& elem : elements(simulator_.gridView())) {
909 if (elem.partitionType() != Dune::InteriorEntity) {
917 template <
typename Flu
idState>
918 void aggregateAverageDensityContributions_(
const FluidState& fs,
919 const unsigned int globalDofIdx,
922 auto pvCellValue = RegionPhasePoreVolAverage::CellValue{};
923 pvCellValue.porv = porv;
925 for (
auto phaseIdx = 0*FluidSystem::numPhases;
926 phaseIdx < FluidSystem::numPhases; ++phaseIdx)
928 if (! FluidSystem::phaseIsActive(phaseIdx)) {
932 pvCellValue.value = getValue(fs.density(phaseIdx));
933 pvCellValue.sat = getValue(fs.saturation(phaseIdx));
936 ->addCell(globalDofIdx,
957 data::InterRegFlowMap::FlowRates
958 getComponentSurfaceRates(
const ElementContext& elemCtx,
959 const Scalar faceArea,
960 const std::size_t scvfIdx,
961 const std::size_t timeIdx)
const
963 using Component = data::InterRegFlowMap::Component;
965 auto rates = data::InterRegFlowMap::FlowRates {};
967 const auto& extQuant = elemCtx.extensiveQuantities(scvfIdx, timeIdx);
969 const auto alpha = getValue(extQuant.extrusionFactor()) * faceArea;
971 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
972 const auto& up = elemCtx
973 .intensiveQuantities(extQuant.upstreamIndex(oilPhaseIdx), timeIdx);
975 const auto pvtReg = up.pvtRegionIndex();
977 const auto bO = getValue(getInvB_<FluidSystem, FluidState, Scalar>
978 (up.fluidState(), oilPhaseIdx, pvtReg));
980 const auto qO = alpha * bO * getValue(extQuant.volumeFlux(oilPhaseIdx));
982 rates[Component::Oil] += qO;
984 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
985 const auto Rs = getValue(
986 BlackOil::getRs_<FluidSystem, FluidState, Scalar>
987 (up.fluidState(), pvtReg));
989 rates[Component::Gas] += qO *
Rs;
990 rates[Component::Disgas] += qO *
Rs;
994 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
995 const auto& up = elemCtx
996 .intensiveQuantities(extQuant.upstreamIndex(gasPhaseIdx), timeIdx);
998 const auto pvtReg = up.pvtRegionIndex();
1000 const auto bG = getValue(getInvB_<FluidSystem, FluidState, Scalar>
1001 (up.fluidState(), gasPhaseIdx, pvtReg));
1003 const auto qG = alpha * bG * getValue(extQuant.volumeFlux(gasPhaseIdx));
1005 rates[Component::Gas] += qG;
1007 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1008 const auto Rv = getValue(
1009 BlackOil::getRv_<FluidSystem, FluidState, Scalar>
1010 (up.fluidState(), pvtReg));
1012 rates[Component::Oil] += qG *
Rv;
1013 rates[Component::Vapoil] += qG *
Rv;
1017 if (FluidSystem::phaseIsActive(waterPhaseIdx)) {
1018 const auto& up = elemCtx
1019 .intensiveQuantities(extQuant.upstreamIndex(waterPhaseIdx), timeIdx);
1021 const auto pvtReg = up.pvtRegionIndex();
1023 const auto bW = getValue(getInvB_<FluidSystem, FluidState, Scalar>
1024 (up.fluidState(), waterPhaseIdx, pvtReg));
1026 rates[Component::Water] +=
1027 alpha * bW * getValue(extQuant.volumeFlux(waterPhaseIdx));
1033 template <
typename Flu
idState>
1034 Scalar hydroCarbonFraction(
const FluidState& fs)
const
1036 if (this->
eclState_.runspec().co2Storage()) {
1043 auto hydrocarbon = Scalar {0};
1044 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1045 hydrocarbon += getValue(fs.saturation(oilPhaseIdx));
1048 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1049 hydrocarbon += getValue(fs.saturation(gasPhaseIdx));
1055 void updateTotalVolumesAndPressures_(
const unsigned globalDofIdx,
1056 const IntensiveQuantities& intQuants,
1057 const double totVolume)
1059 const auto& fs = intQuants.fluidState();
1061 const double pv = totVolume * intQuants.porosity().value();
1062 const auto hydrocarbon = this->hydroCarbonFraction(fs);
1065 totVolume * intQuants.referencePorosity(),
1072 !this->pressureTimesPoreVolume_.empty())
1075 assert(this->
fipC_.
get(Inplace::Phase::PoreVolume).size() == this->pressureTimesPoreVolume_.size());
1077 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1079 getValue(fs.pressure(oilPhaseIdx)) * pv;
1084 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1086 getValue(fs.pressure(gasPhaseIdx)) * pv;
1091 else if (FluidSystem::phaseIsActive(waterPhaseIdx)) {
1093 getValue(fs.pressure(waterPhaseIdx)) * pv;
1098 void updatePhaseInplaceVolumes_(
const unsigned globalDofIdx,
1099 const IntensiveQuantities& intQuants,
1100 const double totVolume)
1102 std::array<Scalar, FluidSystem::numPhases> fip {};
1103 std::array<Scalar, FluidSystem::numPhases> fipr{};
1105 const auto& fs = intQuants.fluidState();
1106 const auto pv = totVolume * intQuants.porosity().value();
1108 for (
unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) {
1109 if (!FluidSystem::phaseIsActive(phaseIdx)) {
1113 const auto b = getValue(fs.invB(phaseIdx));
1114 const auto s = getValue(fs.saturation(phaseIdx));
1116 fipr[phaseIdx] = s * pv;
1117 fip [phaseIdx] = b * fipr[phaseIdx];
1122 fs.saltConcentration().value(),
1125 if (FluidSystem::phaseIsActive(oilPhaseIdx) &&
1126 FluidSystem::phaseIsActive(gasPhaseIdx))
1128 this->updateOilGasDistribution(globalDofIdx, fs, fip);
1131 if (FluidSystem::phaseIsActive(waterPhaseIdx) &&
1132 FluidSystem::phaseIsActive(gasPhaseIdx))
1134 this->updateGasWaterDistribution(globalDofIdx, fs, fip);
1137 if (FluidSystem::phaseIsActive(gasPhaseIdx) &&
1140 this->updateCO2InGas(globalDofIdx, pv, intQuants);
1144 (FluidSystem::phaseIsActive(waterPhaseIdx) ||
1145 FluidSystem::phaseIsActive(oilPhaseIdx)))
1147 this->updateCO2InWater(globalDofIdx, pv, fs);
1150 if constexpr(enableBioeffects) {
1151 const auto surfVolWat = pv * getValue(fs.saturation(waterPhaseIdx)) *
1152 getValue(fs.invB(waterPhaseIdx));
1154 this->updateMicrobialMass(globalDofIdx, intQuants, surfVolWat);
1157 this->updateBiofilmMass(globalDofIdx, intQuants, totVolume);
1159 if constexpr(enableMICP) {
1161 this->updateOxygenMass(globalDofIdx, intQuants, surfVolWat);
1164 this->updateUreaMass(globalDofIdx, intQuants, surfVolWat);
1167 this->updateCalciteMass(globalDofIdx, intQuants, totVolume);
1174 this->updateWaterMass(globalDofIdx, fs, fip);
1178 template <
typename Flu
idState,
typename FIPArray>
1179 void updateOilGasDistribution(
const unsigned globalDofIdx,
1180 const FluidState& fs,
1181 const FIPArray& fip)
1184 const auto gasInPlaceLiquid = getValue(fs.Rs()) * fip[oilPhaseIdx];
1185 const auto oilInPlaceGas = getValue(fs.Rv()) * fip[gasPhaseIdx];
1190 template <
typename Flu
idState,
typename FIPArray>
1191 void updateGasWaterDistribution(
const unsigned globalDofIdx,
1192 const FluidState& fs,
1193 const FIPArray& fip)
1196 const auto gasInPlaceWater = getValue(fs.Rsw()) * fip[waterPhaseIdx];
1197 const auto waterInPlaceGas = getValue(fs.Rvw()) * fip[gasPhaseIdx];
1202 template <
typename IntensiveQuantities>
1203 void updateCO2InGas(
const unsigned globalDofIdx,
1205 const IntensiveQuantities& intQuants)
1207 const auto& scaledDrainageInfo = this->simulator_.problem().materialLawManager()
1208 ->oilWaterScaledEpsInfoDrainage(globalDofIdx);
1210 const auto& fs = intQuants.fluidState();
1211 Scalar sgcr = scaledDrainageInfo.Sgcr;
1212 if (this->simulator_.problem().materialLawManager()->enableHysteresis()) {
1213 const auto& matParams = simulator_.problem().materialLawParams(globalDofIdx);
1214 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
1217 Scalar trappedGasSaturation = scaledDrainageInfo.Sgcr;
1218 if (this->
fipC_.
has(Inplace::Phase::CO2MassInGasPhaseMaximumTrapped) ||
1219 this->fipC_.has(Inplace::Phase::CO2MassInGasPhaseMaximumUnTrapped))
1221 if (this->simulator_.problem().materialLawManager()->enableHysteresis()) {
1222 const auto& matParams = simulator_.problem().materialLawParams(globalDofIdx);
1224 trappedGasSaturation = MaterialLaw::trappedGasSaturation(matParams,
true);
1228 const Scalar sg = getValue(fs.saturation(gasPhaseIdx));
1229 Scalar strandedGasSaturation = scaledDrainageInfo.Sgcr;
1230 if (this->
fipC_.
has(Inplace::Phase::CO2MassInGasPhaseEffectiveTrapped) ||
1231 this->fipC_.has(Inplace::Phase::CO2MassInGasPhaseEffectiveUnTrapped))
1233 if (this->simulator_.problem().materialLawManager()->enableHysteresis()) {
1234 const auto& matParams = simulator_.problem().materialLawParams(globalDofIdx);
1235 const double krg = getValue(intQuants.relativePermeability(gasPhaseIdx));
1236 strandedGasSaturation = MaterialLaw::strandedGasSaturation(matParams, sg, krg);
1240 const typename FIPContainer<FluidSystem>::Co2InGasInput v{
1244 getValue(fs.density(gasPhaseIdx)),
1245 FluidSystem::phaseIsActive(waterPhaseIdx)
1246 ? FluidSystem::convertRvwToXgW(getValue(fs.Rvw()), fs.pvtRegionIndex())
1247 : FluidSystem::convertRvToXgO(getValue(fs.
Rv()), fs.pvtRegionIndex()),
1248 FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex()),
1249 trappedGasSaturation,
1250 strandedGasSaturation,
1256 template <
typename Flu
idState>
1257 void updateCO2InWater(
const unsigned globalDofIdx,
1259 const FluidState& fs)
1261 const auto co2InWater = FluidSystem::phaseIsActive(oilPhaseIdx)
1262 ? this->co2InWaterFromOil(fs, pv)
1263 : this->co2InWaterFromWater(fs, pv);
1265 const Scalar mM = FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex());
1270 template <
typename Flu
idState>
1271 Scalar co2InWaterFromWater(
const FluidState& fs,
const double pv)
const
1273 const double rhow = getValue(fs.density(waterPhaseIdx));
1274 const double sw = getValue(fs.saturation(waterPhaseIdx));
1275 const double xwG = FluidSystem::convertRswToXwG(getValue(fs.Rsw()), fs.pvtRegionIndex());
1277 const Scalar mM = FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex());
1279 return xwG * pv * rhow * sw / mM;
1282 template <
typename Flu
idState>
1283 Scalar co2InWaterFromOil(
const FluidState& fs,
const double pv)
const
1285 const double rhoo = getValue(fs.density(oilPhaseIdx));
1286 const double so = getValue(fs.saturation(oilPhaseIdx));
1287 const double xoG = FluidSystem::convertRsToXoG(getValue(fs.Rs()), fs.pvtRegionIndex());
1289 const Scalar mM = FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex());
1291 return xoG * pv * rhoo * so / mM;
1294 template <
typename Flu
idState,
typename FIPArray>
1295 void updateWaterMass(
const unsigned globalDofIdx,
1296 const FluidState& fs,
1300 const Scalar rhoW = FluidSystem::referenceDensity(waterPhaseIdx, fs.pvtRegionIndex());
1305 template <
typename IntensiveQuantities>
1306 void updateMicrobialMass(
const unsigned globalDofIdx,
1307 const IntensiveQuantities& intQuants,
1308 const double surfVolWat)
1310 const Scalar mass = surfVolWat * intQuants.microbialConcentration().value();
1315 template <
typename IntensiveQuantities>
1316 void updateOxygenMass(
const unsigned globalDofIdx,
1317 const IntensiveQuantities& intQuants,
1318 const double surfVolWat)
1320 const Scalar mass = surfVolWat * intQuants.oxygenConcentration().value();
1325 template <
typename IntensiveQuantities>
1326 void updateUreaMass(
const unsigned globalDofIdx,
1327 const IntensiveQuantities& intQuants,
1328 const double surfVolWat)
1330 const Scalar mass = surfVolWat * intQuants.ureaConcentration().value();
1335 template <
typename IntensiveQuantities>
1336 void updateBiofilmMass(
const unsigned globalDofIdx,
1337 const IntensiveQuantities& intQuants,
1338 const double totVolume)
1340 const Scalar mass = totVolume * intQuants.biofilmMass().value();
1345 template <
typename IntensiveQuantities>
1346 void updateCalciteMass(
const unsigned globalDofIdx,
1347 const IntensiveQuantities& intQuants,
1348 const double totVolume)
1350 const Scalar mass = totVolume * intQuants.calciteMass().value();
1356 void setupElementExtractors_()
1358 using Entry =
typename Extractor::Entry;
1359 using Context =
typename Extractor::Context;
1360 using ScalarEntry =
typename Extractor::ScalarEntry;
1361 using PhaseEntry =
typename Extractor::PhaseEntry;
1363 const bool hasResidual = simulator_.model().linearizer().residual().size() > 0;
1364 const auto& hysteresisConfig = simulator_.problem().materialLawManager()->hysteresisConfig();
1366 auto extractors = std::array{
1368 [](
const unsigned phase,
const Context& ectx)
1369 {
return getValue(ectx.fs.saturation(phase)); }
1372 Entry{PhaseEntry{&this->invB_,
1373 [](
const unsigned phase,
const Context& ectx)
1374 {
return getValue(ectx.fs.invB(phase)); }
1378 [](
const unsigned phase,
const Context& ectx)
1379 {
return getValue(ectx.fs.density(phase)); }
1382 Entry{PhaseEntry{&this->relativePermeability_,
1383 [](
const unsigned phase,
const Context& ectx)
1384 {
return getValue(ectx.intQuants.relativePermeability(phase)); }
1388 [
this](
const unsigned phaseIdx,
const Context& ectx)
1391 if constexpr (enableExtbo) {
1392 if (this->
extboC_.allocated() && phaseIdx == oilPhaseIdx) {
1393 return getValue(ectx.intQuants.oilViscosity());
1395 else if (this->
extboC_.allocated() && phaseIdx == gasPhaseIdx) {
1396 return getValue(ectx.intQuants.gasViscosity());
1399 return getValue(ectx.fs.viscosity(phaseIdx));
1404 [&modelResid = this->simulator_.model().linearizer().residual()]
1405 (
const unsigned phaseIdx,
const Context& ectx)
1407 const unsigned sIdx = FluidSystem::solventComponentIndex(phaseIdx);
1408 const unsigned activeCompIdx = FluidSystem::canonicalToActiveCompIdx(sIdx);
1409 return modelResid[ectx.globalDofIdx][activeCompIdx];
1415 [&problem = this->simulator_.problem()](
const Context& ectx)
1417 return problem.template
1418 rockCompPoroMultiplier<Scalar>(ectx.intQuants,
1424 [&problem = this->simulator_.problem()](
const Context& ectx)
1427 template rockCompTransMultiplier<Scalar>(ectx.intQuants,
1432 [&problem = this->simulator_.problem()](
const Context& ectx)
1434 return std::min(getValue(ectx.fs.pressure(oilPhaseIdx)),
1435 problem.minOilPressure(ectx.globalDofIdx));
1439 Entry{ScalarEntry{&this->bubblePointPressure_,
1441 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1445 FluidSystem::bubblePointPressure(ectx.fs,
1446 ectx.intQuants.pvtRegionIndex())
1448 }
catch (
const NumericalProblem&) {
1449 const auto cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1450 failedCells.push_back(cartesianIdx);
1456 Entry{ScalarEntry{&this->dewPointPressure_,
1458 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1462 FluidSystem::dewPointPressure(ectx.fs,
1463 ectx.intQuants.pvtRegionIndex())
1465 }
catch (
const NumericalProblem&) {
1466 const auto cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1467 failedCells.push_back(cartesianIdx);
1474 [&problem = simulator_.problem()](
const Context& ectx)
1475 {
return problem.overburdenPressure(ectx.globalDofIdx); }
1479 [](
const Context& ectx)
1480 {
return getValue(ectx.fs.temperature(oilPhaseIdx)); }
1483 Entry{ScalarEntry{&this->
sSol_,
1484 [](
const Context& ectx)
1486 if constexpr (enableSolvent) {
1487 return getValue(ectx.intQuants.solventSaturation());
1495 Entry{ScalarEntry{&this->
rswSol_,
1496 [](
const Context& ectx)
1498 if constexpr (enableSolvent) {
1499 return getValue(ectx.intQuants.rsSolw());
1508 [](
const Context& ectx)
1510 if constexpr (enablePolymer) {
1511 return getValue(ectx.intQuants.polymerConcentration());
1519 Entry{ScalarEntry{&this->
cFoam_,
1520 [](
const Context& ectx)
1522 if constexpr (enableFoam) {
1523 return getValue(ectx.intQuants.foamConcentration());
1531 Entry{ScalarEntry{&this->
cSalt_,
1532 [](
const Context& ectx)
1533 {
return getValue(ectx.fs.saltConcentration()); }
1536 Entry{ScalarEntry{&this->
pSalt_,
1537 [](
const Context& ectx)
1538 {
return getValue(ectx.fs.saltSaturation()); }
1542 [](
const Context& ectx)
1543 {
return getValue(ectx.intQuants.permFactor()); }
1546 Entry{ScalarEntry{&this->
rPorV_,
1547 [&model = this->simulator_.model()](
const Context& ectx)
1549 const auto totVolume = model.dofTotalVolume(ectx.globalDofIdx);
1550 return totVolume * getValue(ectx.intQuants.porosity());
1554 Entry{ScalarEntry{&this->rs_,
1555 [](
const Context& ectx)
1556 {
return getValue(ectx.fs.Rs()); }
1559 Entry{ScalarEntry{&this->rv_,
1560 [](
const Context& ectx)
1561 {
return getValue(ectx.fs.Rv()); }
1564 Entry{ScalarEntry{&this->
rsw_,
1565 [](
const Context& ectx)
1566 {
return getValue(ectx.fs.Rsw()); }
1569 Entry{ScalarEntry{&this->
rvw_,
1570 [](
const Context& ectx)
1571 {
return getValue(ectx.fs.Rvw()); }
1574 Entry{ScalarEntry{&this->
ppcw_,
1575 [&matLawManager = *this->simulator_.problem().materialLawManager()]
1576 (
const Context& ectx)
1578 return matLawManager.
1579 oilWaterScaledEpsInfoDrainage(ectx.globalDofIdx).maxPcow;
1584 [&problem = this->simulator_.problem()](
const Context& ectx)
1586 return problem.drsdtcon(ectx.globalDofIdx,
1591 Entry{ScalarEntry{&this->
pcgw_,
1592 [](
const Context& ectx)
1594 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
1595 getValue(ectx.fs.pressure(waterPhaseIdx));
1599 Entry{ScalarEntry{&this->
pcow_,
1600 [](
const Context& ectx)
1602 return getValue(ectx.fs.pressure(oilPhaseIdx)) -
1603 getValue(ectx.fs.pressure(waterPhaseIdx));
1607 Entry{ScalarEntry{&this->
pcog_,
1608 [](
const Context& ectx)
1610 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
1611 getValue(ectx.fs.pressure(oilPhaseIdx));
1616 [](
const Context& ectx)
1618 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1620 return getValue(ectx.fs.pressure(oilPhaseIdx));
1622 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1624 return getValue(ectx.fs.pressure(gasPhaseIdx));
1628 return getValue(ectx.fs.pressure(waterPhaseIdx));
1634 [&problem = this->simulator_.problem()](
const Context& ectx)
1636 const Scalar SoMax = problem.maxOilSaturation(ectx.globalDofIdx);
1637 return FluidSystem::template
1638 saturatedDissolutionFactor<FluidState, Scalar>(ectx.fs,
1646 [&problem = this->simulator_.problem()](
const Context& ectx)
1648 const Scalar SoMax = problem.maxOilSaturation(ectx.globalDofIdx);
1649 return FluidSystem::template
1650 saturatedDissolutionFactor<FluidState, Scalar>(ectx.fs,
1658 [&problem = this->simulator_.problem()](
const Context& ectx)
1660 const Scalar SwMax = problem.maxWaterSaturation(ectx.globalDofIdx);
1661 return FluidSystem::template
1662 saturatedDissolutionFactor<FluidState, Scalar>(ectx.fs,
1670 [](
const Context& ectx)
1672 return FluidSystem::template
1673 saturatedVaporizationFactor<FluidState, Scalar>(ectx.fs,
1680 [](
const Context& ectx)
1682 return 1.0 / FluidSystem::template
1683 inverseFormationVolumeFactor<FluidState, Scalar>(ectx.fs,
1690 [](
const Context& ectx)
1692 return 1.0 / FluidSystem::template
1693 saturatedInverseFormationVolumeFactor<FluidState, Scalar>(ectx.fs,
1700 [](
const Context& ectx)
1702 return FluidSystem::template
1703 saturationPressure<FluidState, Scalar>(ectx.fs,
1709 Entry{ScalarEntry{&this->
soMax_,
1710 [&problem = this->simulator_.problem()](
const Context& ectx)
1712 return std::max(getValue(ectx.fs.saturation(oilPhaseIdx)),
1713 problem.maxOilSaturation(ectx.globalDofIdx));
1716 !hysteresisConfig.enableHysteresis()
1718 Entry{ScalarEntry{&this->
swMax_,
1719 [&problem = this->simulator_.problem()](
const Context& ectx)
1721 return std::max(getValue(ectx.fs.saturation(waterPhaseIdx)),
1722 problem.maxWaterSaturation(ectx.globalDofIdx));
1725 !hysteresisConfig.enableHysteresis()
1727 Entry{ScalarEntry{&this->
soMax_,
1728 [](
const Context& ectx)
1729 {
return ectx.hParams.somax; }
1731 hysteresisConfig.enableHysteresis() &&
1732 hysteresisConfig.enableNonWettingHysteresis() &&
1733 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1734 FluidSystem::phaseIsActive(waterPhaseIdx)
1736 Entry{ScalarEntry{&this->
swMax_,
1737 [](
const Context& ectx)
1738 {
return ectx.hParams.swmax; }
1740 hysteresisConfig.enableHysteresis() &&
1741 hysteresisConfig.enableWettingHysteresis() &&
1742 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1743 FluidSystem::phaseIsActive(waterPhaseIdx)
1745 Entry{ScalarEntry{&this->
swmin_,
1746 [](
const Context& ectx)
1747 {
return ectx.hParams.swmin; }
1749 hysteresisConfig.enableHysteresis() &&
1750 hysteresisConfig.enablePCHysteresis() &&
1751 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1752 FluidSystem::phaseIsActive(waterPhaseIdx)
1754 Entry{ScalarEntry{&this->
sgmax_,
1755 [](
const Context& ectx)
1756 {
return ectx.hParams.sgmax; }
1758 hysteresisConfig.enableHysteresis() &&
1759 hysteresisConfig.enableNonWettingHysteresis() &&
1760 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1761 FluidSystem::phaseIsActive(gasPhaseIdx)
1763 Entry{ScalarEntry{&this->
shmax_,
1764 [](
const Context& ectx)
1765 {
return ectx.hParams.shmax; }
1767 hysteresisConfig.enableHysteresis() &&
1768 hysteresisConfig.enableWettingHysteresis() &&
1769 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1770 FluidSystem::phaseIsActive(gasPhaseIdx)
1772 Entry{ScalarEntry{&this->
somin_,
1773 [](
const Context& ectx)
1774 {
return ectx.hParams.somin; }
1776 hysteresisConfig.enableHysteresis() &&
1777 hysteresisConfig.enablePCHysteresis() &&
1778 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1779 FluidSystem::phaseIsActive(gasPhaseIdx)
1781 Entry{[&model = this->simulator_.model(),
this](
const Context& ectx)
1785 const auto porv = ectx.intQuants.referencePorosity()
1786 * model.dofTotalVolume(ectx.globalDofIdx);
1788 this->aggregateAverageDensityContributions_(ectx.fs, ectx.globalDofIdx,
1789 static_cast<double>(porv));
1792 Entry{[&extboC = this->
extboC_](
const Context& ectx)
1795 if constexpr (enableExtbo) {
1796 extboC.assignVolumes(ectx.globalDofIdx,
1797 ectx.intQuants.xVolume().value(),
1798 ectx.intQuants.yVolume().value());
1799 extboC.assignZFraction(ectx.globalDofIdx,
1800 ectx.intQuants.zFraction().value());
1802 const Scalar stdVolOil = getValue(ectx.fs.saturation(oilPhaseIdx)) *
1803 getValue(ectx.fs.invB(oilPhaseIdx)) +
1804 getValue(ectx.fs.saturation(gasPhaseIdx)) *
1805 getValue(ectx.fs.invB(gasPhaseIdx)) *
1806 getValue(ectx.fs.Rv());
1807 const Scalar stdVolGas = getValue(ectx.fs.saturation(gasPhaseIdx)) *
1808 getValue(ectx.fs.invB(gasPhaseIdx)) *
1809 (1.0 - ectx.intQuants.yVolume().value()) +
1810 getValue(ectx.fs.saturation(oilPhaseIdx)) *
1811 getValue(ectx.fs.invB(oilPhaseIdx)) *
1812 getValue(ectx.fs.Rs()) *
1813 (1.0 - ectx.intQuants.xVolume().value());
1814 const Scalar stdVolCo2 = getValue(ectx.fs.saturation(gasPhaseIdx)) *
1815 getValue(ectx.fs.invB(gasPhaseIdx)) *
1816 ectx.intQuants.yVolume().value() +
1817 getValue(ectx.fs.saturation(oilPhaseIdx)) *
1818 getValue(ectx.fs.invB(oilPhaseIdx)) *
1819 getValue(ectx.fs.Rs()) *
1820 ectx.intQuants.xVolume().value();
1821 const Scalar rhoO = FluidSystem::referenceDensity(oilPhaseIdx, ectx.pvtRegionIdx);
1822 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx, ectx.pvtRegionIdx);
1823 const Scalar rhoCO2 = ectx.intQuants.zRefDensity();
1824 const Scalar stdMassTotal = 1.0e-10 + stdVolOil * rhoO + stdVolGas * rhoG + stdVolCo2 * rhoCO2;
1825 extboC.assignMassFractions(ectx.globalDofIdx,
1826 stdVolGas * rhoG / stdMassTotal,
1827 stdVolOil * rhoO / stdMassTotal,
1828 stdVolCo2 * rhoCO2 / stdMassTotal);
1832 Entry{[&bioeffectsC = this->
bioeffectsC_](
const Context& ectx)
1835 if constexpr (enableBioeffects) {
1836 bioeffectsC.assign(ectx.globalDofIdx,
1837 ectx.intQuants.microbialConcentration().value(),
1838 ectx.intQuants.biofilmVolumeFraction().value());
1839 if (Indices::enableMICP) {
1840 bioeffectsC.assign(ectx.globalDofIdx,
1841 ectx.intQuants.oxygenConcentration().value(),
1842 ectx.intQuants.ureaConcentration().value(),
1843 ectx.intQuants.calciteVolumeFraction().value());
1848 Entry{[&runspec = this->
eclState_.runspec(),
1849 &CO2H2C = this->
CO2H2C_](
const Context& ectx)
1851 const auto xwg = FluidSystem::convertRswToXwG(getValue(ectx.fs.Rsw()), ectx.pvtRegionIdx);
1852 const auto xgw = FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.pvtRegionIdx);
1853 CO2H2C.assign(ectx.globalDofIdx,
1854 FluidSystem::convertXwGToxwG(xwg, ectx.pvtRegionIdx),
1855 FluidSystem::convertXgWToxgW(xgw, ectx.pvtRegionIdx),
1856 runspec.co2Storage());
1859 Entry{[&rftC = this->
rftC_,
1860 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1862 const auto cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1863 rftC.assign(cartesianIdx,
1864 [&fs = ectx.fs]() {
return getValue(fs.pressure(oilPhaseIdx)); },
1865 [&fs = ectx.fs]() {
return getValue(fs.saturation(waterPhaseIdx)); },
1866 [&fs = ectx.fs]() {
return getValue(fs.saturation(gasPhaseIdx)); });
1870 &tM = this->simulator_.problem().tracerModel()](
const Context& ectx)
1872 tC.assignFreeConcentrations(ectx.globalDofIdx,
1873 [gIdx = ectx.globalDofIdx, &tM](
const unsigned tracerIdx)
1874 {
return tM.freeTracerConcentration(tracerIdx, gIdx); });
1875 tC.assignSolConcentrations(ectx.globalDofIdx,
1876 [gIdx = ectx.globalDofIdx, &tM](
const unsigned tracerIdx)
1877 {
return tM.solTracerConcentration(tracerIdx, gIdx); });
1880 Entry{[&flowsInf = this->simulator_.problem().model().linearizer().getFlowsInfo(),
1882 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1884 const auto gas_idx = Indices::gasEnabled ?
1885 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(gasCompIdx) : -1;
1886 const auto oil_idx = Indices::oilEnabled ?
1887 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(oilCompIdx) : -1;
1888 const auto water_idx = Indices::waterEnabled ?
1889 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(waterCompIdx) : -1;
1890 const auto& flowsInfos = flowsInf[ectx.globalDofIdx];
1891 if (!flowsC.blockFlows().empty()) {
1892 const std::vector<int>& blockIdxs = flowsC.blockFlows();
1893 const unsigned cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1894 if (std::ranges::binary_search(blockIdxs, cartesianIdx)) {
1895 const auto compIdxs = std::array{ gasCompIdx, oilCompIdx, waterCompIdx };
1896 const auto compEnabled = std::array{ Indices::gasEnabled, Indices::oilEnabled, Indices::waterEnabled };
1897 for (
const auto& flowsInfo : flowsInfos) {
1898 if (flowsInfo.faceId < 0) {
1901 for (
unsigned ii = 0; ii < compIdxs.size(); ++ii) {
1902 if (!compEnabled[ii]) {
1905 if (flowsC.hasBlockFlowValue(cartesianIdx, flowsInfo.faceId, compIdxs[ii])) {
1906 flowsC.assignBlockFlows(flowsC.blockFlowsIds(cartesianIdx, flowsInfo.faceId, compIdxs[ii]),
1909 flowsInfo.flow[conti0EqIdx
1910 + FluidSystem::canonicalToActiveCompIdx(compIdxs[ii])]);
1917 for (
const auto& flowsInfo : flowsInfos) {
1918 flowsC.assignFlows(ectx.globalDofIdx,
1921 value_or_zero(gas_idx, flowsInfo.flow),
1922 value_or_zero(oil_idx, flowsInfo.flow),
1923 value_or_zero(water_idx, flowsInfo.flow));
1926 }, !this->simulator_.problem().model().linearizer().getFlowsInfo().empty()
1928 Entry{[&floresInf = this->simulator_.problem().model().linearizer().getFloresInfo(),
1929 &flowsC = this->
flowsC_](
const Context& ectx)
1931 const auto gas_idx = Indices::gasEnabled ?
1932 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(gasCompIdx) : -1;
1933 const auto oil_idx = Indices::oilEnabled ?
1934 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(oilCompIdx) : -1;
1935 const auto water_idx = Indices::waterEnabled ?
1936 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(waterCompIdx) : -1;
1937 const auto& floresInfos = floresInf[ectx.globalDofIdx];
1938 for (
const auto& floresInfo : floresInfos) {
1939 flowsC.assignFlores(ectx.globalDofIdx,
1942 value_or_zero(gas_idx, floresInfo.flow),
1943 value_or_zero(oil_idx, floresInfo.flow),
1944 value_or_zero(water_idx, floresInfo.flow));
1946 }, !this->simulator_.problem().model().linearizer().getFloresInfo().empty()
1948 Entry{[&velocityInf = this->simulator_.problem().model().linearizer().getVelocityInfo(),
1950 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1952 const auto& velocityInfos = velocityInf[ectx.globalDofIdx];
1953 const std::vector<int>& blockIdxs = flowsC.blockVelocity();
1954 const unsigned cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1955 if (std::ranges::binary_search(blockIdxs, cartesianIdx)) {
1956 const auto compIdxs = std::array{ gasCompIdx, oilCompIdx, waterCompIdx };
1957 const auto compEnabled = std::array{ Indices::gasEnabled, Indices::oilEnabled, Indices::waterEnabled };
1958 for (
const auto& velocityInfo : velocityInfos) {
1959 if (velocityInfo.faceId < 0) {
1962 for (
unsigned ii = 0; ii < compIdxs.size(); ++ii) {
1963 if (!compEnabled[ii]) {
1966 if (flowsC.hasBlockVelocityValue(cartesianIdx, velocityInfo.faceId, compIdxs[ii])) {
1967 flowsC.assignBlockVelocity(flowsC.blockVelocityIds(cartesianIdx, velocityInfo.faceId, compIdxs[ii]),
1968 velocityInfo.faceId,
1970 velocityInfo.velocity[conti0EqIdx
1971 + FluidSystem::canonicalToActiveCompIdx(compIdxs[ii])]);
1977 !this->simulator_.problem().model().linearizer().getVelocityInfo().empty()
1984 Entry{ScalarEntry{&this->rv_,
1985 [&problem = this->simulator_.problem()](
const Context& ectx)
1986 {
return problem.initialFluidState(ectx.globalDofIdx).Rv(); }
1988 simulator_.episodeIndex() < 0 &&
1989 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1990 FluidSystem::phaseIsActive(gasPhaseIdx)
1992 Entry{ScalarEntry{&this->rs_,
1993 [&problem = this->simulator_.problem()](
const Context& ectx)
1994 {
return problem.initialFluidState(ectx.globalDofIdx).Rs(); }
1996 simulator_.episodeIndex() < 0 &&
1997 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1998 FluidSystem::phaseIsActive(gasPhaseIdx)
2000 Entry{ScalarEntry{&this->
rsw_,
2001 [&problem = this->simulator_.problem()](
const Context& ectx)
2002 {
return problem.initialFluidState(ectx.globalDofIdx).Rsw(); }
2004 simulator_.episodeIndex() < 0 &&
2005 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2006 FluidSystem::phaseIsActive(gasPhaseIdx)
2008 Entry{ScalarEntry{&this->
rvw_,
2009 [&problem = this->simulator_.problem()](
const Context& ectx)
2010 {
return problem.initialFluidState(ectx.globalDofIdx).Rvw(); }
2012 simulator_.episodeIndex() < 0 &&
2013 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2014 FluidSystem::phaseIsActive(gasPhaseIdx)
2018 [&problem = this->simulator_.problem()](
const unsigned phase,
2019 const Context& ectx)
2021 const auto& fsInitial = problem.initialFluidState(ectx.globalDofIdx);
2022 return FluidSystem::density(fsInitial,
2024 ectx.intQuants.pvtRegionIndex());
2027 simulator_.episodeIndex() < 0 &&
2028 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2029 FluidSystem::phaseIsActive(gasPhaseIdx)
2031 Entry{PhaseEntry{&this->invB_,
2032 [&problem = this->simulator_.problem()](
const unsigned phase,
2033 const Context& ectx)
2035 const auto& fsInitial = problem.initialFluidState(ectx.globalDofIdx);
2036 return FluidSystem::inverseFormationVolumeFactor(fsInitial,
2038 ectx.intQuants.pvtRegionIndex());
2041 simulator_.episodeIndex() < 0 &&
2042 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2043 FluidSystem::phaseIsActive(gasPhaseIdx)
2046 [&problem = this->simulator_.problem()](
const unsigned phase,
2047 const Context& ectx)
2049 const auto& fsInitial = problem.initialFluidState(ectx.globalDofIdx);
2050 return FluidSystem::viscosity(fsInitial,
2052 ectx.intQuants.pvtRegionIndex());
2055 simulator_.episodeIndex() < 0 &&
2056 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2057 FluidSystem::phaseIsActive(gasPhaseIdx)
2065 if constexpr (getPropValue<TypeTag, Properties::EnableGeochemistry>()) {
2067 this->extractors_.emplace_back(
2069 &gM = this->simulator_.problem().geochemistryModel()](
const Context& ectx)
2071 gC.assignSpeciesConcentrations(
2073 [gIdx = ectx.globalDofIdx, &gM](
const unsigned speciesIdx)
2074 {
return gM.speciesConcentration(speciesIdx, gIdx); }
2076 gC.assignMineralConcentrations(
2078 [gIdx = ectx.globalDofIdx, &gM](
const unsigned mineralIdx)
2079 {
return gM.mineralConcentration(mineralIdx, gIdx); }
2081 gC.assignPH(ectx.globalDofIdx, gM.PH(ectx.globalDofIdx));
2089 if constexpr (getPropValue<TypeTag, Properties::EnableMech>()) {
2090 if (this->
mech_.allocated()) {
2091 this->extractors_.emplace_back(
2092 [&mech = this->
mech_,
2093 &model = simulator_.problem().geoMechModel()](
const Context& ectx)
2095 mech.assignDelStress(ectx.globalDofIdx,
2096 model.delstress(ectx.globalDofIdx));
2098 mech.assignDisplacement(ectx.globalDofIdx,
2099 model.disp(ectx.globalDofIdx,
true));
2102 mech.assignFracStress(ectx.globalDofIdx,
2103 model.fractureStress(ectx.globalDofIdx));
2105 mech.assignLinStress(ectx.globalDofIdx,
2106 model.linstress(ectx.globalDofIdx));
2108 mech.assignPotentialForces(ectx.globalDofIdx,
2109 model.mechPotentialForce(ectx.globalDofIdx),
2110 model.mechPotentialPressForce(ectx.globalDofIdx),
2111 model.mechPotentialTempForce(ectx.globalDofIdx));
2113 mech.assignStrain(ectx.globalDofIdx,
2114 model.strain(ectx.globalDofIdx,
true));
2117 mech.assignStress(ectx.globalDofIdx,
2118 model.stress(ectx.globalDofIdx,
true));
2123 if (this->
tpsaC_.allocated()) {
2124 this->extractors_.emplace_back(
2126 &model = simulator_.problem().geoMechModel()](
const Context& ectx) {
2127 tpsaC.assignRotation(ectx.globalDofIdx,
2128 model.rotation(ectx.globalDofIdx));
2130 tpsaC.assignSolidPressure(ectx.globalDofIdx,
2131 model.solidPressure(ectx.globalDofIdx));
2140 void setupBlockExtractors_(
const bool isSubStep,
2141 const int reportStepNum)
2144 using Context =
typename BlockExtractor::Context;
2145 using PhaseEntry =
typename BlockExtractor::PhaseEntry;
2146 using ScalarEntry =
typename BlockExtractor::ScalarEntry;
2148 using namespace std::string_view_literals;
2150 const auto pressure_handler =
2151 Entry{ScalarEntry{std::vector{
"BPR"sv,
"BPRESSUR"sv},
2152 [](
const Context& ectx)
2154 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2155 return getValue(ectx.fs.pressure(oilPhaseIdx));
2157 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
2158 return getValue(ectx.fs.pressure(gasPhaseIdx));
2161 return getValue(ectx.fs.pressure(waterPhaseIdx));
2167 const auto handlers = std::array{
2169 Entry{PhaseEntry{std::array{
2170 std::array{
"BWSAT"sv,
"BOSAT"sv,
"BGSAT"sv},
2171 std::array{
"BSWAT"sv,
"BSOIL"sv,
"BSGAS"sv}
2173 [](
const unsigned phaseIdx,
const Context& ectx)
2175 return getValue(ectx.fs.saturation(phaseIdx));
2179 Entry{ScalarEntry{
"BNSAT",
2180 [](
const Context& ectx)
2182 if constexpr (enableSolvent) {
2183 return ectx.intQuants.solventSaturation().value();
2191 Entry{ScalarEntry{std::vector{
"BTCNFHEA"sv,
"BTEMP"sv},
2192 [](
const Context& ectx)
2194 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2195 return getValue(ectx.fs.temperature(oilPhaseIdx));
2197 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
2198 return getValue(ectx.fs.temperature(gasPhaseIdx));
2201 return getValue(ectx.fs.temperature(waterPhaseIdx));
2206 Entry{PhaseEntry{std::array{
2207 std::array{
"BWKR"sv,
"BOKR"sv,
"BGKR"sv},
2208 std::array{
"BKRW"sv,
"BKRO"sv,
"BKRG"sv}
2210 [](
const unsigned phaseIdx,
const Context& ectx)
2212 return getValue(ectx.intQuants.relativePermeability(phaseIdx));
2216 Entry{ScalarEntry{
"BKROG",
2217 [&problem = this->simulator_.problem()](
const Context& ectx)
2219 const auto& materialParams =
2220 problem.materialLawParams(ectx.elemCtx,
2223 return getValue(MaterialLaw::template
2224 relpermOilInOilGasSystem<Evaluation>(materialParams,
2229 Entry{ScalarEntry{
"BKROW",
2230 [&problem = this->simulator_.problem()](
const Context& ectx)
2232 const auto& materialParams = problem.materialLawParams(ectx.elemCtx,
2235 return getValue(MaterialLaw::template
2236 relpermOilInOilWaterSystem<Evaluation>(materialParams,
2241 Entry{ScalarEntry{
"BWPC",
2242 [](
const Context& ectx)
2244 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2245 return getValue(ectx.fs.pressure(oilPhaseIdx)) -
2246 getValue(ectx.fs.pressure(waterPhaseIdx));
2248 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
2249 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
2250 getValue(ectx.fs.pressure(waterPhaseIdx));
2258 Entry{ScalarEntry{
"BGPC",
2259 [](
const Context& ectx)
2261 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2262 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
2263 getValue(ectx.fs.pressure(oilPhaseIdx));
2265 else if (FluidSystem::phaseIsActive(waterPhaseIdx)) {
2266 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
2267 getValue(ectx.fs.pressure(waterPhaseIdx));
2275 Entry{ScalarEntry{
"BWPR",
2276 [](
const Context& ectx)
2278 return getValue(ectx.fs.pressure(waterPhaseIdx));
2282 Entry{ScalarEntry{
"BGPR",
2283 [](
const Context& ectx)
2285 return getValue(ectx.fs.pressure(gasPhaseIdx));
2289 Entry{PhaseEntry{std::array{
2290 std::array{
"BVWAT"sv,
"BVOIL"sv,
"BVGAS"sv},
2291 std::array{
"BWVIS"sv,
"BOVIS"sv,
"BGVIS"sv}
2293 [](
const unsigned phaseIdx,
const Context& ectx)
2295 return getValue(ectx.fs.viscosity(phaseIdx));
2299 Entry{PhaseEntry{std::array{
2300 std::array{
"BWDEN"sv,
"BODEN"sv,
"BGDEN"sv},
2301 std::array{
"BDENW"sv,
"BDENO"sv,
"BDENG"sv}
2303 [](
const unsigned phaseIdx,
const Context& ectx)
2305 return getValue(ectx.fs.density(phaseIdx));
2309 Entry{ScalarEntry{
"BFLOGI",
2311 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2313 const unsigned index = !flowsC.blockFlows().empty() ?
2314 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2315 FaceDir::ToIntersectionIndex(Dir::XPlus), gasCompIdx) : ectx.globalDofIdx;
2316 return flowsC.getFlow(index, Dir::XPlus, gasCompIdx);
2320 Entry{ScalarEntry{
"BFLOGI-",
2322 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2324 const unsigned index = !flowsC.blockFlows().empty() ?
2325 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2326 FaceDir::ToIntersectionIndex(Dir::XMinus), gasCompIdx) : ectx.globalDofIdx;
2327 return flowsC.getFlow(index, Dir::XMinus, gasCompIdx);
2331 Entry{ScalarEntry{
"BFLOGJ",
2333 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2335 const unsigned index = !flowsC.blockFlows().empty() ?
2336 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2337 FaceDir::ToIntersectionIndex(Dir::YPlus), gasCompIdx) : ectx.globalDofIdx;
2338 return flowsC.getFlow(index, Dir::YPlus, gasCompIdx);
2342 Entry{ScalarEntry{
"BFLOGJ-",
2344 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2346 const unsigned index = !flowsC.blockFlows().empty() ?
2347 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2348 FaceDir::ToIntersectionIndex(Dir::YMinus), gasCompIdx) : ectx.globalDofIdx;
2349 return flowsC.getFlow(index, Dir::YMinus, gasCompIdx);
2353 Entry{ScalarEntry{
"BFLOGK",
2355 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2357 const unsigned index = !flowsC.blockFlows().empty() ?
2358 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2359 FaceDir::ToIntersectionIndex(Dir::ZPlus), gasCompIdx) : ectx.globalDofIdx;
2360 return flowsC.getFlow(index, Dir::ZPlus, gasCompIdx);
2364 Entry{ScalarEntry{
"BFLOGK-",
2366 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2368 const unsigned index = !flowsC.blockFlows().empty() ?
2369 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2370 FaceDir::ToIntersectionIndex(Dir::ZMinus), gasCompIdx) : ectx.globalDofIdx;
2371 return flowsC.getFlow(index, Dir::ZMinus, gasCompIdx);
2375 Entry{ScalarEntry{
"BFLOOI",
2377 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2379 const unsigned index = !flowsC.blockFlows().empty() ?
2380 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2381 FaceDir::ToIntersectionIndex(Dir::XPlus), oilCompIdx) : ectx.globalDofIdx;
2382 return flowsC.getFlow(index, Dir::XPlus, oilCompIdx);
2386 Entry{ScalarEntry{
"BFLOOI-",
2388 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2390 const unsigned index = !flowsC.blockFlows().empty() ?
2391 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2392 FaceDir::ToIntersectionIndex(Dir::XMinus), oilCompIdx) : ectx.globalDofIdx;
2393 return flowsC.getFlow(index, Dir::XMinus, oilCompIdx);
2397 Entry{ScalarEntry{
"BFLOOJ",
2399 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2401 const unsigned index = !flowsC.blockFlows().empty() ?
2402 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2403 FaceDir::ToIntersectionIndex(Dir::YPlus), oilCompIdx) : ectx.globalDofIdx;
2404 return flowsC.getFlow(index, Dir::YPlus, oilCompIdx);
2408 Entry{ScalarEntry{
"BFLOOJ-",
2410 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2412 const unsigned index = !flowsC.blockFlows().empty() ?
2413 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2414 FaceDir::ToIntersectionIndex(Dir::YMinus), oilCompIdx) : ectx.globalDofIdx;
2415 return flowsC.getFlow(index, Dir::YMinus, oilCompIdx);
2419 Entry{ScalarEntry{
"BFLOOK",
2421 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2423 const unsigned index = !flowsC.blockFlows().empty() ?
2424 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2425 FaceDir::ToIntersectionIndex(Dir::ZPlus), oilCompIdx) : ectx.globalDofIdx;
2426 return flowsC.getFlow(index, Dir::ZPlus, oilCompIdx);
2430 Entry{ScalarEntry{
"BFLOOK-",
2432 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2434 const unsigned index = !flowsC.blockFlows().empty() ?
2435 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2436 FaceDir::ToIntersectionIndex(Dir::ZMinus), oilCompIdx) : ectx.globalDofIdx;
2437 return flowsC.getFlow(index, Dir::ZMinus, oilCompIdx);
2441 Entry{ScalarEntry{
"BFLOWI",
2443 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2445 const unsigned index = !flowsC.blockFlows().empty() ?
2446 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2447 FaceDir::ToIntersectionIndex(Dir::XPlus), waterCompIdx) : ectx.globalDofIdx;
2448 return flowsC.getFlow(index, Dir::XPlus, waterCompIdx);
2452 Entry{ScalarEntry{
"BFLOWI-",
2454 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2456 const unsigned index = !flowsC.blockFlows().empty() ?
2457 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2458 FaceDir::ToIntersectionIndex(Dir::XMinus), waterCompIdx) : ectx.globalDofIdx;
2459 return flowsC.getFlow(index, Dir::XMinus, waterCompIdx);
2463 Entry{ScalarEntry{
"BFLOWJ",
2465 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2467 const unsigned index = !flowsC.blockFlows().empty() ?
2468 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2469 FaceDir::ToIntersectionIndex(Dir::YPlus), waterCompIdx) : ectx.globalDofIdx;
2470 return flowsC.getFlow(index, Dir::YPlus, waterCompIdx);
2474 Entry{ScalarEntry{
"BFLOWJ-",
2476 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2478 const unsigned index = !flowsC.blockFlows().empty() ?
2479 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2480 FaceDir::ToIntersectionIndex(Dir::YMinus), waterCompIdx) : ectx.globalDofIdx;
2481 return flowsC.getFlow(index, Dir::YMinus, waterCompIdx);
2485 Entry{ScalarEntry{
"BFLOWK",
2487 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2489 const unsigned index = !flowsC.blockFlows().empty() ?
2490 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2491 FaceDir::ToIntersectionIndex(Dir::ZPlus), waterCompIdx) : ectx.globalDofIdx;
2492 return flowsC.getFlow(index, Dir::ZPlus, waterCompIdx);
2496 Entry{ScalarEntry{
"BFLOWK-",
2498 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2500 const unsigned index = !flowsC.blockFlows().empty() ?
2501 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2502 FaceDir::ToIntersectionIndex(Dir::ZMinus), waterCompIdx) : ectx.globalDofIdx;
2503 return flowsC.getFlow(index, Dir::ZMinus, waterCompIdx);
2507 Entry{ScalarEntry{
"BVELGI",
2509 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2511 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2512 FaceDir::ToIntersectionIndex(Dir::XPlus), gasCompIdx);
2513 return flowsC.getVelocity(index, Dir::XPlus, gasCompIdx);
2517 Entry{ScalarEntry{
"BVELGI-",
2519 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2521 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2522 FaceDir::ToIntersectionIndex(Dir::XMinus), gasCompIdx);
2523 return flowsC.getVelocity(index, Dir::XMinus, gasCompIdx);
2527 Entry{ScalarEntry{
"BVELGJ",
2529 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2531 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2532 FaceDir::ToIntersectionIndex(Dir::YPlus), gasCompIdx);
2533 return flowsC.getVelocity(index, Dir::YPlus, gasCompIdx);
2537 Entry{ScalarEntry{
"BVELGJ-",
2539 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2541 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2542 FaceDir::ToIntersectionIndex(Dir::YMinus), gasCompIdx);
2543 return flowsC.getVelocity(index, Dir::YMinus, gasCompIdx);
2547 Entry{ScalarEntry{
"BVELGK",
2549 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2551 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2552 FaceDir::ToIntersectionIndex(Dir::ZPlus), gasCompIdx);
2553 return flowsC.getVelocity(index, Dir::ZPlus, gasCompIdx);
2557 Entry{ScalarEntry{
"BVELGK-",
2559 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2561 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2562 FaceDir::ToIntersectionIndex(Dir::ZMinus), gasCompIdx);
2563 return flowsC.getVelocity(index, Dir::ZMinus, gasCompIdx);
2567 Entry{ScalarEntry{
"BVELOI",
2569 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2571 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2572 FaceDir::ToIntersectionIndex(Dir::XPlus), oilCompIdx);
2573 return flowsC.getVelocity(index, Dir::XPlus, oilCompIdx);
2577 Entry{ScalarEntry{
"BVELOI-",
2579 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2581 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2582 FaceDir::ToIntersectionIndex(Dir::XMinus), oilCompIdx);
2583 return flowsC.getVelocity(index, Dir::XMinus, oilCompIdx);
2587 Entry{ScalarEntry{
"BVELOJ",
2589 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2591 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2592 FaceDir::ToIntersectionIndex(Dir::YPlus), oilCompIdx);
2593 return flowsC.getVelocity(index, Dir::YPlus, oilCompIdx);
2597 Entry{ScalarEntry{
"BVELOJ-",
2599 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2601 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2602 FaceDir::ToIntersectionIndex(Dir::YMinus), oilCompIdx);
2603 return flowsC.getVelocity(index, Dir::YMinus, oilCompIdx);
2607 Entry{ScalarEntry{
"BVELOK",
2609 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2611 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2612 FaceDir::ToIntersectionIndex(Dir::ZPlus), oilCompIdx);
2613 return flowsC.getVelocity(index, Dir::ZPlus, oilCompIdx);
2617 Entry{ScalarEntry{
"BVELOK-",
2619 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2621 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2622 FaceDir::ToIntersectionIndex(Dir::ZMinus), oilCompIdx);
2623 return flowsC.getVelocity(index, Dir::ZMinus, oilCompIdx);
2627 Entry{ScalarEntry{
"BVELWI",
2629 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2631 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2632 FaceDir::ToIntersectionIndex(Dir::XPlus), waterCompIdx);
2633 return flowsC.getVelocity(index, Dir::XPlus, waterCompIdx);
2637 Entry{ScalarEntry{
"BVELWI-",
2639 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2641 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2642 FaceDir::ToIntersectionIndex(Dir::XMinus), waterCompIdx);
2643 return flowsC.getVelocity(index, Dir::XMinus, waterCompIdx);
2647 Entry{ScalarEntry{
"BVELWJ",
2649 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2651 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2652 FaceDir::ToIntersectionIndex(Dir::YPlus), waterCompIdx);
2653 return flowsC.getVelocity(index, Dir::YPlus, waterCompIdx);
2657 Entry{ScalarEntry{
"BVELWJ-",
2659 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2661 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2662 FaceDir::ToIntersectionIndex(Dir::YMinus), waterCompIdx);
2663 return flowsC.getVelocity(index, Dir::YMinus, waterCompIdx);
2667 Entry{ScalarEntry{
"BVELWK",
2669 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2671 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2672 FaceDir::ToIntersectionIndex(Dir::ZPlus), waterCompIdx);
2673 return flowsC.getVelocity(index, Dir::ZPlus, waterCompIdx);
2677 Entry{ScalarEntry{
"BVELWK-",
2679 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2681 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2682 FaceDir::ToIntersectionIndex(Dir::ZMinus), waterCompIdx);
2683 return flowsC.getVelocity(index, Dir::ZMinus, waterCompIdx);
2687 Entry{ScalarEntry{
"BRPV",
2688 [&model = this->simulator_.model()](
const Context& ectx)
2690 return getValue(ectx.intQuants.porosity()) *
2691 model.dofTotalVolume(ectx.globalDofIdx);
2695 Entry{PhaseEntry{std::array{
"BWPV"sv,
"BOPV"sv,
"BGPV"sv},
2696 [&model = this->simulator_.model()](
const unsigned phaseIdx,
2697 const Context& ectx)
2699 return getValue(ectx.fs.saturation(phaseIdx)) *
2700 getValue(ectx.intQuants.porosity()) *
2701 model.dofTotalVolume(ectx.globalDofIdx);
2705 Entry{ScalarEntry{
"BRS",
2706 [](
const Context& ectx)
2708 return getValue(ectx.fs.Rs());
2712 Entry{ScalarEntry{
"BRV",
2713 [](
const Context& ectx)
2715 return getValue(ectx.fs.Rv());
2719 Entry{ScalarEntry{
"BOIP",
2720 [&model = this->simulator_.model()](
const Context& ectx)
2722 return (getValue(ectx.fs.invB(oilPhaseIdx)) *
2723 getValue(ectx.fs.saturation(oilPhaseIdx)) +
2724 getValue(ectx.fs.Rv()) *
2725 getValue(ectx.fs.invB(gasPhaseIdx)) *
2726 getValue(ectx.fs.saturation(gasPhaseIdx))) *
2727 model.dofTotalVolume(ectx.globalDofIdx) *
2728 getValue(ectx.intQuants.porosity());
2732 Entry{ScalarEntry{
"BGIP",
2733 [&model = this->simulator_.model()](
const Context& ectx)
2735 Scalar result = getValue(ectx.fs.invB(gasPhaseIdx)) *
2736 getValue(ectx.fs.saturation(gasPhaseIdx));
2738 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2739 result += getValue(ectx.fs.Rs()) *
2740 getValue(ectx.fs.invB(oilPhaseIdx)) *
2741 getValue(ectx.fs.saturation(oilPhaseIdx));
2744 result += getValue(ectx.fs.Rsw()) *
2745 getValue(ectx.fs.invB(waterPhaseIdx)) *
2746 getValue(ectx.fs.saturation(waterPhaseIdx));
2750 model.dofTotalVolume(ectx.globalDofIdx) *
2751 getValue(ectx.intQuants.porosity());
2755 Entry{ScalarEntry{
"BWIP",
2756 [&model = this->simulator_.model()](
const Context& ectx)
2758 return getValue(ectx.fs.invB(waterPhaseIdx)) *
2759 getValue(ectx.fs.saturation(waterPhaseIdx)) *
2760 model.dofTotalVolume(ectx.globalDofIdx) *
2761 getValue(ectx.intQuants.porosity());
2765 Entry{ScalarEntry{
"BOIPL",
2766 [&model = this->simulator_.model()](
const Context& ectx)
2768 return getValue(ectx.fs.invB(oilPhaseIdx)) *
2769 getValue(ectx.fs.saturation(oilPhaseIdx)) *
2770 model.dofTotalVolume(ectx.globalDofIdx) *
2771 getValue(ectx.intQuants.porosity());
2775 Entry{ScalarEntry{
"BGIPL",
2776 [&model = this->simulator_.model()](
const Context& ectx)
2779 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2780 result = getValue(ectx.fs.Rs()) *
2781 getValue(ectx.fs.invB(oilPhaseIdx)) *
2782 getValue(ectx.fs.saturation(oilPhaseIdx));
2785 result = getValue(ectx.fs.Rsw()) *
2786 getValue(ectx.fs.invB(waterPhaseIdx)) *
2787 getValue(ectx.fs.saturation(waterPhaseIdx));
2790 model.dofTotalVolume(ectx.globalDofIdx) *
2791 getValue(ectx.intQuants.porosity());
2795 Entry{ScalarEntry{
"BGIPG",
2796 [&model = this->simulator_.model()](
const Context& ectx)
2798 return getValue(ectx.fs.invB(gasPhaseIdx)) *
2799 getValue(ectx.fs.saturation(gasPhaseIdx)) *
2800 model.dofTotalVolume(ectx.globalDofIdx) *
2801 getValue(ectx.intQuants.porosity());
2805 Entry{ScalarEntry{
"BOIPG",
2806 [&model = this->simulator_.model()](
const Context& ectx)
2808 return getValue(ectx.fs.Rv()) *
2809 getValue(ectx.fs.invB(gasPhaseIdx)) *
2810 getValue(ectx.fs.saturation(gasPhaseIdx)) *
2811 model.dofTotalVolume(ectx.globalDofIdx) *
2812 getValue(ectx.intQuants.porosity());
2816 Entry{PhaseEntry{std::array{
"BPPW"sv,
"BPPO"sv,
"BPPG"sv},
2817 [&simConfig = this->
eclState_.getSimulationConfig(),
2818 &grav = this->simulator_.problem().gravity(),
2820 &problem = this->simulator_.problem(),
2821 ®ions = this->
regions_](
const unsigned phaseIdx,
const Context& ectx)
2824 phase.ix = phaseIdx;
2833 const auto datum = simConfig.datumDepths()(regions[
"FIPNUM"][ectx.dofIdx] - 1);
2836 const auto region = RegionPhasePoreVolAverage::Region {
2837 ectx.elemCtx.primaryVars(ectx.dofIdx, 0).pvtRegionIndex() + 1
2840 const auto density = regionAvgDensity->value(
"PVTNUM", phase, region);
2842 const auto press = getValue(ectx.fs.pressure(phase.ix));
2843 const auto dz = problem.dofCenterDepth(ectx.globalDofIdx) - datum;
2844 return press - density*dz*grav[GridView::dimensionworld - 1];
2848 Entry{ScalarEntry{
"BAMIP",
2849 [&model = this->simulator_.model()](
const Context& ectx)
2851 const Scalar rhoW = FluidSystem::referenceDensity(waterPhaseIdx,
2852 ectx.intQuants.pvtRegionIndex());
2853 return getValue(ectx.fs.invB(waterPhaseIdx)) *
2854 getValue(ectx.fs.saturation(waterPhaseIdx)) *
2856 model.dofTotalVolume(ectx.globalDofIdx) *
2857 getValue(ectx.intQuants.porosity());
2861 Entry{ScalarEntry{
"BMMIP",
2862 [&model = this->simulator_.model()](
const Context& ectx)
2864 if constexpr (enableBioeffects) {
2865 return getValue(ectx.intQuants.microbialConcentration()) *
2866 getValue(ectx.fs.saturation(waterPhaseIdx)) *
2867 getValue(ectx.intQuants.porosity()) *
2868 model.dofTotalVolume(ectx.globalDofIdx);
2876 Entry{ScalarEntry{
"BMOIP",
2877 [&model = this->simulator_.model()](
const Context& ectx)
2879 if constexpr (enableBioeffects) {
2880 return getValue(ectx.intQuants.oxygenConcentration()) *
2881 getValue(ectx.intQuants.porosity()) *
2882 model.dofTotalVolume(ectx.globalDofIdx);
2890 Entry{ScalarEntry{
"BMUIP",
2891 [&model = this->simulator_.model()](
const Context& ectx)
2893 if constexpr (enableBioeffects) {
2894 return getValue(ectx.intQuants.ureaConcentration()) *
2895 getValue(ectx.intQuants.porosity()) *
2896 model.dofTotalVolume(ectx.globalDofIdx);
2904 Entry{ScalarEntry{
"BMBIP",
2905 [&model = this->simulator_.model()](
const Context& ectx)
2907 if constexpr (enableBioeffects) {
2908 return model.dofTotalVolume(ectx.globalDofIdx) *
2909 getValue(ectx.intQuants.biofilmMass());
2917 Entry{ScalarEntry{
"BMCIP",
2918 [&model = this->simulator_.model()](
const Context& ectx)
2920 if constexpr (enableBioeffects) {
2921 return model.dofTotalVolume(ectx.globalDofIdx) *
2922 getValue(ectx.intQuants.calciteMass());
2930 Entry{ScalarEntry{
"BGMIP",
2931 [&model = this->simulator_.model()](
const Context& ectx)
2933 Scalar result = getValue(ectx.fs.invB(gasPhaseIdx)) *
2934 getValue(ectx.fs.saturation(gasPhaseIdx));
2936 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2937 result += getValue(ectx.fs.Rs()) *
2938 getValue(ectx.fs.invB(oilPhaseIdx)) *
2939 getValue(ectx.fs.saturation(oilPhaseIdx));
2942 result += getValue(ectx.fs.Rsw()) *
2943 getValue(ectx.fs.invB(waterPhaseIdx)) *
2944 getValue(ectx.fs.saturation(waterPhaseIdx));
2946 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
2947 ectx.intQuants.pvtRegionIndex());
2949 model.dofTotalVolume(ectx.globalDofIdx) *
2950 getValue(ectx.intQuants.porosity()) *
2955 Entry{ScalarEntry{
"BGMGP",
2956 [&model = this->simulator_.model()](
const Context& ectx)
2958 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
2959 ectx.intQuants.pvtRegionIndex());
2960 return getValue(ectx.fs.invB(gasPhaseIdx)) *
2961 getValue(ectx.fs.saturation(gasPhaseIdx)) *
2962 model.dofTotalVolume(ectx.globalDofIdx) *
2963 getValue(ectx.intQuants.porosity()) *
2968 Entry{ScalarEntry{
"BGMDS",
2969 [&model = this->simulator_.model()](
const Context& ectx)
2972 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2973 result = getValue(ectx.fs.Rs()) *
2974 getValue(ectx.fs.invB(oilPhaseIdx)) *
2975 getValue(ectx.fs.saturation(oilPhaseIdx));
2978 result = getValue(ectx.fs.Rsw()) *
2979 getValue(ectx.fs.invB(waterPhaseIdx)) *
2980 getValue(ectx.fs.saturation(waterPhaseIdx));
2982 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
2983 ectx.intQuants.pvtRegionIndex());
2985 model.dofTotalVolume(ectx.globalDofIdx) *
2986 getValue(ectx.intQuants.porosity()) *
2991 Entry{ScalarEntry{
"BGMST",
2992 [&model = this->simulator_.model(),
2993 &problem = this->simulator_.problem()](
const Context& ectx)
2995 const auto& scaledDrainageInfo = problem.materialLawManager()
2996 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
2997 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
2998 Scalar strandedGas = scaledDrainageInfo.Sgcr;
2999 if (problem.materialLawManager()->enableHysteresis()) {
3000 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3001 const Scalar krg = getValue(ectx.intQuants.relativePermeability(gasPhaseIdx));
3002 strandedGas = MaterialLaw::strandedGasSaturation(matParams, sg, krg);
3004 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3005 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3006 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3007 return (1.0 - xgW) *
3008 model.dofTotalVolume(ectx.globalDofIdx) *
3009 getValue(ectx.intQuants.porosity()) *
3010 getValue(ectx.fs.density(gasPhaseIdx)) *
3011 std::min(strandedGas, sg);
3015 Entry{ScalarEntry{
"BGMUS",
3016 [&model = this->simulator_.model(),
3017 &problem = this->simulator_.problem()](
const Context& ectx)
3019 const auto& scaledDrainageInfo = problem.materialLawManager()
3020 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3021 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3022 Scalar strandedGas = scaledDrainageInfo.Sgcr;
3023 if (problem.materialLawManager()->enableHysteresis()) {
3024 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3025 const Scalar krg = getValue(ectx.intQuants.relativePermeability(gasPhaseIdx));
3026 strandedGas = MaterialLaw::strandedGasSaturation(matParams, sg, krg);
3028 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3029 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3030 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3031 return (1.0 - xgW) *
3032 model.dofTotalVolume(ectx.globalDofIdx) *
3033 getValue(ectx.intQuants.porosity()) *
3034 getValue(ectx.fs.density(gasPhaseIdx)) *
3035 std::max(Scalar{0.0}, sg - strandedGas);
3039 Entry{ScalarEntry{
"BGMTR",
3040 [&model = this->simulator_.model(),
3041 &problem = this->simulator_.problem()](
const Context& ectx)
3043 const auto& scaledDrainageInfo = problem.materialLawManager()
3044 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3045 Scalar trappedGas = scaledDrainageInfo.Sgcr;
3046 if (problem.materialLawManager()->enableHysteresis()) {
3047 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3048 trappedGas = MaterialLaw::trappedGasSaturation(matParams,
true);
3050 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3051 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3052 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3053 return (1.0 - xgW) *
3054 model.dofTotalVolume(ectx.globalDofIdx) *
3055 getValue(ectx.intQuants.porosity()) *
3056 getValue(ectx.fs.density(gasPhaseIdx)) *
3057 std::min(trappedGas, getValue(ectx.fs.saturation(gasPhaseIdx)));
3061 Entry{ScalarEntry{
"BGMMO",
3062 [&model = this->simulator_.model(),
3063 &problem = this->simulator_.problem()](
const Context& ectx)
3065 const auto& scaledDrainageInfo = problem.materialLawManager()
3066 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3067 Scalar trappedGas = scaledDrainageInfo.Sgcr;
3068 if (problem.materialLawManager()->enableHysteresis()) {
3069 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3070 trappedGas = MaterialLaw::trappedGasSaturation(matParams,
true);
3072 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3073 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3074 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3075 return (1.0 - xgW) *
3076 model.dofTotalVolume(ectx.globalDofIdx) *
3077 getValue(ectx.intQuants.porosity()) *
3078 getValue(ectx.fs.density(gasPhaseIdx)) *
3079 std::max(Scalar{0.0}, getValue(ectx.fs.saturation(gasPhaseIdx)) - trappedGas);
3083 Entry{ScalarEntry{
"BGKTR",
3084 [&model = this->simulator_.model(),
3085 &problem = this->simulator_.problem()](
const Context& ectx)
3087 const auto& scaledDrainageInfo = problem.materialLawManager()
3088 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3089 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3090 Scalar sgcr = scaledDrainageInfo.Sgcr;
3091 if (problem.materialLawManager()->enableHysteresis()) {
3092 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3093 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3099 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3100 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3101 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3102 return (1.0 - xgW) *
3103 model.dofTotalVolume(ectx.globalDofIdx) *
3104 getValue(ectx.intQuants.porosity()) *
3105 getValue(ectx.fs.density(gasPhaseIdx)) *
3106 getValue(ectx.fs.saturation(gasPhaseIdx));
3111 Entry{ScalarEntry{
"BGKMO",
3112 [&model = this->simulator_.model(),
3113 &problem = this->simulator_.problem()](
const Context& ectx)
3115 const auto& scaledDrainageInfo = problem.materialLawManager()
3116 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3117 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3118 Scalar sgcr = scaledDrainageInfo.Sgcr;
3119 if (problem.materialLawManager()->enableHysteresis()) {
3120 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3121 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3127 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3128 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3129 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3130 return (1.0 - xgW) *
3131 model.dofTotalVolume(ectx.globalDofIdx) *
3132 getValue(ectx.intQuants.porosity()) *
3133 getValue(ectx.fs.density(gasPhaseIdx)) *
3134 getValue(ectx.fs.saturation(gasPhaseIdx));
3139 Entry{ScalarEntry{
"BGCDI",
3140 [&model = this->simulator_.model(),
3141 &problem = this->simulator_.problem()](
const Context& ectx)
3143 const auto& scaledDrainageInfo = problem.materialLawManager()
3144 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3145 Scalar sgcr = scaledDrainageInfo.Sgcr;
3146 if (problem.materialLawManager()->enableHysteresis()) {
3147 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3148 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3150 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3151 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3152 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3153 return (1.0 - xgW) *
3154 model.dofTotalVolume(ectx.globalDofIdx) *
3155 getValue(ectx.intQuants.porosity()) *
3156 getValue(ectx.fs.density(gasPhaseIdx)) *
3157 std::min(sgcr, getValue(ectx.fs.saturation(gasPhaseIdx))) /
3158 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3162 Entry{ScalarEntry{
"BGCDM",
3163 [&model = this->simulator_.model(),
3164 &problem = this->simulator_.problem()](
const Context& ectx)
3166 const auto& scaledDrainageInfo = problem.materialLawManager()
3167 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3168 Scalar sgcr = scaledDrainageInfo.Sgcr;
3169 if (problem.materialLawManager()->enableHysteresis()) {
3170 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3171 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3173 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3174 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3175 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3176 return (1.0 - xgW) *
3177 model.dofTotalVolume(ectx.globalDofIdx) *
3178 getValue(ectx.intQuants.porosity()) *
3179 getValue(ectx.fs.density(gasPhaseIdx)) *
3180 std::max(Scalar{0.0}, getValue(ectx.fs.saturation(gasPhaseIdx)) - sgcr) /
3181 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3185 Entry{ScalarEntry{
"BGKDI",
3186 [&model = this->simulator_.model(),
3187 &problem = this->simulator_.problem()](
const Context& ectx)
3189 const auto& scaledDrainageInfo = problem.materialLawManager()
3190 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3191 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3192 Scalar sgcr = scaledDrainageInfo.Sgcr;
3193 if (problem.materialLawManager()->enableHysteresis()) {
3194 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3195 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3201 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3202 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3203 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3204 return (1.0 - xgW) *
3205 model.dofTotalVolume(ectx.globalDofIdx) *
3206 getValue(ectx.intQuants.porosity()) *
3207 getValue(ectx.fs.density(gasPhaseIdx)) *
3208 getValue(ectx.fs.saturation(gasPhaseIdx)) /
3209 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3214 Entry{ScalarEntry{
"BGKDM",
3215 [&model = this->simulator_.model(),
3216 &problem = this->simulator_.problem()](
const Context& ectx)
3218 const auto& scaledDrainageInfo = problem.materialLawManager()
3219 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3220 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3221 Scalar sgcr = scaledDrainageInfo.Sgcr;
3222 if (problem.materialLawManager()->enableHysteresis()) {
3223 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3224 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3230 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3231 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3232 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3233 return (1.0 - xgW) *
3234 model.dofTotalVolume(ectx.globalDofIdx) *
3235 getValue(ectx.intQuants.porosity()) *
3236 getValue(ectx.fs.density(gasPhaseIdx)) *
3237 getValue(ectx.fs.saturation(gasPhaseIdx)) /
3238 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3243 Entry{ScalarEntry{
"BWCD",
3244 [&model = this->simulator_.model()](
const Context& ectx)
3247 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
3248 result = getValue(ectx.fs.Rs()) *
3249 getValue(ectx.fs.invB(oilPhaseIdx)) *
3250 getValue(ectx.fs.saturation(oilPhaseIdx));
3253 result = getValue(ectx.fs.Rsw()) *
3254 getValue(ectx.fs.invB(waterPhaseIdx)) *
3255 getValue(ectx.fs.saturation(waterPhaseIdx));
3257 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
3258 ectx.intQuants.pvtRegionIndex());
3260 model.dofTotalVolume(ectx.globalDofIdx) *
3261 getValue(ectx.intQuants.porosity()) *
3263 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3267 Entry{ScalarEntry{
"BWIPG",
3268 [&model = this->simulator_.model()](
const Context& ectx)
3270 Scalar result = 0.0;
3271 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
3272 result = getValue(ectx.fs.Rvw()) *
3273 getValue(ectx.fs.invB(gasPhaseIdx)) *
3274 getValue(ectx.fs.saturation(gasPhaseIdx));
3277 model.dofTotalVolume(ectx.globalDofIdx) *
3278 getValue(ectx.intQuants.porosity());
3282 Entry{ScalarEntry{
"BWIPL",
3283 [&model = this->simulator_.model()](
const Context& ectx)
3285 return getValue(ectx.fs.invB(waterPhaseIdx)) *
3286 getValue(ectx.fs.saturation(waterPhaseIdx)) *
3287 model.dofTotalVolume(ectx.globalDofIdx) *
3288 getValue(ectx.intQuants.porosity());
3299 this->lgrBlockExtractors_ =
3303 if (reportStepNum > 0 && !isSubStep) {
3305 const auto& rpt = this->
schedule_[reportStepNum - 1].rpt_config.get();
3306 if (rpt.contains(
"WELLS") && rpt.at(
"WELLS") > 1) {
3308 [&c = this->collectOnIORank_](
const int idx)
3309 {
return c.isCartIdxOnThisRank(idx); });
3311 const auto extraHandlers = std::array{
3320 const Simulator& simulator_;
3321 const CollectDataOnIORankType& collectOnIORank_;
3322 std::vector<typename Extractor::Entry> extractors_;
Common output functionality shared by simulator formulations.
Declares the properties required by the black oil model.
Definition: CollectDataOnIORank.hpp:57
The base class for the element-centered finite-volume discretization scheme.
Definition: ecfvdiscretization.hh:160
void assignMicrobialMass(const unsigned globalDofIdx, const Scalar microbialMass)
void assignCalciteMass(const unsigned globalDofIdx, const Scalar calciteMass)
void assignCo2InWater(const unsigned globalDofIdx, const Scalar co2InWater, const Scalar mM)
void assignPoreVolume(const unsigned globalDofIdx, const Scalar poreVolume, const Scalar dynamicPoreVolume)
void assignVolumesSurface(const unsigned globalDofIdx, const std::array< Scalar, numPhases > &fip)
bool has(const Inplace::Phase phase) const
bool hasMicrobialMass() const
void assignWaterMass(const unsigned globalDofIdx, const std::array< Scalar, numPhases > &fip, const Scalar rhoW)
void assignCo2InGas(const unsigned globalDofIdx, const Co2InGasInput &v)
bool hasOxygenMass() const
void assignVolumesReservoir(const unsigned globalDofIdx, const Scalar saltConcentration, const std::array< Scalar, numPhases > &fipr)
void assignOxygenMass(const unsigned globalDofIdx, const Scalar oxygenMass)
void assignOilGasDistribution(const unsigned globalDofIdx, const Scalar gasInPlaceLiquid, const Scalar oilInPlaceGas)
void assignBiofilmMass(const unsigned globalDofIdx, const Scalar biofilmMass)
bool hasWaterMass() const
bool hasCo2InWater() const
void assignUreaMass(const unsigned globalDofIdx, const Scalar ureaMass)
bool hasCalciteMass() const
bool hasBiofilmMass() const
const std::vector< Scalar > & get(const Inplace::Phase phase) const
void assignGasWater(const unsigned globalDofIdx, const std::array< Scalar, numPhases > &fip, const Scalar gasInPlaceWater, const Scalar waterInPlaceGas)
const std::vector< int > blockVelocity() const
Definition: FlowsContainer.hpp:103
Definition: GenericOutputModule.hpp:87
const Schedule & schedule_
Definition: GenericOutputModule.hpp:460
ScalarBuffer oilVaporizationFactor_
Definition: GenericOutputModule.hpp:537
bool forceDisableFipOutput_
Definition: GenericOutputModule.hpp:481
RFTContainer< GetPropType< TypeTag, Properties::FluidSystem > > rftC_
Definition: GenericOutputModule.hpp:566
ScalarBuffer saturatedOilFormationVolumeFactor_
Definition: GenericOutputModule.hpp:542
GeochemistryContainer< Scalar > geochemC_
Definition: GenericOutputModule.hpp:558
ScalarBuffer rockCompPorvMultiplier_
Definition: GenericOutputModule.hpp:540
TracerContainer< GetPropType< TypeTag, Properties::FluidSystem > > tracerC_
Definition: GenericOutputModule.hpp:560
ScalarBuffer hydrocarbonPoreVolume_
Definition: GenericOutputModule.hpp:510
CO2H2Container< Scalar > CO2H2C_
Definition: GenericOutputModule.hpp:545
std::array< ScalarBuffer, numPhases > residual_
Definition: GenericOutputModule.hpp:562
ScalarBuffer sSol_
Definition: GenericOutputModule.hpp:521
void doAllocBuffers(unsigned bufferSize, unsigned reportStepNum, const bool substep, const bool log, const bool isRestart, const EclHysteresisConfig *hysteresisConfig, unsigned numOutputNnc=0, std::map< std::string, int > rstKeywords={})
std::map< std::tuple< std::string, int, int >, double > lgrBlockData_
Definition: GenericOutputModule.hpp:579
void setupExtraBlockData(const std::size_t reportStepNum, std::function< bool(int)> isCartIdxOnThisRank)
std::vector< int > failedCellsPd_
Definition: GenericOutputModule.hpp:507
ScalarBuffer shmax_
Definition: GenericOutputModule.hpp:532
ScalarBuffer sgmax_
Definition: GenericOutputModule.hpp:531
ScalarBuffer rockCompTransMultiplier_
Definition: GenericOutputModule.hpp:543
void setupBlockData(std::function< bool(int)> isCartIdxOnThisRank)
ScalarBuffer minimumOilPressure_
Definition: GenericOutputModule.hpp:541
ScalarBuffer temperature_
Definition: GenericOutputModule.hpp:515
ScalarBuffer pcow_
Definition: GenericOutputModule.hpp:547
ScalarBuffer drsdtcon_
Definition: GenericOutputModule.hpp:520
bool computeFip_
Definition: GenericOutputModule.hpp:483
std::optional< RegionPhasePoreVolAverage > regionAvgDensity_
Definition: GenericOutputModule.hpp:584
ScalarBuffer permFact_
Definition: GenericOutputModule.hpp:527
ScalarBuffer pressureTimesPoreVolume_
Definition: GenericOutputModule.hpp:511
ScalarBuffer overburdenPressure_
Definition: GenericOutputModule.hpp:518
TpsaContainer< Scalar > tpsaC_
Definition: GenericOutputModule.hpp:552
ScalarBuffer rPorV_
Definition: GenericOutputModule.hpp:513
std::array< ScalarBuffer, numPhases > viscosity_
Definition: GenericOutputModule.hpp:556
void setupLgrBlockData(const std::map< std::string, int > &lgrNameToLevel, const std::function< bool(int, int)> &isLgrCellOnThisRank)
ScalarBuffer rvw_
Definition: GenericOutputModule.hpp:517
FIPContainer< GetPropType< TypeTag, Properties::FluidSystem > > fipC_
Definition: GenericOutputModule.hpp:494
ScalarBuffer cPolymer_
Definition: GenericOutputModule.hpp:523
void assignBuffer(data::Solution &sol, std::string_view name, UnitSystem::measure measure, std::vector< Scalar > &buffer)
static bool allocBufferIfRequested(std::map< std::string, int > &rstKeywords, unsigned bufferSize, std::vector< Scalar > &buffer, std::string_view kw, bool supported, bool required=false)
std::unordered_map< std::string, std::vector< int > > regions_
Definition: GenericOutputModule.hpp:495
ScalarBuffer swmin_
Definition: GenericOutputModule.hpp:534
FlowsContainer< GetPropType< TypeTag, Properties::FluidSystem > > flowsC_
Definition: GenericOutputModule.hpp:564
std::map< std::pair< std::string, int >, double > blockData_
Definition: GenericOutputModule.hpp:569
ScalarBuffer gasDissolutionFactor_
Definition: GenericOutputModule.hpp:536
MechContainer< Scalar > mech_
Definition: GenericOutputModule.hpp:551
BioeffectsContainer< Scalar > bioeffectsC_
Definition: GenericOutputModule.hpp:544
ExtboContainer< Scalar > extboC_
Definition: GenericOutputModule.hpp:528
ScalarBuffer gasDissolutionFactorInWater_
Definition: GenericOutputModule.hpp:538
ScalarBuffer pcgw_
Definition: GenericOutputModule.hpp:546
LogOutputHelper< Scalar > logOutput_
Definition: GenericOutputModule.hpp:466
void assignPhaseProperties(data::Solution &sol, const PhasePropertyNames &names)
Move the phase density and viscosity buffers to sol under names.
std::vector< Scalar > ScalarBuffer
Definition: GenericOutputModule.hpp:318
ScalarBuffer somin_
Definition: GenericOutputModule.hpp:533
InterRegFlowMap interRegionFlows_
Definition: GenericOutputModule.hpp:465
ScalarBuffer soMax_
Definition: GenericOutputModule.hpp:529
std::array< ScalarBuffer, numPhases > density_
Definition: GenericOutputModule.hpp:555
ScalarBuffer pressureTimesHydrocarbonVolume_
Definition: GenericOutputModule.hpp:512
ScalarBuffer cFoam_
Definition: GenericOutputModule.hpp:524
ScalarBuffer waterVaporizationFactor_
Definition: GenericOutputModule.hpp:539
std::array< ScalarBuffer, numPhases > saturation_
Definition: GenericOutputModule.hpp:554
ScalarBuffer rsw_
Definition: GenericOutputModule.hpp:516
ScalarBuffer oilSaturationPressure_
Definition: GenericOutputModule.hpp:519
const EclipseState & eclState_
Definition: GenericOutputModule.hpp:459
ScalarBuffer ppcw_
Definition: GenericOutputModule.hpp:535
virtual void assignToSolution(data::Solution &sol)
Move all buffers to data::Solution.
ScalarBuffer cSalt_
Definition: GenericOutputModule.hpp:525
ScalarBuffer pcog_
Definition: GenericOutputModule.hpp:548
const Inplace * initialInplace() const
Definition: GenericOutputModule.hpp:270
ScalarBuffer swMax_
Definition: GenericOutputModule.hpp:530
ScalarBuffer rswSol_
Definition: GenericOutputModule.hpp:522
std::map< std::pair< std::string, int >, double > extraBlockData_
Definition: GenericOutputModule.hpp:572
ScalarBuffer fluidPressure_
Definition: GenericOutputModule.hpp:514
ScalarBuffer gasFormationVolumeFactor_
Definition: GenericOutputModule.hpp:509
virtual void setRestart(const data::Solution &sol, unsigned elemIdx, unsigned globalDofIndex)
std::vector< int > failedCellsPb_
Definition: GenericOutputModule.hpp:506
ScalarBuffer pSalt_
Definition: GenericOutputModule.hpp:526
Inter-region flow accumulation maps for all region definition arrays.
Definition: InterRegFlows.hpp:179
void addConnection(const Cell &source, const Cell &destination, const data::InterRegFlowMap::FlowRates &rates)
void clear()
Clear all internal buffers, but preserve allocated capacity.
Output module for the results black oil model writing in ECL binary format.
Definition: OutputBlackoilModule.hpp:99
void processElement(const ElementContext &elemCtx)
Modify the internal buffers according to the intensive quanties relevant for an element.
Definition: OutputBlackoilModule.hpp:333
void initializeFluxData()
Prepare for capturing connection fluxes, particularly to account for inter-region flows.
Definition: OutputBlackoilModule.hpp:621
void setupExtractors(const bool isSubStep, const int reportStepNum)
Setup list of active element-level data extractors.
Definition: OutputBlackoilModule.hpp:271
void allocBuffers(const unsigned bufferSize, const unsigned reportStepNum, const bool substep, const bool log, const bool isRestart)
Allocate memory for the scalar fields we would like to write to ECL output files.
Definition: OutputBlackoilModule.hpp:249
void processFluxes(const ElementContext &elemCtx, ActiveIndex &&activeIndex, CartesianIndex &&cartesianIndex)
Capture connection fluxes, particularly to account for inter-region flows.
Definition: OutputBlackoilModule.hpp:584
void setRestart(const data::Solution &sol, const unsigned elemIdx, const unsigned globalDofIndex) override
Restore the buffers this module owns from a restart file.
Definition: OutputBlackoilModule.hpp:777
void clearExtractors()
Clear list of active element-level data extractors.
Definition: OutputBlackoilModule.hpp:279
void outputFipAndResvLogToCSV(const std::size_t reportStepNum, const bool substep, const Parallel::Communication &comm)
Definition: OutputBlackoilModule.hpp:518
void allocFormulationBuffers(std::map< std::string, int > &rstKeywords, const unsigned bufferSize) override
Allocate the buffers of the quantities only the black-oil formulation produces, keyed on their restar...
Definition: OutputBlackoilModule.hpp:798
void assignToFluidState(FluidState &fs, unsigned elemIdx) const
Definition: OutputBlackoilModule.hpp:645
void assignToSolution(data::Solution &sol) override
Move all buffers to data::Solution.
Definition: OutputBlackoilModule.hpp:290
void initHysteresisParams(Simulator &simulator, unsigned elemIdx) const
Definition: OutputBlackoilModule.hpp:697
void updateFluidInPlace(const ElementContext &elemCtx)
Definition: OutputBlackoilModule.hpp:762
OutputBlackOilModule(const Simulator &simulator, const SummaryConfig &smryCfg, const CollectDataOnIORankType &collectOnIORank)
Definition: OutputBlackoilModule.hpp:152
void outputFipAndResvLog(const Inplace &inplace, const std::size_t reportStepNum, double elapsed, boost::posix_time::ptime currentDate, const bool substep, const Parallel::Communication &comm)
Definition: OutputBlackoilModule.hpp:467
const InterRegFlowMap & getInterRegFlows() const
Get read-only access to collection of inter-region flows.
Definition: OutputBlackoilModule.hpp:639
void processElementBlockData(const ElementContext &elemCtx)
Definition: OutputBlackoilModule.hpp:379
void finalizeFluxData()
Finalize capturing connection fluxes.
Definition: OutputBlackoilModule.hpp:631
void updateFluidInPlace(const unsigned globalDofIdx, const IntensiveQuantities &intQuants, const double totVolume)
Definition: OutputBlackoilModule.hpp:769
Declare the properties used by the infrastructure code of the finite volume discretizations.
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
Phase
Phase indices for reservoir coupling, we currently only support black-oil phases (oil,...
Definition: ReservoirCoupling.hpp:165
constexpr void ignoreUnused(T &&...) noexcept
Utility to silence "unused variable" warnings in lambdas.
Definition: OutputBlackoilModule.hpp:88
Definition: blackoilbioeffectsmodules.hh:45
std::string moduleVersionName()
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
This file provides the infrastructure to retrieve run-time parameters.
The Opm property system, traits with inheritance.
Definition: GenericOutputModule.hpp:334
std::string_view oilDensity
Definition: GenericOutputModule.hpp:335
Minimal characteristics of a cell from a simulation grid.
Definition: InterRegFlows.hpp:50