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>
33#include <opm/grid/LookUpData.hh>
37#include <opm/common/Exceptions.hpp>
38#include <opm/common/TimingMacros.hpp>
39#include <opm/common/OpmLog/OpmLog.hpp>
40#include <opm/common/utility/Visitor.hpp>
42#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
44#include <opm/material/common/Valgrind.hpp>
45#include <opm/material/fluidmatrixinteractions/EclEpsScalingPoints.hpp>
46#include <opm/material/fluidstates/BlackOilFluidState.hpp>
47#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
54#include <opm/output/data/Cells.hpp>
55#include <opm/output/data/RegionVariableMapping.hpp>
57#include <opm/output/eclipse/EclipseIO.hpp>
58#include <opm/output/eclipse/Inplace.hpp>
59#include <opm/output/eclipse/RegionVariableCollection.hpp>
84template <
class TypeTag>
85class EcfvDiscretization;
89 template <
typename... T>
99template <
class TypeTag>
111 using FluidState =
typename IntensiveQuantities::FluidState;
113 using Element =
typename GridView::template Codim<0>::Entity;
114 using ElementIterator =
typename GridView::template Codim<0>::Iterator;
117 using Dir = FaceDir::DirEnum;
124 static constexpr int conti0EqIdx = Indices::conti0EqIdx;
125 static constexpr int numPhases = FluidSystem::numPhases;
126 static constexpr int oilPhaseIdx = FluidSystem::oilPhaseIdx;
127 static constexpr int gasPhaseIdx = FluidSystem::gasPhaseIdx;
128 static constexpr int waterPhaseIdx = FluidSystem::waterPhaseIdx;
129 static constexpr int gasCompIdx = FluidSystem::gasCompIdx;
130 static constexpr int oilCompIdx = FluidSystem::oilCompIdx;
131 static constexpr int waterCompIdx = FluidSystem::waterCompIdx;
132 static constexpr EnergyModules energyModuleType = getPropValue<TypeTag, Properties::EnergyModuleType>();
133 static constexpr bool enableBioeffects = getPropValue<TypeTag, Properties::EnableBioeffects>();
134 static constexpr bool enableExtbo = getPropValue<TypeTag, Properties::EnableExtbo>();
135 static constexpr bool enableFoam = getPropValue<TypeTag, Properties::EnableFoam>();
136 static constexpr bool enablePolymer = getPropValue<TypeTag, Properties::EnablePolymer>();
137 static constexpr bool enableSolvent = getPropValue<TypeTag, Properties::EnableSolvent>();
138 enum { enableMICP = Indices::enableMICP };
139 enum { enableVapwat = getPropValue<TypeTag, Properties::EnableVapwat>() };
140 enum { enableDisgasInWater = getPropValue<TypeTag, Properties::EnableDisgasInWater>() };
141 static constexpr bool enableDissolvedGas =
142 Indices::compositionSwitchIdx != std::numeric_limits<unsigned>::max();
144 template<
class VectorType>
145 static Scalar value_or_zero(
int idx,
const VectorType& v)
150 return v.empty() ? 0.0 : v[idx];
155 const SummaryConfig& smryCfg,
157 :
BaseType(simulator.vanguard().eclState(),
158 simulator.vanguard().schedule(),
160 simulator.vanguard().summaryState(),
162 [this](const int idx)
163 {
return simulator_.problem().eclWriter().collectOnIORank().localIdxToGlobalIdx(idx); },
164 [&collectOnIORank](
const int idx)
165 {
return collectOnIORank.isCartIdxOnThisRank(idx); },
166 simulator.vanguard().grid().comm(),
167 energyModuleType == EnergyModules::FullyImplicitThermal ||
168 energyModuleType == EnergyModules::SequentialImplicitThermal,
169 energyModuleType == EnergyModules::ConstantTemperature,
170 getPropValue<TypeTag, Properties::EnableMech>(),
171 getPropValue<TypeTag, Properties::EnableSolvent>(),
172 getPropValue<TypeTag, Properties::EnablePolymer>(),
173 getPropValue<TypeTag, Properties::EnableFoam>(),
174 getPropValue<TypeTag, Properties::EnableBrine>(),
175 getPropValue<TypeTag, Properties::EnableSaltPrecipitation>(),
176 getPropValue<TypeTag, Properties::EnableExtbo>(),
177 getPropValue<TypeTag, Properties::EnableBioeffects>(),
178 getPropValue<TypeTag, Properties::EnableGeochemistry>())
179 , simulator_(simulator)
180 , collectOnIORank_(collectOnIORank)
186 this->mapRegionsOntoLeaf_();
188 for (
auto& region_pair : this->
regions_) {
189 this->createLocalRegion_(region_pair.second);
192 auto isCartIdxOnThisRank = [&collectOnIORank](
const int idx) {
193 return collectOnIORank.isCartIdxOnThisRank(idx);
205 std::set<std::pair<int, int>> ownedLgrCells;
206 std::map<std::string, int> lgrNameToLevel;
207 if constexpr (std::is_same_v<Grid, Dune::CpGrid>) {
210 lgrNameToLevel = simulator.vanguard().grid().getLgrNameToLevel();
211 for (
const auto& element : elements(simulator.gridView())) {
212 const int level = element.level();
213 if (level > 0 && element.partitionType() == Dune::InteriorEntity) {
214 const int levelCompressed = element.getLevelElem().index();
215 const int levelCart = simulator.vanguard()
216 .levelCartesianIndexMapper()
217 .cartesianIndex(levelCompressed, level);
218 ownedLgrCells.emplace(level, levelCart);
224 [&ownedLgrCells](
const int level,
const int levelCart) {
225 return ownedLgrCells.count(std::make_pair(level, levelCart)) > 0;
228 if (! Parameters::Get<Parameters::OwnerCellsFirst>()) {
229 const std::string msg =
"The output code does not support --owner-cells-first=false.";
230 if (collectOnIORank.isIORank()) {
233 OPM_THROW_NOLOG(std::runtime_error, msg);
236 if (smryCfg.match(
"[FB]PP[OGW]") || smryCfg.match(
"RPP[OGW]*")) {
237 auto rset = this->
eclState_.fieldProps().fip_regions();
238 rset.push_back(
"PVTNUM");
246 const LookUpData<Grid, GridView> lookUpData(this->simulator_.gridView());
247 auto pvtnum = lookUpData.template assignFieldPropsIntOnLeaf<int>(
248 this->
eclState_.fieldProps(),
"PVTNUM",
false);
251 .emplace(this->simulator_.gridView().comm(),
252 FluidSystem::numPhases, rset,
253 [®ions = std::as_const(this->regions_),
254 pvtnum = std::move(pvtnum)]
255 (
const std::string& rsetName) ->
decltype(
auto)
257 return (rsetName ==
"PVTNUM")
258 ? static_cast<const std::vector<int>&>(pvtnum)
259 : static_cast<const std::vector<int>&>(regions.at(rsetName));
270 const unsigned reportStepNum,
273 const bool forceRestartFieldAllocation)
279 const auto& problem = this->simulator_.problem();
285 forceRestartFieldAllocation,
286 &problem.materialLawManager()->hysteresisConfig(),
287 problem.eclWriter().getOutputNnc().front().size());
292 const int reportStepNum)
294 this->setupElementExtractors_();
295 this->setupBlockExtractors_(isSubStep, reportStepNum);
301 this->extractors_.clear();
302 this->blockExtractors_.clear();
303 this->extraBlockExtractors_.clear();
304 this->lgrBlockExtractors_.clear();
315 using M = UnitSystem::measure;
316 this->
assignBuffer(sol,
"1OVERBO", M::oil_inverse_formation_volume_factor,
317 this->invB_[oilPhaseIdx], oilPhaseIdx);
318 this->
assignBuffer(sol,
"1OVERBG", M::gas_inverse_formation_volume_factor,
319 this->invB_[gasPhaseIdx], gasPhaseIdx);
321 this->relativePermeability_[oilPhaseIdx], oilPhaseIdx);
323 this->relativePermeability_[gasPhaseIdx], gasPhaseIdx);
324 this->
assignBuffer(sol,
"PBUB", M::pressure, this->bubblePointPressure_);
325 this->
assignBuffer(sol,
"PDEW", M::pressure, this->dewPointPressure_);
326 this->
assignBuffer(sol,
"RS", M::gas_oil_ratio, this->rs_);
327 this->
assignBuffer(sol,
"RV", M::oil_gas_ratio, this->rv_);
330 if constexpr (numPhases > 2) {
331 this->
assignBuffer(sol,
"1OVERBW", M::water_inverse_formation_volume_factor,
332 this->invB_[waterPhaseIdx], waterPhaseIdx);
334 this->relativePermeability_[waterPhaseIdx], waterPhaseIdx);
341 .gasDensity =
"GAS_DEN",
342 .waterDensity =
"WAT_DEN",
343 .oilViscosity =
"OIL_VISC",
344 .gasViscosity =
"GAS_VISC",
345 .waterViscosity =
"WAT_VISC",
360 if (this->extractors_.empty()) {
364 const auto& matLawManager = simulator_.problem().materialLawManager();
366 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++dofIdx) {
367 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, 0);
368 const auto& fs = intQuants.fluidState();
369 const auto globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
372 if (matLawManager->enableHysteresis()) {
373 if (FluidSystem::phaseIsActive(oilPhaseIdx) && FluidSystem::phaseIsActive(waterPhaseIdx)) {
374 matLawManager->oilWaterHysteresisParams(hysterParams.
somax,
379 if (FluidSystem::phaseIsActive(oilPhaseIdx) && FluidSystem::phaseIsActive(gasPhaseIdx)) {
380 matLawManager->gasOilHysteresisParams(hysterParams.
sgmax,
389 elemCtx.primaryVars(dofIdx, 0).pvtRegionIndex(),
407 if (this->blockExtractors_.empty() &&
408 this->extraBlockExtractors_.empty() &&
409 this->lgrBlockExtractors_.empty())
420 const auto& element = elemCtx.element();
421 const int level = element.level();
423 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++dofIdx) {
424 const auto globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
426 const std::vector<typename BlockExtractor::Exec>* be_extractors =
nullptr;
427 const std::vector<typename BlockExtractor::Exec>* bee_extractors =
nullptr;
428 const std::vector<typename BlockExtractor::Exec>* lgr_extractors =
nullptr;
431 const auto cartesianIdx = elemCtx.simulator().vanguard().cartesianIndex(globalDofIdx);
432 const auto be_it = this->blockExtractors_.find(cartesianIdx);
433 const auto bee_it = this->extraBlockExtractors_.find(cartesianIdx);
434 if (be_it != this->blockExtractors_.end()) { be_extractors = &be_it->second; }
435 if (bee_it != this->extraBlockExtractors_.end()) { bee_extractors = &bee_it->second; }
437 else if constexpr (std::is_same_v<Grid, Dune::CpGrid>) {
449 const auto level_it = this->lgrBlockExtractors_.find(level);
450 if (level_it != this->lgrBlockExtractors_.end() &&
451 element.partitionType() == Dune::InteriorEntity)
453 const int levelCompressed = element.getLevelElem().index();
454 const int levelCart = elemCtx.simulator().vanguard()
455 .levelCartesianIndexMapper()
456 .cartesianIndex(levelCompressed, level);
457 const auto cell_it = level_it->second.find(levelCart);
458 if (cell_it != level_it->second.end()) {
459 lgr_extractors = &cell_it->second;
464 if (be_extractors ==
nullptr &&
465 bee_extractors ==
nullptr &&
466 lgr_extractors ==
nullptr)
471 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, 0);
472 const auto& fs = intQuants.fluidState();
489 const std::size_t reportStepNum,
491 boost::posix_time::ptime currentDate,
496 if (comm.rank() != 0) {
501 std::unique_ptr<FIPConfig> fipSched;
502 if (reportStepNum > 0) {
503 const auto& rpt = this->
schedule_[reportStepNum-1].rpt_config.get();
504 fipSched = std::make_unique<FIPConfig>(rpt);
506 const FIPConfig& fipc = reportStepNum == 0 ? this->
eclState_.getEclipseConfig().fip()
511 this->
logOutput_.timeStamp(
"BALANCE", elapsed, reportStepNum, currentDate);
514 this->
logOutput_.fip(inplace, initial_inplace,
"");
516 if (fipc.output(FIPConfig::OutputField::FIPNUM)) {
517 this->
logOutput_.fip(inplace, initial_inplace,
"FIPNUM");
519 if (fipc.output(FIPConfig::OutputField::RESV))
523 if (fipc.output(FIPConfig::OutputField::FIP)) {
524 for (
const auto& reg : this->regions_) {
525 if (reg.first !=
"FIPNUM") {
526 std::ostringstream ss;
527 ss <<
"BAL" << reg.first.substr(3);
528 this->
logOutput_.timeStamp(ss.str(), elapsed, reportStepNum, currentDate);
529 this->
logOutput_.fip(inplace, initial_inplace, reg.first);
531 if (fipc.output(FIPConfig::OutputField::RESV))
543 if (comm.rank() != 0) {
547 if ((reportStepNum == 0) && (!substep) &&
548 (this->
schedule_.initialReportConfiguration().has_value()) &&
549 (this->schedule_.initialReportConfiguration()->contains(
"CSVFIP"))) {
551 std::ostringstream csv_stream;
557 this->
logOutput_.fip_csv(csv_stream, initial_inplace,
"FIPNUM");
559 for (
const auto& reg : this->regions_) {
560 if (reg.first !=
"FIPNUM") {
561 this->
logOutput_.fip_csv(csv_stream, initial_inplace, reg.first);
565 const IOConfig& io = this->
eclState_.getIOConfig();
566 auto csv_fname = io.getOutputDir() +
"/" + io.getBaseName() +
".CSV";
568 std::ofstream outputFile(csv_fname);
570 outputFile << csv_stream.str();
604 template <
class ActiveIndex,
class CartesianIndex>
606 ActiveIndex&& activeIndex,
607 CartesianIndex&& cartesianIndex)
610 const auto identifyCell = [&activeIndex, &cartesianIndex](
const Element& elem)
613 const auto cellIndex = activeIndex(elem);
616 static_cast<int>(cellIndex),
617 cartesianIndex(cellIndex),
618 elem.partitionType() == Dune::InteriorEntity
622 const auto timeIdx = 0u;
623 const auto& stencil = elemCtx.stencil(timeIdx);
624 const auto numInteriorFaces = elemCtx.numInteriorFaces(timeIdx);
626 for (
auto scvfIdx = 0 * numInteriorFaces; scvfIdx < numInteriorFaces; ++scvfIdx) {
627 const auto& face = stencil.interiorFace(scvfIdx);
628 const auto left = identifyCell(stencil.element(face.interiorIndex()));
629 const auto right = identifyCell(stencil.element(face.exteriorIndex()));
631 const auto rates = this->
632 getComponentSurfaceRates(elemCtx, face.area(), scvfIdx, timeIdx);
665 template <
class Flu
idState>
668 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
672 fs.setSaturation(phaseIdx, this->
saturation_[phaseIdx][elemIdx]);
678 std::array<Scalar, numPhases> pc = {0};
679 const MaterialLawParams& matParams = simulator_.problem().materialLawParams(elemIdx);
680 MaterialLaw::capillaryPressures(pc, matParams, fs);
682 Valgrind::CheckDefined(pc);
684 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
685 if (!FluidSystem::phaseIsActive(phaseIdx))
688 if (Indices::oilEnabled)
689 fs.setPressure(phaseIdx, pressure + (pc[phaseIdx] - pc[oilPhaseIdx]));
690 else if (Indices::gasEnabled)
691 fs.setPressure(phaseIdx, pressure + (pc[phaseIdx] - pc[gasPhaseIdx]));
692 else if (Indices::waterEnabled)
694 fs.setPressure(phaseIdx, pressure);
698 if constexpr (energyModuleType != EnergyModules::NoTemperature) {
700 fs.setTemperature(this->temperature_[elemIdx]);
702 if constexpr (enableDissolvedGas) {
703 if (!this->rs_.empty())
704 fs.setRs(this->rs_[elemIdx]);
705 if (!this->rv_.empty())
706 fs.setRv(this->rv_[elemIdx]);
708 if constexpr (enableDisgasInWater) {
709 if (!this->
rsw_.empty())
710 fs.setRsw(this->rsw_[elemIdx]);
712 if constexpr (enableVapwat) {
713 if (!this->
rvw_.empty())
714 fs.setRvw(this->rvw_[elemIdx]);
720 if (!this->
soMax_.empty())
721 simulator.problem().setMaxOilSaturation(elemIdx, this->
soMax_[elemIdx]);
723 if (simulator.problem().materialLawManager()->enableHysteresis()) {
724 auto matLawManager = simulator.problem().materialLawManager();
726 if (FluidSystem::phaseIsActive(oilPhaseIdx)
727 && FluidSystem::phaseIsActive(waterPhaseIdx)) {
732 if (matLawManager->enableNonWettingHysteresis()) {
733 if (!this->
soMax_.empty()) {
734 somax = this->
soMax_[elemIdx];
737 if (matLawManager->enableWettingHysteresis()) {
738 if (!this->
swMax_.empty()) {
739 swmax = this->
swMax_[elemIdx];
742 if (matLawManager->enablePCHysteresis()) {
743 if (!this->
swmin_.empty()) {
744 swmin = this->
swmin_[elemIdx];
747 matLawManager->setOilWaterHysteresisParams(
748 somax, swmax, swmin, elemIdx);
750 if (FluidSystem::phaseIsActive(oilPhaseIdx)
751 && FluidSystem::phaseIsActive(gasPhaseIdx)) {
756 if (matLawManager->enableNonWettingHysteresis()) {
757 if (!this->
sgmax_.empty()) {
758 sgmax = this->
sgmax_[elemIdx];
761 if (matLawManager->enableWettingHysteresis()) {
762 if (!this->
shmax_.empty()) {
763 shmax = this->
shmax_[elemIdx];
766 if (matLawManager->enablePCHysteresis()) {
767 if (!this->
somin_.empty()) {
768 somin = this->
somin_[elemIdx];
771 matLawManager->setGasOilHysteresisParams(
772 sgmax, shmax, somin, elemIdx);
777 if (simulator_.vanguard().eclState().fieldProps().has_double(
"SWATINIT")) {
778 simulator.problem().materialLawManager()
779 ->applyRestartSwatInit(elemIdx, this->
ppcw_[elemIdx]);
785 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++dofIdx) {
786 updateFluidInPlace_(elemCtx, dofIdx);
791 const IntensiveQuantities& intQuants,
792 const double totVolume)
794 this->updateFluidInPlace_(globalDofIdx, intQuants, totVolume);
799 const unsigned elemIdx,
800 const unsigned globalDofIndex)
override
804 auto assign = [&sol, elemIdx, globalDofIndex](
const std::string& name,
807 if (!data.empty() && sol.has(name)) {
808 data[elemIdx] = sol.data<
double>(name)[globalDofIndex];
820 const unsigned bufferSize)
override
825 FluidSystem::enableDissolvedGas(),
true);
827 FluidSystem::enableVaporizedOil(),
true);
831 bubblePointPressure_,
"PBPD",
true)) {
832 dewPointPressure_.resize(bufferSize, 0.0);
836 constexpr auto phaseChar = std::string_view{
"WOG"};
837 for (
unsigned phase = 0; phase < numPhases; ++phase) {
838 if (!FluidSystem::phaseIsActive(phase)) {
844 std::string(
"B") + phaseChar[phase],
true);
846 std::string(
"KR") + phaseChar[phase],
true);
856 ScalarBuffer bubblePointPressure_;
857 ScalarBuffer dewPointPressure_;
858 std::array<ScalarBuffer, numPhases> invB_;
859 std::array<ScalarBuffer, numPhases> relativePermeability_;
860 template <
typename T>
861 using RemoveCVR = std::remove_cv_t<std::remove_reference_t<T>>;
863 template <
typename,
class =
void>
864 struct HasGeoMech :
public std::false_type {};
866 template <
typename Problem>
868 Problem, std::void_t<decltype(std::declval<Problem>().geoMechModel())>
869 > :
public std::true_type {};
871 template <
typename,
class =
void>
872 struct HasGeochemistry :
public std::false_type {};
874 template <
typename Problem>
875 struct HasGeochemistry<
876 Problem, std::void_t<decltype(std::declval<Problem>().geochemistryModel())>
877 > :
public std::true_type {};
879 bool isDefunctParallelWell(
const std::string& wname)
const override
881 if (simulator_.gridView().comm().size() == 1)
883 const auto& parallelWells = simulator_.vanguard().parallelWells();
884 std::pair<std::string, bool> value {wname,
true};
885 auto candidate = std::lower_bound(parallelWells.begin(), parallelWells.end(), value);
886 return candidate == parallelWells.end() || *candidate != value;
889 bool isOwnedByCurrentRank(
const std::string& wname)
const override
891 return this->simulator_.problem().wellModel().isOwner(wname);
894 bool isOnCurrentRank(
const std::string& wname)
const override
896 return this->simulator_.problem().wellModel().hasLocalCells(wname);
899 void updateFluidInPlace_(
const ElementContext& elemCtx,
const unsigned dofIdx)
901 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, 0);
902 const unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
903 const auto totVolume = elemCtx.simulator().model().dofTotalVolume(globalDofIdx);
905 this->updateFluidInPlace_(globalDofIdx, intQuants, totVolume);
908 void updateFluidInPlace_(
const unsigned globalDofIdx,
909 const IntensiveQuantities& intQuants,
910 const double totVolume)
917 intQuants.referencePorosity());
920 this->updatePhaseInplaceVolumes_(globalDofIdx, intQuants, totVolume);
928 void mapRegionsOntoLeaf_()
930 const LookUpData<Grid, GridView> lookUpData(simulator_.gridView());
931 const auto numLeaf = simulator_.gridView().size(0);
933 std::vector<int> onLeaf(numLeaf, 0);
934 for (
auto& [name, region] : this->regions_) {
935 std::size_t elemIdx = 0;
936 for (
const auto& elem : elements(simulator_.gridView())) {
937 onLeaf[elemIdx++] = lookUpData(elem, region);
944 void createLocalRegion_(std::vector<int>& region)
946 std::size_t elemIdx = 0;
947 for (
const auto& elem : elements(simulator_.gridView())) {
948 if (elem.partitionType() != Dune::InteriorEntity) {
956 template <
typename Flu
idState>
957 void aggregateAverageDensityContributions_(
const FluidState& fs,
958 const unsigned int globalDofIdx,
961 auto pvCellValue = RegionPhasePoreVolAverage::CellValue{};
962 pvCellValue.porv = porv;
964 for (
auto phaseIdx = 0*FluidSystem::numPhases;
965 phaseIdx < FluidSystem::numPhases; ++phaseIdx)
967 if (! FluidSystem::phaseIsActive(phaseIdx)) {
971 pvCellValue.value = getValue(fs.density(phaseIdx));
972 pvCellValue.sat = getValue(fs.saturation(phaseIdx));
975 ->addCell(globalDofIdx,
996 data::InterRegFlowMap::FlowRates
997 getComponentSurfaceRates(
const ElementContext& elemCtx,
998 const Scalar faceArea,
999 const std::size_t scvfIdx,
1000 const std::size_t timeIdx)
const
1002 using Component = data::InterRegFlowMap::Component;
1004 auto rates = data::InterRegFlowMap::FlowRates {};
1006 const auto& extQuant = elemCtx.extensiveQuantities(scvfIdx, timeIdx);
1008 const auto alpha = getValue(extQuant.extrusionFactor()) * faceArea;
1010 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1011 const auto& up = elemCtx
1012 .intensiveQuantities(extQuant.upstreamIndex(oilPhaseIdx), timeIdx);
1014 const auto pvtReg = up.pvtRegionIndex();
1016 const auto bO = getValue(getInvB_<FluidSystem, FluidState, Scalar>
1017 (up.fluidState(), oilPhaseIdx, pvtReg));
1019 const auto qO = alpha * bO * getValue(extQuant.volumeFlux(oilPhaseIdx));
1021 rates[Component::Oil] += qO;
1023 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1024 const auto Rs = getValue(
1025 BlackOil::getRs_<FluidSystem, FluidState, Scalar>
1026 (up.fluidState(), pvtReg));
1028 rates[Component::Gas] += qO *
Rs;
1029 rates[Component::Disgas] += qO *
Rs;
1033 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1034 const auto& up = elemCtx
1035 .intensiveQuantities(extQuant.upstreamIndex(gasPhaseIdx), timeIdx);
1037 const auto pvtReg = up.pvtRegionIndex();
1039 const auto bG = getValue(getInvB_<FluidSystem, FluidState, Scalar>
1040 (up.fluidState(), gasPhaseIdx, pvtReg));
1042 const auto qG = alpha * bG * getValue(extQuant.volumeFlux(gasPhaseIdx));
1044 rates[Component::Gas] += qG;
1046 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1047 const auto Rv = getValue(
1048 BlackOil::getRv_<FluidSystem, FluidState, Scalar>
1049 (up.fluidState(), pvtReg));
1051 rates[Component::Oil] += qG *
Rv;
1052 rates[Component::Vapoil] += qG *
Rv;
1056 if (FluidSystem::phaseIsActive(waterPhaseIdx)) {
1057 const auto& up = elemCtx
1058 .intensiveQuantities(extQuant.upstreamIndex(waterPhaseIdx), timeIdx);
1060 const auto pvtReg = up.pvtRegionIndex();
1062 const auto bW = getValue(getInvB_<FluidSystem, FluidState, Scalar>
1063 (up.fluidState(), waterPhaseIdx, pvtReg));
1065 rates[Component::Water] +=
1066 alpha * bW * getValue(extQuant.volumeFlux(waterPhaseIdx));
1072 void updatePhaseInplaceVolumes_(
const unsigned globalDofIdx,
1073 const IntensiveQuantities& intQuants,
1074 const double totVolume)
1076 std::array<Scalar, FluidSystem::numPhases> fip {};
1077 std::array<Scalar, FluidSystem::numPhases> fipr{};
1079 const auto& fs = intQuants.fluidState();
1080 const auto pv = totVolume * intQuants.porosity().value();
1082 for (
unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) {
1083 if (!FluidSystem::phaseIsActive(phaseIdx)) {
1087 const auto b = getValue(fs.invB(phaseIdx));
1088 const auto s = getValue(fs.saturation(phaseIdx));
1090 fipr[phaseIdx] = s * pv;
1091 fip [phaseIdx] = b * fipr[phaseIdx];
1096 fs.saltConcentration().value(),
1099 if (FluidSystem::phaseIsActive(oilPhaseIdx) &&
1100 FluidSystem::phaseIsActive(gasPhaseIdx))
1102 this->updateOilGasDistribution(globalDofIdx, fs, fip);
1105 if (FluidSystem::phaseIsActive(waterPhaseIdx) &&
1106 FluidSystem::phaseIsActive(gasPhaseIdx))
1108 this->updateGasWaterDistribution(globalDofIdx, fs, fip);
1111 if (FluidSystem::phaseIsActive(gasPhaseIdx) &&
1114 this->updateCO2InGas(globalDofIdx, pv, intQuants);
1118 (FluidSystem::phaseIsActive(waterPhaseIdx) ||
1119 FluidSystem::phaseIsActive(oilPhaseIdx)))
1121 this->updateCO2InWater(globalDofIdx, pv, fs);
1124 if constexpr(enableBioeffects) {
1125 const auto surfVolWat = pv * getValue(fs.saturation(waterPhaseIdx)) *
1126 getValue(fs.invB(waterPhaseIdx));
1128 this->updateMicrobialMass(globalDofIdx, intQuants, surfVolWat);
1131 this->updateBiofilmMass(globalDofIdx, intQuants, totVolume);
1133 if constexpr(enableMICP) {
1135 this->updateOxygenMass(globalDofIdx, intQuants, surfVolWat);
1138 this->updateUreaMass(globalDofIdx, intQuants, surfVolWat);
1141 this->updateCalciteMass(globalDofIdx, intQuants, totVolume);
1148 this->updateWaterMass(globalDofIdx, fs, fip);
1152 template <
typename Flu
idState,
typename FIPArray>
1153 void updateOilGasDistribution(
const unsigned globalDofIdx,
1154 const FluidState& fs,
1155 const FIPArray& fip)
1158 const auto gasInPlaceLiquid = getValue(fs.Rs()) * fip[oilPhaseIdx];
1159 const auto oilInPlaceGas = getValue(fs.Rv()) * fip[gasPhaseIdx];
1164 template <
typename Flu
idState,
typename FIPArray>
1165 void updateGasWaterDistribution(
const unsigned globalDofIdx,
1166 const FluidState& fs,
1167 const FIPArray& fip)
1170 const auto gasInPlaceWater = getValue(fs.Rsw()) * fip[waterPhaseIdx];
1171 const auto waterInPlaceGas = getValue(fs.Rvw()) * fip[gasPhaseIdx];
1176 template <
typename IntensiveQuantities>
1177 void updateCO2InGas(
const unsigned globalDofIdx,
1179 const IntensiveQuantities& intQuants)
1181 const auto& scaledDrainageInfo = this->simulator_.problem().materialLawManager()
1182 ->oilWaterScaledEpsInfoDrainage(globalDofIdx);
1184 const auto& fs = intQuants.fluidState();
1185 Scalar sgcr = scaledDrainageInfo.Sgcr;
1186 if (this->simulator_.problem().materialLawManager()->enableHysteresis()) {
1187 const auto& matParams = simulator_.problem().materialLawParams(globalDofIdx);
1188 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
1191 Scalar trappedGasSaturation = scaledDrainageInfo.Sgcr;
1192 if (this->
fipC_.
has(Inplace::Phase::CO2MassInGasPhaseMaximumTrapped) ||
1193 this->fipC_.has(Inplace::Phase::CO2MassInGasPhaseMaximumUnTrapped))
1195 if (this->simulator_.problem().materialLawManager()->enableHysteresis()) {
1196 const auto& matParams = simulator_.problem().materialLawParams(globalDofIdx);
1198 trappedGasSaturation = MaterialLaw::trappedGasSaturation(matParams,
true);
1202 const Scalar sg = getValue(fs.saturation(gasPhaseIdx));
1203 Scalar strandedGasSaturation = scaledDrainageInfo.Sgcr;
1204 if (this->
fipC_.
has(Inplace::Phase::CO2MassInGasPhaseEffectiveTrapped) ||
1205 this->fipC_.has(Inplace::Phase::CO2MassInGasPhaseEffectiveUnTrapped))
1207 if (this->simulator_.problem().materialLawManager()->enableHysteresis()) {
1208 const auto& matParams = simulator_.problem().materialLawParams(globalDofIdx);
1209 const double krg = getValue(intQuants.relativePermeability(gasPhaseIdx));
1210 strandedGasSaturation = MaterialLaw::strandedGasSaturation(matParams, sg, krg);
1214 const typename FIPContainer<FluidSystem>::Co2InGasInput v{
1218 getValue(fs.density(gasPhaseIdx)),
1219 FluidSystem::phaseIsActive(waterPhaseIdx)
1220 ? FluidSystem::convertRvwToXgW(getValue(fs.Rvw()), fs.pvtRegionIndex())
1221 : FluidSystem::convertRvToXgO(getValue(fs.
Rv()), fs.pvtRegionIndex()),
1222 FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex()),
1223 trappedGasSaturation,
1224 strandedGasSaturation,
1230 template <
typename Flu
idState>
1231 void updateCO2InWater(
const unsigned globalDofIdx,
1233 const FluidState& fs)
1235 const auto co2InWater = FluidSystem::phaseIsActive(oilPhaseIdx)
1236 ? this->co2InWaterFromOil(fs, pv)
1237 : this->co2InWaterFromWater(fs, pv);
1239 const Scalar mM = FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex());
1244 template <
typename Flu
idState>
1245 Scalar co2InWaterFromWater(
const FluidState& fs,
const double pv)
const
1247 const double rhow = getValue(fs.density(waterPhaseIdx));
1248 const double sw = getValue(fs.saturation(waterPhaseIdx));
1249 const double xwG = FluidSystem::convertRswToXwG(getValue(fs.Rsw()), fs.pvtRegionIndex());
1251 const Scalar mM = FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex());
1253 return xwG * pv * rhow * sw / mM;
1256 template <
typename Flu
idState>
1257 Scalar co2InWaterFromOil(
const FluidState& fs,
const double pv)
const
1259 const double rhoo = getValue(fs.density(oilPhaseIdx));
1260 const double so = getValue(fs.saturation(oilPhaseIdx));
1261 const double xoG = FluidSystem::convertRsToXoG(getValue(fs.Rs()), fs.pvtRegionIndex());
1263 const Scalar mM = FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex());
1265 return xoG * pv * rhoo * so / mM;
1268 template <
typename Flu
idState,
typename FIPArray>
1269 void updateWaterMass(
const unsigned globalDofIdx,
1270 const FluidState& fs,
1274 const Scalar rhoW = FluidSystem::referenceDensity(waterPhaseIdx, fs.pvtRegionIndex());
1279 template <
typename IntensiveQuantities>
1280 void updateMicrobialMass(
const unsigned globalDofIdx,
1281 const IntensiveQuantities& intQuants,
1282 const double surfVolWat)
1284 const Scalar mass = surfVolWat * intQuants.microbialConcentration().value();
1289 template <
typename IntensiveQuantities>
1290 void updateOxygenMass(
const unsigned globalDofIdx,
1291 const IntensiveQuantities& intQuants,
1292 const double surfVolWat)
1294 const Scalar mass = surfVolWat * intQuants.oxygenConcentration().value();
1299 template <
typename IntensiveQuantities>
1300 void updateUreaMass(
const unsigned globalDofIdx,
1301 const IntensiveQuantities& intQuants,
1302 const double surfVolWat)
1304 const Scalar mass = surfVolWat * intQuants.ureaConcentration().value();
1309 template <
typename IntensiveQuantities>
1310 void updateBiofilmMass(
const unsigned globalDofIdx,
1311 const IntensiveQuantities& intQuants,
1312 const double totVolume)
1314 const Scalar mass = totVolume * intQuants.biofilmMass().value();
1319 template <
typename IntensiveQuantities>
1320 void updateCalciteMass(
const unsigned globalDofIdx,
1321 const IntensiveQuantities& intQuants,
1322 const double totVolume)
1324 const Scalar mass = totVolume * intQuants.calciteMass().value();
1330 void setupElementExtractors_()
1332 using Entry =
typename Extractor::Entry;
1333 using Context =
typename Extractor::Context;
1334 using ScalarEntry =
typename Extractor::ScalarEntry;
1335 using PhaseEntry =
typename Extractor::PhaseEntry;
1337 const bool hasResidual = simulator_.model().linearizer().residual().size() > 0;
1338 const auto& hysteresisConfig = simulator_.problem().materialLawManager()->hysteresisConfig();
1340 auto extractors = std::array{
1342 [](
const unsigned phase,
const Context& ectx)
1343 {
return getValue(ectx.fs.saturation(phase)); }
1346 Entry{PhaseEntry{&this->invB_,
1347 [](
const unsigned phase,
const Context& ectx)
1348 {
return getValue(ectx.fs.invB(phase)); }
1352 [](
const unsigned phase,
const Context& ectx)
1353 {
return getValue(ectx.fs.density(phase)); }
1356 Entry{PhaseEntry{&this->relativePermeability_,
1357 [](
const unsigned phase,
const Context& ectx)
1358 {
return getValue(ectx.intQuants.relativePermeability(phase)); }
1362 [
this](
const unsigned phaseIdx,
const Context& ectx)
1365 if constexpr (enableExtbo) {
1366 if (this->
extboC_.allocated() && phaseIdx == oilPhaseIdx) {
1367 return getValue(ectx.intQuants.oilViscosity());
1369 else if (this->
extboC_.allocated() && phaseIdx == gasPhaseIdx) {
1370 return getValue(ectx.intQuants.gasViscosity());
1373 return getValue(ectx.fs.viscosity(phaseIdx));
1378 [&modelResid = this->simulator_.model().linearizer().residual()]
1379 (
const unsigned phaseIdx,
const Context& ectx)
1381 const unsigned sIdx = FluidSystem::solventComponentIndex(phaseIdx);
1382 const unsigned activeCompIdx = FluidSystem::canonicalToActiveCompIdx(sIdx);
1383 return modelResid[ectx.globalDofIdx][activeCompIdx];
1389 [&problem = this->simulator_.problem()](
const Context& ectx)
1391 return problem.template
1392 rockCompPoroMultiplier<Scalar>(ectx.intQuants,
1398 [&problem = this->simulator_.problem()](
const Context& ectx)
1401 template rockCompTransMultiplier<Scalar>(ectx.intQuants,
1406 [&problem = this->simulator_.problem()](
const Context& ectx)
1408 return std::min(getValue(ectx.fs.pressure(oilPhaseIdx)),
1409 problem.minOilPressure(ectx.globalDofIdx));
1413 Entry{ScalarEntry{&this->bubblePointPressure_,
1415 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1419 FluidSystem::bubblePointPressure(ectx.fs,
1420 ectx.intQuants.pvtRegionIndex())
1422 }
catch (
const NumericalProblem&) {
1423 const auto cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1424 failedCells.push_back(cartesianIdx);
1430 Entry{ScalarEntry{&this->dewPointPressure_,
1432 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1436 FluidSystem::dewPointPressure(ectx.fs,
1437 ectx.intQuants.pvtRegionIndex())
1439 }
catch (
const NumericalProblem&) {
1440 const auto cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1441 failedCells.push_back(cartesianIdx);
1448 [&problem = simulator_.problem()](
const Context& ectx)
1449 {
return problem.overburdenPressure(ectx.globalDofIdx); }
1453 [](
const Context& ectx)
1454 {
return getValue(ectx.fs.temperature(oilPhaseIdx)); }
1457 Entry{ScalarEntry{&this->
sSol_,
1458 [](
const Context& ectx)
1460 if constexpr (enableSolvent) {
1461 return getValue(ectx.intQuants.solventSaturation());
1469 Entry{ScalarEntry{&this->
rswSol_,
1470 [](
const Context& ectx)
1472 if constexpr (enableSolvent) {
1473 return getValue(ectx.intQuants.rsSolw());
1482 [](
const Context& ectx)
1484 if constexpr (enablePolymer) {
1485 return getValue(ectx.intQuants.polymerConcentration());
1493 Entry{ScalarEntry{&this->
cFoam_,
1494 [](
const Context& ectx)
1496 if constexpr (enableFoam) {
1497 return getValue(ectx.intQuants.foamConcentration());
1505 Entry{ScalarEntry{&this->
cSalt_,
1506 [](
const Context& ectx)
1507 {
return getValue(ectx.fs.saltConcentration()); }
1510 Entry{ScalarEntry{&this->
pSalt_,
1511 [](
const Context& ectx)
1512 {
return getValue(ectx.fs.saltSaturation()); }
1516 [](
const Context& ectx)
1517 {
return getValue(ectx.intQuants.permFactor()); }
1520 Entry{ScalarEntry{&this->
rPorV_,
1521 [&model = this->simulator_.model()](
const Context& ectx)
1523 const auto totVolume = model.dofTotalVolume(ectx.globalDofIdx);
1524 return totVolume * getValue(ectx.intQuants.porosity());
1528 Entry{ScalarEntry{&this->rs_,
1529 [](
const Context& ectx)
1530 {
return getValue(ectx.fs.Rs()); }
1533 Entry{ScalarEntry{&this->rv_,
1534 [](
const Context& ectx)
1535 {
return getValue(ectx.fs.Rv()); }
1538 Entry{ScalarEntry{&this->
rsw_,
1539 [](
const Context& ectx)
1540 {
return getValue(ectx.fs.Rsw()); }
1543 Entry{ScalarEntry{&this->
rvw_,
1544 [](
const Context& ectx)
1545 {
return getValue(ectx.fs.Rvw()); }
1548 Entry{ScalarEntry{&this->
ppcw_,
1549 [&matLawManager = *this->simulator_.problem().materialLawManager()]
1550 (
const Context& ectx)
1552 return matLawManager.
1553 oilWaterScaledEpsInfoDrainage(ectx.globalDofIdx).maxPcow;
1558 [&problem = this->simulator_.problem()](
const Context& ectx)
1560 return problem.drsdtcon(ectx.globalDofIdx,
1565 Entry{ScalarEntry{&this->
pcgw_,
1566 [](
const Context& ectx)
1568 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
1569 getValue(ectx.fs.pressure(waterPhaseIdx));
1573 Entry{ScalarEntry{&this->
pcow_,
1574 [](
const Context& ectx)
1576 return getValue(ectx.fs.pressure(oilPhaseIdx)) -
1577 getValue(ectx.fs.pressure(waterPhaseIdx));
1581 Entry{ScalarEntry{&this->
pcog_,
1582 [](
const Context& ectx)
1584 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
1585 getValue(ectx.fs.pressure(oilPhaseIdx));
1590 [](
const Context& ectx)
1592 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1594 return getValue(ectx.fs.pressure(oilPhaseIdx));
1596 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1598 return getValue(ectx.fs.pressure(gasPhaseIdx));
1602 return getValue(ectx.fs.pressure(waterPhaseIdx));
1608 [&problem = this->simulator_.problem()](
const Context& ectx)
1610 const Scalar SoMax = problem.maxOilSaturation(ectx.globalDofIdx);
1611 return FluidSystem::template
1612 saturatedDissolutionFactor<FluidState, Scalar>(ectx.fs,
1620 [&problem = this->simulator_.problem()](
const Context& ectx)
1622 const Scalar SoMax = problem.maxOilSaturation(ectx.globalDofIdx);
1623 return FluidSystem::template
1624 saturatedDissolutionFactor<FluidState, Scalar>(ectx.fs,
1632 [&problem = this->simulator_.problem()](
const Context& ectx)
1634 const Scalar SwMax = problem.maxWaterSaturation(ectx.globalDofIdx);
1635 return FluidSystem::template
1636 saturatedDissolutionFactor<FluidState, Scalar>(ectx.fs,
1644 [](
const Context& ectx)
1646 return FluidSystem::template
1647 saturatedVaporizationFactor<FluidState, Scalar>(ectx.fs,
1654 [](
const Context& ectx)
1656 return 1.0 / FluidSystem::template
1657 inverseFormationVolumeFactor<FluidState, Scalar>(ectx.fs,
1664 [](
const Context& ectx)
1666 return 1.0 / FluidSystem::template
1667 saturatedInverseFormationVolumeFactor<FluidState, Scalar>(ectx.fs,
1674 [](
const Context& ectx)
1676 return FluidSystem::template
1677 saturationPressure<FluidState, Scalar>(ectx.fs,
1683 Entry{ScalarEntry{&this->
soMax_,
1684 [&problem = this->simulator_.problem()](
const Context& ectx)
1686 return std::max(getValue(ectx.fs.saturation(oilPhaseIdx)),
1687 problem.maxOilSaturation(ectx.globalDofIdx));
1690 !hysteresisConfig.enableHysteresis()
1692 Entry{ScalarEntry{&this->
swMax_,
1693 [&problem = this->simulator_.problem()](
const Context& ectx)
1695 return std::max(getValue(ectx.fs.saturation(waterPhaseIdx)),
1696 problem.maxWaterSaturation(ectx.globalDofIdx));
1699 !hysteresisConfig.enableHysteresis()
1701 Entry{ScalarEntry{&this->
soMax_,
1702 [](
const Context& ectx)
1703 {
return ectx.hParams.somax; }
1705 hysteresisConfig.enableHysteresis() &&
1706 hysteresisConfig.enableNonWettingHysteresis() &&
1707 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1708 FluidSystem::phaseIsActive(waterPhaseIdx)
1710 Entry{ScalarEntry{&this->
swMax_,
1711 [](
const Context& ectx)
1712 {
return ectx.hParams.swmax; }
1714 hysteresisConfig.enableHysteresis() &&
1715 hysteresisConfig.enableWettingHysteresis() &&
1716 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1717 FluidSystem::phaseIsActive(waterPhaseIdx)
1719 Entry{ScalarEntry{&this->
swmin_,
1720 [](
const Context& ectx)
1721 {
return ectx.hParams.swmin; }
1723 hysteresisConfig.enableHysteresis() &&
1724 hysteresisConfig.enablePCHysteresis() &&
1725 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1726 FluidSystem::phaseIsActive(waterPhaseIdx)
1728 Entry{ScalarEntry{&this->
sgmax_,
1729 [](
const Context& ectx)
1730 {
return ectx.hParams.sgmax; }
1732 hysteresisConfig.enableHysteresis() &&
1733 hysteresisConfig.enableNonWettingHysteresis() &&
1734 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1735 FluidSystem::phaseIsActive(gasPhaseIdx)
1737 Entry{ScalarEntry{&this->
shmax_,
1738 [](
const Context& ectx)
1739 {
return ectx.hParams.shmax; }
1741 hysteresisConfig.enableHysteresis() &&
1742 hysteresisConfig.enableWettingHysteresis() &&
1743 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1744 FluidSystem::phaseIsActive(gasPhaseIdx)
1746 Entry{ScalarEntry{&this->
somin_,
1747 [](
const Context& ectx)
1748 {
return ectx.hParams.somin; }
1750 hysteresisConfig.enableHysteresis() &&
1751 hysteresisConfig.enablePCHysteresis() &&
1752 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1753 FluidSystem::phaseIsActive(gasPhaseIdx)
1755 Entry{[&model = this->simulator_.model(),
this](
const Context& ectx)
1759 const auto porv = ectx.intQuants.referencePorosity()
1760 * model.dofTotalVolume(ectx.globalDofIdx);
1762 this->aggregateAverageDensityContributions_(ectx.fs, ectx.globalDofIdx,
1763 static_cast<double>(porv));
1766 Entry{[&extboC = this->
extboC_](
const Context& ectx)
1769 if constexpr (enableExtbo) {
1770 extboC.assignVolumes(ectx.globalDofIdx,
1771 ectx.intQuants.xVolume().value(),
1772 ectx.intQuants.yVolume().value());
1773 extboC.assignZFraction(ectx.globalDofIdx,
1774 ectx.intQuants.zFraction().value());
1776 const Scalar stdVolOil = getValue(ectx.fs.saturation(oilPhaseIdx)) *
1777 getValue(ectx.fs.invB(oilPhaseIdx)) +
1778 getValue(ectx.fs.saturation(gasPhaseIdx)) *
1779 getValue(ectx.fs.invB(gasPhaseIdx)) *
1780 getValue(ectx.fs.Rv());
1781 const Scalar stdVolGas = getValue(ectx.fs.saturation(gasPhaseIdx)) *
1782 getValue(ectx.fs.invB(gasPhaseIdx)) *
1783 (1.0 - ectx.intQuants.yVolume().value()) +
1784 getValue(ectx.fs.saturation(oilPhaseIdx)) *
1785 getValue(ectx.fs.invB(oilPhaseIdx)) *
1786 getValue(ectx.fs.Rs()) *
1787 (1.0 - ectx.intQuants.xVolume().value());
1788 const Scalar stdVolCo2 = getValue(ectx.fs.saturation(gasPhaseIdx)) *
1789 getValue(ectx.fs.invB(gasPhaseIdx)) *
1790 ectx.intQuants.yVolume().value() +
1791 getValue(ectx.fs.saturation(oilPhaseIdx)) *
1792 getValue(ectx.fs.invB(oilPhaseIdx)) *
1793 getValue(ectx.fs.Rs()) *
1794 ectx.intQuants.xVolume().value();
1795 const Scalar rhoO = FluidSystem::referenceDensity(oilPhaseIdx, ectx.pvtRegionIdx);
1796 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx, ectx.pvtRegionIdx);
1797 const Scalar rhoCO2 = ectx.intQuants.zRefDensity();
1798 const Scalar stdMassTotal = 1.0e-10 + stdVolOil * rhoO + stdVolGas * rhoG + stdVolCo2 * rhoCO2;
1799 extboC.assignMassFractions(ectx.globalDofIdx,
1800 stdVolGas * rhoG / stdMassTotal,
1801 stdVolOil * rhoO / stdMassTotal,
1802 stdVolCo2 * rhoCO2 / stdMassTotal);
1804 if (extboC.phaseMassFractionsRequested()) {
1805 const auto [oil, gas] = extboC.phaseSolventMassFractions({
1806 .oilSaturation = getValue(ectx.fs.saturation(oilPhaseIdx)),
1807 .gasSaturation = getValue(ectx.fs.saturation(gasPhaseIdx)),
1808 .rs = getValue(ectx.fs.Rs()),
1809 .rv = getValue(ectx.fs.Rv()),
1810 .xVolume = ectx.intQuants.xVolume().value(),
1811 .yVolume = ectx.intQuants.yVolume().value(),
1814 .solventDensity = rhoCO2,
1816 extboC.assignPhaseMassFractions(ectx.globalDofIdx, oil, gas);
1821 Entry{[&bioeffectsC = this->
bioeffectsC_](
const Context& ectx)
1824 if constexpr (enableBioeffects) {
1825 bioeffectsC.assign(ectx.globalDofIdx,
1826 ectx.intQuants.microbialConcentration().value(),
1827 ectx.intQuants.biofilmVolumeFraction().value());
1828 if (Indices::enableMICP) {
1829 bioeffectsC.assign(ectx.globalDofIdx,
1830 ectx.intQuants.oxygenConcentration().value(),
1831 ectx.intQuants.ureaConcentration().value(),
1832 ectx.intQuants.calciteVolumeFraction().value());
1837 Entry{[&runspec = this->
eclState_.runspec(),
1838 &CO2H2C = this->
CO2H2C_](
const Context& ectx)
1840 const auto xwg = FluidSystem::convertRswToXwG(getValue(ectx.fs.Rsw()), ectx.pvtRegionIdx);
1841 const auto xgw = FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.pvtRegionIdx);
1842 CO2H2C.assign(ectx.globalDofIdx,
1843 FluidSystem::convertXwGToxwG(xwg, ectx.pvtRegionIdx),
1844 FluidSystem::convertXgWToxgW(xgw, ectx.pvtRegionIdx),
1845 runspec.co2Storage());
1848 Entry{[&rftC = this->
rftC_,
1849 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1851 const auto cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1852 rftC.assign(cartesianIdx,
1857 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1858 return getValue(fs.pressure(oilPhaseIdx));
1860 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1861 return getValue(fs.pressure(gasPhaseIdx));
1864 return getValue(fs.pressure(waterPhaseIdx));
1867 [&fs = ectx.fs]() {
return getValue(fs.saturation(waterPhaseIdx)); },
1868 [&fs = ectx.fs]() {
return getValue(fs.saturation(gasPhaseIdx)); });
1872 &tM = this->simulator_.problem().tracerModel()](
const Context& ectx)
1874 tC.assignFreeConcentrations(ectx.globalDofIdx,
1875 [gIdx = ectx.globalDofIdx, &tM](
const unsigned tracerIdx)
1876 {
return tM.freeTracerConcentration(tracerIdx, gIdx); });
1877 tC.assignSolConcentrations(ectx.globalDofIdx,
1878 [gIdx = ectx.globalDofIdx, &tM](
const unsigned tracerIdx)
1879 {
return tM.solTracerConcentration(tracerIdx, gIdx); });
1882 Entry{[&flowsInf = this->simulator_.problem().model().linearizer().getFlowsInfo(),
1884 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1886 const auto gas_idx = Indices::gasEnabled ?
1887 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(gasCompIdx) : -1;
1888 const auto oil_idx = Indices::oilEnabled ?
1889 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(oilCompIdx) : -1;
1890 const auto water_idx = Indices::waterEnabled ?
1891 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(waterCompIdx) : -1;
1892 const auto& flowsInfos = flowsInf[ectx.globalDofIdx];
1893 if (!flowsC.blockFlows().empty()) {
1894 const std::vector<int>& blockIdxs = flowsC.blockFlows();
1895 const unsigned cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1896 if (std::ranges::binary_search(blockIdxs, cartesianIdx)) {
1897 const auto compIdxs = std::array{ gasCompIdx, oilCompIdx, waterCompIdx };
1898 const auto compEnabled = std::array{ Indices::gasEnabled, Indices::oilEnabled, Indices::waterEnabled };
1899 for (
const auto& flowsInfo : flowsInfos) {
1900 if (flowsInfo.faceId < 0) {
1903 for (
unsigned ii = 0; ii < compIdxs.size(); ++ii) {
1904 if (!compEnabled[ii]) {
1907 if (flowsC.hasBlockFlowValue(cartesianIdx, flowsInfo.faceId, compIdxs[ii])) {
1908 flowsC.assignBlockFlows(flowsC.blockFlowsIds(cartesianIdx, flowsInfo.faceId, compIdxs[ii]),
1911 flowsInfo.flow[conti0EqIdx
1912 + FluidSystem::canonicalToActiveCompIdx(compIdxs[ii])]);
1919 for (
const auto& flowsInfo : flowsInfos) {
1920 flowsC.assignFlows(ectx.globalDofIdx,
1923 value_or_zero(gas_idx, flowsInfo.flow),
1924 value_or_zero(oil_idx, flowsInfo.flow),
1925 value_or_zero(water_idx, flowsInfo.flow));
1928 }, !this->simulator_.problem().model().linearizer().getFlowsInfo().empty()
1930 Entry{[&floresInf = this->simulator_.problem().model().linearizer().getFloresInfo(),
1931 &flowsC = this->
flowsC_](
const Context& ectx)
1933 const auto gas_idx = Indices::gasEnabled ?
1934 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(gasCompIdx) : -1;
1935 const auto oil_idx = Indices::oilEnabled ?
1936 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(oilCompIdx) : -1;
1937 const auto water_idx = Indices::waterEnabled ?
1938 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(waterCompIdx) : -1;
1939 const auto& floresInfos = floresInf[ectx.globalDofIdx];
1940 for (
const auto& floresInfo : floresInfos) {
1941 flowsC.assignFlores(ectx.globalDofIdx,
1944 value_or_zero(gas_idx, floresInfo.flow),
1945 value_or_zero(oil_idx, floresInfo.flow),
1946 value_or_zero(water_idx, floresInfo.flow));
1948 }, !this->simulator_.problem().model().linearizer().getFloresInfo().empty()
1950 Entry{[&velocityInf = this->simulator_.problem().model().linearizer().getVelocityInfo(),
1952 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1954 const auto& velocityInfos = velocityInf[ectx.globalDofIdx];
1955 const std::vector<int>& blockIdxs = flowsC.blockVelocity();
1956 const unsigned cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1957 if (std::ranges::binary_search(blockIdxs, cartesianIdx)) {
1958 const auto compIdxs = std::array{ gasCompIdx, oilCompIdx, waterCompIdx };
1959 const auto compEnabled = std::array{ Indices::gasEnabled, Indices::oilEnabled, Indices::waterEnabled };
1960 for (
const auto& velocityInfo : velocityInfos) {
1961 if (velocityInfo.faceId < 0) {
1964 for (
unsigned ii = 0; ii < compIdxs.size(); ++ii) {
1965 if (!compEnabled[ii]) {
1968 if (flowsC.hasBlockVelocityValue(cartesianIdx, velocityInfo.faceId, compIdxs[ii])) {
1969 flowsC.assignBlockVelocity(flowsC.blockVelocityIds(cartesianIdx, velocityInfo.faceId, compIdxs[ii]),
1970 velocityInfo.faceId,
1972 velocityInfo.velocity[conti0EqIdx
1973 + FluidSystem::canonicalToActiveCompIdx(compIdxs[ii])]);
1979 !this->simulator_.problem().model().linearizer().getVelocityInfo().empty()
1986 Entry{ScalarEntry{&this->rv_,
1987 [&problem = this->simulator_.problem()](
const Context& ectx)
1988 {
return problem.initialFluidState(ectx.globalDofIdx).Rv(); }
1990 simulator_.episodeIndex() < 0 &&
1991 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1992 FluidSystem::phaseIsActive(gasPhaseIdx)
1994 Entry{ScalarEntry{&this->rs_,
1995 [&problem = this->simulator_.problem()](
const Context& ectx)
1996 {
return problem.initialFluidState(ectx.globalDofIdx).Rs(); }
1998 simulator_.episodeIndex() < 0 &&
1999 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2000 FluidSystem::phaseIsActive(gasPhaseIdx)
2002 Entry{ScalarEntry{&this->
rsw_,
2003 [&problem = this->simulator_.problem()](
const Context& ectx)
2004 {
return problem.initialFluidState(ectx.globalDofIdx).Rsw(); }
2006 simulator_.episodeIndex() < 0 &&
2007 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2008 FluidSystem::phaseIsActive(gasPhaseIdx)
2010 Entry{ScalarEntry{&this->
rvw_,
2011 [&problem = this->simulator_.problem()](
const Context& ectx)
2012 {
return problem.initialFluidState(ectx.globalDofIdx).Rvw(); }
2014 simulator_.episodeIndex() < 0 &&
2015 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2016 FluidSystem::phaseIsActive(gasPhaseIdx)
2020 [&problem = this->simulator_.problem()](
const unsigned phase,
2021 const Context& ectx)
2023 const auto& fsInitial = problem.initialFluidState(ectx.globalDofIdx);
2024 return FluidSystem::density(fsInitial,
2026 ectx.intQuants.pvtRegionIndex());
2029 simulator_.episodeIndex() < 0 &&
2030 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2031 FluidSystem::phaseIsActive(gasPhaseIdx)
2033 Entry{PhaseEntry{&this->invB_,
2034 [&problem = this->simulator_.problem()](
const unsigned phase,
2035 const Context& ectx)
2037 const auto& fsInitial = problem.initialFluidState(ectx.globalDofIdx);
2038 return FluidSystem::inverseFormationVolumeFactor(fsInitial,
2040 ectx.intQuants.pvtRegionIndex());
2043 simulator_.episodeIndex() < 0 &&
2044 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2045 FluidSystem::phaseIsActive(gasPhaseIdx)
2048 [&problem = this->simulator_.problem()](
const unsigned phase,
2049 const Context& ectx)
2051 const auto& fsInitial = problem.initialFluidState(ectx.globalDofIdx);
2052 return FluidSystem::viscosity(fsInitial,
2054 ectx.intQuants.pvtRegionIndex());
2057 simulator_.episodeIndex() < 0 &&
2058 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2059 FluidSystem::phaseIsActive(gasPhaseIdx)
2067 if constexpr (getPropValue<TypeTag, Properties::EnableGeochemistry>()) {
2069 this->extractors_.emplace_back(
2071 &gM = this->simulator_.problem().geochemistryModel()](
const Context& ectx)
2073 gC.assignSpeciesConcentrations(
2075 [gIdx = ectx.globalDofIdx, &gM](
const unsigned speciesIdx)
2076 {
return gM.speciesConcentration(speciesIdx, gIdx); }
2078 gC.assignMineralConcentrations(
2080 [gIdx = ectx.globalDofIdx, &gM](
const unsigned mineralIdx)
2081 {
return gM.mineralConcentration(mineralIdx, gIdx); }
2083 gC.assignPH(ectx.globalDofIdx, gM.PH(ectx.globalDofIdx));
2091 if constexpr (getPropValue<TypeTag, Properties::EnableMech>()) {
2092 if (this->
mech_.allocated()) {
2093 this->extractors_.emplace_back(
2094 [&mech = this->
mech_,
2095 &model = simulator_.problem().geoMechModel()](
const Context& ectx)
2097 mech.assignDelStress(ectx.globalDofIdx,
2098 model.delstress(ectx.globalDofIdx));
2100 mech.assignDisplacement(ectx.globalDofIdx,
2101 model.disp(ectx.globalDofIdx,
true));
2104 mech.assignFracStress(ectx.globalDofIdx,
2105 model.fractureStress(ectx.globalDofIdx));
2107 mech.assignLinStress(ectx.globalDofIdx,
2108 model.linstress(ectx.globalDofIdx));
2110 mech.assignPotentialForces(ectx.globalDofIdx,
2111 model.mechPotentialForce(ectx.globalDofIdx),
2112 model.mechPotentialPressForce(ectx.globalDofIdx),
2113 model.mechPotentialTempForce(ectx.globalDofIdx));
2115 mech.assignStrain(ectx.globalDofIdx,
2116 model.strain(ectx.globalDofIdx,
true));
2119 mech.assignStress(ectx.globalDofIdx,
2120 model.stress(ectx.globalDofIdx,
true));
2123 if (mech.enableTraction()) {
2124 mech.assignTraction(ectx.globalDofIdx,
2125 model.traction(ectx.globalDofIdx));
2131 if (this->
tpsaC_.allocated()) {
2132 this->extractors_.emplace_back(
2134 &model = simulator_.problem().geoMechModel()](
const Context& ectx) {
2135 tpsaC.assignRotation(ectx.globalDofIdx,
2136 model.rotation(ectx.globalDofIdx));
2138 tpsaC.assignSolidPressure(ectx.globalDofIdx,
2139 model.solidPressure(ectx.globalDofIdx));
2148 void setupBlockExtractors_(
const bool isSubStep,
2149 const int reportStepNum)
2152 using Context =
typename BlockExtractor::Context;
2153 using PhaseEntry =
typename BlockExtractor::PhaseEntry;
2154 using ScalarEntry =
typename BlockExtractor::ScalarEntry;
2155 using TensorEntry =
typename BlockExtractor::TensorEntry;
2157 using namespace std::string_view_literals;
2159 const auto pressure_handler =
2160 Entry{ScalarEntry{std::vector{
"BPR"sv,
"BPRESSUR"sv},
2161 [](
const Context& ectx)
2163 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2164 return getValue(ectx.fs.pressure(oilPhaseIdx));
2166 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
2167 return getValue(ectx.fs.pressure(gasPhaseIdx));
2170 return getValue(ectx.fs.pressure(waterPhaseIdx));
2176 const auto handlers = std::array{
2178 Entry{PhaseEntry{std::array{
2179 std::array{
"BWSAT"sv,
"BOSAT"sv,
"BGSAT"sv},
2180 std::array{
"BSWAT"sv,
"BSOIL"sv,
"BSGAS"sv}
2182 [](
const unsigned phaseIdx,
const Context& ectx)
2184 return getValue(ectx.fs.saturation(phaseIdx));
2188 Entry{ScalarEntry{
"BNSAT",
2189 [](
const Context& ectx)
2191 if constexpr (enableSolvent) {
2192 return ectx.intQuants.solventSaturation().value();
2200 Entry{ScalarEntry{std::vector{
"BTCNFHEA"sv,
"BTEMP"sv},
2201 [](
const Context& ectx)
2203 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2204 return getValue(ectx.fs.temperature(oilPhaseIdx));
2206 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
2207 return getValue(ectx.fs.temperature(gasPhaseIdx));
2210 return getValue(ectx.fs.temperature(waterPhaseIdx));
2215 Entry{PhaseEntry{std::array{
2216 std::array{
"BWKR"sv,
"BOKR"sv,
"BGKR"sv},
2217 std::array{
"BKRW"sv,
"BKRO"sv,
"BKRG"sv}
2219 [](
const unsigned phaseIdx,
const Context& ectx)
2221 return getValue(ectx.intQuants.relativePermeability(phaseIdx));
2225 Entry{ScalarEntry{
"BKROG",
2226 [&problem = this->simulator_.problem()](
const Context& ectx)
2228 const auto& materialParams =
2229 problem.materialLawParams(ectx.elemCtx,
2232 return getValue(MaterialLaw::template
2233 relpermOilInOilGasSystem<Evaluation>(materialParams,
2238 Entry{ScalarEntry{
"BKROW",
2239 [&problem = this->simulator_.problem()](
const Context& ectx)
2241 const auto& materialParams = problem.materialLawParams(ectx.elemCtx,
2244 return getValue(MaterialLaw::template
2245 relpermOilInOilWaterSystem<Evaluation>(materialParams,
2250 Entry{ScalarEntry{
"BWPC",
2251 [](
const Context& ectx)
2253 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2254 return getValue(ectx.fs.pressure(oilPhaseIdx)) -
2255 getValue(ectx.fs.pressure(waterPhaseIdx));
2257 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
2258 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
2259 getValue(ectx.fs.pressure(waterPhaseIdx));
2267 Entry{ScalarEntry{
"BGPC",
2268 [](
const Context& ectx)
2270 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2271 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
2272 getValue(ectx.fs.pressure(oilPhaseIdx));
2274 else if (FluidSystem::phaseIsActive(waterPhaseIdx)) {
2275 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
2276 getValue(ectx.fs.pressure(waterPhaseIdx));
2284 Entry{ScalarEntry{
"BWPR",
2285 [](
const Context& ectx)
2287 return getValue(ectx.fs.pressure(waterPhaseIdx));
2291 Entry{ScalarEntry{
"BGPR",
2292 [](
const Context& ectx)
2294 return getValue(ectx.fs.pressure(gasPhaseIdx));
2298 Entry{PhaseEntry{std::array{
2299 std::array{
"BVWAT"sv,
"BVOIL"sv,
"BVGAS"sv},
2300 std::array{
"BWVIS"sv,
"BOVIS"sv,
"BGVIS"sv}
2302 [](
const unsigned phaseIdx,
const Context& ectx)
2304 return getValue(ectx.fs.viscosity(phaseIdx));
2308 Entry{PhaseEntry{std::array{
2309 std::array{
"BWDEN"sv,
"BODEN"sv,
"BGDEN"sv},
2310 std::array{
"BDENW"sv,
"BDENO"sv,
"BDENG"sv}
2312 [](
const unsigned phaseIdx,
const Context& ectx)
2314 return getValue(ectx.fs.density(phaseIdx));
2318 Entry{ScalarEntry{
"BFLOGI",
2320 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2322 const unsigned index = !flowsC.blockFlows().empty() ?
2323 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2324 FaceDir::ToIntersectionIndex(Dir::XPlus), gasCompIdx) : ectx.globalDofIdx;
2325 return flowsC.getFlow(index, Dir::XPlus, gasCompIdx);
2329 Entry{ScalarEntry{
"BFLOGI-",
2331 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2333 const unsigned index = !flowsC.blockFlows().empty() ?
2334 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2335 FaceDir::ToIntersectionIndex(Dir::XMinus), gasCompIdx) : ectx.globalDofIdx;
2336 return flowsC.getFlow(index, Dir::XMinus, gasCompIdx);
2340 Entry{ScalarEntry{
"BFLOGJ",
2342 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2344 const unsigned index = !flowsC.blockFlows().empty() ?
2345 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2346 FaceDir::ToIntersectionIndex(Dir::YPlus), gasCompIdx) : ectx.globalDofIdx;
2347 return flowsC.getFlow(index, Dir::YPlus, gasCompIdx);
2351 Entry{ScalarEntry{
"BFLOGJ-",
2353 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2355 const unsigned index = !flowsC.blockFlows().empty() ?
2356 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2357 FaceDir::ToIntersectionIndex(Dir::YMinus), gasCompIdx) : ectx.globalDofIdx;
2358 return flowsC.getFlow(index, Dir::YMinus, gasCompIdx);
2362 Entry{ScalarEntry{
"BFLOGK",
2364 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2366 const unsigned index = !flowsC.blockFlows().empty() ?
2367 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2368 FaceDir::ToIntersectionIndex(Dir::ZPlus), gasCompIdx) : ectx.globalDofIdx;
2369 return flowsC.getFlow(index, Dir::ZPlus, gasCompIdx);
2373 Entry{ScalarEntry{
"BFLOGK-",
2375 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2377 const unsigned index = !flowsC.blockFlows().empty() ?
2378 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2379 FaceDir::ToIntersectionIndex(Dir::ZMinus), gasCompIdx) : ectx.globalDofIdx;
2380 return flowsC.getFlow(index, Dir::ZMinus, gasCompIdx);
2384 Entry{ScalarEntry{
"BFLOOI",
2386 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2388 const unsigned index = !flowsC.blockFlows().empty() ?
2389 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2390 FaceDir::ToIntersectionIndex(Dir::XPlus), oilCompIdx) : ectx.globalDofIdx;
2391 return flowsC.getFlow(index, Dir::XPlus, oilCompIdx);
2395 Entry{ScalarEntry{
"BFLOOI-",
2397 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2399 const unsigned index = !flowsC.blockFlows().empty() ?
2400 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2401 FaceDir::ToIntersectionIndex(Dir::XMinus), oilCompIdx) : ectx.globalDofIdx;
2402 return flowsC.getFlow(index, Dir::XMinus, oilCompIdx);
2406 Entry{ScalarEntry{
"BFLOOJ",
2408 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2410 const unsigned index = !flowsC.blockFlows().empty() ?
2411 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2412 FaceDir::ToIntersectionIndex(Dir::YPlus), oilCompIdx) : ectx.globalDofIdx;
2413 return flowsC.getFlow(index, Dir::YPlus, oilCompIdx);
2417 Entry{ScalarEntry{
"BFLOOJ-",
2419 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2421 const unsigned index = !flowsC.blockFlows().empty() ?
2422 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2423 FaceDir::ToIntersectionIndex(Dir::YMinus), oilCompIdx) : ectx.globalDofIdx;
2424 return flowsC.getFlow(index, Dir::YMinus, oilCompIdx);
2428 Entry{ScalarEntry{
"BFLOOK",
2430 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2432 const unsigned index = !flowsC.blockFlows().empty() ?
2433 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2434 FaceDir::ToIntersectionIndex(Dir::ZPlus), oilCompIdx) : ectx.globalDofIdx;
2435 return flowsC.getFlow(index, Dir::ZPlus, oilCompIdx);
2439 Entry{ScalarEntry{
"BFLOOK-",
2441 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2443 const unsigned index = !flowsC.blockFlows().empty() ?
2444 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2445 FaceDir::ToIntersectionIndex(Dir::ZMinus), oilCompIdx) : ectx.globalDofIdx;
2446 return flowsC.getFlow(index, Dir::ZMinus, oilCompIdx);
2450 Entry{ScalarEntry{
"BFLOWI",
2452 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2454 const unsigned index = !flowsC.blockFlows().empty() ?
2455 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2456 FaceDir::ToIntersectionIndex(Dir::XPlus), waterCompIdx) : ectx.globalDofIdx;
2457 return flowsC.getFlow(index, Dir::XPlus, waterCompIdx);
2461 Entry{ScalarEntry{
"BFLOWI-",
2463 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2465 const unsigned index = !flowsC.blockFlows().empty() ?
2466 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2467 FaceDir::ToIntersectionIndex(Dir::XMinus), waterCompIdx) : ectx.globalDofIdx;
2468 return flowsC.getFlow(index, Dir::XMinus, waterCompIdx);
2472 Entry{ScalarEntry{
"BFLOWJ",
2474 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2476 const unsigned index = !flowsC.blockFlows().empty() ?
2477 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2478 FaceDir::ToIntersectionIndex(Dir::YPlus), waterCompIdx) : ectx.globalDofIdx;
2479 return flowsC.getFlow(index, Dir::YPlus, waterCompIdx);
2483 Entry{ScalarEntry{
"BFLOWJ-",
2485 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2487 const unsigned index = !flowsC.blockFlows().empty() ?
2488 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2489 FaceDir::ToIntersectionIndex(Dir::YMinus), waterCompIdx) : ectx.globalDofIdx;
2490 return flowsC.getFlow(index, Dir::YMinus, waterCompIdx);
2494 Entry{ScalarEntry{
"BFLOWK",
2496 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2498 const unsigned index = !flowsC.blockFlows().empty() ?
2499 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2500 FaceDir::ToIntersectionIndex(Dir::ZPlus), waterCompIdx) : ectx.globalDofIdx;
2501 return flowsC.getFlow(index, Dir::ZPlus, waterCompIdx);
2505 Entry{ScalarEntry{
"BFLOWK-",
2507 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2509 const unsigned index = !flowsC.blockFlows().empty() ?
2510 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2511 FaceDir::ToIntersectionIndex(Dir::ZMinus), waterCompIdx) : ectx.globalDofIdx;
2512 return flowsC.getFlow(index, Dir::ZMinus, waterCompIdx);
2516 Entry{ScalarEntry{
"BVELGI",
2518 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2520 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2521 FaceDir::ToIntersectionIndex(Dir::XPlus), gasCompIdx);
2522 return flowsC.getVelocity(index, Dir::XPlus, gasCompIdx);
2526 Entry{ScalarEntry{
"BVELGI-",
2528 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2530 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2531 FaceDir::ToIntersectionIndex(Dir::XMinus), gasCompIdx);
2532 return flowsC.getVelocity(index, Dir::XMinus, gasCompIdx);
2536 Entry{ScalarEntry{
"BVELGJ",
2538 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2540 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2541 FaceDir::ToIntersectionIndex(Dir::YPlus), gasCompIdx);
2542 return flowsC.getVelocity(index, Dir::YPlus, gasCompIdx);
2546 Entry{ScalarEntry{
"BVELGJ-",
2548 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2550 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2551 FaceDir::ToIntersectionIndex(Dir::YMinus), gasCompIdx);
2552 return flowsC.getVelocity(index, Dir::YMinus, gasCompIdx);
2556 Entry{ScalarEntry{
"BVELGK",
2558 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2560 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2561 FaceDir::ToIntersectionIndex(Dir::ZPlus), gasCompIdx);
2562 return flowsC.getVelocity(index, Dir::ZPlus, gasCompIdx);
2566 Entry{ScalarEntry{
"BVELGK-",
2568 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2570 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2571 FaceDir::ToIntersectionIndex(Dir::ZMinus), gasCompIdx);
2572 return flowsC.getVelocity(index, Dir::ZMinus, gasCompIdx);
2576 Entry{ScalarEntry{
"BVELOI",
2578 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2580 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2581 FaceDir::ToIntersectionIndex(Dir::XPlus), oilCompIdx);
2582 return flowsC.getVelocity(index, Dir::XPlus, oilCompIdx);
2586 Entry{ScalarEntry{
"BVELOI-",
2588 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2590 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2591 FaceDir::ToIntersectionIndex(Dir::XMinus), oilCompIdx);
2592 return flowsC.getVelocity(index, Dir::XMinus, oilCompIdx);
2596 Entry{ScalarEntry{
"BVELOJ",
2598 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2600 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2601 FaceDir::ToIntersectionIndex(Dir::YPlus), oilCompIdx);
2602 return flowsC.getVelocity(index, Dir::YPlus, oilCompIdx);
2606 Entry{ScalarEntry{
"BVELOJ-",
2608 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2610 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2611 FaceDir::ToIntersectionIndex(Dir::YMinus), oilCompIdx);
2612 return flowsC.getVelocity(index, Dir::YMinus, oilCompIdx);
2616 Entry{ScalarEntry{
"BVELOK",
2618 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2620 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2621 FaceDir::ToIntersectionIndex(Dir::ZPlus), oilCompIdx);
2622 return flowsC.getVelocity(index, Dir::ZPlus, oilCompIdx);
2626 Entry{ScalarEntry{
"BVELOK-",
2628 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2630 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2631 FaceDir::ToIntersectionIndex(Dir::ZMinus), oilCompIdx);
2632 return flowsC.getVelocity(index, Dir::ZMinus, oilCompIdx);
2636 Entry{ScalarEntry{
"BVELWI",
2638 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2640 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2641 FaceDir::ToIntersectionIndex(Dir::XPlus), waterCompIdx);
2642 return flowsC.getVelocity(index, Dir::XPlus, waterCompIdx);
2646 Entry{ScalarEntry{
"BVELWI-",
2648 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2650 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2651 FaceDir::ToIntersectionIndex(Dir::XMinus), waterCompIdx);
2652 return flowsC.getVelocity(index, Dir::XMinus, waterCompIdx);
2656 Entry{ScalarEntry{
"BVELWJ",
2658 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2660 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2661 FaceDir::ToIntersectionIndex(Dir::YPlus), waterCompIdx);
2662 return flowsC.getVelocity(index, Dir::YPlus, waterCompIdx);
2666 Entry{ScalarEntry{
"BVELWJ-",
2668 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2670 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2671 FaceDir::ToIntersectionIndex(Dir::YMinus), waterCompIdx);
2672 return flowsC.getVelocity(index, Dir::YMinus, waterCompIdx);
2676 Entry{ScalarEntry{
"BVELWK",
2678 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2680 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2681 FaceDir::ToIntersectionIndex(Dir::ZPlus), waterCompIdx);
2682 return flowsC.getVelocity(index, Dir::ZPlus, waterCompIdx);
2686 Entry{ScalarEntry{
"BVELWK-",
2688 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2690 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2691 FaceDir::ToIntersectionIndex(Dir::ZMinus), waterCompIdx);
2692 return flowsC.getVelocity(index, Dir::ZMinus, waterCompIdx);
2696 Entry{ScalarEntry{
"BRPV",
2697 [&model = this->simulator_.model()](
const Context& ectx)
2699 return getValue(ectx.intQuants.porosity()) *
2700 model.dofTotalVolume(ectx.globalDofIdx);
2704 Entry{PhaseEntry{std::array{
"BWPV"sv,
"BOPV"sv,
"BGPV"sv},
2705 [&model = this->simulator_.model()](
const unsigned phaseIdx,
2706 const Context& ectx)
2708 return getValue(ectx.fs.saturation(phaseIdx)) *
2709 getValue(ectx.intQuants.porosity()) *
2710 model.dofTotalVolume(ectx.globalDofIdx);
2714 Entry{ScalarEntry{
"BRS",
2715 [](
const Context& ectx)
2717 return getValue(ectx.fs.Rs());
2721 Entry{ScalarEntry{
"BRV",
2722 [](
const Context& ectx)
2724 return getValue(ectx.fs.Rv());
2728 Entry{ScalarEntry{
"BOIP",
2729 [&model = this->simulator_.model()](
const Context& ectx)
2731 return (getValue(ectx.fs.invB(oilPhaseIdx)) *
2732 getValue(ectx.fs.saturation(oilPhaseIdx)) +
2733 getValue(ectx.fs.Rv()) *
2734 getValue(ectx.fs.invB(gasPhaseIdx)) *
2735 getValue(ectx.fs.saturation(gasPhaseIdx))) *
2736 model.dofTotalVolume(ectx.globalDofIdx) *
2737 getValue(ectx.intQuants.porosity());
2741 Entry{ScalarEntry{
"BGIP",
2742 [&model = this->simulator_.model()](
const Context& ectx)
2744 Scalar result = getValue(ectx.fs.invB(gasPhaseIdx)) *
2745 getValue(ectx.fs.saturation(gasPhaseIdx));
2747 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2748 result += getValue(ectx.fs.Rs()) *
2749 getValue(ectx.fs.invB(oilPhaseIdx)) *
2750 getValue(ectx.fs.saturation(oilPhaseIdx));
2753 result += getValue(ectx.fs.Rsw()) *
2754 getValue(ectx.fs.invB(waterPhaseIdx)) *
2755 getValue(ectx.fs.saturation(waterPhaseIdx));
2759 model.dofTotalVolume(ectx.globalDofIdx) *
2760 getValue(ectx.intQuants.porosity());
2764 Entry{ScalarEntry{
"BWIP",
2765 [&model = this->simulator_.model()](
const Context& ectx)
2767 return getValue(ectx.fs.invB(waterPhaseIdx)) *
2768 getValue(ectx.fs.saturation(waterPhaseIdx)) *
2769 model.dofTotalVolume(ectx.globalDofIdx) *
2770 getValue(ectx.intQuants.porosity());
2774 Entry{ScalarEntry{
"BOIPL",
2775 [&model = this->simulator_.model()](
const Context& ectx)
2777 return getValue(ectx.fs.invB(oilPhaseIdx)) *
2778 getValue(ectx.fs.saturation(oilPhaseIdx)) *
2779 model.dofTotalVolume(ectx.globalDofIdx) *
2780 getValue(ectx.intQuants.porosity());
2784 Entry{ScalarEntry{
"BGIPL",
2785 [&model = this->simulator_.model()](
const Context& ectx)
2788 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2789 result = getValue(ectx.fs.Rs()) *
2790 getValue(ectx.fs.invB(oilPhaseIdx)) *
2791 getValue(ectx.fs.saturation(oilPhaseIdx));
2794 result = getValue(ectx.fs.Rsw()) *
2795 getValue(ectx.fs.invB(waterPhaseIdx)) *
2796 getValue(ectx.fs.saturation(waterPhaseIdx));
2799 model.dofTotalVolume(ectx.globalDofIdx) *
2800 getValue(ectx.intQuants.porosity());
2804 Entry{ScalarEntry{
"BGIPG",
2805 [&model = this->simulator_.model()](
const Context& ectx)
2807 return getValue(ectx.fs.invB(gasPhaseIdx)) *
2808 getValue(ectx.fs.saturation(gasPhaseIdx)) *
2809 model.dofTotalVolume(ectx.globalDofIdx) *
2810 getValue(ectx.intQuants.porosity());
2814 Entry{ScalarEntry{
"BOIPG",
2815 [&model = this->simulator_.model()](
const Context& ectx)
2817 return getValue(ectx.fs.Rv()) *
2818 getValue(ectx.fs.invB(gasPhaseIdx)) *
2819 getValue(ectx.fs.saturation(gasPhaseIdx)) *
2820 model.dofTotalVolume(ectx.globalDofIdx) *
2821 getValue(ectx.intQuants.porosity());
2825 Entry{PhaseEntry{std::array{
"BPPW"sv,
"BPPO"sv,
"BPPG"sv},
2826 [&simConfig = this->
eclState_.getSimulationConfig(),
2827 &grav = this->simulator_.problem().gravity(),
2829 &problem = this->simulator_.problem(),
2830 ®ions = this->
regions_](
const unsigned phaseIdx,
const Context& ectx)
2833 phase.ix = phaseIdx;
2842 const auto datum = simConfig.datumDepths()(regions[
"FIPNUM"][ectx.dofIdx] - 1);
2845 const auto region = RegionPhasePoreVolAverage::Region {
2846 ectx.elemCtx.primaryVars(ectx.dofIdx, 0).pvtRegionIndex() + 1
2849 const auto density = regionAvgDensity->value(
"PVTNUM", phase, region);
2851 const auto press = getValue(ectx.fs.pressure(phase.ix));
2852 const auto dz = problem.dofCenterDepth(ectx.globalDofIdx) - datum;
2853 return press - density*dz*grav[GridView::dimensionworld - 1];
2857 Entry{ScalarEntry{
"BAMIP",
2858 [&model = this->simulator_.model()](
const Context& ectx)
2860 const Scalar rhoW = FluidSystem::referenceDensity(waterPhaseIdx,
2861 ectx.intQuants.pvtRegionIndex());
2862 return getValue(ectx.fs.invB(waterPhaseIdx)) *
2863 getValue(ectx.fs.saturation(waterPhaseIdx)) *
2865 model.dofTotalVolume(ectx.globalDofIdx) *
2866 getValue(ectx.intQuants.porosity());
2870 Entry{ScalarEntry{
"BMMIP",
2871 [&model = this->simulator_.model()](
const Context& ectx)
2873 if constexpr (enableBioeffects) {
2874 return getValue(ectx.intQuants.microbialConcentration()) *
2875 getValue(ectx.fs.saturation(waterPhaseIdx)) *
2876 getValue(ectx.intQuants.porosity()) *
2877 model.dofTotalVolume(ectx.globalDofIdx);
2885 Entry{ScalarEntry{
"BMOIP",
2886 [&model = this->simulator_.model()](
const Context& ectx)
2888 if constexpr (enableBioeffects) {
2889 return getValue(ectx.intQuants.oxygenConcentration()) *
2890 getValue(ectx.intQuants.porosity()) *
2891 model.dofTotalVolume(ectx.globalDofIdx);
2899 Entry{ScalarEntry{
"BMUIP",
2900 [&model = this->simulator_.model()](
const Context& ectx)
2902 if constexpr (enableBioeffects) {
2903 return getValue(ectx.intQuants.ureaConcentration()) *
2904 getValue(ectx.intQuants.porosity()) *
2905 model.dofTotalVolume(ectx.globalDofIdx);
2913 Entry{ScalarEntry{
"BMBIP",
2914 [&model = this->simulator_.model()](
const Context& ectx)
2916 if constexpr (enableBioeffects) {
2917 return model.dofTotalVolume(ectx.globalDofIdx) *
2918 getValue(ectx.intQuants.biofilmMass());
2926 Entry{ScalarEntry{
"BMCIP",
2927 [&model = this->simulator_.model()](
const Context& ectx)
2929 if constexpr (enableBioeffects) {
2930 return model.dofTotalVolume(ectx.globalDofIdx) *
2931 getValue(ectx.intQuants.calciteMass());
2939 Entry{ScalarEntry{
"BGMIP",
2940 [&model = this->simulator_.model()](
const Context& ectx)
2942 Scalar result = getValue(ectx.fs.invB(gasPhaseIdx)) *
2943 getValue(ectx.fs.saturation(gasPhaseIdx));
2945 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2946 result += getValue(ectx.fs.Rs()) *
2947 getValue(ectx.fs.invB(oilPhaseIdx)) *
2948 getValue(ectx.fs.saturation(oilPhaseIdx));
2951 result += getValue(ectx.fs.Rsw()) *
2952 getValue(ectx.fs.invB(waterPhaseIdx)) *
2953 getValue(ectx.fs.saturation(waterPhaseIdx));
2955 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
2956 ectx.intQuants.pvtRegionIndex());
2958 model.dofTotalVolume(ectx.globalDofIdx) *
2959 getValue(ectx.intQuants.porosity()) *
2964 Entry{ScalarEntry{
"BGMGP",
2965 [&model = this->simulator_.model()](
const Context& ectx)
2967 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
2968 ectx.intQuants.pvtRegionIndex());
2969 return getValue(ectx.fs.invB(gasPhaseIdx)) *
2970 getValue(ectx.fs.saturation(gasPhaseIdx)) *
2971 model.dofTotalVolume(ectx.globalDofIdx) *
2972 getValue(ectx.intQuants.porosity()) *
2977 Entry{ScalarEntry{
"BGMDS",
2978 [&model = this->simulator_.model()](
const Context& ectx)
2981 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2982 result = getValue(ectx.fs.Rs()) *
2983 getValue(ectx.fs.invB(oilPhaseIdx)) *
2984 getValue(ectx.fs.saturation(oilPhaseIdx));
2987 result = getValue(ectx.fs.Rsw()) *
2988 getValue(ectx.fs.invB(waterPhaseIdx)) *
2989 getValue(ectx.fs.saturation(waterPhaseIdx));
2991 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
2992 ectx.intQuants.pvtRegionIndex());
2994 model.dofTotalVolume(ectx.globalDofIdx) *
2995 getValue(ectx.intQuants.porosity()) *
3000 Entry{ScalarEntry{
"BGMST",
3001 [&model = this->simulator_.model(),
3002 &problem = this->simulator_.problem()](
const Context& ectx)
3004 const auto& scaledDrainageInfo = problem.materialLawManager()
3005 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3006 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3007 Scalar strandedGas = scaledDrainageInfo.Sgcr;
3008 if (problem.materialLawManager()->enableHysteresis()) {
3009 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3010 const Scalar krg = getValue(ectx.intQuants.relativePermeability(gasPhaseIdx));
3011 strandedGas = MaterialLaw::strandedGasSaturation(matParams, sg, krg);
3013 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3014 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3015 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3016 return (1.0 - xgW) *
3017 model.dofTotalVolume(ectx.globalDofIdx) *
3018 getValue(ectx.intQuants.porosity()) *
3019 getValue(ectx.fs.density(gasPhaseIdx)) *
3020 std::min(strandedGas, sg);
3024 Entry{ScalarEntry{
"BGMUS",
3025 [&model = this->simulator_.model(),
3026 &problem = this->simulator_.problem()](
const Context& ectx)
3028 const auto& scaledDrainageInfo = problem.materialLawManager()
3029 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3030 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3031 Scalar strandedGas = scaledDrainageInfo.Sgcr;
3032 if (problem.materialLawManager()->enableHysteresis()) {
3033 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3034 const Scalar krg = getValue(ectx.intQuants.relativePermeability(gasPhaseIdx));
3035 strandedGas = MaterialLaw::strandedGasSaturation(matParams, sg, krg);
3037 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3038 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3039 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3040 return (1.0 - xgW) *
3041 model.dofTotalVolume(ectx.globalDofIdx) *
3042 getValue(ectx.intQuants.porosity()) *
3043 getValue(ectx.fs.density(gasPhaseIdx)) *
3044 std::max(Scalar{0.0}, sg - strandedGas);
3048 Entry{ScalarEntry{
"BGMTR",
3049 [&model = this->simulator_.model(),
3050 &problem = this->simulator_.problem()](
const Context& ectx)
3052 const auto& scaledDrainageInfo = problem.materialLawManager()
3053 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3054 Scalar trappedGas = scaledDrainageInfo.Sgcr;
3055 if (problem.materialLawManager()->enableHysteresis()) {
3056 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3057 trappedGas = MaterialLaw::trappedGasSaturation(matParams,
true);
3059 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3060 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3061 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3062 return (1.0 - xgW) *
3063 model.dofTotalVolume(ectx.globalDofIdx) *
3064 getValue(ectx.intQuants.porosity()) *
3065 getValue(ectx.fs.density(gasPhaseIdx)) *
3066 std::min(trappedGas, getValue(ectx.fs.saturation(gasPhaseIdx)));
3070 Entry{ScalarEntry{
"BGMMO",
3071 [&model = this->simulator_.model(),
3072 &problem = this->simulator_.problem()](
const Context& ectx)
3074 const auto& scaledDrainageInfo = problem.materialLawManager()
3075 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3076 Scalar trappedGas = scaledDrainageInfo.Sgcr;
3077 if (problem.materialLawManager()->enableHysteresis()) {
3078 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3079 trappedGas = MaterialLaw::trappedGasSaturation(matParams,
true);
3081 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3082 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3083 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3084 return (1.0 - xgW) *
3085 model.dofTotalVolume(ectx.globalDofIdx) *
3086 getValue(ectx.intQuants.porosity()) *
3087 getValue(ectx.fs.density(gasPhaseIdx)) *
3088 std::max(Scalar{0.0}, getValue(ectx.fs.saturation(gasPhaseIdx)) - trappedGas);
3092 Entry{ScalarEntry{
"BGKTR",
3093 [&model = this->simulator_.model(),
3094 &problem = this->simulator_.problem()](
const Context& ectx)
3096 const auto& scaledDrainageInfo = problem.materialLawManager()
3097 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3098 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3099 Scalar sgcr = scaledDrainageInfo.Sgcr;
3100 if (problem.materialLawManager()->enableHysteresis()) {
3101 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3102 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3108 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3109 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3110 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3111 return (1.0 - xgW) *
3112 model.dofTotalVolume(ectx.globalDofIdx) *
3113 getValue(ectx.intQuants.porosity()) *
3114 getValue(ectx.fs.density(gasPhaseIdx)) *
3115 getValue(ectx.fs.saturation(gasPhaseIdx));
3120 Entry{ScalarEntry{
"BGKMO",
3121 [&model = this->simulator_.model(),
3122 &problem = this->simulator_.problem()](
const Context& ectx)
3124 const auto& scaledDrainageInfo = problem.materialLawManager()
3125 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3126 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3127 Scalar sgcr = scaledDrainageInfo.Sgcr;
3128 if (problem.materialLawManager()->enableHysteresis()) {
3129 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3130 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3136 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3137 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3138 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3139 return (1.0 - xgW) *
3140 model.dofTotalVolume(ectx.globalDofIdx) *
3141 getValue(ectx.intQuants.porosity()) *
3142 getValue(ectx.fs.density(gasPhaseIdx)) *
3143 getValue(ectx.fs.saturation(gasPhaseIdx));
3148 Entry{ScalarEntry{
"BGCDI",
3149 [&model = this->simulator_.model(),
3150 &problem = this->simulator_.problem()](
const Context& ectx)
3152 const auto& scaledDrainageInfo = problem.materialLawManager()
3153 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3154 Scalar sgcr = scaledDrainageInfo.Sgcr;
3155 if (problem.materialLawManager()->enableHysteresis()) {
3156 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3157 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3159 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3160 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3161 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3162 return (1.0 - xgW) *
3163 model.dofTotalVolume(ectx.globalDofIdx) *
3164 getValue(ectx.intQuants.porosity()) *
3165 getValue(ectx.fs.density(gasPhaseIdx)) *
3166 std::min(sgcr, getValue(ectx.fs.saturation(gasPhaseIdx))) /
3167 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3171 Entry{ScalarEntry{
"BGCDM",
3172 [&model = this->simulator_.model(),
3173 &problem = this->simulator_.problem()](
const Context& ectx)
3175 const auto& scaledDrainageInfo = problem.materialLawManager()
3176 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3177 Scalar sgcr = scaledDrainageInfo.Sgcr;
3178 if (problem.materialLawManager()->enableHysteresis()) {
3179 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3180 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3182 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3183 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3184 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3185 return (1.0 - xgW) *
3186 model.dofTotalVolume(ectx.globalDofIdx) *
3187 getValue(ectx.intQuants.porosity()) *
3188 getValue(ectx.fs.density(gasPhaseIdx)) *
3189 std::max(Scalar{0.0}, getValue(ectx.fs.saturation(gasPhaseIdx)) - sgcr) /
3190 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3194 Entry{ScalarEntry{
"BGKDI",
3195 [&model = this->simulator_.model(),
3196 &problem = this->simulator_.problem()](
const Context& ectx)
3198 const auto& scaledDrainageInfo = problem.materialLawManager()
3199 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3200 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3201 Scalar sgcr = scaledDrainageInfo.Sgcr;
3202 if (problem.materialLawManager()->enableHysteresis()) {
3203 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3204 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3210 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3211 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3212 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3213 return (1.0 - xgW) *
3214 model.dofTotalVolume(ectx.globalDofIdx) *
3215 getValue(ectx.intQuants.porosity()) *
3216 getValue(ectx.fs.density(gasPhaseIdx)) *
3217 getValue(ectx.fs.saturation(gasPhaseIdx)) /
3218 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3223 Entry{ScalarEntry{
"BGKDM",
3224 [&model = this->simulator_.model(),
3225 &problem = this->simulator_.problem()](
const Context& ectx)
3227 const auto& scaledDrainageInfo = problem.materialLawManager()
3228 ->oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3229 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3230 Scalar sgcr = scaledDrainageInfo.Sgcr;
3231 if (problem.materialLawManager()->enableHysteresis()) {
3232 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3233 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3239 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3240 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3241 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3242 return (1.0 - xgW) *
3243 model.dofTotalVolume(ectx.globalDofIdx) *
3244 getValue(ectx.intQuants.porosity()) *
3245 getValue(ectx.fs.density(gasPhaseIdx)) *
3246 getValue(ectx.fs.saturation(gasPhaseIdx)) /
3247 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3252 Entry{ScalarEntry{
"BWCD",
3253 [&model = this->simulator_.model()](
const Context& ectx)
3256 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
3257 result = getValue(ectx.fs.Rs()) *
3258 getValue(ectx.fs.invB(oilPhaseIdx)) *
3259 getValue(ectx.fs.saturation(oilPhaseIdx));
3262 result = getValue(ectx.fs.Rsw()) *
3263 getValue(ectx.fs.invB(waterPhaseIdx)) *
3264 getValue(ectx.fs.saturation(waterPhaseIdx));
3266 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
3267 ectx.intQuants.pvtRegionIndex());
3269 model.dofTotalVolume(ectx.globalDofIdx) *
3270 getValue(ectx.intQuants.porosity()) *
3272 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3276 Entry{ScalarEntry{
"BWIPG",
3277 [&model = this->simulator_.model()](
const Context& ectx)
3279 Scalar result = 0.0;
3280 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
3281 result = getValue(ectx.fs.Rvw()) *
3282 getValue(ectx.fs.invB(gasPhaseIdx)) *
3283 getValue(ectx.fs.saturation(gasPhaseIdx));
3286 model.dofTotalVolume(ectx.globalDofIdx) *
3287 getValue(ectx.intQuants.porosity());
3291 Entry{ScalarEntry{
"BWIPL",
3292 [&model = this->simulator_.model()](
const Context& ectx)
3294 return getValue(ectx.fs.invB(waterPhaseIdx)) *
3295 getValue(ectx.fs.saturation(waterPhaseIdx)) *
3296 model.dofTotalVolume(ectx.globalDofIdx) *
3297 getValue(ectx.intQuants.porosity());
3303 auto blockHandlers = std::span<const Entry>{handlers};
3304 auto mechHandlers = std::vector<Entry>{};
3305 if constexpr (getPropValue<TypeTag, Properties::EnableMech>()) {
3306 if (this->
mech_.allocated()) {
3307 mechHandlers.assign(handlers.begin(), handlers.end());
3308 mechHandlers.push_back(
3309 Entry{TensorEntry{
"BSTRSS",
3310 [&model = this->simulator_.problem().geoMechModel()]
3311 (
const VoigtIndex index,
const Context& ectx)
3313 return model.stress(ectx.globalDofIdx,
true)[index];
3317 blockHandlers = mechHandlers;
3326 this->lgrBlockExtractors_ =
3330 if (reportStepNum > 0 && !isSubStep) {
3332 const auto& rpt = this->
schedule_[reportStepNum - 1].rpt_config.get();
3333 if (rpt.contains(
"WELLS") && rpt.at(
"WELLS") > 1) {
3335 [&c = this->collectOnIORank_](
const int idx)
3336 {
return c.isCartIdxOnThisRank(idx); });
3338 const auto extraHandlers = std::array{
3347 const Simulator& simulator_;
3348 const CollectDataOnIORankType& collectOnIORank_;
3349 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 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
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:91
const Schedule & schedule_
Definition: GenericOutputModule.hpp:536
ScalarBuffer oilVaporizationFactor_
Definition: GenericOutputModule.hpp:613
bool forceDisableFipOutput_
Definition: GenericOutputModule.hpp:557
RFTContainer< GetPropType< TypeTag, Properties::FluidSystem > > rftC_
Definition: GenericOutputModule.hpp:642
ScalarBuffer saturatedOilFormationVolumeFactor_
Definition: GenericOutputModule.hpp:618
GeochemistryContainer< Scalar > geochemC_
Definition: GenericOutputModule.hpp:634
ScalarBuffer rockCompPorvMultiplier_
Definition: GenericOutputModule.hpp:616
TracerContainer< GetPropType< TypeTag, Properties::FluidSystem > > tracerC_
Definition: GenericOutputModule.hpp:636
void doAllocBuffers(unsigned bufferSize, unsigned reportStepNum, const bool substep, const bool log, const bool forceRestartFieldAllocation, const EclHysteresisConfig *hysteresisConfig, unsigned numOutputNnc=0, std::map< std::string, int > rstKeywords={})
CO2H2Container< Scalar > CO2H2C_
Definition: GenericOutputModule.hpp:621
std::array< ScalarBuffer, numPhases > residual_
Definition: GenericOutputModule.hpp:638
ScalarBuffer sSol_
Definition: GenericOutputModule.hpp:597
std::map< std::tuple< std::string, int, int >, double > lgrBlockData_
Definition: GenericOutputModule.hpp:655
void setupExtraBlockData(const std::size_t reportStepNum, std::function< bool(int)> isCartIdxOnThisRank)
std::vector< int > failedCellsPd_
Definition: GenericOutputModule.hpp:583
ScalarBuffer shmax_
Definition: GenericOutputModule.hpp:608
ScalarBuffer sgmax_
Definition: GenericOutputModule.hpp:607
ScalarBuffer rockCompTransMultiplier_
Definition: GenericOutputModule.hpp:619
void setupBlockData(std::function< bool(int)> isCartIdxOnThisRank)
ScalarBuffer minimumOilPressure_
Definition: GenericOutputModule.hpp:617
ScalarBuffer temperature_
Definition: GenericOutputModule.hpp:591
ScalarBuffer pcow_
Definition: GenericOutputModule.hpp:623
ScalarBuffer drsdtcon_
Definition: GenericOutputModule.hpp:596
bool computeFip_
Definition: GenericOutputModule.hpp:559
std::optional< RegionPhasePoreVolAverage > regionAvgDensity_
Definition: GenericOutputModule.hpp:660
ScalarBuffer permFact_
Definition: GenericOutputModule.hpp:603
ScalarBuffer overburdenPressure_
Definition: GenericOutputModule.hpp:594
TpsaContainer< Scalar > tpsaC_
Definition: GenericOutputModule.hpp:628
ScalarBuffer rPorV_
Definition: GenericOutputModule.hpp:589
std::array< ScalarBuffer, numPhases > viscosity_
Definition: GenericOutputModule.hpp:632
void setupLgrBlockData(const std::map< std::string, int > &lgrNameToLevel, const std::function< bool(int, int)> &isLgrCellOnThisRank)
ScalarBuffer rvw_
Definition: GenericOutputModule.hpp:593
FIPContainer< GetPropType< TypeTag, Properties::FluidSystem > > fipC_
Definition: GenericOutputModule.hpp:570
ScalarBuffer cPolymer_
Definition: GenericOutputModule.hpp:599
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:571
ScalarBuffer swmin_
Definition: GenericOutputModule.hpp:610
FlowsContainer< GetPropType< TypeTag, Properties::FluidSystem > > flowsC_
Definition: GenericOutputModule.hpp:640
std::map< std::pair< std::string, int >, double > blockData_
Definition: GenericOutputModule.hpp:645
ScalarBuffer gasDissolutionFactor_
Definition: GenericOutputModule.hpp:612
MechContainer< Scalar > mech_
Definition: GenericOutputModule.hpp:627
BioeffectsContainer< Scalar > bioeffectsC_
Definition: GenericOutputModule.hpp:620
ExtboContainer< Scalar > extboC_
Definition: GenericOutputModule.hpp:604
ScalarBuffer gasDissolutionFactorInWater_
Definition: GenericOutputModule.hpp:614
ScalarBuffer pcgw_
Definition: GenericOutputModule.hpp:622
LogOutputHelper< Scalar > logOutput_
Definition: GenericOutputModule.hpp:542
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:325
ScalarBuffer somin_
Definition: GenericOutputModule.hpp:609
void updateTotalVolumesAndPressures_(const unsigned globalDofIdx, const IntensiveQuantities &intQuants, const double totVolume, const Scalar referencePorosity)
Definition: GenericOutputModule.hpp:362
InterRegFlowMap interRegionFlows_
Definition: GenericOutputModule.hpp:541
ScalarBuffer soMax_
Definition: GenericOutputModule.hpp:605
std::array< ScalarBuffer, numPhases > density_
Definition: GenericOutputModule.hpp:631
ScalarBuffer cFoam_
Definition: GenericOutputModule.hpp:600
ScalarBuffer waterVaporizationFactor_
Definition: GenericOutputModule.hpp:615
std::array< ScalarBuffer, numPhases > saturation_
Definition: GenericOutputModule.hpp:630
ScalarBuffer rsw_
Definition: GenericOutputModule.hpp:592
ScalarBuffer oilSaturationPressure_
Definition: GenericOutputModule.hpp:595
const EclipseState & eclState_
Definition: GenericOutputModule.hpp:535
ScalarBuffer ppcw_
Definition: GenericOutputModule.hpp:611
virtual void assignToSolution(data::Solution &sol)
Move all buffers to data::Solution.
ScalarBuffer cSalt_
Definition: GenericOutputModule.hpp:601
ScalarBuffer pcog_
Definition: GenericOutputModule.hpp:624
const Inplace * initialInplace() const
Definition: GenericOutputModule.hpp:274
ScalarBuffer swMax_
Definition: GenericOutputModule.hpp:606
ScalarBuffer rswSol_
Definition: GenericOutputModule.hpp:598
std::map< std::pair< std::string, int >, double > extraBlockData_
Definition: GenericOutputModule.hpp:648
ScalarBuffer fluidPressure_
Definition: GenericOutputModule.hpp:590
ScalarBuffer gasFormationVolumeFactor_
Definition: GenericOutputModule.hpp:585
virtual void setRestart(const data::Solution &sol, unsigned elemIdx, unsigned globalDofIndex)
std::vector< int > failedCellsPb_
Definition: GenericOutputModule.hpp:582
ScalarBuffer pSalt_
Definition: GenericOutputModule.hpp:602
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:101
void processElement(const ElementContext &elemCtx)
Modify the internal buffers according to the intensive quanties relevant for an element.
Definition: OutputBlackoilModule.hpp:353
void initializeFluxData()
Prepare for capturing connection fluxes, particularly to account for inter-region flows.
Definition: OutputBlackoilModule.hpp:642
void setupExtractors(const bool isSubStep, const int reportStepNum)
Setup list of active element-level data extractors.
Definition: OutputBlackoilModule.hpp:291
void processFluxes(const ElementContext &elemCtx, ActiveIndex &&activeIndex, CartesianIndex &&cartesianIndex)
Capture connection fluxes, particularly to account for inter-region flows.
Definition: OutputBlackoilModule.hpp:605
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:798
void clearExtractors()
Clear list of active element-level data extractors.
Definition: OutputBlackoilModule.hpp:299
void allocBuffers(const unsigned bufferSize, const unsigned reportStepNum, const bool substep, const bool log, const bool forceRestartFieldAllocation)
Allocate memory for the scalar fields we would like to write to ECL output files.
Definition: OutputBlackoilModule.hpp:269
void outputFipAndResvLogToCSV(const std::size_t reportStepNum, const bool substep, const Parallel::Communication &comm)
Definition: OutputBlackoilModule.hpp:539
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:819
void assignToFluidState(FluidState &fs, unsigned elemIdx) const
Definition: OutputBlackoilModule.hpp:666
void assignToSolution(data::Solution &sol) override
Move all buffers to data::Solution.
Definition: OutputBlackoilModule.hpp:310
void initHysteresisParams(Simulator &simulator, unsigned elemIdx) const
Definition: OutputBlackoilModule.hpp:718
void updateFluidInPlace(const ElementContext &elemCtx)
Definition: OutputBlackoilModule.hpp:783
OutputBlackOilModule(const Simulator &simulator, const SummaryConfig &smryCfg, const CollectDataOnIORankType &collectOnIORank)
Definition: OutputBlackoilModule.hpp:154
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:488
const InterRegFlowMap & getInterRegFlows() const
Get read-only access to collection of inter-region flows.
Definition: OutputBlackoilModule.hpp:660
void processElementBlockData(const ElementContext &elemCtx)
Definition: OutputBlackoilModule.hpp:400
void finalizeFluxData()
Finalize capturing connection fluxes.
Definition: OutputBlackoilModule.hpp:652
void updateFluidInPlace(const unsigned globalDofIdx, const IntensiveQuantities &intQuants, const double totVolume)
Definition: OutputBlackoilModule.hpp:790
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:183
constexpr void ignoreUnused(T &&...) noexcept
Utility to silence "unused variable" warnings in lambdas.
Definition: OutputBlackoilModule.hpp:90
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:410
std::string_view oilDensity
Definition: GenericOutputModule.hpp:411
Minimal characteristics of a cell from a simulation grid.
Definition: InterRegFlows.hpp:50