101 using Element =
typename GridView::template Codim<0>::Entity;
102 using ElementIterator =
typename GridView::template Codim<0>::Iterator;
105 using Dir = FaceDir::DirEnum;
107 enum { conti0EqIdx = Indices::conti0EqIdx };
108 enum { numPhases = FluidSystem::numPhases };
109 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
110 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
111 enum { waterPhaseIdx = FluidSystem::waterPhaseIdx };
112 enum { gasCompIdx = FluidSystem::gasCompIdx };
113 enum { oilCompIdx = FluidSystem::oilCompIdx };
114 enum { waterCompIdx = FluidSystem::waterCompIdx };
118 template <
class CollectDataToIORankType>
122 :
BaseType(simulator.vanguard().eclState(),
123 simulator.vanguard().schedule(),
125 simulator.vanguard().summaryState(),
137 , simulator_(simulator)
147 this->setupBlockData(isCartIdxOnThisRank);
149 this->forceDisableFipOutput_ =
150 Parameters::Get<Parameters::ForceDisableFluidInPlaceOutput>();
152 this->forceDisableFipresvOutput_ =
153 Parameters::Get<Parameters::ForceDisableResvFluidInPlaceOutput>();
155 if (! Parameters::Get<Parameters::OwnerCellsFirst>()) {
156 const std::string
msg =
"The output code does not support --owner-cells-first=false.";
164 auto rset = this->eclState_.fieldProps().fip_regions();
165 rset.push_back(
"PVTNUM");
170 this->regionAvgDensity_
171 .emplace(this->simulator_.gridView().comm(),
172 FluidSystem::numPhases,
rset,
173 [
fp = std::cref(
this->eclState_.fieldProps())]
174 (
const std::string&
rsetName) ->
decltype(
auto)
175 { return fp.get().get_int(rsetName); });
184 Parameters::Register<Parameters::ForceDisableFluidInPlaceOutput>
185 (
"Do not print fluid-in-place values after each report step "
186 "even if requested by the deck.");
187 Parameters::Register<Parameters::ForceDisableResvFluidInPlaceOutput>
188 (
"Do not print reservoir volumes values after each report step "
189 "even if requested by the deck.");
198 const unsigned reportStepNum,
201 const bool isRestart)
207 const auto& problem = this->simulator_.problem();
214 problem.vapparsActive(std::max(simulator_.episodeIndex(), 0)),
215 problem.materialLawManager()->enablePCHysteresis(),
216 problem.materialLawManager()->enableNonWettingHysteresis(),
217 problem.materialLawManager()->enableWettingHysteresis(),
218 problem.tracerModel().numTracers(),
219 problem.tracerModel().enableSolTracers(),
220 problem.eclWriter()->getOutputNnc().size());
223 void processElementMech(
const ElementContext&
elemCtx)
226 const auto& problem =
elemCtx.simulator().problem();
227 const auto& model = problem.geoMechModel();
230 if (!this->mechPotentialForce_.empty()) {
278 const auto& problem =
elemCtx.simulator().problem();
284 using FluidState = std::remove_cv_t<std::remove_reference_t<
decltype(
fs)>>;
287 const unsigned pvtRegionIdx =
elemCtx.primaryVars(
dofIdx, 0).pvtRegionIndex();
290 if (this->saturation_[
phaseIdx].empty())
297 if (this->regionAvgDensity_.has_value()) {
300 const auto porv =
intQuants.referencePorosity()
304 static_cast<double>(porv));
307 if (!this->fluidPressure_.empty()) {
308 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
311 }
else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
318 Valgrind::CheckDefined(this->fluidPressure_[
globalDofIdx]);
321 if (!this->temperature_.empty()) {
323 Valgrind::CheckDefined(this->temperature_[
globalDofIdx]);
325 if (!this->gasDissolutionFactor_.empty()) {
329 fs, oilPhaseIdx, pvtRegionIdx,
SoMax);
330 Valgrind::CheckDefined(this->gasDissolutionFactor_[
globalDofIdx]);
332 if (!this->oilVaporizationFactor_.empty()) {
336 fs, gasPhaseIdx, pvtRegionIdx,
SoMax);
337 Valgrind::CheckDefined(this->oilVaporizationFactor_[
globalDofIdx]);
339 if (!this->gasDissolutionFactorInWater_.empty()) {
343 fs, waterPhaseIdx, pvtRegionIdx,
SwMax);
344 Valgrind::CheckDefined(this->gasDissolutionFactorInWater_[
globalDofIdx]);
346 if (!this->waterVaporizationFactor_.empty()) {
349 fs, gasPhaseIdx, pvtRegionIdx);
350 Valgrind::CheckDefined(this->waterVaporizationFactor_[
globalDofIdx]);
352 if (!this->gasFormationVolumeFactor_.empty()) {
355 fs, gasPhaseIdx, pvtRegionIdx);
356 Valgrind::CheckDefined(this->gasFormationVolumeFactor_[
globalDofIdx]);
358 if (!this->saturatedOilFormationVolumeFactor_.empty()) {
359 this->saturatedOilFormationVolumeFactor_[
globalDofIdx] = 1.0
361 fs, oilPhaseIdx, pvtRegionIdx);
362 Valgrind::CheckDefined(this->saturatedOilFormationVolumeFactor_[
globalDofIdx]);
364 if (!this->oilSaturationPressure_.empty()) {
367 Valgrind::CheckDefined(this->oilSaturationPressure_[
globalDofIdx]);
370 if (!this->rs_.empty()) {
374 if (!this->rsw_.empty()) {
379 if (!this->rv_.empty()) {
383 if (!this->pcgw_.empty()) {
387 if (!this->pcow_.empty()) {
391 if (!this->pcog_.empty()) {
396 if (!this->rvw_.empty()) {
410 if (this->density_[
phaseIdx].empty())
418 if (this->viscosity_[
phaseIdx].empty())
421 if (!this->extboX_.empty() &&
phaseIdx == oilPhaseIdx)
423 else if (!this->extboX_.empty() &&
phaseIdx == gasPhaseIdx)
431 if (this->relativePermeability_[
phaseIdx].empty())
439 if (!this->drsdtcon_.empty()) {
443 if (!this->sSol_.empty()) {
447 if (!this->rswSol_.empty()) {
451 if (!this->cPolymer_.empty()) {
455 if (!this->cFoam_.empty()) {
459 if (!this->cSalt_.empty()) {
463 if (!this->pSalt_.empty()) {
467 if (!this->permFact_.empty()) {
471 if (!this->extboX_.empty()) {
475 if (!this->extboY_.empty()) {
479 if (!this->extboZ_.empty()) {
483 if (!this->rPorV_.empty()) {
488 if (!this->mFracCo2_.empty()) {
499 const Scalar
rhoO = FluidSystem::referenceDensity(gasPhaseIdx, pvtRegionIdx);
500 const Scalar
rhoG = FluidSystem::referenceDensity(gasPhaseIdx, pvtRegionIdx);
508 if (!this->cMicrobes_.empty()) {
512 if (!this->cOxygen_.empty()) {
516 if (!this->cUrea_.empty()) {
522 if (!this->cBiofilm_.empty()) {
526 if (!this->cCalcite_.empty()) {
530 if (!this->bubblePointPressure_.empty()) {
540 if (!this->dewPointPressure_.empty()) {
550 if (!this->minimumOilPressure_.empty())
554 if (!this->overburdenPressure_.empty())
557 if (!this->rockCompPorvMultiplier_.empty())
561 if (!this->rockCompTransMultiplier_.empty())
567 if (FluidSystem::phaseIsActive(oilPhaseIdx)
568 && FluidSystem::phaseIsActive(waterPhaseIdx)) {
577 if (!this->soMax_.empty()) {
582 if (!this->swMax_.empty()) {
587 if (!this->swmin_.empty()) {
593 if (FluidSystem::phaseIsActive(oilPhaseIdx)
594 && FluidSystem::phaseIsActive(gasPhaseIdx)) {
602 if (!this->sgmax_.empty()) {
607 if (!this->shmax_.empty()) {
612 if (!this->somin_.empty()) {
619 if (!this->soMax_.empty())
623 if (!this->swMax_.empty())
628 if (!this->ppcw_.empty()) {
638 if ((
elemCtx.simulator().episodeIndex() < 0) &&
639 FluidSystem::phaseIsActive(oilPhaseIdx) &&
640 FluidSystem::phaseIsActive(gasPhaseIdx))
645 if (!this->rv_.empty())
648 if (!this->rs_.empty())
651 if (!this->rsw_.empty())
654 if (!this->rvw_.empty())
658 if (!this->density_[oilPhaseIdx].empty())
662 if (!this->density_[gasPhaseIdx].empty())
666 if (!this->invB_[oilPhaseIdx].empty())
668 = FluidSystem::inverseFormationVolumeFactor(
fsInitial, oilPhaseIdx,
intQuants.pvtRegionIndex());
670 if (!this->invB_[gasPhaseIdx].empty())
672 = FluidSystem::inverseFormationVolumeFactor(
fsInitial, gasPhaseIdx,
intQuants.pvtRegionIndex());
674 if (!this->viscosity_[oilPhaseIdx].empty())
678 if (!this->viscosity_[gasPhaseIdx].empty())
685 if (this->oilConnectionPressures_.count(
cartesianIdx) > 0) {
688 if (this->waterConnectionSaturations_.count(
cartesianIdx) > 0) {
691 if (this->gasConnectionSaturations_.count(
cartesianIdx) > 0) {
696 const auto& tracerModel = simulator_.problem().tracerModel();
697 if (! this->freeTracerConcentrations_.empty()) {
699 if (this->freeTracerConcentrations_[
tracerIdx].empty()) {
706 if (! this->solTracerConcentrations_.empty()) {
708 if (this->solTracerConcentrations_[
tracerIdx].empty()) {
720 if (!this->residual_[
phaseIdx].empty()) {
721 const unsigned activeCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::solventComponentIndex(
phaseIdx));
728 void processElementFlows(
const ElementContext&
elemCtx)
734 const auto& problem =
elemCtx.simulator().problem();
738 if (!problem.model().linearizer().getFlowsInfo().empty()) {
739 const auto&
flowsInf = problem.model().linearizer().getFlowsInfo();
743 if (!this->flows_[
flowsInfo.faceId][gasCompIdx].empty()) {
745 =
flowsInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(gasCompIdx)];
747 if (!this->flows_[
flowsInfo.faceId][oilCompIdx].empty()) {
749 =
flowsInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(oilCompIdx)];
751 if (!this->flows_[
flowsInfo.faceId][waterCompIdx].empty()) {
753 =
flowsInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(waterCompIdx)];
757 if (!this->flowsn_[gasCompIdx].indices.empty()) {
759 this->flowsn_[gasCompIdx].values[
flowsInfo.nncId]
760 =
flowsInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(gasCompIdx)];
762 if (!this->flowsn_[oilCompIdx].indices.empty()) {
764 this->flowsn_[oilCompIdx].values[
flowsInfo.nncId]
765 =
flowsInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(oilCompIdx)];
767 if (!this->flowsn_[waterCompIdx].indices.empty()) {
769 this->flowsn_[waterCompIdx].values[
flowsInfo.nncId]
770 =
flowsInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(waterCompIdx)];
777 if (!problem.model().linearizer().getFloresInfo().empty()) {
778 const auto&
floresInf = problem.model().linearizer().getFloresInfo();
782 if (!this->flores_[
floresInfo.faceId][gasCompIdx].empty()) {
784 =
floresInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(gasCompIdx)];
786 if (!this->flores_[
floresInfo.faceId][oilCompIdx].empty()) {
788 =
floresInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(oilCompIdx)];
790 if (!this->flores_[
floresInfo.faceId][waterCompIdx].empty()) {
792 =
floresInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(waterCompIdx)];
797 if (!this->floresn_[gasCompIdx].indices.empty()) {
799 this->floresn_[gasCompIdx].values[
floresInfo.nncId]
800 =
floresInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(gasCompIdx)];
802 if (!this->floresn_[oilCompIdx].indices.empty()) {
804 this->floresn_[oilCompIdx].values[
floresInfo.nncId]
805 =
floresInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(oilCompIdx)];
807 if (!this->floresn_[waterCompIdx].indices.empty()) {
809 this->floresn_[waterCompIdx].values[
floresInfo.nncId]
810 =
floresInfo.flow[conti0EqIdx + Indices::canonicalToActiveComponentIndex(waterCompIdx)];
818 void processElementBlockData(
const ElementContext&
elemCtx)
824 const auto& problem =
elemCtx.simulator().problem();
831 for (
auto&
val :
this->blockData_) {
832 const auto& key =
val.first;
839 if ((key.first ==
"BWSAT") || (key.first ==
"BSWAT"))
841 else if ((key.first ==
"BGSAT") || (key.first ==
"BSGAS"))
843 else if ((key.first ==
"BOSAT") || (key.first ==
"BSOIL"))
845 else if (key.first ==
"BNSAT")
847 else if ((key.first ==
"BPR") || (key.first ==
"BPRESSUR")) {
848 if (FluidSystem::phaseIsActive(oilPhaseIdx))
850 else if (FluidSystem::phaseIsActive(gasPhaseIdx))
852 else if (FluidSystem::phaseIsActive(waterPhaseIdx))
855 else if ((key.first ==
"BTCNFHEA") || (key.first ==
"BTEMP")) {
856 if (FluidSystem::phaseIsActive(oilPhaseIdx))
858 else if (FluidSystem::phaseIsActive(gasPhaseIdx))
860 else if (FluidSystem::phaseIsActive(waterPhaseIdx))
863 else if (key.first ==
"BWKR" || key.first ==
"BKRW")
865 else if (key.first ==
"BGKR" || key.first ==
"BKRG")
867 else if (key.first ==
"BOKR" || key.first ==
"BKRO")
869 else if (key.first ==
"BKROG") {
875 else if (key.first ==
"BKROW") {
881 else if (key.first ==
"BWPC")
883 else if (key.first ==
"BGPC")
885 else if (key.first ==
"BWPR")
887 else if (key.first ==
"BGPR")
889 else if (key.first ==
"BVWAT" || key.first ==
"BWVIS")
891 else if (key.first ==
"BVGAS" || key.first ==
"BGVIS")
893 else if (key.first ==
"BVOIL" || key.first ==
"BOVIS")
895 else if ((key.first ==
"BODEN") || (key.first ==
"BDENO"))
897 else if ((key.first ==
"BGDEN") || (key.first ==
"BDENG"))
899 else if ((key.first ==
"BWDEN") || (key.first ==
"BDENW"))
901 else if ((key.first ==
"BRPV") ||
902 (key.first ==
"BOPV") ||
903 (key.first ==
"BWPV") ||
904 (key.first ==
"BGPV"))
906 if (key.first ==
"BRPV") {
909 else if (key.first ==
"BOPV") {
912 else if (key.first ==
"BWPV") {
923 else if (key.first ==
"BRS")
925 else if (key.first ==
"BRV")
927 else if ((key.first ==
"BOIP") || (key.first ==
"BOIPL") || (key.first ==
"BOIPG") ||
928 (key.first ==
"BGIP") || (key.first ==
"BGIPL") || (key.first ==
"BGIPG") ||
929 (key.first ==
"BWIP"))
931 if ((key.first ==
"BOIP") || (key.first ==
"BOIPL")) {
934 if (key.first ==
"BOIP") {
939 else if (key.first ==
"BOIPG") {
943 else if ((key.first ==
"BGIP") || (key.first ==
"BGIPG")) {
946 if (key.first ==
"BGIP") {
947 if (!FluidSystem::phaseIsActive(oilPhaseIdx)) {
957 else if (key.first ==
"BGIPL") {
958 if (!FluidSystem::phaseIsActive(oilPhaseIdx)) {
975 else if ((key.first ==
"BPPO") ||
976 (key.first ==
"BPPG") ||
977 (key.first ==
"BPPW"))
979 auto phase = RegionPhasePoreVolAverage::Phase{};
981 if (key.first ==
"BPPO") {
982 phase.ix = oilPhaseIdx;
984 else if (key.first ==
"BPPG") {
985 phase.ix = gasPhaseIdx;
988 phase.ix = waterPhaseIdx;
998 const auto datum = this->eclState_.getSimulationConfig()
999 .datumDepths()(this->regions_[
"FIPNUM"][
dofIdx] - 1);
1002 const auto region = RegionPhasePoreVolAverage::Region {
1006 const auto density = this->regionAvgDensity_
1007 ->value(
"PVTNUM", phase, region);
1009 const auto press =
getValue(
fs.pressure(phase.ix));
1011 elemCtx.problem().gravity()[GridView::dimensionworld - 1];
1016 else if ((key.first ==
"BFLOWI") ||
1017 (key.first ==
"BFLOWJ") ||
1018 (key.first ==
"BFLOWK"))
1020 auto dir = FaceDir::ToIntersectionIndex(Dir::XPlus);
1022 if (key.first ==
"BFLOWJ") {
1023 dir = FaceDir::ToIntersectionIndex(Dir::YPlus);
1025 else if (key.first ==
"BFLOWK") {
1026 dir = FaceDir::ToIntersectionIndex(Dir::ZPlus);
1034 logstring.append(
"' is unhandled for output to summary file.");
1035 OpmLog::warning(
"Unhandled output keyword",
logstring);
1070 template <
class ActiveIndex,
class CartesianIndex>
1076 const auto identifyCell = [&activeIndex, &cartesianIndex](
const Element&
elem)
1084 elem.partitionType() == Dune::InteriorEntity
1097 const auto rates = this->
1112 this->interRegionFlows_.
clear();
1120 this->interRegionFlows_.
compress();
1128 return this->interRegionFlows_;
1131 template <
class Flu
idState>
1132 void assignToFluidState(FluidState&
fs,
unsigned elemIdx)
const
1135 if (this->saturation_[
phaseIdx].empty())
1141 if (!this->fluidPressure_.empty()) {
1144 std::array<Scalar, numPhases>
pc = {0};
1145 const MaterialLawParams&
matParams = simulator_.problem().materialLawParams(
elemIdx);
1147 Valgrind::CheckDefined(this->fluidPressure_[
elemIdx]);
1148 Valgrind::CheckDefined(
pc);
1149 const auto& pressure = this->fluidPressure_[
elemIdx];
1151 if (!FluidSystem::phaseIsActive(
phaseIdx))
1154 if (Indices::oilEnabled)
1156 else if (Indices::gasEnabled)
1158 else if (Indices::waterEnabled)
1164 if (!this->temperature_.empty())
1165 fs.setTemperature(this->temperature_[
elemIdx]);
1166 if (!this->rs_.empty())
1168 if (!this->rsw_.empty())
1170 if (!this->rv_.empty())
1172 if (!this->rvw_.empty())
1176 void initHysteresisParams(Simulator& simulator,
unsigned elemIdx)
const
1178 if (!this->soMax_.empty())
1179 simulator.problem().setMaxOilSaturation(
elemIdx, this->soMax_[
elemIdx]);
1181 if (simulator.problem().materialLawManager()->enableHysteresis()) {
1182 auto matLawManager = simulator.problem().materialLawManager();
1184 if (FluidSystem::phaseIsActive(oilPhaseIdx)
1185 && FluidSystem::phaseIsActive(waterPhaseIdx)) {
1187 Scalar
swmax = -2.0;
1191 if (!this->soMax_.empty()) {
1196 if (!this->swMax_.empty()) {
1201 if (!this->swmin_.empty()) {
1208 if (FluidSystem::phaseIsActive(oilPhaseIdx)
1209 && FluidSystem::phaseIsActive(gasPhaseIdx)) {
1211 Scalar
shmax = -2.0;
1215 if (!this->sgmax_.empty()) {
1220 if (!this->shmax_.empty()) {
1225 if (!this->somin_.empty()) {
1235 if (simulator_.vanguard().eclState().fieldProps().has_double(
"SWATINIT")) {
1236 simulator.problem().materialLawManager()
1241 void updateFluidInPlace(
const ElementContext&
elemCtx)
1256 bool isDefunctParallelWell(std::string
wname)
const override
1258 if (simulator_.gridView().comm().size() == 1)
1260 const auto& parallelWells = simulator_.vanguard().parallelWells();
1261 std::pair<std::string, bool> value {
wname,
true};
1262 auto candidate = std::lower_bound(parallelWells.begin(), parallelWells.end(), value);
1266 void updateFluidInPlace_(
const ElementContext&
elemCtx,
const unsigned dofIdx)
1283 if (this->computeFip_) {
1288 void createLocalRegion_(std::vector<int>& region)
1291 for (
const auto&
elem :
elements(simulator_.gridView())) {
1292 if (
elem.partitionType() != Dune::InteriorEntity) {
1300 template <
typename Flu
idState>
1301 void aggregateAverageDensityContributions_(
const FluidState&
fs,
1305 auto pvCellValue = RegionPhasePoreVolAverage::CellValue{};
1308 for (
auto phaseIdx = 0*FluidSystem::numPhases;
1311 if (! FluidSystem::phaseIsActive(
phaseIdx)) {
1318 this->regionAvgDensity_
1320 RegionPhasePoreVolAverage::Phase {
phaseIdx },
1340 data::InterRegFlowMap::FlowRates
1341 getComponentSurfaceRates(
const ElementContext&
elemCtx,
1342 const Scalar faceArea,
1344 const std::size_t
timeIdx)
const
1346 using Component = data::InterRegFlowMap::Component;
1348 auto rates = data::InterRegFlowMap::FlowRates {};
1354 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1358 using FluidState = std::remove_cv_t<std::remove_reference_t<
1359 decltype(
up.fluidState())>>;
1361 const auto pvtReg =
up.pvtRegionIndex();
1364 (
up.fluidState(), oilPhaseIdx,
pvtReg));
1368 rates[Component::Oil] +=
qO;
1370 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1372 BlackOil::getRs_<FluidSystem, FluidState, Scalar>
1375 rates[Component::Gas] +=
qO * Rs;
1376 rates[Component::Disgas] +=
qO * Rs;
1380 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1384 using FluidState = std::remove_cv_t<std::remove_reference_t<
1385 decltype(
up.fluidState())>>;
1387 const auto pvtReg =
up.pvtRegionIndex();
1390 (
up.fluidState(), gasPhaseIdx,
pvtReg));
1394 rates[Component::Gas] +=
qG;
1396 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1398 BlackOil::getRv_<FluidSystem, FluidState, Scalar>
1401 rates[Component::Oil] +=
qG * Rv;
1402 rates[Component::Vapoil] +=
qG * Rv;
1406 if (FluidSystem::phaseIsActive(waterPhaseIdx)) {
1410 using FluidState = std::remove_cv_t<std::remove_reference_t<
1411 decltype(
up.fluidState())>>;
1413 const auto pvtReg =
up.pvtRegionIndex();
1416 (
up.fluidState(), waterPhaseIdx,
pvtReg));
1418 rates[Component::Water] +=
1425 template <
typename Flu
idState>
1426 Scalar hydroCarbonFraction(
const FluidState&
fs)
const
1428 if (this->eclState_.runspec().co2Storage()) {
1436 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1440 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1447 void updateTotalVolumesAndPressures_(
const unsigned globalDofIdx,
1456 if (! this->hydrocarbonPoreVolume_.empty()) {
1464 if (!this->pressureTimesHydrocarbonVolume_.empty() &&
1465 !
this->pressureTimesPoreVolume_.empty())
1467 assert(this->hydrocarbonPoreVolume_.size() ==
this->pressureTimesHydrocarbonVolume_.size());
1468 assert(this->fip_[Inplace::Phase::PoreVolume].size() == this->pressureTimesPoreVolume_.size());
1470 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
1477 else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
1484 else if (FluidSystem::phaseIsActive(waterPhaseIdx)) {
1491 void updatePhaseInplaceVolumes_(
const unsigned globalDofIdx,
1495 std::array<Scalar, FluidSystem::numPhases> fip {};
1496 std::array<Scalar, FluidSystem::numPhases>
fipr{};
1502 if (!FluidSystem::phaseIsActive(
phaseIdx)) {
1516 if (FluidSystem::phaseIsActive(oilPhaseIdx) &&
1517 FluidSystem::phaseIsActive(gasPhaseIdx))
1522 if (FluidSystem::phaseIsActive(waterPhaseIdx) &&
1523 FluidSystem::phaseIsActive(gasPhaseIdx))
1528 if (FluidSystem::phaseIsActive(gasPhaseIdx) &&
1529 (!this->fip_[Inplace::Phase::CO2InGasPhaseInMob].empty() ||
1530 !this->fip_[Inplace::Phase::CO2InGasPhaseMob].empty() ||
1531 !this->fip_[Inplace::Phase::CO2MassInGasPhaseInMob].empty() ||
1532 !this->fip_[Inplace::Phase::CO2MassInGasPhaseMob].empty() ||
1533 !this->fip_[Inplace::Phase::CO2Mass].empty() ||
1534 !this->fip_[Inplace::Phase::CO2MassInGasPhase].empty() ||
1535 !this->fip_[Inplace::Phase::CO2InGasPhaseInMobKrg].empty() ||
1536 !this->fip_[Inplace::Phase::CO2InGasPhaseMobKrg].empty() ||
1537 !this->fip_[Inplace::Phase::CO2MassInGasPhaseInMobKrg].empty() ||
1538 !this->fip_[Inplace::Phase::CO2MassInGasPhaseMobKrg].empty() ||
1539 !this->fip_[Inplace::Phase::CO2MassInGasPhaseEffectiveTrapped].empty() ||
1540 !this->fip_[Inplace::Phase::CO2MassInGasPhaseEffectiveUnTrapped].empty() ||
1541 !this->fip_[Inplace::Phase::CO2MassInGasPhaseMaximumTrapped].empty() ||
1542 !this->fip_[Inplace::Phase::CO2MassInGasPhaseMaximumUnTrapped].empty()))
1547 if ((!this->fip_[Inplace::Phase::CO2InWaterPhase].empty() ||
1548 !this->fip_[Inplace::Phase::CO2MassInWaterPhase].empty() ||
1549 !this->fip_[Inplace::Phase::CO2Mass].empty()) &&
1550 (FluidSystem::phaseIsActive(waterPhaseIdx) ||
1551 FluidSystem::phaseIsActive(oilPhaseIdx)))
1557 template <
typename FIPArray>
1558 void updateInplaceVolumesSurface(
const unsigned globalDofIdx,
1561 if (FluidSystem::phaseIsActive(oilPhaseIdx) &&
1562 !this->fip_[Inplace::Phase::OIL].empty())
1564 this->fip_[Inplace::Phase::OIL][
globalDofIdx] = fip[oilPhaseIdx];
1567 if (FluidSystem::phaseIsActive(oilPhaseIdx) &&
1568 !this->fip_[Inplace::Phase::OilInLiquidPhase].empty())
1570 this->fip_[Inplace::Phase::OilInLiquidPhase][
globalDofIdx] = fip[oilPhaseIdx];
1573 if (FluidSystem::phaseIsActive(gasPhaseIdx) &&
1574 !this->fip_[Inplace::Phase::GAS].empty())
1576 this->fip_[Inplace::Phase::GAS][
globalDofIdx] = fip[gasPhaseIdx];
1579 if (FluidSystem::phaseIsActive(gasPhaseIdx) &&
1580 !this->fip_[Inplace::Phase::GasInGasPhase].empty())
1582 this->fip_[Inplace::Phase::GasInGasPhase][
globalDofIdx] = fip[gasPhaseIdx];
1585 if (FluidSystem::phaseIsActive(waterPhaseIdx) &&
1586 !this->fip_[Inplace::Phase::WATER].empty())
1588 this->fip_[Inplace::Phase::WATER][
globalDofIdx] = fip[waterPhaseIdx];
1592 template <
typename Flu
idState,
typename FIPArray>
1593 void updateInplaceVolumesReservoir(
const unsigned globalDofIdx,
1594 const FluidState&
fs,
1597 if (FluidSystem::phaseIsActive(oilPhaseIdx) &&
1598 !this->fip_[Inplace::Phase::OilResVolume].empty())
1600 this->fip_[Inplace::Phase::OilResVolume][
globalDofIdx] =
fipr[oilPhaseIdx];
1603 if (FluidSystem::phaseIsActive(gasPhaseIdx) &&
1604 !this->fip_[Inplace::Phase::GasResVolume].empty())
1606 this->fip_[Inplace::Phase::GasResVolume][
globalDofIdx] =
fipr[gasPhaseIdx];
1609 if (FluidSystem::phaseIsActive(waterPhaseIdx) &&
1610 !this->fip_[Inplace::Phase::WaterResVolume].empty())
1612 this->fip_[Inplace::Phase::WaterResVolume][
globalDofIdx] =
fipr[waterPhaseIdx];
1615 if (FluidSystem::phaseIsActive(waterPhaseIdx) &&
1616 !this->fip_[Inplace::Phase::SALT].empty())
1619 fipr[waterPhaseIdx] *
fs.saltConcentration().value();
1623 template <
typename Flu
idState,
typename FIPArray>
1624 void updateOilGasDistribution(
const unsigned globalDofIdx,
1625 const FluidState&
fs,
1632 if (!this->fip_[Inplace::Phase::GasInLiquidPhase].empty()) {
1636 if (!this->fip_[Inplace::Phase::OilInGasPhase].empty()) {
1641 if (!this->fip_[Inplace::Phase::OIL].empty()) {
1645 if (!this->fip_[Inplace::Phase::GAS].empty()) {
1650 template <
typename Flu
idState,
typename FIPArray>
1651 void updateGasWaterDistribution(
const unsigned globalDofIdx,
1652 const FluidState&
fs,
1659 if (!this->fip_[Inplace::Phase::WaterInGasPhase].empty()) {
1663 if (!this->fip_[Inplace::Phase::WaterInWaterPhase].empty()) {
1664 this->fip_[Inplace::Phase::WaterInWaterPhase][
globalDofIdx] = fip[waterPhaseIdx];
1668 if (!this->fip_[Inplace::Phase::GasInLiquidPhase].empty() &&
1669 !FluidSystem::phaseIsActive(oilPhaseIdx))
1675 if (!this->fip_[Inplace::Phase::WATER].empty()) {
1679 if (!this->fip_[Inplace::Phase::GAS].empty()) {
1684 template <
typename IntensiveQuantities>
1694 if (this->simulator_.problem().materialLawManager()->enableHysteresis()) {
1699 const Scalar
sg =
getValue(
fs.saturation(gasPhaseIdx));
1701 const Scalar
xgW = FluidSystem::phaseIsActive(waterPhaseIdx)
1702 ? FluidSystem::convertRvwToXgW(
getValue(
fs.Rvw()),
fs.pvtRegionIndex())
1705 const Scalar
mM = FluidSystem::molarMass(gasCompIdx,
fs.pvtRegionIndex());
1707 if (!this->fip_[Inplace::Phase::CO2Mass].empty()) {
1711 if (!this->fip_[Inplace::Phase::CO2MassInGasPhase].empty()) {
1715 if (!this->fip_[Inplace::Phase::CO2InGasPhaseInMob].empty()) {
1720 if (!this->fip_[Inplace::Phase::CO2InGasPhaseMob].empty()) {
1725 if (!this->fip_[Inplace::Phase::CO2InGasPhaseInMobKrg].empty()) {
1730 this->fip_[Inplace::Phase::CO2InGasPhaseInMobKrg][
globalDofIdx] = 0;
1734 if (!this->fip_[Inplace::Phase::CO2InGasPhaseMobKrg].empty()) {
1739 this->fip_[Inplace::Phase::CO2InGasPhaseMobKrg][
globalDofIdx] = 0;
1743 if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseInMob].empty()) {
1748 if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseMob].empty()) {
1753 if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseInMobKrg].empty()) {
1758 this->fip_[Inplace::Phase::CO2MassInGasPhaseInMobKrg][
globalDofIdx] = 0;
1762 if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseMobKrg].empty()) {
1767 this->fip_[Inplace::Phase::CO2MassInGasPhaseMobKrg][
globalDofIdx] = 0;
1771 if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseMaximumTrapped].empty() ||
1772 !this->fip_[Inplace::Phase::CO2MassInGasPhaseMaximumUnTrapped].empty() ) {
1774 if (this->simulator_.problem().materialLawManager()->enableHysteresis()) {
1779 if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseMaximumTrapped].empty()) {
1783 if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseMaximumUnTrapped].empty()) {
1789 if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseEffectiveTrapped].empty() ||
1790 !this->fip_[Inplace::Phase::CO2MassInGasPhaseEffectiveUnTrapped].empty()) {
1792 if (this->simulator_.problem().materialLawManager()->enableHysteresis()) {
1797 if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseEffectiveTrapped].empty()) {
1801 if (!this->fip_[Inplace::Phase::CO2MassInGasPhaseEffectiveUnTrapped].empty()) {
1808 template <
typename Flu
idState>
1811 const FluidState&
fs)
1813 const auto co2InWater = FluidSystem::phaseIsActive(oilPhaseIdx)
1814 ? this->co2InWaterFromOil(
fs, pv)
1815 :
this->co2InWaterFromWater(
fs, pv);
1817 const Scalar
mM = FluidSystem::molarMass(gasCompIdx,
fs.pvtRegionIndex());
1818 if (!this->fip_[Inplace::Phase::CO2Mass].empty()) {
1821 if (!this->fip_[Inplace::Phase::CO2MassInWaterPhase].empty()) {
1824 if (!this->fip_[Inplace::Phase::CO2InWaterPhase].empty()) {
1829 template <
typename Flu
idState>
1830 Scalar co2InWaterFromWater(
const FluidState&
fs,
const double pv)
const
1833 const double sw =
getValue(
fs.saturation(waterPhaseIdx));
1834 const double xwG = FluidSystem::convertRswToXwG(
getValue(
fs.Rsw()),
fs.pvtRegionIndex());
1836 const Scalar
mM = FluidSystem::molarMass(gasCompIdx,
fs.pvtRegionIndex());
1841 template <
typename Flu
idState>
1842 Scalar co2InWaterFromOil(
const FluidState&
fs,
const double pv)
const
1845 const double so =
getValue(
fs.saturation(oilPhaseIdx));
1846 const double xoG = FluidSystem::convertRsToXoG(
getValue(
fs.Rs()),
fs.pvtRegionIndex());
1848 const Scalar
mM = FluidSystem::molarMass(gasCompIdx,
fs.pvtRegionIndex());
1853 const Simulator& simulator_;