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.swatinitMaxPc(ectx.globalDofIdx);
1586 [&problem = this->simulator_.problem()](
const Context& ectx)
1588 return problem.drsdtcon(ectx.globalDofIdx,
1593 Entry{ScalarEntry{&this->
pcgw_,
1594 [](
const Context& ectx)
1596 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
1597 getValue(ectx.fs.pressure(waterPhaseIdx));
1601 Entry{ScalarEntry{&this->
pcow_,
1602 [](
const Context& ectx)
1604 return getValue(ectx.fs.pressure(oilPhaseIdx)) -
1605 getValue(ectx.fs.pressure(waterPhaseIdx));
1609 Entry{ScalarEntry{&this->
pcog_,
1610 [](
const Context& ectx)
1612 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
1613 getValue(ectx.fs.pressure(oilPhaseIdx));
1618 [](
const Context& ectx)
1620 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1622 return getValue(ectx.fs.pressure(oilPhaseIdx));
1624 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1626 return getValue(ectx.fs.pressure(gasPhaseIdx));
1630 return getValue(ectx.fs.pressure(waterPhaseIdx));
1636 [&problem = this->simulator_.problem()](
const Context& ectx)
1638 const Scalar SoMax = problem.maxOilSaturation(ectx.globalDofIdx);
1639 return FluidSystem::template
1640 saturatedDissolutionFactor<FluidState, Scalar>(ectx.fs,
1648 [&problem = this->simulator_.problem()](
const Context& ectx)
1650 const Scalar SoMax = problem.maxOilSaturation(ectx.globalDofIdx);
1651 return FluidSystem::template
1652 saturatedDissolutionFactor<FluidState, Scalar>(ectx.fs,
1660 [&problem = this->simulator_.problem()](
const Context& ectx)
1662 const Scalar SwMax = problem.maxWaterSaturation(ectx.globalDofIdx);
1663 return FluidSystem::template
1664 saturatedDissolutionFactor<FluidState, Scalar>(ectx.fs,
1672 [](
const Context& ectx)
1674 return FluidSystem::template
1675 saturatedVaporizationFactor<FluidState, Scalar>(ectx.fs,
1682 [](
const Context& ectx)
1684 return 1.0 / FluidSystem::template
1685 inverseFormationVolumeFactor<FluidState, Scalar>(ectx.fs,
1692 [](
const Context& ectx)
1694 return 1.0 / FluidSystem::template
1695 saturatedInverseFormationVolumeFactor<FluidState, Scalar>(ectx.fs,
1702 [](
const Context& ectx)
1704 return FluidSystem::template
1705 saturationPressure<FluidState, Scalar>(ectx.fs,
1711 Entry{ScalarEntry{&this->
soMax_,
1712 [&problem = this->simulator_.problem()](
const Context& ectx)
1714 return std::max(getValue(ectx.fs.saturation(oilPhaseIdx)),
1715 problem.maxOilSaturation(ectx.globalDofIdx));
1718 !hysteresisConfig.enableHysteresis()
1720 Entry{ScalarEntry{&this->
swMax_,
1721 [&problem = this->simulator_.problem()](
const Context& ectx)
1723 return std::max(getValue(ectx.fs.saturation(waterPhaseIdx)),
1724 problem.maxWaterSaturation(ectx.globalDofIdx));
1727 !hysteresisConfig.enableHysteresis()
1729 Entry{ScalarEntry{&this->
soMax_,
1730 [](
const Context& ectx)
1731 {
return ectx.hParams.somax; }
1733 hysteresisConfig.enableHysteresis() &&
1734 hysteresisConfig.enableNonWettingHysteresis() &&
1735 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1736 FluidSystem::phaseIsActive(waterPhaseIdx)
1738 Entry{ScalarEntry{&this->
swMax_,
1739 [](
const Context& ectx)
1740 {
return ectx.hParams.swmax; }
1742 hysteresisConfig.enableHysteresis() &&
1743 hysteresisConfig.enableWettingHysteresis() &&
1744 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1745 FluidSystem::phaseIsActive(waterPhaseIdx)
1747 Entry{ScalarEntry{&this->
swmin_,
1748 [](
const Context& ectx)
1749 {
return ectx.hParams.swmin; }
1751 hysteresisConfig.enableHysteresis() &&
1752 hysteresisConfig.enablePCHysteresis() &&
1753 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1754 FluidSystem::phaseIsActive(waterPhaseIdx)
1756 Entry{ScalarEntry{&this->
sgmax_,
1757 [](
const Context& ectx)
1758 {
return ectx.hParams.sgmax; }
1760 hysteresisConfig.enableHysteresis() &&
1761 hysteresisConfig.enableNonWettingHysteresis() &&
1762 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1763 FluidSystem::phaseIsActive(gasPhaseIdx)
1765 Entry{ScalarEntry{&this->
shmax_,
1766 [](
const Context& ectx)
1767 {
return ectx.hParams.shmax; }
1769 hysteresisConfig.enableHysteresis() &&
1770 hysteresisConfig.enableWettingHysteresis() &&
1771 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1772 FluidSystem::phaseIsActive(gasPhaseIdx)
1774 Entry{ScalarEntry{&this->
somin_,
1775 [](
const Context& ectx)
1776 {
return ectx.hParams.somin; }
1778 hysteresisConfig.enableHysteresis() &&
1779 hysteresisConfig.enablePCHysteresis() &&
1780 FluidSystem::phaseIsActive(oilPhaseIdx) &&
1781 FluidSystem::phaseIsActive(gasPhaseIdx)
1783 Entry{[&model = this->simulator_.model(),
this](
const Context& ectx)
1787 const auto porv = ectx.intQuants.referencePorosity()
1788 * model.dofTotalVolume(ectx.globalDofIdx);
1790 this->aggregateAverageDensityContributions_(ectx.fs, ectx.globalDofIdx,
1791 static_cast<double>(porv));
1794 Entry{[&extboC = this->
extboC_](
const Context& ectx)
1797 if constexpr (enableExtbo) {
1798 extboC.assignVolumes(ectx.globalDofIdx,
1799 ectx.intQuants.xVolume().value(),
1800 ectx.intQuants.yVolume().value());
1801 extboC.assignZFraction(ectx.globalDofIdx,
1802 ectx.intQuants.zFraction().value());
1804 const Scalar stdVolOil = getValue(ectx.fs.saturation(oilPhaseIdx)) *
1805 getValue(ectx.fs.invB(oilPhaseIdx)) +
1806 getValue(ectx.fs.saturation(gasPhaseIdx)) *
1807 getValue(ectx.fs.invB(gasPhaseIdx)) *
1808 getValue(ectx.fs.Rv());
1809 const Scalar stdVolGas = getValue(ectx.fs.saturation(gasPhaseIdx)) *
1810 getValue(ectx.fs.invB(gasPhaseIdx)) *
1811 (1.0 - ectx.intQuants.yVolume().value()) +
1812 getValue(ectx.fs.saturation(oilPhaseIdx)) *
1813 getValue(ectx.fs.invB(oilPhaseIdx)) *
1814 getValue(ectx.fs.Rs()) *
1815 (1.0 - ectx.intQuants.xVolume().value());
1816 const Scalar stdVolCo2 = getValue(ectx.fs.saturation(gasPhaseIdx)) *
1817 getValue(ectx.fs.invB(gasPhaseIdx)) *
1818 ectx.intQuants.yVolume().value() +
1819 getValue(ectx.fs.saturation(oilPhaseIdx)) *
1820 getValue(ectx.fs.invB(oilPhaseIdx)) *
1821 getValue(ectx.fs.Rs()) *
1822 ectx.intQuants.xVolume().value();
1823 const Scalar rhoO = FluidSystem::referenceDensity(oilPhaseIdx, ectx.pvtRegionIdx);
1824 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx, ectx.pvtRegionIdx);
1825 const Scalar rhoCO2 = ectx.intQuants.zRefDensity();
1826 const Scalar stdMassTotal = 1.0e-10 + stdVolOil * rhoO + stdVolGas * rhoG + stdVolCo2 * rhoCO2;
1827 extboC.assignMassFractions(ectx.globalDofIdx,
1828 stdVolGas * rhoG / stdMassTotal,
1829 stdVolOil * rhoO / stdMassTotal,
1830 stdVolCo2 * rhoCO2 / stdMassTotal);
1832 if (extboC.phaseMassFractionsRequested()) {
1833 const auto [oil, gas] = extboC.phaseSolventMassFractions({
1834 .oilSaturation = getValue(ectx.fs.saturation(oilPhaseIdx)),
1835 .gasSaturation = getValue(ectx.fs.saturation(gasPhaseIdx)),
1836 .rs = getValue(ectx.fs.Rs()),
1837 .rv = getValue(ectx.fs.Rv()),
1838 .xVolume = ectx.intQuants.xVolume().value(),
1839 .yVolume = ectx.intQuants.yVolume().value(),
1842 .solventDensity = rhoCO2,
1844 extboC.assignPhaseMassFractions(ectx.globalDofIdx, oil, gas);
1849 Entry{[&bioeffectsC = this->
bioeffectsC_](
const Context& ectx)
1852 if constexpr (enableBioeffects) {
1853 bioeffectsC.assign(ectx.globalDofIdx,
1854 ectx.intQuants.microbialConcentration().value(),
1855 ectx.intQuants.biofilmVolumeFraction().value());
1856 if (Indices::enableMICP) {
1857 bioeffectsC.assign(ectx.globalDofIdx,
1858 ectx.intQuants.oxygenConcentration().value(),
1859 ectx.intQuants.ureaConcentration().value(),
1860 ectx.intQuants.calciteVolumeFraction().value());
1865 Entry{[&runspec = this->
eclState_.runspec(),
1866 &CO2H2C = this->
CO2H2C_](
const Context& ectx)
1868 const auto xwg = FluidSystem::convertRswToXwG(getValue(ectx.fs.Rsw()), ectx.pvtRegionIdx);
1869 const auto xgw = FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.pvtRegionIdx);
1870 CO2H2C.assign(ectx.globalDofIdx,
1871 FluidSystem::convertXwGToxwG(xwg, ectx.pvtRegionIdx),
1872 FluidSystem::convertXgWToxgW(xgw, ectx.pvtRegionIdx),
1873 runspec.co2Storage());
1876 Entry{[&rftC = this->
rftC_,
1877 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1879 const auto cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1880 rftC.assign(cartesianIdx,
1885 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1886 return getValue(fs.pressure(oilPhaseIdx));
1888 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1889 return getValue(fs.pressure(gasPhaseIdx));
1892 return getValue(fs.pressure(waterPhaseIdx));
1895 [&fs = ectx.fs]() {
return getValue(fs.saturation(waterPhaseIdx)); },
1896 [&fs = ectx.fs]() {
return getValue(fs.saturation(gasPhaseIdx)); });
1900 &tM = this->simulator_.problem().tracerModel()](
const Context& ectx)
1902 tC.assignFreeConcentrations(ectx.globalDofIdx,
1903 [gIdx = ectx.globalDofIdx, &tM](
const unsigned tracerIdx)
1904 {
return tM.freeTracerConcentration(tracerIdx, gIdx); });
1905 tC.assignSolConcentrations(ectx.globalDofIdx,
1906 [gIdx = ectx.globalDofIdx, &tM](
const unsigned tracerIdx)
1907 {
return tM.solTracerConcentration(tracerIdx, gIdx); });
1910 Entry{[&flowsInf = this->simulator_.problem().model().linearizer().getFlowsInfo(),
1912 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1914 const auto gas_idx = Indices::gasEnabled ?
1915 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(gasCompIdx) : -1;
1916 const auto oil_idx = Indices::oilEnabled ?
1917 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(oilCompIdx) : -1;
1918 const auto water_idx = Indices::waterEnabled ?
1919 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(waterCompIdx) : -1;
1920 const auto& flowsInfos = flowsInf[ectx.globalDofIdx];
1921 if (!flowsC.blockFlows().empty()) {
1922 const std::vector<int>& blockIdxs = flowsC.blockFlows();
1923 const unsigned cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1924 if (std::ranges::binary_search(blockIdxs, cartesianIdx)) {
1925 const auto compIdxs = std::array{ gasCompIdx, oilCompIdx, waterCompIdx };
1926 const auto compEnabled = std::array{ Indices::gasEnabled, Indices::oilEnabled, Indices::waterEnabled };
1927 for (
const auto& flowsInfo : flowsInfos) {
1928 if (flowsInfo.faceId < 0) {
1931 for (
unsigned ii = 0; ii < compIdxs.size(); ++ii) {
1932 if (!compEnabled[ii]) {
1935 if (flowsC.hasBlockFlowValue(cartesianIdx, flowsInfo.faceId, compIdxs[ii])) {
1936 flowsC.assignBlockFlows(flowsC.blockFlowsIds(cartesianIdx, flowsInfo.faceId, compIdxs[ii]),
1939 flowsInfo.flow[conti0EqIdx
1940 + FluidSystem::canonicalToActiveCompIdx(compIdxs[ii])]);
1947 for (
const auto& flowsInfo : flowsInfos) {
1948 flowsC.assignFlows(ectx.globalDofIdx,
1951 value_or_zero(gas_idx, flowsInfo.flow),
1952 value_or_zero(oil_idx, flowsInfo.flow),
1953 value_or_zero(water_idx, flowsInfo.flow));
1956 }, !this->simulator_.problem().model().linearizer().getFlowsInfo().empty()
1958 Entry{[&floresInf = this->simulator_.problem().model().linearizer().getFloresInfo(),
1959 &flowsC = this->
flowsC_](
const Context& ectx)
1961 const auto gas_idx = Indices::gasEnabled ?
1962 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(gasCompIdx) : -1;
1963 const auto oil_idx = Indices::oilEnabled ?
1964 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(oilCompIdx) : -1;
1965 const auto water_idx = Indices::waterEnabled ?
1966 conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(waterCompIdx) : -1;
1967 const auto& floresInfos = floresInf[ectx.globalDofIdx];
1968 for (
const auto& floresInfo : floresInfos) {
1969 flowsC.assignFlores(ectx.globalDofIdx,
1972 value_or_zero(gas_idx, floresInfo.flow),
1973 value_or_zero(oil_idx, floresInfo.flow),
1974 value_or_zero(water_idx, floresInfo.flow));
1976 }, !this->simulator_.problem().model().linearizer().getFloresInfo().empty()
1978 Entry{[&velocityInf = this->simulator_.problem().model().linearizer().getVelocityInfo(),
1980 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
1982 const auto& velocityInfos = velocityInf[ectx.globalDofIdx];
1983 const std::vector<int>& blockIdxs = flowsC.blockVelocity();
1984 const unsigned cartesianIdx = vanguard.cartesianIndex(ectx.globalDofIdx);
1985 if (std::ranges::binary_search(blockIdxs, cartesianIdx)) {
1986 const auto compIdxs = std::array{ gasCompIdx, oilCompIdx, waterCompIdx };
1987 const auto compEnabled = std::array{ Indices::gasEnabled, Indices::oilEnabled, Indices::waterEnabled };
1988 for (
const auto& velocityInfo : velocityInfos) {
1989 if (velocityInfo.faceId < 0) {
1992 for (
unsigned ii = 0; ii < compIdxs.size(); ++ii) {
1993 if (!compEnabled[ii]) {
1996 if (flowsC.hasBlockVelocityValue(cartesianIdx, velocityInfo.faceId, compIdxs[ii])) {
1997 flowsC.assignBlockVelocity(flowsC.blockVelocityIds(cartesianIdx, velocityInfo.faceId, compIdxs[ii]),
1998 velocityInfo.faceId,
2000 velocityInfo.velocity[conti0EqIdx
2001 + FluidSystem::canonicalToActiveCompIdx(compIdxs[ii])]);
2007 !this->simulator_.problem().model().linearizer().getVelocityInfo().empty()
2014 Entry{ScalarEntry{&this->rv_,
2015 [&problem = this->simulator_.problem()](
const Context& ectx)
2016 {
return problem.initialFluidState(ectx.globalDofIdx).Rv(); }
2018 simulator_.episodeIndex() < 0 &&
2019 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2020 FluidSystem::phaseIsActive(gasPhaseIdx)
2022 Entry{ScalarEntry{&this->rs_,
2023 [&problem = this->simulator_.problem()](
const Context& ectx)
2024 {
return problem.initialFluidState(ectx.globalDofIdx).Rs(); }
2026 simulator_.episodeIndex() < 0 &&
2027 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2028 FluidSystem::phaseIsActive(gasPhaseIdx)
2030 Entry{ScalarEntry{&this->
rsw_,
2031 [&problem = this->simulator_.problem()](
const Context& ectx)
2032 {
return problem.initialFluidState(ectx.globalDofIdx).Rsw(); }
2034 simulator_.episodeIndex() < 0 &&
2035 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2036 FluidSystem::phaseIsActive(gasPhaseIdx)
2038 Entry{ScalarEntry{&this->
rvw_,
2039 [&problem = this->simulator_.problem()](
const Context& ectx)
2040 {
return problem.initialFluidState(ectx.globalDofIdx).Rvw(); }
2042 simulator_.episodeIndex() < 0 &&
2043 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2044 FluidSystem::phaseIsActive(gasPhaseIdx)
2048 [&problem = this->simulator_.problem()](
const unsigned phase,
2049 const Context& ectx)
2051 const auto& fsInitial = problem.initialFluidState(ectx.globalDofIdx);
2052 return FluidSystem::density(fsInitial,
2054 ectx.intQuants.pvtRegionIndex());
2057 simulator_.episodeIndex() < 0 &&
2058 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2059 FluidSystem::phaseIsActive(gasPhaseIdx)
2061 Entry{PhaseEntry{&this->formationVolFactor_,
2062 [&problem = this->simulator_.problem()]
2063 (
const unsigned phase,
const Context& ectx)
2065 constexpr auto zero = Scalar{};
2067 const auto& fsInitial = problem.initialFluidState(ectx.globalDofIdx);
2069 const auto recipFVF = getValue
2070 (FluidSystem::inverseFormationVolumeFactor
2071 (fsInitial, phase, ectx.intQuants.pvtRegionIndex()));
2073 return (recipFVF > zero)
2074 ?
static_cast<Scalar
>(1) / recipFVF
2078 simulator_.episodeIndex() < 0 &&
2079 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2080 FluidSystem::phaseIsActive(gasPhaseIdx)
2082 Entry{PhaseEntry{&this->invB_,
2083 [&problem = this->simulator_.problem()](
const unsigned phase,
2084 const Context& ectx)
2086 const auto& fsInitial = problem.initialFluidState(ectx.globalDofIdx);
2087 return FluidSystem::inverseFormationVolumeFactor(fsInitial,
2089 ectx.intQuants.pvtRegionIndex());
2092 simulator_.episodeIndex() < 0 &&
2093 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2094 FluidSystem::phaseIsActive(gasPhaseIdx)
2097 [&problem = this->simulator_.problem()](
const unsigned phase,
2098 const Context& ectx)
2100 const auto& fsInitial = problem.initialFluidState(ectx.globalDofIdx);
2101 return FluidSystem::viscosity(fsInitial,
2103 ectx.intQuants.pvtRegionIndex());
2106 simulator_.episodeIndex() < 0 &&
2107 FluidSystem::phaseIsActive(oilPhaseIdx) &&
2108 FluidSystem::phaseIsActive(gasPhaseIdx)
2116 if constexpr (getPropValue<TypeTag, Properties::EnableGeochemistry>()) {
2118 this->extractors_.emplace_back(
2120 &gM = this->simulator_.problem().geochemistryModel()](
const Context& ectx)
2122 gC.assignSpeciesConcentrations(
2124 [gIdx = ectx.globalDofIdx, &gM](
const unsigned speciesIdx)
2125 {
return gM.speciesConcentration(speciesIdx, gIdx); }
2127 gC.assignMineralConcentrations(
2129 [gIdx = ectx.globalDofIdx, &gM](
const unsigned mineralIdx)
2130 {
return gM.mineralConcentration(mineralIdx, gIdx); }
2132 gC.assignPH(ectx.globalDofIdx, gM.PH(ectx.globalDofIdx));
2140 if constexpr (getPropValue<TypeTag, Properties::EnableMech>()) {
2141 if (this->
mech_.allocated()) {
2142 this->extractors_.emplace_back(
2143 [&mech = this->
mech_,
2144 &model = simulator_.problem().geoMechModel()](
const Context& ectx)
2146 mech.assignDelStress(ectx.globalDofIdx,
2147 model.delstress(ectx.globalDofIdx));
2149 mech.assignDisplacement(ectx.globalDofIdx,
2150 model.disp(ectx.globalDofIdx,
true));
2153 mech.assignFracStress(ectx.globalDofIdx,
2154 model.fractureStress(ectx.globalDofIdx));
2156 mech.assignLinStress(ectx.globalDofIdx,
2157 model.linstress(ectx.globalDofIdx));
2159 mech.assignPotentialForces(ectx.globalDofIdx,
2160 model.mechPotentialForce(ectx.globalDofIdx),
2161 model.mechPotentialPressForce(ectx.globalDofIdx),
2162 model.mechPotentialTempForce(ectx.globalDofIdx));
2164 mech.assignStrain(ectx.globalDofIdx,
2165 model.strain(ectx.globalDofIdx,
true));
2168 mech.assignStress(ectx.globalDofIdx,
2169 model.stress(ectx.globalDofIdx,
true));
2172 if (mech.enableTraction()) {
2173 mech.assignTraction(ectx.globalDofIdx,
2174 model.traction(ectx.globalDofIdx));
2180 if (this->
tpsaC_.allocated()) {
2181 this->extractors_.emplace_back(
2183 &model = simulator_.problem().geoMechModel()](
const Context& ectx) {
2184 tpsaC.assignRotation(ectx.globalDofIdx,
2185 model.rotation(ectx.globalDofIdx));
2187 tpsaC.assignSolidPressure(ectx.globalDofIdx,
2188 model.solidPressure(ectx.globalDofIdx));
2197 void setupBlockExtractors_(
const bool isSubStep,
2198 const int reportStepNum)
2201 using Context =
typename BlockExtractor::Context;
2202 using PhaseEntry =
typename BlockExtractor::PhaseEntry;
2203 using ScalarEntry =
typename BlockExtractor::ScalarEntry;
2204 using TensorEntry =
typename BlockExtractor::TensorEntry;
2206 using namespace std::string_view_literals;
2208 const auto pressure_handler =
2209 Entry{ScalarEntry{std::vector{
"BPR"sv,
"BPRESSUR"sv},
2210 [](
const Context& ectx)
2212 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2213 return getValue(ectx.fs.pressure(oilPhaseIdx));
2215 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
2216 return getValue(ectx.fs.pressure(gasPhaseIdx));
2219 return getValue(ectx.fs.pressure(waterPhaseIdx));
2225 const auto handlers = std::array{
2227 Entry{PhaseEntry{std::array{
2228 std::array{
"BWSAT"sv,
"BOSAT"sv,
"BGSAT"sv},
2229 std::array{
"BSWAT"sv,
"BSOIL"sv,
"BSGAS"sv}
2231 [](
const unsigned phaseIdx,
const Context& ectx)
2233 return getValue(ectx.fs.saturation(phaseIdx));
2237 Entry{ScalarEntry{
"BNSAT",
2238 [](
const Context& ectx)
2240 if constexpr (enableSolvent) {
2241 return ectx.intQuants.solventSaturation().value();
2249 Entry{ScalarEntry{std::vector{
"BTCNFHEA"sv,
"BTEMP"sv},
2250 [](
const Context& ectx)
2252 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2253 return getValue(ectx.fs.temperature(oilPhaseIdx));
2255 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
2256 return getValue(ectx.fs.temperature(gasPhaseIdx));
2259 return getValue(ectx.fs.temperature(waterPhaseIdx));
2264 Entry{PhaseEntry{std::array{
2265 std::array{
"BWKR"sv,
"BOKR"sv,
"BGKR"sv},
2266 std::array{
"BKRW"sv,
"BKRO"sv,
"BKRG"sv}
2268 [](
const unsigned phaseIdx,
const Context& ectx)
2270 return getValue(ectx.intQuants.relativePermeability(phaseIdx));
2274 Entry{ScalarEntry{
"BKROG",
2275 [&problem = this->simulator_.problem()](
const Context& ectx)
2277 const auto& materialParams =
2278 problem.materialLawParams(ectx.elemCtx,
2281 return getValue(MaterialLaw::template
2282 relpermOilInOilGasSystem<Evaluation>(materialParams,
2287 Entry{ScalarEntry{
"BKROW",
2288 [&problem = this->simulator_.problem()](
const Context& ectx)
2290 const auto& materialParams = problem.materialLawParams(ectx.elemCtx,
2293 return getValue(MaterialLaw::template
2294 relpermOilInOilWaterSystem<Evaluation>(materialParams,
2299 Entry{ScalarEntry{
"BWPC",
2300 [](
const Context& ectx)
2302 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2303 return getValue(ectx.fs.pressure(oilPhaseIdx)) -
2304 getValue(ectx.fs.pressure(waterPhaseIdx));
2306 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
2307 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
2308 getValue(ectx.fs.pressure(waterPhaseIdx));
2316 Entry{ScalarEntry{
"BGPC",
2317 [](
const Context& ectx)
2319 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2320 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
2321 getValue(ectx.fs.pressure(oilPhaseIdx));
2323 else if (FluidSystem::phaseIsActive(waterPhaseIdx)) {
2324 return getValue(ectx.fs.pressure(gasPhaseIdx)) -
2325 getValue(ectx.fs.pressure(waterPhaseIdx));
2333 Entry{ScalarEntry{
"BWPR",
2334 [](
const Context& ectx)
2336 return getValue(ectx.fs.pressure(waterPhaseIdx));
2340 Entry{ScalarEntry{
"BGPR",
2341 [](
const Context& ectx)
2343 return getValue(ectx.fs.pressure(gasPhaseIdx));
2347 Entry{PhaseEntry{std::array{
2348 std::array{
"BVWAT"sv,
"BVOIL"sv,
"BVGAS"sv},
2349 std::array{
"BWVIS"sv,
"BOVIS"sv,
"BGVIS"sv}
2351 [](
const unsigned phaseIdx,
const Context& ectx)
2353 return getValue(ectx.fs.viscosity(phaseIdx));
2357 Entry{PhaseEntry{std::array{
2358 std::array{
"BWDEN"sv,
"BODEN"sv,
"BGDEN"sv},
2359 std::array{
"BDENW"sv,
"BDENO"sv,
"BDENG"sv}
2361 [](
const unsigned phaseIdx,
const Context& ectx)
2363 return getValue(ectx.fs.density(phaseIdx));
2367 Entry{ScalarEntry{
"BFLOGI",
2369 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2371 const unsigned index = !flowsC.blockFlows().empty() ?
2372 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2373 FaceDir::ToIntersectionIndex(Dir::XPlus), gasCompIdx) : ectx.globalDofIdx;
2374 return flowsC.getFlow(index, Dir::XPlus, gasCompIdx);
2378 Entry{ScalarEntry{
"BFLOGI-",
2380 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2382 const unsigned index = !flowsC.blockFlows().empty() ?
2383 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2384 FaceDir::ToIntersectionIndex(Dir::XMinus), gasCompIdx) : ectx.globalDofIdx;
2385 return flowsC.getFlow(index, Dir::XMinus, gasCompIdx);
2389 Entry{ScalarEntry{
"BFLOGJ",
2391 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2393 const unsigned index = !flowsC.blockFlows().empty() ?
2394 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2395 FaceDir::ToIntersectionIndex(Dir::YPlus), gasCompIdx) : ectx.globalDofIdx;
2396 return flowsC.getFlow(index, Dir::YPlus, gasCompIdx);
2400 Entry{ScalarEntry{
"BFLOGJ-",
2402 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2404 const unsigned index = !flowsC.blockFlows().empty() ?
2405 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2406 FaceDir::ToIntersectionIndex(Dir::YMinus), gasCompIdx) : ectx.globalDofIdx;
2407 return flowsC.getFlow(index, Dir::YMinus, gasCompIdx);
2411 Entry{ScalarEntry{
"BFLOGK",
2413 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2415 const unsigned index = !flowsC.blockFlows().empty() ?
2416 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2417 FaceDir::ToIntersectionIndex(Dir::ZPlus), gasCompIdx) : ectx.globalDofIdx;
2418 return flowsC.getFlow(index, Dir::ZPlus, gasCompIdx);
2422 Entry{ScalarEntry{
"BFLOGK-",
2424 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2426 const unsigned index = !flowsC.blockFlows().empty() ?
2427 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2428 FaceDir::ToIntersectionIndex(Dir::ZMinus), gasCompIdx) : ectx.globalDofIdx;
2429 return flowsC.getFlow(index, Dir::ZMinus, gasCompIdx);
2433 Entry{ScalarEntry{
"BFLOOI",
2435 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2437 const unsigned index = !flowsC.blockFlows().empty() ?
2438 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2439 FaceDir::ToIntersectionIndex(Dir::XPlus), oilCompIdx) : ectx.globalDofIdx;
2440 return flowsC.getFlow(index, Dir::XPlus, oilCompIdx);
2444 Entry{ScalarEntry{
"BFLOOI-",
2446 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2448 const unsigned index = !flowsC.blockFlows().empty() ?
2449 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2450 FaceDir::ToIntersectionIndex(Dir::XMinus), oilCompIdx) : ectx.globalDofIdx;
2451 return flowsC.getFlow(index, Dir::XMinus, oilCompIdx);
2455 Entry{ScalarEntry{
"BFLOOJ",
2457 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2459 const unsigned index = !flowsC.blockFlows().empty() ?
2460 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2461 FaceDir::ToIntersectionIndex(Dir::YPlus), oilCompIdx) : ectx.globalDofIdx;
2462 return flowsC.getFlow(index, Dir::YPlus, oilCompIdx);
2466 Entry{ScalarEntry{
"BFLOOJ-",
2468 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2470 const unsigned index = !flowsC.blockFlows().empty() ?
2471 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2472 FaceDir::ToIntersectionIndex(Dir::YMinus), oilCompIdx) : ectx.globalDofIdx;
2473 return flowsC.getFlow(index, Dir::YMinus, oilCompIdx);
2477 Entry{ScalarEntry{
"BFLOOK",
2479 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2481 const unsigned index = !flowsC.blockFlows().empty() ?
2482 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2483 FaceDir::ToIntersectionIndex(Dir::ZPlus), oilCompIdx) : ectx.globalDofIdx;
2484 return flowsC.getFlow(index, Dir::ZPlus, oilCompIdx);
2488 Entry{ScalarEntry{
"BFLOOK-",
2490 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2492 const unsigned index = !flowsC.blockFlows().empty() ?
2493 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2494 FaceDir::ToIntersectionIndex(Dir::ZMinus), oilCompIdx) : ectx.globalDofIdx;
2495 return flowsC.getFlow(index, Dir::ZMinus, oilCompIdx);
2499 Entry{ScalarEntry{
"BFLOWI",
2501 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2503 const unsigned index = !flowsC.blockFlows().empty() ?
2504 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2505 FaceDir::ToIntersectionIndex(Dir::XPlus), waterCompIdx) : ectx.globalDofIdx;
2506 return flowsC.getFlow(index, Dir::XPlus, waterCompIdx);
2510 Entry{ScalarEntry{
"BFLOWI-",
2512 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2514 const unsigned index = !flowsC.blockFlows().empty() ?
2515 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2516 FaceDir::ToIntersectionIndex(Dir::XMinus), waterCompIdx) : ectx.globalDofIdx;
2517 return flowsC.getFlow(index, Dir::XMinus, waterCompIdx);
2521 Entry{ScalarEntry{
"BFLOWJ",
2523 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2525 const unsigned index = !flowsC.blockFlows().empty() ?
2526 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2527 FaceDir::ToIntersectionIndex(Dir::YPlus), waterCompIdx) : ectx.globalDofIdx;
2528 return flowsC.getFlow(index, Dir::YPlus, waterCompIdx);
2532 Entry{ScalarEntry{
"BFLOWJ-",
2534 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2536 const unsigned index = !flowsC.blockFlows().empty() ?
2537 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2538 FaceDir::ToIntersectionIndex(Dir::YMinus), waterCompIdx) : ectx.globalDofIdx;
2539 return flowsC.getFlow(index, Dir::YMinus, waterCompIdx);
2543 Entry{ScalarEntry{
"BFLOWK",
2545 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2547 const unsigned index = !flowsC.blockFlows().empty() ?
2548 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2549 FaceDir::ToIntersectionIndex(Dir::ZPlus), waterCompIdx) : ectx.globalDofIdx;
2550 return flowsC.getFlow(index, Dir::ZPlus, waterCompIdx);
2554 Entry{ScalarEntry{
"BFLOWK-",
2556 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2558 const unsigned index = !flowsC.blockFlows().empty() ?
2559 flowsC.blockFlowsIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2560 FaceDir::ToIntersectionIndex(Dir::ZMinus), waterCompIdx) : ectx.globalDofIdx;
2561 return flowsC.getFlow(index, Dir::ZMinus, waterCompIdx);
2565 Entry{ScalarEntry{
"BVELGI",
2567 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2569 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2570 FaceDir::ToIntersectionIndex(Dir::XPlus), gasCompIdx);
2571 return flowsC.getVelocity(index, Dir::XPlus, gasCompIdx);
2575 Entry{ScalarEntry{
"BVELGI-",
2577 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2579 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2580 FaceDir::ToIntersectionIndex(Dir::XMinus), gasCompIdx);
2581 return flowsC.getVelocity(index, Dir::XMinus, gasCompIdx);
2585 Entry{ScalarEntry{
"BVELGJ",
2587 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2589 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2590 FaceDir::ToIntersectionIndex(Dir::YPlus), gasCompIdx);
2591 return flowsC.getVelocity(index, Dir::YPlus, gasCompIdx);
2595 Entry{ScalarEntry{
"BVELGJ-",
2597 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2599 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2600 FaceDir::ToIntersectionIndex(Dir::YMinus), gasCompIdx);
2601 return flowsC.getVelocity(index, Dir::YMinus, gasCompIdx);
2605 Entry{ScalarEntry{
"BVELGK",
2607 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2609 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2610 FaceDir::ToIntersectionIndex(Dir::ZPlus), gasCompIdx);
2611 return flowsC.getVelocity(index, Dir::ZPlus, gasCompIdx);
2615 Entry{ScalarEntry{
"BVELGK-",
2617 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2619 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2620 FaceDir::ToIntersectionIndex(Dir::ZMinus), gasCompIdx);
2621 return flowsC.getVelocity(index, Dir::ZMinus, gasCompIdx);
2625 Entry{ScalarEntry{
"BVELOI",
2627 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2629 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2630 FaceDir::ToIntersectionIndex(Dir::XPlus), oilCompIdx);
2631 return flowsC.getVelocity(index, Dir::XPlus, oilCompIdx);
2635 Entry{ScalarEntry{
"BVELOI-",
2637 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2639 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2640 FaceDir::ToIntersectionIndex(Dir::XMinus), oilCompIdx);
2641 return flowsC.getVelocity(index, Dir::XMinus, oilCompIdx);
2645 Entry{ScalarEntry{
"BVELOJ",
2647 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2649 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2650 FaceDir::ToIntersectionIndex(Dir::YPlus), oilCompIdx);
2651 return flowsC.getVelocity(index, Dir::YPlus, oilCompIdx);
2655 Entry{ScalarEntry{
"BVELOJ-",
2657 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2659 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2660 FaceDir::ToIntersectionIndex(Dir::YMinus), oilCompIdx);
2661 return flowsC.getVelocity(index, Dir::YMinus, oilCompIdx);
2665 Entry{ScalarEntry{
"BVELOK",
2667 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2669 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2670 FaceDir::ToIntersectionIndex(Dir::ZPlus), oilCompIdx);
2671 return flowsC.getVelocity(index, Dir::ZPlus, oilCompIdx);
2675 Entry{ScalarEntry{
"BVELOK-",
2677 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2679 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2680 FaceDir::ToIntersectionIndex(Dir::ZMinus), oilCompIdx);
2681 return flowsC.getVelocity(index, Dir::ZMinus, oilCompIdx);
2685 Entry{ScalarEntry{
"BVELWI",
2687 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2689 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2690 FaceDir::ToIntersectionIndex(Dir::XPlus), waterCompIdx);
2691 return flowsC.getVelocity(index, Dir::XPlus, waterCompIdx);
2695 Entry{ScalarEntry{
"BVELWI-",
2697 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2699 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2700 FaceDir::ToIntersectionIndex(Dir::XMinus), waterCompIdx);
2701 return flowsC.getVelocity(index, Dir::XMinus, waterCompIdx);
2705 Entry{ScalarEntry{
"BVELWJ",
2707 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2709 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2710 FaceDir::ToIntersectionIndex(Dir::YPlus), waterCompIdx);
2711 return flowsC.getVelocity(index, Dir::YPlus, waterCompIdx);
2715 Entry{ScalarEntry{
"BVELWJ-",
2717 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2719 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2720 FaceDir::ToIntersectionIndex(Dir::YMinus), waterCompIdx);
2721 return flowsC.getVelocity(index, Dir::YMinus, waterCompIdx);
2725 Entry{ScalarEntry{
"BVELWK",
2727 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2729 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2730 FaceDir::ToIntersectionIndex(Dir::ZPlus), waterCompIdx);
2731 return flowsC.getVelocity(index, Dir::ZPlus, waterCompIdx);
2735 Entry{ScalarEntry{
"BVELWK-",
2737 &vanguard = this->simulator_.vanguard()](
const Context& ectx)
2739 const unsigned index = flowsC.blockVelocityIds(vanguard.cartesianIndex(ectx.globalDofIdx),
2740 FaceDir::ToIntersectionIndex(Dir::ZMinus), waterCompIdx);
2741 return flowsC.getVelocity(index, Dir::ZMinus, waterCompIdx);
2745 Entry{ScalarEntry{
"BRPV",
2746 [&model = this->simulator_.model()](
const Context& ectx)
2748 return getValue(ectx.intQuants.porosity()) *
2749 model.dofTotalVolume(ectx.globalDofIdx);
2753 Entry{PhaseEntry{std::array{
"BWPV"sv,
"BOPV"sv,
"BGPV"sv},
2754 [&model = this->simulator_.model()](
const unsigned phaseIdx,
2755 const Context& ectx)
2757 return getValue(ectx.fs.saturation(phaseIdx)) *
2758 getValue(ectx.intQuants.porosity()) *
2759 model.dofTotalVolume(ectx.globalDofIdx);
2763 Entry{ScalarEntry{
"BRS",
2764 [](
const Context& ectx)
2766 return getValue(ectx.fs.Rs());
2770 Entry{ScalarEntry{
"BRV",
2771 [](
const Context& ectx)
2773 return getValue(ectx.fs.Rv());
2777 Entry{ScalarEntry{
"BOIP",
2778 [&model = this->simulator_.model()](
const Context& ectx)
2780 return (getValue(ectx.fs.invB(oilPhaseIdx)) *
2781 getValue(ectx.fs.saturation(oilPhaseIdx)) +
2782 getValue(ectx.fs.Rv()) *
2783 getValue(ectx.fs.invB(gasPhaseIdx)) *
2784 getValue(ectx.fs.saturation(gasPhaseIdx))) *
2785 model.dofTotalVolume(ectx.globalDofIdx) *
2786 getValue(ectx.intQuants.porosity());
2790 Entry{ScalarEntry{
"BGIP",
2791 [&model = this->simulator_.model()](
const Context& ectx)
2793 Scalar result = getValue(ectx.fs.invB(gasPhaseIdx)) *
2794 getValue(ectx.fs.saturation(gasPhaseIdx));
2796 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2797 result += getValue(ectx.fs.Rs()) *
2798 getValue(ectx.fs.invB(oilPhaseIdx)) *
2799 getValue(ectx.fs.saturation(oilPhaseIdx));
2802 result += getValue(ectx.fs.Rsw()) *
2803 getValue(ectx.fs.invB(waterPhaseIdx)) *
2804 getValue(ectx.fs.saturation(waterPhaseIdx));
2808 model.dofTotalVolume(ectx.globalDofIdx) *
2809 getValue(ectx.intQuants.porosity());
2813 Entry{ScalarEntry{
"BWIP",
2814 [&model = this->simulator_.model()](
const Context& ectx)
2816 return getValue(ectx.fs.invB(waterPhaseIdx)) *
2817 getValue(ectx.fs.saturation(waterPhaseIdx)) *
2818 model.dofTotalVolume(ectx.globalDofIdx) *
2819 getValue(ectx.intQuants.porosity());
2823 Entry{ScalarEntry{
"BOIPL",
2824 [&model = this->simulator_.model()](
const Context& ectx)
2826 return getValue(ectx.fs.invB(oilPhaseIdx)) *
2827 getValue(ectx.fs.saturation(oilPhaseIdx)) *
2828 model.dofTotalVolume(ectx.globalDofIdx) *
2829 getValue(ectx.intQuants.porosity());
2833 Entry{ScalarEntry{
"BGIPL",
2834 [&model = this->simulator_.model()](
const Context& ectx)
2837 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2838 result = getValue(ectx.fs.Rs()) *
2839 getValue(ectx.fs.invB(oilPhaseIdx)) *
2840 getValue(ectx.fs.saturation(oilPhaseIdx));
2843 result = getValue(ectx.fs.Rsw()) *
2844 getValue(ectx.fs.invB(waterPhaseIdx)) *
2845 getValue(ectx.fs.saturation(waterPhaseIdx));
2848 model.dofTotalVolume(ectx.globalDofIdx) *
2849 getValue(ectx.intQuants.porosity());
2853 Entry{ScalarEntry{
"BGIPG",
2854 [&model = this->simulator_.model()](
const Context& ectx)
2856 return getValue(ectx.fs.invB(gasPhaseIdx)) *
2857 getValue(ectx.fs.saturation(gasPhaseIdx)) *
2858 model.dofTotalVolume(ectx.globalDofIdx) *
2859 getValue(ectx.intQuants.porosity());
2863 Entry{ScalarEntry{
"BOIPG",
2864 [&model = this->simulator_.model()](
const Context& ectx)
2866 return getValue(ectx.fs.Rv()) *
2867 getValue(ectx.fs.invB(gasPhaseIdx)) *
2868 getValue(ectx.fs.saturation(gasPhaseIdx)) *
2869 model.dofTotalVolume(ectx.globalDofIdx) *
2870 getValue(ectx.intQuants.porosity());
2874 Entry{PhaseEntry{std::array{
"BPPW"sv,
"BPPO"sv,
"BPPG"sv},
2875 [&simConfig = this->
eclState_.getSimulationConfig(),
2876 &grav = this->simulator_.problem().gravity(),
2878 &problem = this->simulator_.problem(),
2879 ®ions = this->
regions_](
const unsigned phaseIdx,
const Context& ectx)
2882 phase.ix = phaseIdx;
2891 const auto datum = simConfig.datumDepths()(regions[
"FIPNUM"][ectx.dofIdx] - 1);
2894 const auto region = RegionPhasePoreVolAverage::Region {
2895 ectx.elemCtx.primaryVars(ectx.dofIdx, 0).pvtRegionIndex() + 1
2898 const auto density = regionAvgDensity->value(
"PVTNUM", phase, region);
2900 const auto press = getValue(ectx.fs.pressure(phase.ix));
2901 const auto dz = problem.dofCenterDepth(ectx.globalDofIdx) - datum;
2902 return press - density*dz*grav[GridView::dimensionworld - 1];
2906 Entry{ScalarEntry{
"BAMIP",
2907 [&model = this->simulator_.model()](
const Context& ectx)
2909 const Scalar rhoW = FluidSystem::referenceDensity(waterPhaseIdx,
2910 ectx.intQuants.pvtRegionIndex());
2911 return getValue(ectx.fs.invB(waterPhaseIdx)) *
2912 getValue(ectx.fs.saturation(waterPhaseIdx)) *
2914 model.dofTotalVolume(ectx.globalDofIdx) *
2915 getValue(ectx.intQuants.porosity());
2919 Entry{ScalarEntry{
"BMMIP",
2920 [&model = this->simulator_.model()](
const Context& ectx)
2922 if constexpr (enableBioeffects) {
2923 return getValue(ectx.intQuants.microbialConcentration()) *
2924 getValue(ectx.fs.saturation(waterPhaseIdx)) *
2925 getValue(ectx.intQuants.porosity()) *
2926 model.dofTotalVolume(ectx.globalDofIdx);
2934 Entry{ScalarEntry{
"BMOIP",
2935 [&model = this->simulator_.model()](
const Context& ectx)
2937 if constexpr (enableBioeffects) {
2938 return getValue(ectx.intQuants.oxygenConcentration()) *
2939 getValue(ectx.intQuants.porosity()) *
2940 model.dofTotalVolume(ectx.globalDofIdx);
2948 Entry{ScalarEntry{
"BMUIP",
2949 [&model = this->simulator_.model()](
const Context& ectx)
2951 if constexpr (enableBioeffects) {
2952 return getValue(ectx.intQuants.ureaConcentration()) *
2953 getValue(ectx.intQuants.porosity()) *
2954 model.dofTotalVolume(ectx.globalDofIdx);
2962 Entry{ScalarEntry{
"BMBIP",
2963 [&model = this->simulator_.model()](
const Context& ectx)
2965 if constexpr (enableBioeffects) {
2966 return model.dofTotalVolume(ectx.globalDofIdx) *
2967 getValue(ectx.intQuants.biofilmMass());
2975 Entry{ScalarEntry{
"BMCIP",
2976 [&model = this->simulator_.model()](
const Context& ectx)
2978 if constexpr (enableBioeffects) {
2979 return model.dofTotalVolume(ectx.globalDofIdx) *
2980 getValue(ectx.intQuants.calciteMass());
2988 Entry{ScalarEntry{
"BGMIP",
2989 [&model = this->simulator_.model()](
const Context& ectx)
2991 Scalar result = getValue(ectx.fs.invB(gasPhaseIdx)) *
2992 getValue(ectx.fs.saturation(gasPhaseIdx));
2994 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
2995 result += getValue(ectx.fs.Rs()) *
2996 getValue(ectx.fs.invB(oilPhaseIdx)) *
2997 getValue(ectx.fs.saturation(oilPhaseIdx));
3000 result += getValue(ectx.fs.Rsw()) *
3001 getValue(ectx.fs.invB(waterPhaseIdx)) *
3002 getValue(ectx.fs.saturation(waterPhaseIdx));
3004 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
3005 ectx.intQuants.pvtRegionIndex());
3007 model.dofTotalVolume(ectx.globalDofIdx) *
3008 getValue(ectx.intQuants.porosity()) *
3013 Entry{ScalarEntry{
"BGMGP",
3014 [&model = this->simulator_.model()](
const Context& ectx)
3016 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
3017 ectx.intQuants.pvtRegionIndex());
3018 return getValue(ectx.fs.invB(gasPhaseIdx)) *
3019 getValue(ectx.fs.saturation(gasPhaseIdx)) *
3020 model.dofTotalVolume(ectx.globalDofIdx) *
3021 getValue(ectx.intQuants.porosity()) *
3026 Entry{ScalarEntry{
"BGMDS",
3027 [&model = this->simulator_.model()](
const Context& ectx)
3030 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
3031 result = getValue(ectx.fs.Rs()) *
3032 getValue(ectx.fs.invB(oilPhaseIdx)) *
3033 getValue(ectx.fs.saturation(oilPhaseIdx));
3036 result = getValue(ectx.fs.Rsw()) *
3037 getValue(ectx.fs.invB(waterPhaseIdx)) *
3038 getValue(ectx.fs.saturation(waterPhaseIdx));
3040 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
3041 ectx.intQuants.pvtRegionIndex());
3043 model.dofTotalVolume(ectx.globalDofIdx) *
3044 getValue(ectx.intQuants.porosity()) *
3049 Entry{ScalarEntry{
"BGMST",
3050 [&model = this->simulator_.model(),
3051 &problem = this->simulator_.problem()](
const Context& ectx)
3053 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3054 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3055 Scalar strandedGas = scaledDrainageInfo.Sgcr;
3056 if (problem.materialLawManager().enableHysteresis()) {
3057 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3058 const Scalar krg = getValue(ectx.intQuants.relativePermeability(gasPhaseIdx));
3059 strandedGas = MaterialLaw::strandedGasSaturation(matParams, sg, krg);
3061 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3062 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3063 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3064 return (1.0 - xgW) *
3065 model.dofTotalVolume(ectx.globalDofIdx) *
3066 getValue(ectx.intQuants.porosity()) *
3067 getValue(ectx.fs.density(gasPhaseIdx)) *
3068 std::min(strandedGas, sg);
3072 Entry{ScalarEntry{
"BGMUS",
3073 [&model = this->simulator_.model(),
3074 &problem = this->simulator_.problem()](
const Context& ectx)
3076 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3077 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3078 Scalar strandedGas = scaledDrainageInfo.Sgcr;
3079 if (problem.materialLawManager().enableHysteresis()) {
3080 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3081 const Scalar krg = getValue(ectx.intQuants.relativePermeability(gasPhaseIdx));
3082 strandedGas = MaterialLaw::strandedGasSaturation(matParams, sg, krg);
3084 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3085 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3086 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3087 return (1.0 - xgW) *
3088 model.dofTotalVolume(ectx.globalDofIdx) *
3089 getValue(ectx.intQuants.porosity()) *
3090 getValue(ectx.fs.density(gasPhaseIdx)) *
3091 std::max(Scalar{0.0}, sg - strandedGas);
3095 Entry{ScalarEntry{
"BGMTR",
3096 [&model = this->simulator_.model(),
3097 &problem = this->simulator_.problem()](
const Context& ectx)
3099 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3100 Scalar trappedGas = scaledDrainageInfo.Sgcr;
3101 if (problem.materialLawManager().enableHysteresis()) {
3102 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3103 trappedGas = MaterialLaw::trappedGasSaturation(matParams,
true);
3105 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3106 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3107 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3108 return (1.0 - xgW) *
3109 model.dofTotalVolume(ectx.globalDofIdx) *
3110 getValue(ectx.intQuants.porosity()) *
3111 getValue(ectx.fs.density(gasPhaseIdx)) *
3112 std::min(trappedGas, getValue(ectx.fs.saturation(gasPhaseIdx)));
3116 Entry{ScalarEntry{
"BGMMO",
3117 [&model = this->simulator_.model(),
3118 &problem = this->simulator_.problem()](
const Context& ectx)
3120 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3121 Scalar trappedGas = scaledDrainageInfo.Sgcr;
3122 if (problem.materialLawManager().enableHysteresis()) {
3123 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3124 trappedGas = MaterialLaw::trappedGasSaturation(matParams,
true);
3126 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3127 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3128 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3129 return (1.0 - xgW) *
3130 model.dofTotalVolume(ectx.globalDofIdx) *
3131 getValue(ectx.intQuants.porosity()) *
3132 getValue(ectx.fs.density(gasPhaseIdx)) *
3133 std::max(Scalar{0.0}, getValue(ectx.fs.saturation(gasPhaseIdx)) - trappedGas);
3137 Entry{ScalarEntry{
"BGKTR",
3138 [&model = this->simulator_.model(),
3139 &problem = this->simulator_.problem()](
const Context& ectx)
3141 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3142 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3143 Scalar sgcr = scaledDrainageInfo.Sgcr;
3144 if (problem.materialLawManager().enableHysteresis()) {
3145 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3146 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3152 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3153 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3154 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3155 return (1.0 - xgW) *
3156 model.dofTotalVolume(ectx.globalDofIdx) *
3157 getValue(ectx.intQuants.porosity()) *
3158 getValue(ectx.fs.density(gasPhaseIdx)) *
3159 getValue(ectx.fs.saturation(gasPhaseIdx));
3164 Entry{ScalarEntry{
"BGKMO",
3165 [&model = this->simulator_.model(),
3166 &problem = this->simulator_.problem()](
const Context& ectx)
3168 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3169 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3170 Scalar sgcr = scaledDrainageInfo.Sgcr;
3171 if (problem.materialLawManager().enableHysteresis()) {
3172 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3173 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3179 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3180 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3181 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3182 return (1.0 - xgW) *
3183 model.dofTotalVolume(ectx.globalDofIdx) *
3184 getValue(ectx.intQuants.porosity()) *
3185 getValue(ectx.fs.density(gasPhaseIdx)) *
3186 getValue(ectx.fs.saturation(gasPhaseIdx));
3191 Entry{ScalarEntry{
"BGCDI",
3192 [&model = this->simulator_.model(),
3193 &problem = this->simulator_.problem()](
const Context& ectx)
3195 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3196 Scalar sgcr = scaledDrainageInfo.Sgcr;
3197 if (problem.materialLawManager().enableHysteresis()) {
3198 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3199 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3201 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3202 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3203 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3204 return (1.0 - xgW) *
3205 model.dofTotalVolume(ectx.globalDofIdx) *
3206 getValue(ectx.intQuants.porosity()) *
3207 getValue(ectx.fs.density(gasPhaseIdx)) *
3208 std::min(sgcr, getValue(ectx.fs.saturation(gasPhaseIdx))) /
3209 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3213 Entry{ScalarEntry{
"BGCDM",
3214 [&model = this->simulator_.model(),
3215 &problem = this->simulator_.problem()](
const Context& ectx)
3217 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3218 Scalar sgcr = scaledDrainageInfo.Sgcr;
3219 if (problem.materialLawManager().enableHysteresis()) {
3220 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3221 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3223 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3224 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3225 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3226 return (1.0 - xgW) *
3227 model.dofTotalVolume(ectx.globalDofIdx) *
3228 getValue(ectx.intQuants.porosity()) *
3229 getValue(ectx.fs.density(gasPhaseIdx)) *
3230 std::max(Scalar{0.0}, getValue(ectx.fs.saturation(gasPhaseIdx)) - sgcr) /
3231 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3235 Entry{ScalarEntry{
"BGKDI",
3236 [&model = this->simulator_.model(),
3237 &problem = this->simulator_.problem()](
const Context& ectx)
3239 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3240 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3241 Scalar sgcr = scaledDrainageInfo.Sgcr;
3242 if (problem.materialLawManager().enableHysteresis()) {
3243 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3244 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3250 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3251 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3252 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3253 return (1.0 - xgW) *
3254 model.dofTotalVolume(ectx.globalDofIdx) *
3255 getValue(ectx.intQuants.porosity()) *
3256 getValue(ectx.fs.density(gasPhaseIdx)) *
3257 getValue(ectx.fs.saturation(gasPhaseIdx)) /
3258 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3263 Entry{ScalarEntry{
"BGKDM",
3264 [&model = this->simulator_.model(),
3265 &problem = this->simulator_.problem()](
const Context& ectx)
3267 const auto& scaledDrainageInfo = problem.materialLawManager().oilWaterScaledEpsInfoDrainage(ectx.dofIdx);
3268 const Scalar sg = getValue(ectx.fs.saturation(gasPhaseIdx));
3269 Scalar sgcr = scaledDrainageInfo.Sgcr;
3270 if (problem.materialLawManager().enableHysteresis()) {
3271 const auto& matParams = problem.materialLawParams(ectx.dofIdx);
3272 sgcr = MaterialLaw::trappedGasSaturation(matParams,
false);
3278 const Scalar xgW = FluidSystem::phaseIsActive(waterPhaseIdx) ?
3279 FluidSystem::convertRvwToXgW(getValue(ectx.fs.Rvw()), ectx.intQuants.pvtRegionIndex())
3280 : FluidSystem::convertRvToXgO(getValue(ectx.fs.
Rv()), ectx.intQuants.pvtRegionIndex());
3281 return (1.0 - xgW) *
3282 model.dofTotalVolume(ectx.globalDofIdx) *
3283 getValue(ectx.intQuants.porosity()) *
3284 getValue(ectx.fs.density(gasPhaseIdx)) *
3285 getValue(ectx.fs.saturation(gasPhaseIdx)) /
3286 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3291 Entry{ScalarEntry{
"BWCD",
3292 [&model = this->simulator_.model()](
const Context& ectx)
3295 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
3296 result = getValue(ectx.fs.Rs()) *
3297 getValue(ectx.fs.invB(oilPhaseIdx)) *
3298 getValue(ectx.fs.saturation(oilPhaseIdx));
3301 result = getValue(ectx.fs.Rsw()) *
3302 getValue(ectx.fs.invB(waterPhaseIdx)) *
3303 getValue(ectx.fs.saturation(waterPhaseIdx));
3305 const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx,
3306 ectx.intQuants.pvtRegionIndex());
3308 model.dofTotalVolume(ectx.globalDofIdx) *
3309 getValue(ectx.intQuants.porosity()) *
3311 FluidSystem::molarMass(gasCompIdx, ectx.intQuants.pvtRegionIndex());
3315 Entry{ScalarEntry{
"BWIPG",
3316 [&model = this->simulator_.model()](
const Context& ectx)
3318 Scalar result = 0.0;
3319 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
3320 result = getValue(ectx.fs.Rvw()) *
3321 getValue(ectx.fs.invB(gasPhaseIdx)) *
3322 getValue(ectx.fs.saturation(gasPhaseIdx));
3325 model.dofTotalVolume(ectx.globalDofIdx) *
3326 getValue(ectx.intQuants.porosity());
3330 Entry{ScalarEntry{
"BWIPL",
3331 [&model = this->simulator_.model()](
const Context& ectx)
3333 return getValue(ectx.fs.invB(waterPhaseIdx)) *
3334 getValue(ectx.fs.saturation(waterPhaseIdx)) *
3335 model.dofTotalVolume(ectx.globalDofIdx) *
3336 getValue(ectx.intQuants.porosity());
3342 auto blockHandlers = std::span<const Entry>{handlers};
3343 auto mechHandlers = std::vector<Entry>{};
3344 if constexpr (getPropValue<TypeTag, Properties::EnableMech>()) {
3345 if (this->
mech_.allocated()) {
3346 mechHandlers.assign(handlers.begin(), handlers.end());
3347 mechHandlers.push_back(
3348 Entry{TensorEntry{
"BSTRSS",
3349 [&model = this->simulator_.problem().geoMechModel()]
3350 (
const VoigtIndex index,
const Context& ectx)
3352 return model.stress(ectx.globalDofIdx,
true)[index];
3356 blockHandlers = mechHandlers;
3365 this->lgrBlockExtractors_ =
3369 if (reportStepNum > 0 && !isSubStep) {
3371 const auto& rpt = this->
schedule_[reportStepNum - 1].rpt_config.get();
3372 if (rpt.contains(
"WELLS") && rpt.at(
"WELLS") > 1) {
3374 [&c = this->collectOnIORank_](
const int idx)
3375 {
return c.isCartIdxOnThisRank(idx); });
3377 const auto extraHandlers = std::array{
3386 const Simulator& simulator_;
3387 const CollectDataOnIORankType& collectOnIORank_;
3388 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:537
ScalarBuffer oilVaporizationFactor_
Definition: GenericOutputModule.hpp:614
bool forceDisableFipOutput_
Definition: GenericOutputModule.hpp:558
RFTContainer< GetPropType< TypeTag, Properties::FluidSystem > > rftC_
Definition: GenericOutputModule.hpp:643
ScalarBuffer saturatedOilFormationVolumeFactor_
Definition: GenericOutputModule.hpp:619
GeochemistryContainer< Scalar > geochemC_
Definition: GenericOutputModule.hpp:635
ScalarBuffer rockCompPorvMultiplier_
Definition: GenericOutputModule.hpp:617
TracerContainer< GetPropType< TypeTag, Properties::FluidSystem > > tracerC_
Definition: GenericOutputModule.hpp:637
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:622
std::array< ScalarBuffer, numPhases > residual_
Definition: GenericOutputModule.hpp:639
ScalarBuffer sSol_
Definition: GenericOutputModule.hpp:598
std::map< std::tuple< std::string, int, int >, double > lgrBlockData_
Definition: GenericOutputModule.hpp:656
void setupExtraBlockData(const std::size_t reportStepNum, std::function< bool(int)> isCartIdxOnThisRank)
std::vector< int > failedCellsPd_
Definition: GenericOutputModule.hpp:584
ScalarBuffer shmax_
Definition: GenericOutputModule.hpp:609
ScalarBuffer sgmax_
Definition: GenericOutputModule.hpp:608
ScalarBuffer rockCompTransMultiplier_
Definition: GenericOutputModule.hpp:620
void setupBlockData(std::function< bool(int)> isCartIdxOnThisRank)
ScalarBuffer minimumOilPressure_
Definition: GenericOutputModule.hpp:618
ScalarBuffer temperature_
Definition: GenericOutputModule.hpp:592
ScalarBuffer pcow_
Definition: GenericOutputModule.hpp:624
ScalarBuffer drsdtcon_
Definition: GenericOutputModule.hpp:597
bool computeFip_
Definition: GenericOutputModule.hpp:560
std::optional< RegionPhasePoreVolAverage > regionAvgDensity_
Definition: GenericOutputModule.hpp:661
ScalarBuffer permFact_
Definition: GenericOutputModule.hpp:604
ScalarBuffer overburdenPressure_
Definition: GenericOutputModule.hpp:595
TpsaContainer< Scalar > tpsaC_
Definition: GenericOutputModule.hpp:629
ScalarBuffer rPorV_
Definition: GenericOutputModule.hpp:590
std::array< ScalarBuffer, numPhases > viscosity_
Definition: GenericOutputModule.hpp:633
void setupLgrBlockData(const std::map< std::string, int > &lgrNameToLevel, const std::function< bool(int, int)> &isLgrCellOnThisRank)
ScalarBuffer rvw_
Definition: GenericOutputModule.hpp:594
FIPContainer< GetPropType< TypeTag, Properties::FluidSystem > > fipC_
Definition: GenericOutputModule.hpp:571
ScalarBuffer cPolymer_
Definition: GenericOutputModule.hpp:600
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:572
ScalarBuffer swmin_
Definition: GenericOutputModule.hpp:611
FlowsContainer< GetPropType< TypeTag, Properties::FluidSystem > > flowsC_
Definition: GenericOutputModule.hpp:641
std::map< std::pair< std::string, int >, double > blockData_
Definition: GenericOutputModule.hpp:646
ScalarBuffer gasDissolutionFactor_
Definition: GenericOutputModule.hpp:613
MechContainer< Scalar > mech_
Definition: GenericOutputModule.hpp:628
BioeffectsContainer< Scalar > bioeffectsC_
Definition: GenericOutputModule.hpp:621
ExtboContainer< Scalar > extboC_
Definition: GenericOutputModule.hpp:605
ScalarBuffer gasDissolutionFactorInWater_
Definition: GenericOutputModule.hpp:615
ScalarBuffer pcgw_
Definition: GenericOutputModule.hpp:623
LogOutputHelper< Scalar > logOutput_
Definition: GenericOutputModule.hpp:543
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:610
void updateTotalVolumesAndPressures_(const unsigned globalDofIdx, const IntensiveQuantities &intQuants, const double totVolume, const Scalar referencePorosity)
Definition: GenericOutputModule.hpp:362
InterRegFlowMap interRegionFlows_
Definition: GenericOutputModule.hpp:542
ScalarBuffer soMax_
Definition: GenericOutputModule.hpp:606
std::array< ScalarBuffer, numPhases > density_
Definition: GenericOutputModule.hpp:632
ScalarBuffer cFoam_
Definition: GenericOutputModule.hpp:601
ScalarBuffer waterVaporizationFactor_
Definition: GenericOutputModule.hpp:616
std::array< ScalarBuffer, numPhases > saturation_
Definition: GenericOutputModule.hpp:631
ScalarBuffer rsw_
Definition: GenericOutputModule.hpp:593
ScalarBuffer oilSaturationPressure_
Definition: GenericOutputModule.hpp:596
const EclipseState & eclState_
Definition: GenericOutputModule.hpp:536
ScalarBuffer ppcw_
Definition: GenericOutputModule.hpp:612
virtual void assignToSolution(data::Solution &sol)
Move all buffers to data::Solution.
ScalarBuffer cSalt_
Definition: GenericOutputModule.hpp:602
ScalarBuffer pcog_
Definition: GenericOutputModule.hpp:625
const Inplace * initialInplace() const
Definition: GenericOutputModule.hpp:274
ScalarBuffer swMax_
Definition: GenericOutputModule.hpp:607
ScalarBuffer rswSol_
Definition: GenericOutputModule.hpp:599
std::map< std::pair< std::string, int >, double > extraBlockData_
Definition: GenericOutputModule.hpp:649
ScalarBuffer fluidPressure_
Definition: GenericOutputModule.hpp:591
ScalarBuffer gasFormationVolumeFactor_
Definition: GenericOutputModule.hpp:586
virtual void setRestart(const data::Solution &sol, unsigned elemIdx, unsigned globalDofIndex)
std::vector< int > failedCellsPb_
Definition: GenericOutputModule.hpp:583
ScalarBuffer pSalt_
Definition: GenericOutputModule.hpp:603
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:184
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