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;
317 this->
assignBuffer(sol,
"BO", M::oil_formation_volume_factor,
318 this->formationVolFactor_[oilPhaseIdx], oilPhaseIdx);
319 this->
assignBuffer(sol,
"1OVERBO", M::oil_inverse_formation_volume_factor,
320 this->invB_[oilPhaseIdx], oilPhaseIdx);
322 this->
assignBuffer(sol,
"BG", M::gas_formation_volume_factor,
323 this->formationVolFactor_[gasPhaseIdx], gasPhaseIdx);
324 this->
assignBuffer(sol,
"1OVERBG", M::gas_inverse_formation_volume_factor,
325 this->invB_[gasPhaseIdx], gasPhaseIdx);
328 this->relativePermeability_[oilPhaseIdx], oilPhaseIdx);
330 this->relativePermeability_[gasPhaseIdx], gasPhaseIdx);
331 this->
assignBuffer(sol,
"PBUB", M::pressure, this->bubblePointPressure_);
332 this->
assignBuffer(sol,
"PDEW", M::pressure, this->dewPointPressure_);
333 this->
assignBuffer(sol,
"RS", M::gas_oil_ratio, this->rs_);
334 this->
assignBuffer(sol,
"RV", M::oil_gas_ratio, this->rv_);
337 if constexpr (numPhases > 2) {
338 this->
assignBuffer(sol,
"BW", M::water_formation_volume_factor,
339 this->formationVolFactor_[waterPhaseIdx], waterPhaseIdx);
340 this->
assignBuffer(sol,
"1OVERBW", M::water_inverse_formation_volume_factor,
341 this->invB_[waterPhaseIdx], waterPhaseIdx);
344 this->relativePermeability_[waterPhaseIdx], waterPhaseIdx);
351 .gasDensity =
"GAS_DEN",
352 .waterDensity =
"WAT_DEN",
353 .oilViscosity =
"OIL_VISC",
354 .gasViscosity =
"GAS_VISC",
355 .waterViscosity =
"WAT_VISC",
370 if (this->extractors_.empty()) {
374 const auto& matLawManager = simulator_.problem().materialLawManager();
376 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++dofIdx) {
377 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, 0);
378 const auto& fs = intQuants.fluidState();
379 const auto globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
382 if (matLawManager.enableHysteresis()) {
383 if (FluidSystem::phaseIsActive(oilPhaseIdx) && FluidSystem::phaseIsActive(waterPhaseIdx)) {
384 matLawManager.oilWaterHysteresisParams(hysterParams.
somax,
389 if (FluidSystem::phaseIsActive(oilPhaseIdx) && FluidSystem::phaseIsActive(gasPhaseIdx)) {
390 matLawManager.gasOilHysteresisParams(hysterParams.
sgmax,
399 elemCtx.primaryVars(dofIdx, 0).pvtRegionIndex(),
417 if (this->blockExtractors_.empty() &&
418 this->extraBlockExtractors_.empty() &&
419 this->lgrBlockExtractors_.empty())
430 const auto& element = elemCtx.element();
431 const int level = element.level();
433 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++dofIdx) {
434 const auto globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
436 const std::vector<typename BlockExtractor::Exec>* be_extractors =
nullptr;
437 const std::vector<typename BlockExtractor::Exec>* bee_extractors =
nullptr;
438 const std::vector<typename BlockExtractor::Exec>* lgr_extractors =
nullptr;
441 const auto cartesianIdx = elemCtx.simulator().vanguard().cartesianIndex(globalDofIdx);
442 const auto be_it = this->blockExtractors_.find(cartesianIdx);
443 const auto bee_it = this->extraBlockExtractors_.find(cartesianIdx);
444 if (be_it != this->blockExtractors_.end()) { be_extractors = &be_it->second; }
445 if (bee_it != this->extraBlockExtractors_.end()) { bee_extractors = &bee_it->second; }
447 else if constexpr (std::is_same_v<Grid, Dune::CpGrid>) {
459 const auto level_it = this->lgrBlockExtractors_.find(level);
460 if (level_it != this->lgrBlockExtractors_.end() &&
461 element.partitionType() == Dune::InteriorEntity)
463 const int levelCompressed = element.getLevelElem().index();
464 const int levelCart = elemCtx.simulator().vanguard()
465 .levelCartesianIndexMapper()
466 .cartesianIndex(levelCompressed, level);
467 const auto cell_it = level_it->second.find(levelCart);
468 if (cell_it != level_it->second.end()) {
469 lgr_extractors = &cell_it->second;
474 if (be_extractors ==
nullptr &&
475 bee_extractors ==
nullptr &&
476 lgr_extractors ==
nullptr)
481 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, 0);
482 const auto& fs = intQuants.fluidState();
499 const std::size_t reportStepNum,
501 boost::posix_time::ptime currentDate,
506 if (comm.rank() != 0) {
511 std::unique_ptr<FIPConfig> fipSched;
512 if (reportStepNum > 0) {
513 const auto& rpt = this->
schedule_[reportStepNum-1].rpt_config.get();
514 fipSched = std::make_unique<FIPConfig>(rpt);
516 const FIPConfig& fipc = reportStepNum == 0 ? this->
eclState_.getEclipseConfig().fip()
521 this->
logOutput_.timeStamp(
"BALANCE", elapsed, reportStepNum, currentDate);
524 this->
logOutput_.fip(inplace, initial_inplace,
"");
526 if (fipc.output(FIPConfig::OutputField::FIPNUM)) {
527 this->
logOutput_.fip(inplace, initial_inplace,
"FIPNUM");
529 if (fipc.output(FIPConfig::OutputField::RESV))
533 if (fipc.output(FIPConfig::OutputField::FIP)) {
534 for (
const auto& reg : this->regions_) {
535 if (reg.first !=
"FIPNUM") {
536 std::ostringstream ss;
537 ss <<
"BAL" << reg.first.substr(3);
538 this->
logOutput_.timeStamp(ss.str(), elapsed, reportStepNum, currentDate);
539 this->
logOutput_.fip(inplace, initial_inplace, reg.first);
541 if (fipc.output(FIPConfig::OutputField::RESV))
553 if (comm.rank() != 0) {
557 if ((reportStepNum == 0) && (!substep) &&
558 (this->
schedule_.initialReportConfiguration().has_value()) &&
559 (this->schedule_.initialReportConfiguration()->contains(
"CSVFIP"))) {
561 std::ostringstream csv_stream;
567 this->
logOutput_.fip_csv(csv_stream, initial_inplace,
"FIPNUM");
569 for (
const auto& reg : this->regions_) {
570 if (reg.first !=
"FIPNUM") {
571 this->
logOutput_.fip_csv(csv_stream, initial_inplace, reg.first);
575 const IOConfig& io = this->
eclState_.getIOConfig();
576 auto csv_fname = io.getOutputDir() +
"/" + io.getBaseName() +
".CSV";
578 std::ofstream outputFile(csv_fname);
580 outputFile << csv_stream.str();
614 template <
class ActiveIndex,
class CartesianIndex>
616 ActiveIndex&& activeIndex,
617 CartesianIndex&& cartesianIndex)
620 const auto identifyCell = [&activeIndex, &cartesianIndex](
const Element& elem)
623 const auto cellIndex = activeIndex(elem);
626 static_cast<int>(cellIndex),
627 cartesianIndex(cellIndex),
628 elem.partitionType() == Dune::InteriorEntity
632 const auto timeIdx = 0u;
633 const auto& stencil = elemCtx.stencil(timeIdx);
634 const auto numInteriorFaces = elemCtx.numInteriorFaces(timeIdx);
636 for (
auto scvfIdx = 0 * numInteriorFaces; scvfIdx < numInteriorFaces; ++scvfIdx) {
637 const auto& face = stencil.interiorFace(scvfIdx);
638 const auto left = identifyCell(stencil.element(face.interiorIndex()));
639 const auto right = identifyCell(stencil.element(face.exteriorIndex()));
641 const auto rates = this->
642 getComponentSurfaceRates(elemCtx, face.area(), scvfIdx, timeIdx);
675 template <
class Flu
idState>
678 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
682 fs.setSaturation(phaseIdx, this->
saturation_[phaseIdx][elemIdx]);
688 std::array<Scalar, numPhases> pc = {0};
689 const MaterialLawParams& matParams = simulator_.problem().materialLawParams(elemIdx);
690 MaterialLaw::capillaryPressures(pc, matParams, fs);
692 Valgrind::CheckDefined(pc);
694 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
695 if (!FluidSystem::phaseIsActive(phaseIdx))
698 if (Indices::oilEnabled)
699 fs.setPressure(phaseIdx, pressure + (pc[phaseIdx] - pc[oilPhaseIdx]));
700 else if (Indices::gasEnabled)
701 fs.setPressure(phaseIdx, pressure + (pc[phaseIdx] - pc[gasPhaseIdx]));
702 else if (Indices::waterEnabled)
704 fs.setPressure(phaseIdx, pressure);
708 if constexpr (energyModuleType != EnergyModules::NoTemperature) {
710 fs.setTemperature(this->temperature_[elemIdx]);
712 if constexpr (enableDissolvedGas) {
713 if (!this->rs_.empty())
714 fs.setRs(this->rs_[elemIdx]);
715 if (!this->rv_.empty())
716 fs.setRv(this->rv_[elemIdx]);
718 if constexpr (enableDisgasInWater) {
719 if (!this->
rsw_.empty())
720 fs.setRsw(this->rsw_[elemIdx]);
722 if constexpr (enableVapwat) {
723 if (!this->
rvw_.empty())
724 fs.setRvw(this->rvw_[elemIdx]);
730 if (!this->
soMax_.empty())
731 simulator.problem().setMaxOilSaturation(elemIdx, this->
soMax_[elemIdx]);
733 if (simulator.problem().materialLawManager().enableHysteresis()) {
734 auto& matLawManager = simulator.problem().materialLawManager();
736 if (FluidSystem::phaseIsActive(oilPhaseIdx)
737 && FluidSystem::phaseIsActive(waterPhaseIdx)) {
742 if (matLawManager.enableNonWettingHysteresis()) {
743 if (!this->
soMax_.empty()) {
744 somax = this->
soMax_[elemIdx];
747 if (matLawManager.enableWettingHysteresis()) {
748 if (!this->
swMax_.empty()) {
749 swmax = this->
swMax_[elemIdx];
752 if (matLawManager.enablePCHysteresis()) {
753 if (!this->
swmin_.empty()) {
754 swmin = this->
swmin_[elemIdx];
757 matLawManager.setOilWaterHysteresisParams(
758 somax, swmax, swmin, elemIdx);
760 if (FluidSystem::phaseIsActive(oilPhaseIdx)
761 && FluidSystem::phaseIsActive(gasPhaseIdx)) {
766 if (matLawManager.enableNonWettingHysteresis()) {
767 if (!this->
sgmax_.empty()) {
768 sgmax = this->
sgmax_[elemIdx];
771 if (matLawManager.enableWettingHysteresis()) {
772 if (!this->
shmax_.empty()) {
773 shmax = this->
shmax_[elemIdx];
776 if (matLawManager.enablePCHysteresis()) {
777 if (!this->
somin_.empty()) {
778 somin = this->
somin_[elemIdx];
781 matLawManager.setGasOilHysteresisParams(
782 sgmax, shmax, somin, elemIdx);
787 if (simulator_.vanguard().eclState().fieldProps().has_double(
"SWATINIT")) {
788 simulator.problem().materialLawManager().applyRestartSwatInit(elemIdx, this->
ppcw_[elemIdx]);
794 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++dofIdx) {
795 updateFluidInPlace_(elemCtx, dofIdx);
800 const IntensiveQuantities& intQuants,
801 const double totVolume)
803 this->updateFluidInPlace_(globalDofIdx, intQuants, totVolume);
808 const unsigned elemIdx,
809 const unsigned globalDofIndex)
override
813 auto assign = [&sol, elemIdx, globalDofIndex](
const std::string& name,
816 if (!data.empty() && sol.has(name)) {
817 data[elemIdx] = sol.data<
double>(name)[globalDofIndex];
829 const unsigned bufferSize)
override
834 FluidSystem::enableDissolvedGas(),
true);
836 FluidSystem::enableVaporizedOil(),
true);
840 bubblePointPressure_,
"PBPD",
true)) {
841 dewPointPressure_.resize(bufferSize, 0.0);
845 constexpr auto phaseChar = std::string_view{
"WOG"};
846 for (
unsigned phase = 0; phase < numPhases; ++phase) {
847 if (!FluidSystem::phaseIsActive(phase)) {
854 this->formationVolFactor_[phase],
855 std::string(
"B") + phaseChar[phase],
true);
858 std::string(
"1OVERB") + phaseChar[phase],
true);
861 std::string(
"KR") + phaseChar[phase],
true);
871 ScalarBuffer bubblePointPressure_;
872 ScalarBuffer dewPointPressure_;
873 std::array<ScalarBuffer, numPhases> formationVolFactor_;
874 std::array<ScalarBuffer, numPhases> invB_;
875 std::array<ScalarBuffer, numPhases> relativePermeability_;
876 template <
typename T>
877 using RemoveCVR = std::remove_cv_t<std::remove_reference_t<T>>;
879 template <
typename,
class =
void>
880 struct HasGeoMech :
public std::false_type {};
882 template <
typename Problem>
884 Problem, std::void_t<decltype(std::declval<Problem>().geoMechModel())>
885 > :
public std::true_type {};
887 template <
typename,
class =
void>
888 struct HasGeochemistry :
public std::false_type {};
890 template <
typename Problem>
891 struct HasGeochemistry<
892 Problem, std::void_t<decltype(std::declval<Problem>().geochemistryModel())>
893 > :
public std::true_type {};
895 bool isDefunctParallelWell(
const std::string& wname)
const override
897 if (simulator_.gridView().comm().size() == 1)
899 const auto& parallelWells = simulator_.vanguard().parallelWells();
900 std::pair<std::string, bool> value {wname,
true};
901 auto candidate = std::lower_bound(parallelWells.begin(), parallelWells.end(), value);
902 return candidate == parallelWells.end() || *candidate != value;
905 bool isOwnedByCurrentRank(
const std::string& wname)
const override
907 return this->simulator_.problem().wellModel().isOwner(wname);
910 bool isOnCurrentRank(
const std::string& wname)
const override
912 return this->simulator_.problem().wellModel().hasLocalCells(wname);
915 void updateFluidInPlace_(
const ElementContext& elemCtx,
const unsigned dofIdx)
917 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, 0);
918 const unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
919 const auto totVolume = elemCtx.simulator().model().dofTotalVolume(globalDofIdx);
921 this->updateFluidInPlace_(globalDofIdx, intQuants, totVolume);
924 void updateFluidInPlace_(
const unsigned globalDofIdx,
925 const IntensiveQuantities& intQuants,
926 const double totVolume)
933 intQuants.referencePorosity());
936 this->updatePhaseInplaceVolumes_(globalDofIdx, intQuants, totVolume);
944 void mapRegionsOntoLeaf_()
946 const LookUpData<Grid, GridView> lookUpData(simulator_.gridView());
947 const auto numLeaf = simulator_.gridView().size(0);
949 std::vector<int> onLeaf(numLeaf, 0);
950 for (
auto& [name, region] : this->regions_) {
951 std::size_t elemIdx = 0;
952 for (
const auto& elem : elements(simulator_.gridView())) {
953 onLeaf[elemIdx++] = lookUpData(elem, region);
960 void createLocalRegion_(std::vector<int>& region)
962 std::size_t elemIdx = 0;
963 for (
const auto& elem : elements(simulator_.gridView())) {
964 if (elem.partitionType() != Dune::InteriorEntity) {
972 template <
typename Flu
idState>
973 void aggregateAverageDensityContributions_(
const FluidState& fs,
974 const unsigned int globalDofIdx,
977 auto pvCellValue = RegionPhasePoreVolAverage::CellValue{};
978 pvCellValue.porv = porv;
980 for (
auto phaseIdx = 0*FluidSystem::numPhases;
981 phaseIdx < FluidSystem::numPhases; ++phaseIdx)
983 if (! FluidSystem::phaseIsActive(phaseIdx)) {
987 pvCellValue.value = getValue(fs.density(phaseIdx));
988 pvCellValue.sat = getValue(fs.saturation(phaseIdx));
991 ->addCell(globalDofIdx,
1012 data::InterRegFlowMap::FlowRates
1013 getComponentSurfaceRates(
const ElementContext& elemCtx,
1014 const Scalar faceArea,
1015 const std::size_t scvfIdx,
1016 const std::size_t timeIdx)
const
1018 using Component = data::InterRegFlowMap::Component;
1020 auto rates = data::InterRegFlowMap::FlowRates {};
1022 const auto& extQuant = elemCtx.extensiveQuantities(scvfIdx, timeIdx);
1024 const auto alpha = getValue(extQuant.extrusionFactor()) * faceArea;
1026 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1027 const auto& up = elemCtx
1028 .intensiveQuantities(extQuant.upstreamIndex(oilPhaseIdx), timeIdx);
1030 const auto pvtReg = up.pvtRegionIndex();
1032 const auto bO = getValue(getInvB_<FluidSystem, FluidState, Scalar>
1033 (up.fluidState(), oilPhaseIdx, pvtReg));
1035 const auto qO = alpha * bO * getValue(extQuant.volumeFlux(oilPhaseIdx));
1037 rates[Component::Oil] += qO;
1039 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1040 const auto Rs = getValue(
1041 BlackOil::getRs_<FluidSystem, FluidState, Scalar>
1042 (up.fluidState(), pvtReg));
1044 rates[Component::Gas] += qO *
Rs;
1045 rates[Component::Disgas] += qO *
Rs;
1049 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1050 const auto& up = elemCtx
1051 .intensiveQuantities(extQuant.upstreamIndex(gasPhaseIdx), timeIdx);
1053 const auto pvtReg = up.pvtRegionIndex();
1055 const auto bG = getValue(getInvB_<FluidSystem, FluidState, Scalar>
1056 (up.fluidState(), gasPhaseIdx, pvtReg));
1058 const auto qG = alpha * bG * getValue(extQuant.volumeFlux(gasPhaseIdx));
1060 rates[Component::Gas] += qG;
1062 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1063 const auto Rv = getValue(
1064 BlackOil::getRv_<FluidSystem, FluidState, Scalar>
1065 (up.fluidState(), pvtReg));
1067 rates[Component::Oil] += qG *
Rv;
1068 rates[Component::Vapoil] += qG *
Rv;
1072 if (FluidSystem::phaseIsActive(waterPhaseIdx)) {
1073 const auto& up = elemCtx
1074 .intensiveQuantities(extQuant.upstreamIndex(waterPhaseIdx), timeIdx);
1076 const auto pvtReg = up.pvtRegionIndex();
1078 const auto bW = getValue(getInvB_<FluidSystem, FluidState, Scalar>
1079 (up.fluidState(), waterPhaseIdx, pvtReg));
1081 rates[Component::Water] +=
1082 alpha * bW * getValue(extQuant.volumeFlux(waterPhaseIdx));
1088 void updatePhaseInplaceVolumes_(
const unsigned globalDofIdx,
1089 const IntensiveQuantities& intQuants,
1090 const double totVolume)
1092 std::array<Scalar, FluidSystem::numPhases> fip {};
1093 std::array<Scalar, FluidSystem::numPhases> fipr{};
1095 const auto& fs = intQuants.fluidState();
1096 const auto pv = totVolume * intQuants.porosity().value();
1098 for (
unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) {
1099 if (!FluidSystem::phaseIsActive(phaseIdx)) {
1103 const auto b = getValue(fs.invB(phaseIdx));
1104 const auto s = getValue(fs.saturation(phaseIdx));
1106 fipr[phaseIdx] = s * pv;
1107 fip [phaseIdx] = b * fipr[phaseIdx];
1112 fs.saltConcentration().value(),
1115 if (FluidSystem::phaseIsActive(oilPhaseIdx) &&
1116 FluidSystem::phaseIsActive(gasPhaseIdx))
1118 this->updateOilGasDistribution(globalDofIdx, fs, fip);
1121 if (FluidSystem::phaseIsActive(waterPhaseIdx) &&
1122 FluidSystem::phaseIsActive(gasPhaseIdx))
1124 this->updateGasWaterDistribution(globalDofIdx, fs, fip);
1127 if (FluidSystem::phaseIsActive(gasPhaseIdx) &&
1130 this->updateCO2InGas(globalDofIdx, pv, intQuants);
1134 (FluidSystem::phaseIsActive(waterPhaseIdx) ||
1135 FluidSystem::phaseIsActive(oilPhaseIdx)))
1137 this->updateCO2InWater(globalDofIdx, pv, fs);
1140 if constexpr(enableBioeffects) {
1141 const auto surfVolWat = pv * getValue(fs.saturation(waterPhaseIdx)) *
1142 getValue(fs.invB(waterPhaseIdx));
1144 this->updateMicrobialMass(globalDofIdx, intQuants, surfVolWat);
1147 this->updateBiofilmMass(globalDofIdx, intQuants, totVolume);
1149 if constexpr(enableMICP) {
1151 this->updateOxygenMass(globalDofIdx, intQuants, surfVolWat);
1154 this->updateUreaMass(globalDofIdx, intQuants, surfVolWat);
1157 this->updateCalciteMass(globalDofIdx, intQuants, totVolume);
1164 this->updateWaterMass(globalDofIdx, fs, fip);
1168 template <
typename Flu
idState,
typename FIPArray>
1169 void updateOilGasDistribution(
const unsigned globalDofIdx,
1170 const FluidState& fs,
1171 const FIPArray& fip)
1174 const auto gasInPlaceLiquid = getValue(fs.Rs()) * fip[oilPhaseIdx];
1175 const auto oilInPlaceGas = getValue(fs.Rv()) * fip[gasPhaseIdx];
1180 template <
typename Flu
idState,
typename FIPArray>
1181 void updateGasWaterDistribution(
const unsigned globalDofIdx,
1182 const FluidState& fs,
1183 const FIPArray& fip)
1186 const auto gasInPlaceWater = getValue(fs.Rsw()) * fip[waterPhaseIdx];
1187 const auto waterInPlaceGas = getValue(fs.Rvw()) * fip[gasPhaseIdx];
1192 template <
typename IntensiveQuantities>
1193 void updateCO2InGas(
const unsigned globalDofIdx,
1195 const IntensiveQuantities& intQuants)
1197 const auto& materialLawManager = this->simulator_.problem().materialLawManager();
1198 const auto& scaledDrainageInfo = materialLawManager.oilWaterScaledEpsInfoDrainage(globalDofIdx);
1200 const auto& fs = intQuants.fluidState();
1201 Scalar sgcr = scaledDrainageInfo.Sgcr;
1202 if (materialLawManager.enableHysteresis()) {
1203 const auto& matParams = simulator_.problem().materialLawParams(globalDofIdx);
1204 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
1207 Scalar trappedGasSaturation = scaledDrainageInfo.Sgcr;
1208 if (this->
fipC_.
has(Inplace::Phase::CO2MassInGasPhaseMaximumTrapped) ||
1209 this->fipC_.has(Inplace::Phase::CO2MassInGasPhaseMaximumUnTrapped))
1211 if (materialLawManager.enableHysteresis()) {
1212 const auto& matParams = simulator_.problem().materialLawParams(globalDofIdx);
1214 trappedGasSaturation = MaterialLaw::trappedGasSaturation(matParams,
true);
1218 const Scalar sg = getValue(fs.saturation(gasPhaseIdx));
1219 Scalar strandedGasSaturation = scaledDrainageInfo.Sgcr;
1220 if (this->
fipC_.
has(Inplace::Phase::CO2MassInGasPhaseEffectiveTrapped) ||
1221 this->fipC_.has(Inplace::Phase::CO2MassInGasPhaseEffectiveUnTrapped))
1223 if (materialLawManager.enableHysteresis()) {
1224 const auto& matParams = simulator_.problem().materialLawParams(globalDofIdx);
1225 const double krg = getValue(intQuants.relativePermeability(gasPhaseIdx));
1226 strandedGasSaturation = MaterialLaw::strandedGasSaturation(matParams, sg, krg);
1230 const typename FIPContainer<FluidSystem>::Co2InGasInput v{
1234 getValue(fs.density(gasPhaseIdx)),
1235 FluidSystem::phaseIsActive(waterPhaseIdx)
1236 ? FluidSystem::convertRvwToXgW(getValue(fs.Rvw()), fs.pvtRegionIndex())
1237 : FluidSystem::convertRvToXgO(getValue(fs.
Rv()), fs.pvtRegionIndex()),
1238 FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex()),
1239 trappedGasSaturation,
1240 strandedGasSaturation,
1246 template <
typename Flu
idState>
1247 void updateCO2InWater(
const unsigned globalDofIdx,
1249 const FluidState& fs)
1251 const auto co2InWater = FluidSystem::phaseIsActive(oilPhaseIdx)
1252 ? this->co2InWaterFromOil(fs, pv)
1253 : this->co2InWaterFromWater(fs, pv);
1255 const Scalar mM = FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex());
1260 template <
typename Flu
idState>
1261 Scalar co2InWaterFromWater(
const FluidState& fs,
const double pv)
const
1263 const double rhow = getValue(fs.density(waterPhaseIdx));
1264 const double sw = getValue(fs.saturation(waterPhaseIdx));
1265 const double xwG = FluidSystem::convertRswToXwG(getValue(fs.Rsw()), fs.pvtRegionIndex());
1267 const Scalar mM = FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex());
1269 return xwG * pv * rhow * sw / mM;
1272 template <
typename Flu
idState>
1273 Scalar co2InWaterFromOil(
const FluidState& fs,
const double pv)
const
1275 const double rhoo = getValue(fs.density(oilPhaseIdx));
1276 const double so = getValue(fs.saturation(oilPhaseIdx));
1277 const double xoG = FluidSystem::convertRsToXoG(getValue(fs.Rs()), fs.pvtRegionIndex());
1279 const Scalar mM = FluidSystem::molarMass(gasCompIdx, fs.pvtRegionIndex());
1281 return xoG * pv * rhoo * so / mM;
1284 template <
typename Flu
idState,
typename FIPArray>
1285 void updateWaterMass(
const unsigned globalDofIdx,
1286 const FluidState& fs,
1290 const Scalar rhoW = FluidSystem::referenceDensity(waterPhaseIdx, fs.pvtRegionIndex());
1295 template <
typename IntensiveQuantities>
1296 void updateMicrobialMass(
const unsigned globalDofIdx,
1297 const IntensiveQuantities& intQuants,
1298 const double surfVolWat)
1300 const Scalar mass = surfVolWat * intQuants.microbialConcentration().value();
1305 template <
typename IntensiveQuantities>
1306 void updateOxygenMass(
const unsigned globalDofIdx,
1307 const IntensiveQuantities& intQuants,
1308 const double surfVolWat)
1310 const Scalar mass = surfVolWat * intQuants.oxygenConcentration().value();
1315 template <
typename IntensiveQuantities>
1316 void updateUreaMass(
const unsigned globalDofIdx,
1317 const IntensiveQuantities& intQuants,
1318 const double surfVolWat)
1320 const Scalar mass = surfVolWat * intQuants.ureaConcentration().value();
1325 template <
typename IntensiveQuantities>
1326 void updateBiofilmMass(
const unsigned globalDofIdx,
1327 const IntensiveQuantities& intQuants,
1328 const double totVolume)
1330 const Scalar mass = totVolume * intQuants.biofilmMass().value();
1335 template <
typename IntensiveQuantities>
1336 void updateCalciteMass(
const unsigned globalDofIdx,
1337 const IntensiveQuantities& intQuants,
1338 const double totVolume)
1340 const Scalar mass = totVolume * intQuants.calciteMass().value();
1346 void setupElementExtractors_()
1348 using Entry =
typename Extractor::Entry;
1349 using Context =
typename Extractor::Context;
1350 using ScalarEntry =
typename Extractor::ScalarEntry;
1351 using PhaseEntry =
typename Extractor::PhaseEntry;
1353 const bool hasResidual = simulator_.model().linearizer().residual().size() > 0;
1354 const auto& hysteresisConfig = simulator_.problem().materialLawManager().hysteresisConfig();
1356 auto extractors = std::array{
1358 [](
const unsigned phase,
const Context& ectx)
1359 {
return getValue(ectx.fs.saturation(phase)); }
1362 Entry{PhaseEntry{&this->formationVolFactor_,
1363 [](
const unsigned phase,
const Context& ectx)
1365 constexpr auto zero = Scalar{};
1367 const auto recipFVF = getValue(ectx.fs.invB(phase));
1369 return (recipFVF > zero)
1370 ?
static_cast<Scalar
>(1) / recipFVF
1375 Entry{PhaseEntry{&this->invB_,
1376 [](
const unsigned phase,
const Context& ectx)
1377 {
return getValue(ectx.fs.invB(phase)); }
1381 [](
const unsigned phase,
const Context& ectx)
1382 {
return getValue(ectx.fs.density(phase)); }
1385 Entry{PhaseEntry{&this->relativePermeability_,
1386 [](
const unsigned phase,
const Context& ectx)
1387 {
return getValue(ectx.intQuants.relativePermeability(phase)); }
1391 [
this](
const unsigned phaseIdx,
const Context& ectx)
1394 if constexpr (enableExtbo) {
1395 if (this->
extboC_.allocated() && phaseIdx == oilPhaseIdx) {
1396 return getValue(ectx.intQuants.oilViscosity());
1398 else if (this->
extboC_.allocated() && phaseIdx == gasPhaseIdx) {
1399 return getValue(ectx.intQuants.gasViscosity());
1402 return getValue(ectx.fs.viscosity(phaseIdx));
1407 [&modelResid = this->simulator_.model().linearizer().residual()]
1408 (
const unsigned phaseIdx,
const Context& ectx)
1410 const unsigned sIdx = FluidSystem::solventComponentIndex(phaseIdx);
1411 const unsigned activeCompIdx = FluidSystem::canonicalToActiveCompIdx(sIdx);
1412 return modelResid[ectx.globalDofIdx][activeCompIdx];
1418 [&problem = this->simulator_.problem()](
const Context& ectx)
1420 return problem.template
1421 rockCompPoroMultiplier<Scalar>(ectx.intQuants,
1427 [&problem = this->simulator_.problem()](
const Context& ectx)
1430 template rockCompTransMultiplier<Scalar>(ectx.intQuants,
1435 [&problem = this->simulator_.problem()](
const Context& ectx)
1437 return std::min(getValue(ectx.fs.pressure(oilPhaseIdx)),
1438 problem.minOilPressure(ectx.globalDofIdx));
1442 Entry{ScalarEntry{&this->bubblePointPressure_,
1444 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1448 FluidSystem::bubblePointPressure(ectx.fs,
1449 ectx.intQuants.pvtRegionIndex())
1451 }
catch (
const NumericalProblem&) {
1452 const auto cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1453 failedCells.push_back(cartesianIdx);
1459 Entry{ScalarEntry{&this->dewPointPressure_,
1461 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1465 FluidSystem::dewPointPressure(ectx.fs,
1466 ectx.intQuants.pvtRegionIndex())
1468 }
catch (
const NumericalProblem&) {
1469 const auto cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1470 failedCells.push_back(cartesianIdx);
1477 [&problem = simulator_.problem()](
const Context& ectx)
1478 {
return problem.overburdenPressure(ectx.globalDofIdx); }
1482 [](
const Context& ectx)
1483 {
return getValue(ectx.fs.temperature(oilPhaseIdx)); }
1486 Entry{ScalarEntry{&this->
sSol_,
1487 [](
const Context& ectx)
1489 if constexpr (enableSolvent) {
1490 return getValue(ectx.intQuants.solventSaturation());
1498 Entry{ScalarEntry{&this->
rswSol_,
1499 [](
const Context& ectx)
1501 if constexpr (enableSolvent) {
1502 return getValue(ectx.intQuants.rsSolw());
1511 [](
const Context& ectx)
1513 if constexpr (enablePolymer) {
1514 return getValue(ectx.intQuants.polymerConcentration());
1522 Entry{ScalarEntry{&this->
cFoam_,
1523 [](
const Context& ectx)
1525 if constexpr (enableFoam) {
1526 return getValue(ectx.intQuants.foamConcentration());
1534 Entry{ScalarEntry{&this->
cSalt_,
1535 [](
const Context& ectx)
1536 {
return getValue(ectx.fs.saltConcentration()); }
1539 Entry{ScalarEntry{&this->
pSalt_,
1540 [](
const Context& ectx)
1541 {
return getValue(ectx.fs.saltSaturation()); }
1545 [](
const Context& ectx)
1546 {
return getValue(ectx.intQuants.permFactor()); }
1549 Entry{ScalarEntry{&this->
rPorV_,
1550 [&model = this->simulator_.model()](
const Context& ectx)
1552 const auto totVolume = model.dofTotalVolume(ectx.globalDofIdx);
1553 return totVolume * getValue(ectx.intQuants.porosity());
1557 Entry{ScalarEntry{&this->rs_,
1558 [](
const Context& ectx)
1559 {
return getValue(ectx.fs.Rs()); }
1562 Entry{ScalarEntry{&this->rv_,
1563 [](
const Context& ectx)
1564 {
return getValue(ectx.fs.Rv()); }
1567 Entry{ScalarEntry{&this->
rsw_,
1568 [](
const Context& ectx)
1569 {
return getValue(ectx.fs.Rsw()); }
1572 Entry{ScalarEntry{&this->
rvw_,
1573 [](
const Context& ectx)
1574 {
return getValue(ectx.fs.Rvw()); }
1577 Entry{ScalarEntry{&this->
ppcw_,
1578 [&matLawManager = this->simulator_.problem().materialLawManager()]
1579 (
const Context& ectx)
1581 return matLawManager.
1582 oilWaterScaledEpsInfoDrainage(ectx.globalDofIdx).maxPcow;
1587 [&problem = this->simulator_.problem()](
const Context& ectx)
1589 return problem.drsdtcon(ectx.globalDofIdx,
1594 Entry{ScalarEntry{&this->
pcgw_,
1595 [](
const Context& ectx)
1597 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
1598 getValue(ectx.fs.pressure(waterPhaseIdx));
1602 Entry{ScalarEntry{&this->
pcow_,
1603 [](
const Context& ectx)
1605 return getValue(ectx.fs.pressure(oilPhaseIdx)) -
1606 getValue(ectx.fs.pressure(waterPhaseIdx));
1610 Entry{ScalarEntry{&this->
pcog_,
1611 [](
const Context& ectx)
1613 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
1614 getValue(ectx.fs.pressure(oilPhaseIdx));
1619 [](
const Context& ectx)
1621 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1623 return getValue(ectx.fs.pressure(oilPhaseIdx));
1625 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1627 return getValue(ectx.fs.pressure(gasPhaseIdx));
1631 return getValue(ectx.fs.pressure(waterPhaseIdx));
1637 [&problem = this->simulator_.problem()](
const Context& ectx)
1639 const Scalar SoMax = problem.maxOilSaturation(ectx.globalDofIdx);
1640 return FluidSystem::template
1641 saturatedDissolutionFactor<FluidState, Scalar>(ectx.fs,
1649 [&problem = this->simulator_.problem()](
const Context& ectx)
1651 const Scalar SoMax = problem.maxOilSaturation(ectx.globalDofIdx);
1652 return FluidSystem::template
1653 saturatedDissolutionFactor<FluidState, Scalar>(ectx.fs,
1661 [&problem = this->simulator_.problem()](
const Context& ectx)
1663 const Scalar SwMax = problem.maxWaterSaturation(ectx.globalDofIdx);
1664 return FluidSystem::template
1665 saturatedDissolutionFactor<FluidState, Scalar>(ectx.fs,
1673 [](
const Context& ectx)
1675 return FluidSystem::template
1676 saturatedVaporizationFactor<FluidState, Scalar>(ectx.fs,
1683 [](
const Context& ectx)
1685 return 1.0 / FluidSystem::template
1686 inverseFormationVolumeFactor<FluidState, Scalar>(ectx.fs,
1693 [](
const Context& ectx)
1695 return 1.0 / FluidSystem::template
1696 saturatedInverseFormationVolumeFactor<FluidState, Scalar>(ectx.fs,
1703 [](
const Context& ectx)
1705 return FluidSystem::template
1706 saturationPressure<FluidState, Scalar>(ectx.fs,
1712 Entry{ScalarEntry{&this->
soMax_,
1713 [&problem = this->simulator_.problem()](
const Context& ectx)
1715 return std::max(getValue(ectx.fs.saturation(oilPhaseIdx)),
1716 problem.maxOilSaturation(ectx.globalDofIdx));
1719 !hysteresisConfig.enableHysteresis()
1721 Entry{ScalarEntry{&this->
swMax_,
1722 [&problem = this->simulator_.problem()](
const Context& ectx)
1724 return std::max(getValue(ectx.fs.saturation(waterPhaseIdx)),
1725 problem.maxWaterSaturation(ectx.globalDofIdx));
1728 !hysteresisConfig.enableHysteresis()
1730 Entry{ScalarEntry{&this->
soMax_,
1731 [](
const Context& ectx)
1732 {
return ectx.hParams.somax; }
1734 hysteresisConfig.enableHysteresis() &&
1735 hysteresisConfig.enableNonWettingHysteresis() &&
1736 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1737 FluidSystem::phaseIsActive(waterPhaseIdx)
1739 Entry{ScalarEntry{&this->
swMax_,
1740 [](
const Context& ectx)
1741 {
return ectx.hParams.swmax; }
1743 hysteresisConfig.enableHysteresis() &&
1744 hysteresisConfig.enableWettingHysteresis() &&
1745 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1746 FluidSystem::phaseIsActive(waterPhaseIdx)
1748 Entry{ScalarEntry{&this->
swmin_,
1749 [](
const Context& ectx)
1750 {
return ectx.hParams.swmin; }
1752 hysteresisConfig.enableHysteresis() &&
1753 hysteresisConfig.enablePCHysteresis() &&
1754 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1755 FluidSystem::phaseIsActive(waterPhaseIdx)
1757 Entry{ScalarEntry{&this->
sgmax_,
1758 [](
const Context& ectx)
1759 {
return ectx.hParams.sgmax; }
1761 hysteresisConfig.enableHysteresis() &&
1762 hysteresisConfig.enableNonWettingHysteresis() &&
1763 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1764 FluidSystem::phaseIsActive(gasPhaseIdx)
1766 Entry{ScalarEntry{&this->
shmax_,
1767 [](
const Context& ectx)
1768 {
return ectx.hParams.shmax; }
1770 hysteresisConfig.enableHysteresis() &&
1771 hysteresisConfig.enableWettingHysteresis() &&
1772 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1773 FluidSystem::phaseIsActive(gasPhaseIdx)
1775 Entry{ScalarEntry{&this->
somin_,
1776 [](
const Context& ectx)
1777 {
return ectx.hParams.somin; }
1779 hysteresisConfig.enableHysteresis() &&
1780 hysteresisConfig.enablePCHysteresis() &&
1781 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1782 FluidSystem::phaseIsActive(gasPhaseIdx)
1784 Entry{[&model = this->simulator_.model(),
this](
const Context& ectx)
1788 const auto porv = ectx.intQuants.referencePorosity()
1789 * model.dofTotalVolume(ectx.globalDofIdx);
1791 this->aggregateAverageDensityContributions_(ectx.fs, ectx.globalDofIdx,
1792 static_cast<double>(porv));
1795 Entry{[&extboC = this->
extboC_](
const Context& ectx)
1798 if constexpr (enableExtbo) {
1799 extboC.assignVolumes(ectx.globalDofIdx,
1800 ectx.intQuants.xVolume().value(),
1801 ectx.intQuants.yVolume().value());
1802 extboC.assignZFraction(ectx.globalDofIdx,
1803 ectx.intQuants.zFraction().value());
1805 const Scalar stdVolOil = getValue(ectx.fs.saturation(oilPhaseIdx)) *
1806 getValue(ectx.fs.invB(oilPhaseIdx)) +
1807 getValue(ectx.fs.saturation(gasPhaseIdx)) *
1808 getValue(ectx.fs.invB(gasPhaseIdx)) *
1809 getValue(ectx.fs.Rv());
1810 const Scalar stdVolGas = getValue(ectx.fs.saturation(gasPhaseIdx)) *
1811 getValue(ectx.fs.invB(gasPhaseIdx)) *
1812 (1.0 - ectx.intQuants.yVolume().value()) +
1813 getValue(ectx.fs.saturation(oilPhaseIdx)) *
1814 getValue(ectx.fs.invB(oilPhaseIdx)) *
1815 getValue(ectx.fs.Rs()) *
1816 (1.0 - ectx.intQuants.xVolume().value());
1817 const Scalar stdVolCo2 = getValue(ectx.fs.saturation(gasPhaseIdx)) *
1818 getValue(ectx.fs.invB(gasPhaseIdx)) *
1819 ectx.intQuants.yVolume().value() +
1820 getValue(ectx.fs.saturation(oilPhaseIdx)) *
1821 getValue(ectx.fs.invB(oilPhaseIdx)) *
1822 getValue(ectx.fs.Rs()) *
1823 ectx.intQuants.xVolume().value();
1824 const Scalar rhoO = FluidSystem::referenceDensity(oilPhaseIdx, ectx.pvtRegionIdx);
1825 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx, ectx.pvtRegionIdx);
1826 const Scalar rhoCO2 = ectx.intQuants.zRefDensity();
1827 const Scalar stdMassTotal = 1.0e-10 + stdVolOil * rhoO + stdVolGas * rhoG + stdVolCo2 * rhoCO2;
1828 extboC.assignMassFractions(ectx.globalDofIdx,
1829 stdVolGas * rhoG / stdMassTotal,
1830 stdVolOil * rhoO / stdMassTotal,
1831 stdVolCo2 * rhoCO2 / stdMassTotal);
1833 if (extboC.phaseMassFractionsRequested()) {
1834 const auto [oil, gas] = extboC.phaseSolventMassFractions({
1835 .oilSaturation = getValue(ectx.fs.saturation(oilPhaseIdx)),
1836 .gasSaturation = getValue(ectx.fs.saturation(gasPhaseIdx)),
1837 .rs = getValue(ectx.fs.Rs()),
1838 .rv = getValue(ectx.fs.Rv()),
1839 .xVolume = ectx.intQuants.xVolume().value(),
1840 .yVolume = ectx.intQuants.yVolume().value(),
1843 .solventDensity = rhoCO2,
1845 extboC.assignPhaseMassFractions(ectx.globalDofIdx, oil, gas);
1850 Entry{[&bioeffectsC = this->
bioeffectsC_](
const Context& ectx)
1853 if constexpr (enableBioeffects) {
1854 bioeffectsC.assign(ectx.globalDofIdx,
1855 ectx.intQuants.microbialConcentration().value(),
1856 ectx.intQuants.biofilmVolumeFraction().value());
1857 if (Indices::enableMICP) {
1858 bioeffectsC.assign(ectx.globalDofIdx,
1859 ectx.intQuants.oxygenConcentration().value(),
1860 ectx.intQuants.ureaConcentration().value(),
1861 ectx.intQuants.calciteVolumeFraction().value());
1866 Entry{[&runspec = this->
eclState_.runspec(),
1867 &CO2H2C = this->
CO2H2C_](
const Context& ectx)
1869 const auto xwg = FluidSystem::convertRswToXwG(getValue(ectx.fs.Rsw()), ectx.pvtRegionIdx);
1870 const auto xgw = FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.pvtRegionIdx);
1871 CO2H2C.assign(ectx.globalDofIdx,
1872 FluidSystem::convertXwGToxwG(xwg, ectx.pvtRegionIdx),
1873 FluidSystem::convertXgWToxgW(xgw, ectx.pvtRegionIdx),
1874 runspec.co2Storage());
1877 Entry{[&rftC = this->
rftC_,
1878 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1880 const auto cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1881 rftC.assign(cartesianIdx,
1886 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1887 return getValue(fs.pressure(oilPhaseIdx));
1889 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1890 return getValue(fs.pressure(gasPhaseIdx));
1893 return getValue(fs.pressure(waterPhaseIdx));
1896 [&fs = ectx.fs]() {
return getValue(fs.saturation(waterPhaseIdx)); },
1897 [&fs = ectx.fs]() {
return getValue(fs.saturation(gasPhaseIdx)); });
1901 &tM = this->simulator_.problem().tracerModel()](
const Context& ectx)
1903 tC.assignFreeConcentrations(ectx.globalDofIdx,
1904 [gIdx = ectx.globalDofIdx, &tM](
const unsigned tracerIdx)
1905 {
return tM.freeTracerConcentration(tracerIdx, gIdx); });
1906 tC.assignSolConcentrations(ectx.globalDofIdx,
1907 [gIdx = ectx.globalDofIdx, &tM](
const unsigned tracerIdx)
1908 {
return tM.solTracerConcentration(tracerIdx, gIdx); });
1911 Entry{[&flowsInf = this->simulator_.problem().model().linearizer().getFlowsInfo(),
1913 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1915 const auto gas_idx = Indices::gasEnabled ?
1916 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(gasCompIdx) : -1;
1917 const auto oil_idx = Indices::oilEnabled ?
1918 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(oilCompIdx) : -1;
1919 const auto water_idx = Indices::waterEnabled ?
1920 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(waterCompIdx) : -1;
1921 const auto& flowsInfos = flowsInf[ectx.globalDofIdx];
1922 if (!flowsC.blockFlows().empty()) {
1923 const std::vector<int>& blockIdxs = flowsC.blockFlows();
1924 const unsigned cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1925 if (std::ranges::binary_search(blockIdxs, cartesianIdx)) {
1926 const auto compIdxs = std::array{ gasCompIdx, oilCompIdx, waterCompIdx };
1927 const auto compEnabled = std::array{ Indices::gasEnabled, Indices::oilEnabled, Indices::waterEnabled };
1928 for (
const auto& flowsInfo : flowsInfos) {
1929 if (flowsInfo.faceId < 0) {
1932 for (
unsigned ii = 0; ii < compIdxs.size(); ++ii) {
1933 if (!compEnabled[ii]) {
1936 if (flowsC.hasBlockFlowValue(cartesianIdx, flowsInfo.faceId, compIdxs[ii])) {
1937 flowsC.assignBlockFlows(flowsC.blockFlowsIds(cartesianIdx, flowsInfo.faceId, compIdxs[ii]),
1940 flowsInfo.flow[conti0EqIdx
1941 + FluidSystem::canonicalToActiveCompIdx(compIdxs[ii])]);
1948 for (
const auto& flowsInfo : flowsInfos) {
1949 flowsC.assignFlows(ectx.globalDofIdx,
1952 value_or_zero(gas_idx, flowsInfo.flow),
1953 value_or_zero(oil_idx, flowsInfo.flow),
1954 value_or_zero(water_idx, flowsInfo.flow));
1957 }, !this->simulator_.problem().model().linearizer().getFlowsInfo().empty()
1959 Entry{[&floresInf = this->simulator_.problem().model().linearizer().getFloresInfo(),
1960 &flowsC = this->
flowsC_](
const Context& ectx)
1962 const auto gas_idx = Indices::gasEnabled ?
1963 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(gasCompIdx) : -1;
1964 const auto oil_idx = Indices::oilEnabled ?
1965 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(oilCompIdx) : -1;
1966 const auto water_idx = Indices::waterEnabled ?
1967 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(waterCompIdx) : -1;
1968 const auto& floresInfos = floresInf[ectx.globalDofIdx];
1969 for (
const auto& floresInfo : floresInfos) {
1970 flowsC.assignFlores(ectx.globalDofIdx,
1973 value_or_zero(gas_idx, floresInfo.flow),
1974 value_or_zero(oil_idx, floresInfo.flow),
1975 value_or_zero(water_idx, floresInfo.flow));
1977 }, !this->simulator_.problem().model().linearizer().getFloresInfo().empty()
1979 Entry{[&velocityInf = this->simulator_.problem().model().linearizer().getVelocityInfo(),
1981 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1983 const auto& velocityInfos = velocityInf[ectx.globalDofIdx];
1984 const std::vector<int>& blockIdxs = flowsC.blockVelocity();
1985 const unsigned cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1986 if (std::ranges::binary_search(blockIdxs, cartesianIdx)) {
1987 const auto compIdxs = std::array{ gasCompIdx, oilCompIdx, waterCompIdx };
1988 const auto compEnabled = std::array{ Indices::gasEnabled, Indices::oilEnabled, Indices::waterEnabled };
1989 for (
const auto& velocityInfo : velocityInfos) {
1990 if (velocityInfo.faceId < 0) {
1993 for (
unsigned ii = 0; ii < compIdxs.size(); ++ii) {
1994 if (!compEnabled[ii]) {
1997 if (flowsC.hasBlockVelocityValue(cartesianIdx, velocityInfo.faceId, compIdxs[ii])) {
1998 flowsC.assignBlockVelocity(flowsC.blockVelocityIds(cartesianIdx, velocityInfo.faceId, compIdxs[ii]),
1999 velocityInfo.faceId,
2001 velocityInfo.velocity[conti0EqIdx
2002 + FluidSystem::canonicalToActiveCompIdx(compIdxs[ii])]);
2008 !this->simulator_.problem().model().linearizer().getVelocityInfo().empty()
2015 Entry{ScalarEntry{&this->rv_,
2016 [&problem = this->simulator_.problem()](
const Context& ectx)
2017 {
return problem.initialFluidState(ectx.globalDofIdx).Rv(); }
2019 simulator_.episodeIndex() < 0 &&
2020 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2021 FluidSystem::phaseIsActive(gasPhaseIdx)
2023 Entry{ScalarEntry{&this->rs_,
2024 [&problem = this->simulator_.problem()](
const Context& ectx)
2025 {
return problem.initialFluidState(ectx.globalDofIdx).Rs(); }
2027 simulator_.episodeIndex() < 0 &&
2028 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2029 FluidSystem::phaseIsActive(gasPhaseIdx)
2031 Entry{ScalarEntry{&this->
rsw_,
2032 [&problem = this->simulator_.problem()](
const Context& ectx)
2033 {
return problem.initialFluidState(ectx.globalDofIdx).Rsw(); }
2035 simulator_.episodeIndex() < 0 &&
2036 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2037 FluidSystem::phaseIsActive(gasPhaseIdx)
2039 Entry{ScalarEntry{&this->
rvw_,
2040 [&problem = this->simulator_.problem()](
const Context& ectx)
2041 {
return problem.initialFluidState(ectx.globalDofIdx).Rvw(); }
2043 simulator_.episodeIndex() < 0 &&
2044 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2045 FluidSystem::phaseIsActive(gasPhaseIdx)
2049 [&problem = this->simulator_.problem()](
const unsigned phase,
2050 const Context& ectx)
2052 const auto& fsInitial = problem.initialFluidState(ectx.globalDofIdx);
2053 return FluidSystem::density(fsInitial,
2055 ectx.intQuants.pvtRegionIndex());
2058 simulator_.episodeIndex() < 0 &&
2059 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2060 FluidSystem::phaseIsActive(gasPhaseIdx)
2062 Entry{PhaseEntry{&this->formationVolFactor_,
2063 [&problem = this->simulator_.problem()]
2064 (
const unsigned phase,
const Context& ectx)
2066 constexpr auto zero = Scalar{};
2068 const auto& fsInitial = problem.initialFluidState(ectx.globalDofIdx);
2070 const auto recipFVF = getValue
2071 (FluidSystem::inverseFormationVolumeFactor
2072 (fsInitial, phase, ectx.intQuants.pvtRegionIndex()));
2074 return (recipFVF > zero)
2075 ?
static_cast<Scalar
>(1) / recipFVF
2079 simulator_.episodeIndex() < 0 &&
2080 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2081 FluidSystem::phaseIsActive(gasPhaseIdx)
2083 Entry{PhaseEntry{&this->invB_,
2084 [&problem = this->simulator_.problem()](
const unsigned phase,
2085 const Context& ectx)
2087 const auto& fsInitial = problem.initialFluidState(ectx.globalDofIdx);
2088 return FluidSystem::inverseFormationVolumeFactor(fsInitial,
2090 ectx.intQuants.pvtRegionIndex());
2093 simulator_.episodeIndex() < 0 &&
2094 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2095 FluidSystem::phaseIsActive(gasPhaseIdx)
2098 [&problem = this->simulator_.problem()](
const unsigned phase,
2099 const Context& ectx)
2101 const auto& fsInitial = problem.initialFluidState(ectx.globalDofIdx);
2102 return FluidSystem::viscosity(fsInitial,
2104 ectx.intQuants.pvtRegionIndex());
2107 simulator_.episodeIndex() < 0 &&
2108 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2109 FluidSystem::phaseIsActive(gasPhaseIdx)
2117 if constexpr (getPropValue<TypeTag, Properties::EnableGeochemistry>()) {
2119 this->extractors_.emplace_back(
2121 &gM = this->simulator_.problem().geochemistryModel()](
const Context& ectx)
2123 gC.assignSpeciesConcentrations(
2125 [gIdx = ectx.globalDofIdx, &gM](
const unsigned speciesIdx)
2126 {
return gM.speciesConcentration(speciesIdx, gIdx); }
2128 gC.assignMineralConcentrations(
2130 [gIdx = ectx.globalDofIdx, &gM](
const unsigned mineralIdx)
2131 {
return gM.mineralConcentration(mineralIdx, gIdx); }
2133 gC.assignPH(ectx.globalDofIdx, gM.PH(ectx.globalDofIdx));
2141 if constexpr (getPropValue<TypeTag, Properties::EnableMech>()) {
2142 if (this->
mech_.allocated()) {
2143 this->extractors_.emplace_back(
2144 [&mech = this->
mech_,
2145 &model = simulator_.problem().geoMechModel()](
const Context& ectx)
2147 mech.assignDelStress(ectx.globalDofIdx,
2148 model.delstress(ectx.globalDofIdx));
2150 mech.assignDisplacement(ectx.globalDofIdx,
2151 model.disp(ectx.globalDofIdx,
true));
2154 mech.assignFracStress(ectx.globalDofIdx,
2155 model.fractureStress(ectx.globalDofIdx));
2157 mech.assignLinStress(ectx.globalDofIdx,
2158 model.linstress(ectx.globalDofIdx));
2160 mech.assignPotentialForces(ectx.globalDofIdx,
2161 model.mechPotentialForce(ectx.globalDofIdx),
2162 model.mechPotentialPressForce(ectx.globalDofIdx),
2163 model.mechPotentialTempForce(ectx.globalDofIdx));
2165 mech.assignStrain(ectx.globalDofIdx,
2166 model.strain(ectx.globalDofIdx,
true));
2169 mech.assignStress(ectx.globalDofIdx,
2170 model.stress(ectx.globalDofIdx,
true));
2173 if (mech.enableTraction()) {
2174 mech.assignTraction(ectx.globalDofIdx,
2175 model.traction(ectx.globalDofIdx));
2181 if (this->
tpsaC_.allocated()) {
2182 this->extractors_.emplace_back(
2184 &model = simulator_.problem().geoMechModel()](
const Context& ectx) {
2185 tpsaC.assignRotation(ectx.globalDofIdx,
2186 model.rotation(ectx.globalDofIdx));
2188 tpsaC.assignSolidPressure(ectx.globalDofIdx,
2189 model.solidPressure(ectx.globalDofIdx));
2198 void setupBlockExtractors_(
const bool isSubStep,
2199 const int reportStepNum)
2202 using Context =
typename BlockExtractor::Context;
2203 using PhaseEntry =
typename BlockExtractor::PhaseEntry;
2204 using ScalarEntry =
typename BlockExtractor::ScalarEntry;
2205 using TensorEntry =
typename BlockExtractor::TensorEntry;
2207 using namespace std::string_view_literals;
2209 const auto pressure_handler =
2210 Entry{ScalarEntry{std::vector{
"BPR"sv,
"BPRESSUR"sv},
2211 [](
const Context& ectx)
2213 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2214 return getValue(ectx.fs.pressure(oilPhaseIdx));
2216 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
2217 return getValue(ectx.fs.pressure(gasPhaseIdx));
2220 return getValue(ectx.fs.pressure(waterPhaseIdx));
2226 const auto handlers = std::array{
2228 Entry{PhaseEntry{std::array{
2229 std::array{
"BWSAT"sv,
"BOSAT"sv,
"BGSAT"sv},
2230 std::array{
"BSWAT"sv,
"BSOIL"sv,
"BSGAS"sv}
2232 [](
const unsigned phaseIdx,
const Context& ectx)
2234 return getValue(ectx.fs.saturation(phaseIdx));
2238 Entry{ScalarEntry{
"BNSAT",
2239 [](
const Context& ectx)
2241 if constexpr (enableSolvent) {
2242 return ectx.intQuants.solventSaturation().value();
2250 Entry{ScalarEntry{std::vector{
"BTCNFHEA"sv,
"BTEMP"sv},
2251 [](
const Context& ectx)
2253 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2254 return getValue(ectx.fs.temperature(oilPhaseIdx));
2256 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
2257 return getValue(ectx.fs.temperature(gasPhaseIdx));
2260 return getValue(ectx.fs.temperature(waterPhaseIdx));
2265 Entry{PhaseEntry{std::array{
2266 std::array{
"BWKR"sv,
"BOKR"sv,
"BGKR"sv},
2267 std::array{
"BKRW"sv,
"BKRO"sv,
"BKRG"sv}
2269 [](
const unsigned phaseIdx,
const Context& ectx)
2271 return getValue(ectx.intQuants.relativePermeability(phaseIdx));
2275 Entry{ScalarEntry{
"BKROG",
2276 [&problem = this->simulator_.problem()](
const Context& ectx)
2278 const auto& materialParams =
2279 problem.materialLawParams(ectx.elemCtx,
2282 return getValue(MaterialLaw::template
2283 relpermOilInOilGasSystem<Evaluation>(materialParams,
2288 Entry{ScalarEntry{
"BKROW",
2289 [&problem = this->simulator_.problem()](
const Context& ectx)
2291 const auto& materialParams = problem.materialLawParams(ectx.elemCtx,
2294 return getValue(MaterialLaw::template
2295 relpermOilInOilWaterSystem<Evaluation>(materialParams,
2300 Entry{ScalarEntry{
"BWPC",
2301 [](
const Context& ectx)
2303 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2304 return getValue(ectx.fs.pressure(oilPhaseIdx)) -
2305 getValue(ectx.fs.pressure(waterPhaseIdx));
2307 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
2308 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
2309 getValue(ectx.fs.pressure(waterPhaseIdx));
2317 Entry{ScalarEntry{
"BGPC",
2318 [](
const Context& ectx)
2320 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2321 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
2322 getValue(ectx.fs.pressure(oilPhaseIdx));
2324 else if (FluidSystem::phaseIsActive(waterPhaseIdx)) {
2325 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
2326 getValue(ectx.fs.pressure(waterPhaseIdx));
2334 Entry{ScalarEntry{
"BWPR",
2335 [](
const Context& ectx)
2337 return getValue(ectx.fs.pressure(waterPhaseIdx));
2341 Entry{ScalarEntry{
"BGPR",
2342 [](
const Context& ectx)
2344 return getValue(ectx.fs.pressure(gasPhaseIdx));
2348 Entry{PhaseEntry{std::array{
2349 std::array{
"BVWAT"sv,
"BVOIL"sv,
"BVGAS"sv},
2350 std::array{
"BWVIS"sv,
"BOVIS"sv,
"BGVIS"sv}
2352 [](
const unsigned phaseIdx,
const Context& ectx)
2354 return getValue(ectx.fs.viscosity(phaseIdx));
2358 Entry{PhaseEntry{std::array{
2359 std::array{
"BWDEN"sv,
"BODEN"sv,
"BGDEN"sv},
2360 std::array{
"BDENW"sv,
"BDENO"sv,
"BDENG"sv}
2362 [](
const unsigned phaseIdx,
const Context& ectx)
2364 return getValue(ectx.fs.density(phaseIdx));
2368 Entry{ScalarEntry{
"BFLOGI",
2370 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2372 const unsigned index = !flowsC.blockFlows().empty() ?
2373 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2374 FaceDir::ToIntersectionIndex(Dir::XPlus), gasCompIdx) : ectx.globalDofIdx;
2375 return flowsC.getFlow(index, Dir::XPlus, gasCompIdx);
2379 Entry{ScalarEntry{
"BFLOGI-",
2381 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2383 const unsigned index = !flowsC.blockFlows().empty() ?
2384 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2385 FaceDir::ToIntersectionIndex(Dir::XMinus), gasCompIdx) : ectx.globalDofIdx;
2386 return flowsC.getFlow(index, Dir::XMinus, gasCompIdx);
2390 Entry{ScalarEntry{
"BFLOGJ",
2392 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2394 const unsigned index = !flowsC.blockFlows().empty() ?
2395 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2396 FaceDir::ToIntersectionIndex(Dir::YPlus), gasCompIdx) : ectx.globalDofIdx;
2397 return flowsC.getFlow(index, Dir::YPlus, gasCompIdx);
2401 Entry{ScalarEntry{
"BFLOGJ-",
2403 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2405 const unsigned index = !flowsC.blockFlows().empty() ?
2406 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2407 FaceDir::ToIntersectionIndex(Dir::YMinus), gasCompIdx) : ectx.globalDofIdx;
2408 return flowsC.getFlow(index, Dir::YMinus, gasCompIdx);
2412 Entry{ScalarEntry{
"BFLOGK",
2414 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2416 const unsigned index = !flowsC.blockFlows().empty() ?
2417 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2418 FaceDir::ToIntersectionIndex(Dir::ZPlus), gasCompIdx) : ectx.globalDofIdx;
2419 return flowsC.getFlow(index, Dir::ZPlus, gasCompIdx);
2423 Entry{ScalarEntry{
"BFLOGK-",
2425 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2427 const unsigned index = !flowsC.blockFlows().empty() ?
2428 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2429 FaceDir::ToIntersectionIndex(Dir::ZMinus), gasCompIdx) : ectx.globalDofIdx;
2430 return flowsC.getFlow(index, Dir::ZMinus, gasCompIdx);
2434 Entry{ScalarEntry{
"BFLOOI",
2436 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2438 const unsigned index = !flowsC.blockFlows().empty() ?
2439 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2440 FaceDir::ToIntersectionIndex(Dir::XPlus), oilCompIdx) : ectx.globalDofIdx;
2441 return flowsC.getFlow(index, Dir::XPlus, oilCompIdx);
2445 Entry{ScalarEntry{
"BFLOOI-",
2447 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2449 const unsigned index = !flowsC.blockFlows().empty() ?
2450 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2451 FaceDir::ToIntersectionIndex(Dir::XMinus), oilCompIdx) : ectx.globalDofIdx;
2452 return flowsC.getFlow(index, Dir::XMinus, oilCompIdx);
2456 Entry{ScalarEntry{
"BFLOOJ",
2458 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2460 const unsigned index = !flowsC.blockFlows().empty() ?
2461 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2462 FaceDir::ToIntersectionIndex(Dir::YPlus), oilCompIdx) : ectx.globalDofIdx;
2463 return flowsC.getFlow(index, Dir::YPlus, oilCompIdx);
2467 Entry{ScalarEntry{
"BFLOOJ-",
2469 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2471 const unsigned index = !flowsC.blockFlows().empty() ?
2472 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2473 FaceDir::ToIntersectionIndex(Dir::YMinus), oilCompIdx) : ectx.globalDofIdx;
2474 return flowsC.getFlow(index, Dir::YMinus, oilCompIdx);
2478 Entry{ScalarEntry{
"BFLOOK",
2480 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2482 const unsigned index = !flowsC.blockFlows().empty() ?
2483 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2484 FaceDir::ToIntersectionIndex(Dir::ZPlus), oilCompIdx) : ectx.globalDofIdx;
2485 return flowsC.getFlow(index, Dir::ZPlus, oilCompIdx);
2489 Entry{ScalarEntry{
"BFLOOK-",
2491 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2493 const unsigned index = !flowsC.blockFlows().empty() ?
2494 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2495 FaceDir::ToIntersectionIndex(Dir::ZMinus), oilCompIdx) : ectx.globalDofIdx;
2496 return flowsC.getFlow(index, Dir::ZMinus, oilCompIdx);
2500 Entry{ScalarEntry{
"BFLOWI",
2502 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2504 const unsigned index = !flowsC.blockFlows().empty() ?
2505 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2506 FaceDir::ToIntersectionIndex(Dir::XPlus), waterCompIdx) : ectx.globalDofIdx;
2507 return flowsC.getFlow(index, Dir::XPlus, waterCompIdx);
2511 Entry{ScalarEntry{
"BFLOWI-",
2513 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2515 const unsigned index = !flowsC.blockFlows().empty() ?
2516 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2517 FaceDir::ToIntersectionIndex(Dir::XMinus), waterCompIdx) : ectx.globalDofIdx;
2518 return flowsC.getFlow(index, Dir::XMinus, waterCompIdx);
2522 Entry{ScalarEntry{
"BFLOWJ",
2524 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2526 const unsigned index = !flowsC.blockFlows().empty() ?
2527 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2528 FaceDir::ToIntersectionIndex(Dir::YPlus), waterCompIdx) : ectx.globalDofIdx;
2529 return flowsC.getFlow(index, Dir::YPlus, waterCompIdx);
2533 Entry{ScalarEntry{
"BFLOWJ-",
2535 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2537 const unsigned index = !flowsC.blockFlows().empty() ?
2538 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2539 FaceDir::ToIntersectionIndex(Dir::YMinus), waterCompIdx) : ectx.globalDofIdx;
2540 return flowsC.getFlow(index, Dir::YMinus, waterCompIdx);
2544 Entry{ScalarEntry{
"BFLOWK",
2546 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2548 const unsigned index = !flowsC.blockFlows().empty() ?
2549 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2550 FaceDir::ToIntersectionIndex(Dir::ZPlus), waterCompIdx) : ectx.globalDofIdx;
2551 return flowsC.getFlow(index, Dir::ZPlus, waterCompIdx);
2555 Entry{ScalarEntry{
"BFLOWK-",
2557 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2559 const unsigned index = !flowsC.blockFlows().empty() ?
2560 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2561 FaceDir::ToIntersectionIndex(Dir::ZMinus), waterCompIdx) : ectx.globalDofIdx;
2562 return flowsC.getFlow(index, Dir::ZMinus, waterCompIdx);
2566 Entry{ScalarEntry{
"BVELGI",
2568 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2570 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2571 FaceDir::ToIntersectionIndex(Dir::XPlus), gasCompIdx);
2572 return flowsC.getVelocity(index, Dir::XPlus, gasCompIdx);
2576 Entry{ScalarEntry{
"BVELGI-",
2578 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2580 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2581 FaceDir::ToIntersectionIndex(Dir::XMinus), gasCompIdx);
2582 return flowsC.getVelocity(index, Dir::XMinus, gasCompIdx);
2586 Entry{ScalarEntry{
"BVELGJ",
2588 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2590 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2591 FaceDir::ToIntersectionIndex(Dir::YPlus), gasCompIdx);
2592 return flowsC.getVelocity(index, Dir::YPlus, gasCompIdx);
2596 Entry{ScalarEntry{
"BVELGJ-",
2598 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2600 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2601 FaceDir::ToIntersectionIndex(Dir::YMinus), gasCompIdx);
2602 return flowsC.getVelocity(index, Dir::YMinus, gasCompIdx);
2606 Entry{ScalarEntry{
"BVELGK",
2608 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2610 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2611 FaceDir::ToIntersectionIndex(Dir::ZPlus), gasCompIdx);
2612 return flowsC.getVelocity(index, Dir::ZPlus, gasCompIdx);
2616 Entry{ScalarEntry{
"BVELGK-",
2618 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2620 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2621 FaceDir::ToIntersectionIndex(Dir::ZMinus), gasCompIdx);
2622 return flowsC.getVelocity(index, Dir::ZMinus, gasCompIdx);
2626 Entry{ScalarEntry{
"BVELOI",
2628 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2630 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2631 FaceDir::ToIntersectionIndex(Dir::XPlus), oilCompIdx);
2632 return flowsC.getVelocity(index, Dir::XPlus, oilCompIdx);
2636 Entry{ScalarEntry{
"BVELOI-",
2638 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2640 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2641 FaceDir::ToIntersectionIndex(Dir::XMinus), oilCompIdx);
2642 return flowsC.getVelocity(index, Dir::XMinus, oilCompIdx);
2646 Entry{ScalarEntry{
"BVELOJ",
2648 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2650 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2651 FaceDir::ToIntersectionIndex(Dir::YPlus), oilCompIdx);
2652 return flowsC.getVelocity(index, Dir::YPlus, oilCompIdx);
2656 Entry{ScalarEntry{
"BVELOJ-",
2658 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2660 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2661 FaceDir::ToIntersectionIndex(Dir::YMinus), oilCompIdx);
2662 return flowsC.getVelocity(index, Dir::YMinus, oilCompIdx);
2666 Entry{ScalarEntry{
"BVELOK",
2668 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2670 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2671 FaceDir::ToIntersectionIndex(Dir::ZPlus), oilCompIdx);
2672 return flowsC.getVelocity(index, Dir::ZPlus, oilCompIdx);
2676 Entry{ScalarEntry{
"BVELOK-",
2678 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2680 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2681 FaceDir::ToIntersectionIndex(Dir::ZMinus), oilCompIdx);
2682 return flowsC.getVelocity(index, Dir::ZMinus, oilCompIdx);
2686 Entry{ScalarEntry{
"BVELWI",
2688 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2690 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2691 FaceDir::ToIntersectionIndex(Dir::XPlus), waterCompIdx);
2692 return flowsC.getVelocity(index, Dir::XPlus, waterCompIdx);
2696 Entry{ScalarEntry{
"BVELWI-",
2698 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2700 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2701 FaceDir::ToIntersectionIndex(Dir::XMinus), waterCompIdx);
2702 return flowsC.getVelocity(index, Dir::XMinus, waterCompIdx);
2706 Entry{ScalarEntry{
"BVELWJ",
2708 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2710 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2711 FaceDir::ToIntersectionIndex(Dir::YPlus), waterCompIdx);
2712 return flowsC.getVelocity(index, Dir::YPlus, waterCompIdx);
2716 Entry{ScalarEntry{
"BVELWJ-",
2718 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2720 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2721 FaceDir::ToIntersectionIndex(Dir::YMinus), waterCompIdx);
2722 return flowsC.getVelocity(index, Dir::YMinus, waterCompIdx);
2726 Entry{ScalarEntry{
"BVELWK",
2728 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2730 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2731 FaceDir::ToIntersectionIndex(Dir::ZPlus), waterCompIdx);
2732 return flowsC.getVelocity(index, Dir::ZPlus, waterCompIdx);
2736 Entry{ScalarEntry{
"BVELWK-",
2738 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2740 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2741 FaceDir::ToIntersectionIndex(Dir::ZMinus), waterCompIdx);
2742 return flowsC.getVelocity(index, Dir::ZMinus, waterCompIdx);
2746 Entry{ScalarEntry{
"BRPV",
2747 [&model = this->simulator_.model()](
const Context& ectx)
2749 return getValue(ectx.intQuants.porosity()) *
2750 model.dofTotalVolume(ectx.globalDofIdx);
2754 Entry{PhaseEntry{std::array{
"BWPV"sv,
"BOPV"sv,
"BGPV"sv},
2755 [&model = this->simulator_.model()](
const unsigned phaseIdx,
2756 const Context& ectx)
2758 return getValue(ectx.fs.saturation(phaseIdx)) *
2759 getValue(ectx.intQuants.porosity()) *
2760 model.dofTotalVolume(ectx.globalDofIdx);
2764 Entry{ScalarEntry{
"BRS",
2765 [](
const Context& ectx)
2767 return getValue(ectx.fs.Rs());
2771 Entry{ScalarEntry{
"BRV",
2772 [](
const Context& ectx)
2774 return getValue(ectx.fs.Rv());
2778 Entry{ScalarEntry{
"BOIP",
2779 [&model = this->simulator_.model()](
const Context& ectx)
2781 return (getValue(ectx.fs.invB(oilPhaseIdx)) *
2782 getValue(ectx.fs.saturation(oilPhaseIdx)) +
2783 getValue(ectx.fs.Rv()) *
2784 getValue(ectx.fs.invB(gasPhaseIdx)) *
2785 getValue(ectx.fs.saturation(gasPhaseIdx))) *
2786 model.dofTotalVolume(ectx.globalDofIdx) *
2787 getValue(ectx.intQuants.porosity());
2791 Entry{ScalarEntry{
"BGIP",
2792 [&model = this->simulator_.model()](
const Context& ectx)
2794 Scalar result = getValue(ectx.fs.invB(gasPhaseIdx)) *
2795 getValue(ectx.fs.saturation(gasPhaseIdx));
2797 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2798 result += getValue(ectx.fs.Rs()) *
2799 getValue(ectx.fs.invB(oilPhaseIdx)) *
2800 getValue(ectx.fs.saturation(oilPhaseIdx));
2803 result += getValue(ectx.fs.Rsw()) *
2804 getValue(ectx.fs.invB(waterPhaseIdx)) *
2805 getValue(ectx.fs.saturation(waterPhaseIdx));
2809 model.dofTotalVolume(ectx.globalDofIdx) *
2810 getValue(ectx.intQuants.porosity());
2814 Entry{ScalarEntry{
"BWIP",
2815 [&model = this->simulator_.model()](
const Context& ectx)
2817 return getValue(ectx.fs.invB(waterPhaseIdx)) *
2818 getValue(ectx.fs.saturation(waterPhaseIdx)) *
2819 model.dofTotalVolume(ectx.globalDofIdx) *
2820 getValue(ectx.intQuants.porosity());
2824 Entry{ScalarEntry{
"BOIPL",
2825 [&model = this->simulator_.model()](
const Context& ectx)
2827 return getValue(ectx.fs.invB(oilPhaseIdx)) *
2828 getValue(ectx.fs.saturation(oilPhaseIdx)) *
2829 model.dofTotalVolume(ectx.globalDofIdx) *
2830 getValue(ectx.intQuants.porosity());
2834 Entry{ScalarEntry{
"BGIPL",
2835 [&model = this->simulator_.model()](
const Context& ectx)
2838 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2839 result = getValue(ectx.fs.Rs()) *
2840 getValue(ectx.fs.invB(oilPhaseIdx)) *
2841 getValue(ectx.fs.saturation(oilPhaseIdx));
2844 result = getValue(ectx.fs.Rsw()) *
2845 getValue(ectx.fs.invB(waterPhaseIdx)) *
2846 getValue(ectx.fs.saturation(waterPhaseIdx));
2849 model.dofTotalVolume(ectx.globalDofIdx) *
2850 getValue(ectx.intQuants.porosity());
2854 Entry{ScalarEntry{
"BGIPG",
2855 [&model = this->simulator_.model()](
const Context& ectx)
2857 return getValue(ectx.fs.invB(gasPhaseIdx)) *
2858 getValue(ectx.fs.saturation(gasPhaseIdx)) *
2859 model.dofTotalVolume(ectx.globalDofIdx) *
2860 getValue(ectx.intQuants.porosity());
2864 Entry{ScalarEntry{
"BOIPG",
2865 [&model = this->simulator_.model()](
const Context& ectx)
2867 return getValue(ectx.fs.Rv()) *
2868 getValue(ectx.fs.invB(gasPhaseIdx)) *
2869 getValue(ectx.fs.saturation(gasPhaseIdx)) *
2870 model.dofTotalVolume(ectx.globalDofIdx) *
2871 getValue(ectx.intQuants.porosity());
2875 Entry{PhaseEntry{std::array{
"BPPW"sv,
"BPPO"sv,
"BPPG"sv},
2876 [&simConfig = this->
eclState_.getSimulationConfig(),
2877 &grav = this->simulator_.problem().gravity(),
2879 &problem = this->simulator_.problem(),
2880 ®ions = this->
regions_](
const unsigned phaseIdx,
const Context& ectx)
2883 phase.ix = phaseIdx;
2892 const auto datum = simConfig.datumDepths()(regions[
"FIPNUM"][ectx.dofIdx] - 1);
2895 const auto region = RegionPhasePoreVolAverage::Region {
2896 ectx.elemCtx.primaryVars(ectx.dofIdx, 0).pvtRegionIndex() + 1
2899 const auto density = regionAvgDensity->value(
"PVTNUM", phase, region);
2901 const auto press = getValue(ectx.fs.pressure(phase.ix));
2902 const auto dz = problem.dofCenterDepth(ectx.globalDofIdx) - datum;
2903 return press - density*dz*grav[GridView::dimensionworld - 1];
2907 Entry{ScalarEntry{
"BAMIP",
2908 [&model = this->simulator_.model()](
const Context& ectx)
2910 const Scalar rhoW = FluidSystem::referenceDensity(waterPhaseIdx,
2911 ectx.intQuants.pvtRegionIndex());
2912 return getValue(ectx.fs.invB(waterPhaseIdx)) *
2913 getValue(ectx.fs.saturation(waterPhaseIdx)) *
2915 model.dofTotalVolume(ectx.globalDofIdx) *
2916 getValue(ectx.intQuants.porosity());
2920 Entry{ScalarEntry{
"BMMIP",
2921 [&model = this->simulator_.model()](
const Context& ectx)
2923 if constexpr (enableBioeffects) {
2924 return getValue(ectx.intQuants.microbialConcentration()) *
2925 getValue(ectx.fs.saturation(waterPhaseIdx)) *
2926 getValue(ectx.intQuants.porosity()) *
2927 model.dofTotalVolume(ectx.globalDofIdx);
2935 Entry{ScalarEntry{
"BMOIP",
2936 [&model = this->simulator_.model()](
const Context& ectx)
2938 if constexpr (enableBioeffects) {
2939 return getValue(ectx.intQuants.oxygenConcentration()) *
2940 getValue(ectx.intQuants.porosity()) *
2941 model.dofTotalVolume(ectx.globalDofIdx);
2949 Entry{ScalarEntry{
"BMUIP",
2950 [&model = this->simulator_.model()](
const Context& ectx)
2952 if constexpr (enableBioeffects) {
2953 return getValue(ectx.intQuants.ureaConcentration()) *
2954 getValue(ectx.intQuants.porosity()) *
2955 model.dofTotalVolume(ectx.globalDofIdx);
2963 Entry{ScalarEntry{
"BMBIP",
2964 [&model = this->simulator_.model()](
const Context& ectx)
2966 if constexpr (enableBioeffects) {
2967 return model.dofTotalVolume(ectx.globalDofIdx) *
2968 getValue(ectx.intQuants.biofilmMass());
2976 Entry{ScalarEntry{
"BMCIP",
2977 [&model = this->simulator_.model()](
const Context& ectx)
2979 if constexpr (enableBioeffects) {
2980 return model.dofTotalVolume(ectx.globalDofIdx) *
2981 getValue(ectx.intQuants.calciteMass());
2989 Entry{ScalarEntry{
"BGMIP",
2990 [&model = this->simulator_.model()](
const Context& ectx)
2992 Scalar result = getValue(ectx.fs.invB(gasPhaseIdx)) *
2993 getValue(ectx.fs.saturation(gasPhaseIdx));
2995 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2996 result += getValue(ectx.fs.Rs()) *
2997 getValue(ectx.fs.invB(oilPhaseIdx)) *
2998 getValue(ectx.fs.saturation(oilPhaseIdx));
3001 result += getValue(ectx.fs.Rsw()) *
3002 getValue(ectx.fs.invB(waterPhaseIdx)) *
3003 getValue(ectx.fs.saturation(waterPhaseIdx));
3005 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
3006 ectx.intQuants.pvtRegionIndex());
3008 model.dofTotalVolume(ectx.globalDofIdx) *
3009 getValue(ectx.intQuants.porosity()) *
3014 Entry{ScalarEntry{
"BGMGP",
3015 [&model = this->simulator_.model()](
const Context& ectx)
3017 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
3018 ectx.intQuants.pvtRegionIndex());
3019 return getValue(ectx.fs.invB(gasPhaseIdx)) *
3020 getValue(ectx.fs.saturation(gasPhaseIdx)) *
3021 model.dofTotalVolume(ectx.globalDofIdx) *
3022 getValue(ectx.intQuants.porosity()) *
3027 Entry{ScalarEntry{
"BGMDS",
3028 [&model = this->simulator_.model()](
const Context& ectx)
3031 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
3032 result = getValue(ectx.fs.Rs()) *
3033 getValue(ectx.fs.invB(oilPhaseIdx)) *
3034 getValue(ectx.fs.saturation(oilPhaseIdx));
3037 result = getValue(ectx.fs.Rsw()) *
3038 getValue(ectx.fs.invB(waterPhaseIdx)) *
3039 getValue(ectx.fs.saturation(waterPhaseIdx));
3041 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
3042 ectx.intQuants.pvtRegionIndex());
3044 model.dofTotalVolume(ectx.globalDofIdx) *
3045 getValue(ectx.intQuants.porosity()) *
3050 Entry{ScalarEntry{
"BGMST",
3051 [&model = this->simulator_.model(),
3052 &problem = this->simulator_.problem()](
const Context& ectx)
3054 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3055 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3056 Scalar strandedGas = scaledDrainageInfo.Sgcr;
3057 if (problem.materialLawManager().enableHysteresis()) {
3058 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3059 const Scalar krg = getValue(ectx.intQuants.relativePermeability(gasPhaseIdx));
3060 strandedGas = MaterialLaw::strandedGasSaturation(matParams, sg, krg);
3062 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3063 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3064 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3065 return (1.0 - xgW) *
3066 model.dofTotalVolume(ectx.globalDofIdx) *
3067 getValue(ectx.intQuants.porosity()) *
3068 getValue(ectx.fs.density(gasPhaseIdx)) *
3069 std::min(strandedGas, sg);
3073 Entry{ScalarEntry{
"BGMUS",
3074 [&model = this->simulator_.model(),
3075 &problem = this->simulator_.problem()](
const Context& ectx)
3077 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3078 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3079 Scalar strandedGas = scaledDrainageInfo.Sgcr;
3080 if (problem.materialLawManager().enableHysteresis()) {
3081 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3082 const Scalar krg = getValue(ectx.intQuants.relativePermeability(gasPhaseIdx));
3083 strandedGas = MaterialLaw::strandedGasSaturation(matParams, sg, krg);
3085 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3086 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3087 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3088 return (1.0 - xgW) *
3089 model.dofTotalVolume(ectx.globalDofIdx) *
3090 getValue(ectx.intQuants.porosity()) *
3091 getValue(ectx.fs.density(gasPhaseIdx)) *
3092 std::max(Scalar{0.0}, sg - strandedGas);
3096 Entry{ScalarEntry{
"BGMTR",
3097 [&model = this->simulator_.model(),
3098 &problem = this->simulator_.problem()](
const Context& ectx)
3100 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3101 Scalar trappedGas = scaledDrainageInfo.Sgcr;
3102 if (problem.materialLawManager().enableHysteresis()) {
3103 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3104 trappedGas = MaterialLaw::trappedGasSaturation(matParams,
true);
3106 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3107 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3108 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3109 return (1.0 - xgW) *
3110 model.dofTotalVolume(ectx.globalDofIdx) *
3111 getValue(ectx.intQuants.porosity()) *
3112 getValue(ectx.fs.density(gasPhaseIdx)) *
3113 std::min(trappedGas, getValue(ectx.fs.saturation(gasPhaseIdx)));
3117 Entry{ScalarEntry{
"BGMMO",
3118 [&model = this->simulator_.model(),
3119 &problem = this->simulator_.problem()](
const Context& ectx)
3121 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3122 Scalar trappedGas = scaledDrainageInfo.Sgcr;
3123 if (problem.materialLawManager().enableHysteresis()) {
3124 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3125 trappedGas = MaterialLaw::trappedGasSaturation(matParams,
true);
3127 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3128 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3129 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3130 return (1.0 - xgW) *
3131 model.dofTotalVolume(ectx.globalDofIdx) *
3132 getValue(ectx.intQuants.porosity()) *
3133 getValue(ectx.fs.density(gasPhaseIdx)) *
3134 std::max(Scalar{0.0}, getValue(ectx.fs.saturation(gasPhaseIdx)) - trappedGas);
3138 Entry{ScalarEntry{
"BGKTR",
3139 [&model = this->simulator_.model(),
3140 &problem = this->simulator_.problem()](
const Context& ectx)
3142 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3143 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3144 Scalar sgcr = scaledDrainageInfo.Sgcr;
3145 if (problem.materialLawManager().enableHysteresis()) {
3146 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3147 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3153 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3154 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3155 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3156 return (1.0 - xgW) *
3157 model.dofTotalVolume(ectx.globalDofIdx) *
3158 getValue(ectx.intQuants.porosity()) *
3159 getValue(ectx.fs.density(gasPhaseIdx)) *
3160 getValue(ectx.fs.saturation(gasPhaseIdx));
3165 Entry{ScalarEntry{
"BGKMO",
3166 [&model = this->simulator_.model(),
3167 &problem = this->simulator_.problem()](
const Context& ectx)
3169 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3170 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3171 Scalar sgcr = scaledDrainageInfo.Sgcr;
3172 if (problem.materialLawManager().enableHysteresis()) {
3173 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3174 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3180 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3181 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3182 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3183 return (1.0 - xgW) *
3184 model.dofTotalVolume(ectx.globalDofIdx) *
3185 getValue(ectx.intQuants.porosity()) *
3186 getValue(ectx.fs.density(gasPhaseIdx)) *
3187 getValue(ectx.fs.saturation(gasPhaseIdx));
3192 Entry{ScalarEntry{
"BGCDI",
3193 [&model = this->simulator_.model(),
3194 &problem = this->simulator_.problem()](
const Context& ectx)
3196 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3197 Scalar sgcr = scaledDrainageInfo.Sgcr;
3198 if (problem.materialLawManager().enableHysteresis()) {
3199 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3200 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3202 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3203 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3204 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3205 return (1.0 - xgW) *
3206 model.dofTotalVolume(ectx.globalDofIdx) *
3207 getValue(ectx.intQuants.porosity()) *
3208 getValue(ectx.fs.density(gasPhaseIdx)) *
3209 std::min(sgcr, getValue(ectx.fs.saturation(gasPhaseIdx))) /
3210 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3214 Entry{ScalarEntry{
"BGCDM",
3215 [&model = this->simulator_.model(),
3216 &problem = this->simulator_.problem()](
const Context& ectx)
3218 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3219 Scalar sgcr = scaledDrainageInfo.Sgcr;
3220 if (problem.materialLawManager().enableHysteresis()) {
3221 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3222 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3224 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3225 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3226 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3227 return (1.0 - xgW) *
3228 model.dofTotalVolume(ectx.globalDofIdx) *
3229 getValue(ectx.intQuants.porosity()) *
3230 getValue(ectx.fs.density(gasPhaseIdx)) *
3231 std::max(Scalar{0.0}, getValue(ectx.fs.saturation(gasPhaseIdx)) - sgcr) /
3232 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3236 Entry{ScalarEntry{
"BGKDI",
3237 [&model = this->simulator_.model(),
3238 &problem = this->simulator_.problem()](
const Context& ectx)
3240 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3241 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3242 Scalar sgcr = scaledDrainageInfo.Sgcr;
3243 if (problem.materialLawManager().enableHysteresis()) {
3244 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3245 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3251 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3252 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3253 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3254 return (1.0 - xgW) *
3255 model.dofTotalVolume(ectx.globalDofIdx) *
3256 getValue(ectx.intQuants.porosity()) *
3257 getValue(ectx.fs.density(gasPhaseIdx)) *
3258 getValue(ectx.fs.saturation(gasPhaseIdx)) /
3259 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3264 Entry{ScalarEntry{
"BGKDM",
3265 [&model = this->simulator_.model(),
3266 &problem = this->simulator_.problem()](
const Context& ectx)
3268 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3269 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3270 Scalar sgcr = scaledDrainageInfo.Sgcr;
3271 if (problem.materialLawManager().enableHysteresis()) {
3272 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3273 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3279 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3280 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3281 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3282 return (1.0 - xgW) *
3283 model.dofTotalVolume(ectx.globalDofIdx) *
3284 getValue(ectx.intQuants.porosity()) *
3285 getValue(ectx.fs.density(gasPhaseIdx)) *
3286 getValue(ectx.fs.saturation(gasPhaseIdx)) /
3287 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3292 Entry{ScalarEntry{
"BWCD",
3293 [&model = this->simulator_.model()](
const Context& ectx)
3296 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
3297 result = getValue(ectx.fs.Rs()) *
3298 getValue(ectx.fs.invB(oilPhaseIdx)) *
3299 getValue(ectx.fs.saturation(oilPhaseIdx));
3302 result = getValue(ectx.fs.Rsw()) *
3303 getValue(ectx.fs.invB(waterPhaseIdx)) *
3304 getValue(ectx.fs.saturation(waterPhaseIdx));
3306 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
3307 ectx.intQuants.pvtRegionIndex());
3309 model.dofTotalVolume(ectx.globalDofIdx) *
3310 getValue(ectx.intQuants.porosity()) *
3312 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3316 Entry{ScalarEntry{
"BWIPG",
3317 [&model = this->simulator_.model()](
const Context& ectx)
3319 Scalar result = 0.0;
3320 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
3321 result = getValue(ectx.fs.Rvw()) *
3322 getValue(ectx.fs.invB(gasPhaseIdx)) *
3323 getValue(ectx.fs.saturation(gasPhaseIdx));
3326 model.dofTotalVolume(ectx.globalDofIdx) *
3327 getValue(ectx.intQuants.porosity());
3331 Entry{ScalarEntry{
"BWIPL",
3332 [&model = this->simulator_.model()](
const Context& ectx)
3334 return getValue(ectx.fs.invB(waterPhaseIdx)) *
3335 getValue(ectx.fs.saturation(waterPhaseIdx)) *
3336 model.dofTotalVolume(ectx.globalDofIdx) *
3337 getValue(ectx.intQuants.porosity());
3343 auto blockHandlers = std::span<const Entry>{handlers};
3344 auto mechHandlers = std::vector<Entry>{};
3345 if constexpr (getPropValue<TypeTag, Properties::EnableMech>()) {
3346 if (this->
mech_.allocated()) {
3347 mechHandlers.assign(handlers.begin(), handlers.end());
3348 mechHandlers.push_back(
3349 Entry{TensorEntry{
"BSTRSS",
3350 [&model = this->simulator_.problem().geoMechModel()]
3351 (
const VoigtIndex index,
const Context& ectx)
3353 return model.stress(ectx.globalDofIdx,
true)[index];
3357 blockHandlers = mechHandlers;
3366 this->lgrBlockExtractors_ =
3370 if (reportStepNum > 0 && !isSubStep) {
3372 const auto& rpt = this->
schedule_[reportStepNum - 1].rpt_config.get();
3373 if (rpt.contains(
"WELLS") && rpt.at(
"WELLS") > 1) {
3375 [&c = this->collectOnIORank_](
const int idx)
3376 {
return c.isCartIdxOnThisRank(idx); });
3378 const auto extraHandlers = std::array{
3387 const Simulator& simulator_;
3388 const CollectDataOnIORankType& collectOnIORank_;
3389 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:363
void initializeFluxData()
Prepare for capturing connection fluxes, particularly to account for inter-region flows.
Definition: OutputBlackoilModule.hpp:652
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:615
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:807
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:549
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:828
void assignToFluidState(FluidState &fs, unsigned elemIdx) const
Definition: OutputBlackoilModule.hpp:676
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:728
void updateFluidInPlace(const ElementContext &elemCtx)
Definition: OutputBlackoilModule.hpp:792
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:498
const InterRegFlowMap & getInterRegFlows() const
Get read-only access to collection of inter-region flows.
Definition: OutputBlackoilModule.hpp:670
void processElementBlockData(const ElementContext &elemCtx)
Definition: OutputBlackoilModule.hpp:410
void finalizeFluxData()
Finalize capturing connection fluxes.
Definition: OutputBlackoilModule.hpp:662
void updateFluidInPlace(const unsigned globalDofIdx, const IntensiveQuantities &intQuants, const double totVolume)
Definition: OutputBlackoilModule.hpp:799
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