Merge pull request #4372 from totto82/fix_gp

output gas pressure for gas-water case
This commit is contained in:
Bård Skaflestad 2023-01-16 11:11:39 +01:00 committed by GitHub
commit 2691e6328f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 213 additions and 261 deletions

View File

@ -682,7 +682,7 @@ assignToSolution(data::Solution& sol)
{"PORV_RC", UnitSystem::measure::identity, data::TargetType::RESTART_AUXILIARY, rockCompPorvMultiplier_}, {"PORV_RC", UnitSystem::measure::identity, data::TargetType::RESTART_AUXILIARY, rockCompPorvMultiplier_},
{"PPCW", UnitSystem::measure::pressure, data::TargetType::RESTART_SOLUTION, ppcw_}, {"PPCW", UnitSystem::measure::pressure, data::TargetType::RESTART_SOLUTION, ppcw_},
{"PRESROCC", UnitSystem::measure::pressure, data::TargetType::RESTART_SOLUTION, minimumOilPressure_}, {"PRESROCC", UnitSystem::measure::pressure, data::TargetType::RESTART_SOLUTION, minimumOilPressure_},
{"PRESSURE", UnitSystem::measure::pressure, data::TargetType::RESTART_SOLUTION, oilPressure_}, {"PRESSURE", UnitSystem::measure::pressure, data::TargetType::RESTART_SOLUTION, fluidPressure_},
{"PCOW", UnitSystem::measure::pressure, data::TargetType::RESTART_SOLUTION, pcow_}, {"PCOW", UnitSystem::measure::pressure, data::TargetType::RESTART_SOLUTION, pcow_},
{"PCOG", UnitSystem::measure::pressure, data::TargetType::RESTART_SOLUTION, pcog_}, {"PCOG", UnitSystem::measure::pressure, data::TargetType::RESTART_SOLUTION, pcog_},
{"PRES_OVB", UnitSystem::measure::pressure, data::TargetType::RESTART_SOLUTION, overburdenPressure_}, {"PRES_OVB", UnitSystem::measure::pressure, data::TargetType::RESTART_SOLUTION, overburdenPressure_},
@ -788,8 +788,8 @@ setRestart(const data::Solution& sol,
assert(!saturation_[oilPhaseIdx].empty()); assert(!saturation_[oilPhaseIdx].empty());
saturation_[oilPhaseIdx][elemIdx] = so; saturation_[oilPhaseIdx][elemIdx] = so;
if (!oilPressure_.empty() && sol.has("PRESSURE")) if (!fluidPressure_.empty() && sol.has("PRESSURE"))
oilPressure_[elemIdx] = sol.data("PRESSURE")[globalDofIndex]; fluidPressure_[elemIdx] = sol.data("PRESSURE")[globalDofIndex];
if (!temperature_.empty() && sol.has("TEMP")) if (!temperature_.empty() && sol.has("TEMP"))
temperature_[elemIdx] = sol.data("TEMP")[globalDofIndex]; temperature_[elemIdx] = sol.data("TEMP")[globalDofIndex];
if (!rs_.empty() && sol.has("RS")) if (!rs_.empty() && sol.has("RS"))
@ -969,7 +969,7 @@ doAllocBuffers(unsigned bufferSize,
saturation_[phaseIdx].resize(bufferSize, 0.0); saturation_[phaseIdx].resize(bufferSize, 0.0);
} }
// and oil pressure // and oil pressure
oilPressure_.resize(bufferSize, 0.0); fluidPressure_.resize(bufferSize, 0.0);
rstKeywords["PRES"] = 0; rstKeywords["PRES"] = 0;
rstKeywords["PRESSURE"] = 0; rstKeywords["PRESSURE"] = 0;

View File

@ -48,11 +48,11 @@ template<class FluidSystem, class Scalar>
class EclGenericOutputBlackoilModule { class EclGenericOutputBlackoilModule {
public: public:
Scalar* getPRESSURE_ptr(void) { Scalar* getPRESSURE_ptr(void) {
return (this->oilPressure_.data()) ; return (this->fluidPressure_.data()) ;
}; };
int getPRESSURE_size( void ) { int getPRESSURE_size( void ) {
return (this->oilPressure_.size()) ; return (this->fluidPressure_.size()) ;
}; };
// write cumulative production and injection reports to output // write cumulative production and injection reports to output
@ -411,7 +411,7 @@ protected:
ScalarBuffer pressureTimesPoreVolume_; ScalarBuffer pressureTimesPoreVolume_;
ScalarBuffer pressureTimesHydrocarbonVolume_; ScalarBuffer pressureTimesHydrocarbonVolume_;
ScalarBuffer dynamicPoreVolume_; ScalarBuffer dynamicPoreVolume_;
ScalarBuffer oilPressure_; ScalarBuffer fluidPressure_;
ScalarBuffer temperature_; ScalarBuffer temperature_;
ScalarBuffer rs_; ScalarBuffer rs_;
ScalarBuffer rsw_; ScalarBuffer rsw_;

View File

@ -32,8 +32,8 @@
#include <opm/models/blackoil/blackoilproperties.hh> #include <opm/models/blackoil/blackoilproperties.hh>
#include <opm/models/utils/propertysystem.hh>
#include <opm/models/utils/parametersystem.hh> #include <opm/models/utils/parametersystem.hh>
#include <opm/models/utils/propertysystem.hh>
#include <opm/material/common/Valgrind.hpp> #include <opm/material/common/Valgrind.hpp>
@ -59,37 +59,41 @@
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
namespace Opm::Properties { namespace Opm::Properties
{
// create new type tag for the Ecl-output // create new type tag for the Ecl-output
namespace TTag { namespace TTag
struct EclOutputBlackOil {}; {
} struct EclOutputBlackOil {
};
} // namespace TTag
template<class TypeTag, class MyTypeTag> template <class TypeTag, class MyTypeTag>
struct ForceDisableFluidInPlaceOutput { struct ForceDisableFluidInPlaceOutput {
using type = UndefinedProperty; using type = UndefinedProperty;
}; };
template<class TypeTag> template <class TypeTag>
struct ForceDisableFluidInPlaceOutput<TypeTag, TTag::EclOutputBlackOil> { struct ForceDisableFluidInPlaceOutput<TypeTag, TTag::EclOutputBlackOil> {
static constexpr bool value = false; static constexpr bool value = false;
}; };
template<class TypeTag, class MyTypeTag> template <class TypeTag, class MyTypeTag>
struct ForceDisableResvFluidInPlaceOutput { struct ForceDisableResvFluidInPlaceOutput {
using type = UndefinedProperty; using type = UndefinedProperty;
}; };
template<class TypeTag> template <class TypeTag>
struct ForceDisableResvFluidInPlaceOutput<TypeTag, TTag::EclOutputBlackOil> { struct ForceDisableResvFluidInPlaceOutput<TypeTag, TTag::EclOutputBlackOil> {
static constexpr bool value = false; static constexpr bool value = false;
}; };
} // namespace Opm::Properties } // namespace Opm::Properties
namespace Opm { namespace Opm
{
// forward declaration // forward declaration
template <class TypeTag> template <class TypeTag>
@ -128,9 +132,9 @@ class EclOutputBlackOilModule : public EclGenericOutputBlackoilModule<GetPropTyp
public: public:
template <class CollectDataToIORankType> template <class CollectDataToIORankType>
EclOutputBlackOilModule(const Simulator& simulator, EclOutputBlackOilModule(const Simulator& simulator,
const std::vector<std::size_t>& wbp_index_list, const std::vector<std::size_t>& wbp_index_list,
const CollectDataToIORankType& collectToIORank) const CollectDataToIORankType& collectToIORank)
: BaseType(simulator.vanguard().eclState(), : BaseType(simulator.vanguard().eclState(),
simulator.vanguard().schedule(), simulator.vanguard().schedule(),
simulator.vanguard().summaryConfig(), simulator.vanguard().summaryConfig(),
@ -144,19 +148,17 @@ public:
getPropValue<TypeTag, Properties::EnableSaltPrecipitation>(), getPropValue<TypeTag, Properties::EnableSaltPrecipitation>(),
getPropValue<TypeTag, Properties::EnableExtbo>(), getPropValue<TypeTag, Properties::EnableExtbo>(),
getPropValue<TypeTag, Properties::EnableMICP>()) getPropValue<TypeTag, Properties::EnableMICP>())
, simulator_(simulator) , simulator_(simulator)
{ {
for (auto& region_pair : this->regions_) { for (auto& region_pair : this->regions_) {
this->createLocalRegion_(region_pair.second); this->createLocalRegion_(region_pair.second);
} }
for (const auto& node : this->simulator_.vanguard().summaryConfig()) { for (const auto& node : this->simulator_.vanguard().summaryConfig()) {
if ((node.category() == SummaryConfigNode::Category::Block) && if ((node.category() == SummaryConfigNode::Category::Block)
collectToIORank.isCartIdxOnThisRank(node.number() - 1)) && collectToIORank.isCartIdxOnThisRank(node.number() - 1)) {
{
this->blockData_.emplace(std::piecewise_construct, this->blockData_.emplace(std::piecewise_construct,
std::forward_as_tuple(node.keyword(), std::forward_as_tuple(node.keyword(), node.number()),
node.number()),
std::forward_as_tuple(0.0)); std::forward_as_tuple(0.0));
} }
} }
@ -167,11 +169,9 @@ public:
} }
} }
this->forceDisableFipOutput_ = this->forceDisableFipOutput_ = EWOMS_GET_PARAM(TypeTag, bool, ForceDisableFluidInPlaceOutput);
EWOMS_GET_PARAM(TypeTag, bool, ForceDisableFluidInPlaceOutput);
this->forceDisableFipresvOutput_ = this->forceDisableFipresvOutput_ = EWOMS_GET_PARAM(TypeTag, bool, ForceDisableResvFluidInPlaceOutput);
EWOMS_GET_PARAM(TypeTag, bool, ForceDisableResvFluidInPlaceOutput);
} }
/*! /*!
@ -179,19 +179,26 @@ public:
*/ */
static void registerParameters() static void registerParameters()
{ {
EWOMS_REGISTER_PARAM(TypeTag, bool, ForceDisableFluidInPlaceOutput, EWOMS_REGISTER_PARAM(
"Do not print fluid-in-place values after each report step even if requested by the deck."); TypeTag,
EWOMS_REGISTER_PARAM(TypeTag, bool, ForceDisableResvFluidInPlaceOutput, bool,
"Do not print reservoir volumes values after each report step even if requested by the deck."); ForceDisableFluidInPlaceOutput,
"Do not print fluid-in-place values after each report step even if requested by the deck.");
EWOMS_REGISTER_PARAM(
TypeTag,
bool,
ForceDisableResvFluidInPlaceOutput,
"Do not print reservoir volumes values after each report step even if requested by the deck.");
} }
/*! /*!
* \brief Allocate memory for the scalar fields we would like to * \brief Allocate memory for the scalar fields we would like to
* write to ECL output files * write to ECL output files
*/ */
void allocBuffers(unsigned bufferSize, unsigned reportStepNum, const bool substep, const bool log, const bool isRestart) void
allocBuffers(unsigned bufferSize, unsigned reportStepNum, const bool substep, const bool log, const bool isRestart)
{ {
if (!std::is_same<Discretization, EcfvDiscretization<TypeTag> >::value) if (!std::is_same<Discretization, EcfvDiscretization<TypeTag>>::value)
return; return;
this->doAllocBuffers(bufferSize, this->doAllocBuffers(bufferSize,
@ -210,7 +217,7 @@ public:
*/ */
void processElement(const ElementContext& elemCtx) void processElement(const ElementContext& elemCtx)
{ {
if (!std::is_same<Discretization, EcfvDiscretization<TypeTag> >::value) if (!std::is_same<Discretization, EcfvDiscretization<TypeTag>>::value)
return; return;
const auto& problem = elemCtx.simulator().problem(); const auto& problem = elemCtx.simulator().problem();
@ -222,7 +229,7 @@ public:
unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0); unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0);
unsigned pvtRegionIdx = elemCtx.primaryVars(dofIdx, /*timeIdx=*/0).pvtRegionIndex(); unsigned pvtRegionIdx = elemCtx.primaryVars(dofIdx, /*timeIdx=*/0).pvtRegionIndex();
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) { for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
if (this->saturation_[phaseIdx].empty()) if (this->saturation_[phaseIdx].empty())
continue; continue;
@ -230,18 +237,18 @@ public:
Valgrind::CheckDefined(this->saturation_[phaseIdx][globalDofIdx]); Valgrind::CheckDefined(this->saturation_[phaseIdx][globalDofIdx]);
} }
if (!this->oilPressure_.empty()) { if (!this->fluidPressure_.empty()) {
if (FluidSystem::phaseIsActive(oilPhaseIdx)) { if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
this->oilPressure_[globalDofIdx] = getValue(fs.pressure(oilPhaseIdx)); // Output oil pressure as default
}else{ this->fluidPressure_[globalDofIdx] = getValue(fs.pressure(oilPhaseIdx));
// put pressure in oil pressure for output } else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
if (FluidSystem::phaseIsActive(waterPhaseIdx)) { // Output gas if oil is not present
this->oilPressure_[globalDofIdx] = getValue(fs.pressure(waterPhaseIdx)); this->fluidPressure_[globalDofIdx] = getValue(fs.pressure(gasPhaseIdx));
} else { } else {
this->oilPressure_[globalDofIdx] = getValue(fs.pressure(gasPhaseIdx)); // Output water if neither oil nor gas is present
} this->fluidPressure_[globalDofIdx] = getValue(fs.pressure(waterPhaseIdx));
} }
Valgrind::CheckDefined(this->oilPressure_[globalDofIdx]); Valgrind::CheckDefined(this->fluidPressure_[globalDofIdx]);
} }
if (!this->temperature_.empty()) { if (!this->temperature_.empty()) {
@ -250,35 +257,34 @@ public:
} }
if (!this->gasDissolutionFactor_.empty()) { if (!this->gasDissolutionFactor_.empty()) {
Scalar SoMax = elemCtx.problem().maxOilSaturation(globalDofIdx); Scalar SoMax = elemCtx.problem().maxOilSaturation(globalDofIdx);
this->gasDissolutionFactor_[globalDofIdx] = this->gasDissolutionFactor_[globalDofIdx]
FluidSystem::template saturatedDissolutionFactor<FluidState, Scalar>(fs, oilPhaseIdx, pvtRegionIdx, SoMax); = FluidSystem::template saturatedDissolutionFactor<FluidState, Scalar>(
fs, oilPhaseIdx, pvtRegionIdx, SoMax);
Valgrind::CheckDefined(this->gasDissolutionFactor_[globalDofIdx]); Valgrind::CheckDefined(this->gasDissolutionFactor_[globalDofIdx]);
} }
if (!this->oilVaporizationFactor_.empty()) { if (!this->oilVaporizationFactor_.empty()) {
Scalar SoMax = elemCtx.problem().maxOilSaturation(globalDofIdx); Scalar SoMax = elemCtx.problem().maxOilSaturation(globalDofIdx);
this->oilVaporizationFactor_[globalDofIdx] = this->oilVaporizationFactor_[globalDofIdx]
FluidSystem::template saturatedDissolutionFactor<FluidState, Scalar>(fs, gasPhaseIdx, pvtRegionIdx, SoMax); = FluidSystem::template saturatedDissolutionFactor<FluidState, Scalar>(
fs, gasPhaseIdx, pvtRegionIdx, SoMax);
Valgrind::CheckDefined(this->oilVaporizationFactor_[globalDofIdx]); Valgrind::CheckDefined(this->oilVaporizationFactor_[globalDofIdx]);
} }
if (!this->gasFormationVolumeFactor_.empty()) { if (!this->gasFormationVolumeFactor_.empty()) {
this->gasFormationVolumeFactor_[globalDofIdx] = this->gasFormationVolumeFactor_[globalDofIdx] = 1.0
1.0/FluidSystem::template inverseFormationVolumeFactor<FluidState, Scalar>(fs, gasPhaseIdx, pvtRegionIdx); / FluidSystem::template inverseFormationVolumeFactor<FluidState, Scalar>(
fs, gasPhaseIdx, pvtRegionIdx);
Valgrind::CheckDefined(this->gasFormationVolumeFactor_[globalDofIdx]); Valgrind::CheckDefined(this->gasFormationVolumeFactor_[globalDofIdx]);
} }
if (!this->saturatedOilFormationVolumeFactor_.empty()) { if (!this->saturatedOilFormationVolumeFactor_.empty()) {
this->saturatedOilFormationVolumeFactor_[globalDofIdx] = this->saturatedOilFormationVolumeFactor_[globalDofIdx] = 1.0
1.0/FluidSystem::template saturatedInverseFormationVolumeFactor<FluidState, Scalar>(fs, oilPhaseIdx, pvtRegionIdx); / FluidSystem::template saturatedInverseFormationVolumeFactor<FluidState, Scalar>(
fs, oilPhaseIdx, pvtRegionIdx);
Valgrind::CheckDefined(this->saturatedOilFormationVolumeFactor_[globalDofIdx]); Valgrind::CheckDefined(this->saturatedOilFormationVolumeFactor_[globalDofIdx]);
} }
if (!this->oilSaturationPressure_.empty()) { if (!this->oilSaturationPressure_.empty()) {
this->oilSaturationPressure_[globalDofIdx] = this->oilSaturationPressure_[globalDofIdx]
FluidSystem::template saturationPressure<FluidState, Scalar>(fs, oilPhaseIdx, pvtRegionIdx); = FluidSystem::template saturationPressure<FluidState, Scalar>(fs, oilPhaseIdx, pvtRegionIdx);
Valgrind::CheckDefined(this->oilSaturationPressure_[globalDofIdx]); Valgrind::CheckDefined(this->oilSaturationPressure_[globalDofIdx]);
} }
if (!this->rs_.empty()) { if (!this->rs_.empty()) {
@ -308,7 +314,7 @@ public:
Valgrind::CheckDefined(this->rvw_[globalDofIdx]); Valgrind::CheckDefined(this->rvw_[globalDofIdx]);
} }
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) { for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
if (this->invB_[phaseIdx].empty()) if (this->invB_[phaseIdx].empty())
continue; continue;
@ -316,7 +322,7 @@ public:
Valgrind::CheckDefined(this->invB_[phaseIdx][globalDofIdx]); Valgrind::CheckDefined(this->invB_[phaseIdx][globalDofIdx]);
} }
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) { for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
if (this->density_[phaseIdx].empty()) if (this->density_[phaseIdx].empty())
continue; continue;
@ -324,24 +330,25 @@ public:
Valgrind::CheckDefined(this->density_[phaseIdx][globalDofIdx]); Valgrind::CheckDefined(this->density_[phaseIdx][globalDofIdx]);
} }
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) { for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
if (this->viscosity_[phaseIdx].empty()) if (this->viscosity_[phaseIdx].empty())
continue; continue;
if (!this->extboX_.empty() && phaseIdx==oilPhaseIdx) if (!this->extboX_.empty() && phaseIdx == oilPhaseIdx)
this->viscosity_[phaseIdx][globalDofIdx] = getValue(intQuants.oilViscosity()); this->viscosity_[phaseIdx][globalDofIdx] = getValue(intQuants.oilViscosity());
else if (!this->extboX_.empty() && phaseIdx==gasPhaseIdx) else if (!this->extboX_.empty() && phaseIdx == gasPhaseIdx)
this->viscosity_[phaseIdx][globalDofIdx] = getValue(intQuants.gasViscosity()); this->viscosity_[phaseIdx][globalDofIdx] = getValue(intQuants.gasViscosity());
else else
this->viscosity_[phaseIdx][globalDofIdx] = getValue(fs.viscosity(phaseIdx)); this->viscosity_[phaseIdx][globalDofIdx] = getValue(fs.viscosity(phaseIdx));
Valgrind::CheckDefined(this->viscosity_[phaseIdx][globalDofIdx]); Valgrind::CheckDefined(this->viscosity_[phaseIdx][globalDofIdx]);
} }
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) { for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
if (this->relativePermeability_[phaseIdx].empty()) if (this->relativePermeability_[phaseIdx].empty())
continue; continue;
this->relativePermeability_[phaseIdx][globalDofIdx] = getValue(intQuants.relativePermeability(phaseIdx)); this->relativePermeability_[phaseIdx][globalDofIdx]
= getValue(intQuants.relativePermeability(phaseIdx));
Valgrind::CheckDefined(this->relativePermeability_[phaseIdx][globalDofIdx]); Valgrind::CheckDefined(this->relativePermeability_[phaseIdx][globalDofIdx]);
} }
@ -372,7 +379,7 @@ public:
if (!this->permFact_.empty()) { if (!this->permFact_.empty()) {
this->permFact_[globalDofIdx] = intQuants.permFactor().value(); this->permFact_[globalDofIdx] = intQuants.permFactor().value();
} }
if (!this->extboX_.empty()) { if (!this->extboX_.empty()) {
this->extboX_[globalDofIdx] = intQuants.xVolume().value(); this->extboX_[globalDofIdx] = intQuants.xVolume().value();
} }
@ -386,19 +393,23 @@ public:
} }
if (!this->mFracCo2_.empty()) { if (!this->mFracCo2_.empty()) {
const Scalar stdVolOil = getValue(fs.saturation(oilPhaseIdx))*getValue(fs.invB(oilPhaseIdx)) const Scalar stdVolOil = getValue(fs.saturation(oilPhaseIdx)) * getValue(fs.invB(oilPhaseIdx))
+ getValue(fs.saturation(gasPhaseIdx))*getValue(fs.invB(gasPhaseIdx))*getValue(fs.Rv()); + getValue(fs.saturation(gasPhaseIdx)) * getValue(fs.invB(gasPhaseIdx)) * getValue(fs.Rv());
const Scalar stdVolGas = getValue(fs.saturation(gasPhaseIdx))*getValue(fs.invB(gasPhaseIdx))*(1.0-intQuants.yVolume().value()) const Scalar stdVolGas = getValue(fs.saturation(gasPhaseIdx)) * getValue(fs.invB(gasPhaseIdx))
+ getValue(fs.saturation(oilPhaseIdx))*getValue(fs.invB(oilPhaseIdx))*getValue(fs.Rs())*(1.0-intQuants.xVolume().value()); * (1.0 - intQuants.yVolume().value())
const Scalar stdVolCo2 = getValue(fs.saturation(gasPhaseIdx))*getValue(fs.invB(gasPhaseIdx))*intQuants.yVolume().value() + getValue(fs.saturation(oilPhaseIdx)) * getValue(fs.invB(oilPhaseIdx)) * getValue(fs.Rs())
+ getValue(fs.saturation(oilPhaseIdx))*getValue(fs.invB(oilPhaseIdx))*getValue(fs.Rs())*intQuants.xVolume().value(); * (1.0 - intQuants.xVolume().value());
const Scalar rhoO= FluidSystem::referenceDensity(gasPhaseIdx, pvtRegionIdx); const Scalar stdVolCo2 = getValue(fs.saturation(gasPhaseIdx)) * getValue(fs.invB(gasPhaseIdx))
const Scalar rhoG= FluidSystem::referenceDensity(gasPhaseIdx, pvtRegionIdx); * intQuants.yVolume().value()
const Scalar rhoCO2= intQuants.zRefDensity(); + getValue(fs.saturation(oilPhaseIdx)) * getValue(fs.invB(oilPhaseIdx)) * getValue(fs.Rs())
const Scalar stdMassTotal= 1.0e-10 + stdVolOil*rhoO + stdVolGas*rhoG + stdVolCo2*rhoCO2; * intQuants.xVolume().value();
this->mFracOil_[globalDofIdx] = stdVolOil*rhoO/stdMassTotal; const Scalar rhoO = FluidSystem::referenceDensity(gasPhaseIdx, pvtRegionIdx);
this->mFracGas_[globalDofIdx] = stdVolGas*rhoG/stdMassTotal; const Scalar rhoG = FluidSystem::referenceDensity(gasPhaseIdx, pvtRegionIdx);
this->mFracCo2_[globalDofIdx] = stdVolCo2*rhoCO2/stdMassTotal; const Scalar rhoCO2 = intQuants.zRefDensity();
const Scalar stdMassTotal = 1.0e-10 + stdVolOil * rhoO + stdVolGas * rhoG + stdVolCo2 * rhoCO2;
this->mFracOil_[globalDofIdx] = stdVolOil * rhoO / stdMassTotal;
this->mFracGas_[globalDofIdx] = stdVolGas * rhoG / stdMassTotal;
this->mFracCo2_[globalDofIdx] = stdVolCo2 * rhoCO2 / stdMassTotal;
} }
if (!this->cMicrobes_.empty()) { if (!this->cMicrobes_.empty()) {
@ -410,7 +421,9 @@ public:
} }
if (!this->cUrea_.empty()) { if (!this->cUrea_.empty()) {
this->cUrea_[globalDofIdx] = 10 * intQuants.ureaConcentration().value(); //Reescaling back the urea concentration (see WellInterface_impl.hpp) this->cUrea_[globalDofIdx] = 10
* intQuants.ureaConcentration()
.value(); // Reescaling back the urea concentration (see WellInterface_impl.hpp)
} }
if (!this->cBiofilm_.empty()) { if (!this->cBiofilm_.empty()) {
@ -423,67 +436,62 @@ public:
if (!this->bubblePointPressure_.empty()) { if (!this->bubblePointPressure_.empty()) {
try { try {
this->bubblePointPressure_[globalDofIdx] = getValue(FluidSystem::bubblePointPressure(fs, intQuants.pvtRegionIndex())); this->bubblePointPressure_[globalDofIdx]
} = getValue(FluidSystem::bubblePointPressure(fs, intQuants.pvtRegionIndex()));
catch (const NumericalProblem&) { } catch (const NumericalProblem&) {
const auto cartesianIdx = elemCtx.simulator().vanguard().cartesianIndex(globalDofIdx); const auto cartesianIdx = elemCtx.simulator().vanguard().cartesianIndex(globalDofIdx);
this->failedCellsPb_.push_back(cartesianIdx); this->failedCellsPb_.push_back(cartesianIdx);
} }
} }
if (!this->dewPointPressure_.empty()) { if (!this->dewPointPressure_.empty()) {
try { try {
this->dewPointPressure_[globalDofIdx] = getValue(FluidSystem::dewPointPressure(fs, intQuants.pvtRegionIndex())); this->dewPointPressure_[globalDofIdx]
} = getValue(FluidSystem::dewPointPressure(fs, intQuants.pvtRegionIndex()));
catch (const NumericalProblem&) { } catch (const NumericalProblem&) {
const auto cartesianIdx = elemCtx.simulator().vanguard().cartesianIndex(globalDofIdx); const auto cartesianIdx = elemCtx.simulator().vanguard().cartesianIndex(globalDofIdx);
this->failedCellsPd_.push_back(cartesianIdx); this->failedCellsPd_.push_back(cartesianIdx);
} }
} }
if (!this->soMax_.empty()) if (!this->soMax_.empty())
this->soMax_[globalDofIdx] = this->soMax_[globalDofIdx]
std::max(getValue(fs.saturation(oilPhaseIdx)), = std::max(getValue(fs.saturation(oilPhaseIdx)), problem.maxOilSaturation(globalDofIdx));
problem.maxOilSaturation(globalDofIdx));
if (!this->swMax_.empty()) if (!this->swMax_.empty())
this->swMax_[globalDofIdx] = this->swMax_[globalDofIdx]
std::max(getValue(fs.saturation(waterPhaseIdx)), = std::max(getValue(fs.saturation(waterPhaseIdx)), problem.maxWaterSaturation(globalDofIdx));
problem.maxWaterSaturation(globalDofIdx));
if (!this->minimumOilPressure_.empty()) if (!this->minimumOilPressure_.empty())
this->minimumOilPressure_[globalDofIdx] = this->minimumOilPressure_[globalDofIdx]
std::min(getValue(fs.pressure(oilPhaseIdx)), = std::min(getValue(fs.pressure(oilPhaseIdx)), problem.minOilPressure(globalDofIdx));
problem.minOilPressure(globalDofIdx));
if (!this->overburdenPressure_.empty()) if (!this->overburdenPressure_.empty())
this->overburdenPressure_[globalDofIdx] = problem.overburdenPressure(globalDofIdx); this->overburdenPressure_[globalDofIdx] = problem.overburdenPressure(globalDofIdx);
if (!this->rockCompPorvMultiplier_.empty()) if (!this->rockCompPorvMultiplier_.empty())
this->rockCompPorvMultiplier_[globalDofIdx] = problem.template rockCompPoroMultiplier<Scalar>(intQuants, globalDofIdx); this->rockCompPorvMultiplier_[globalDofIdx]
= problem.template rockCompPoroMultiplier<Scalar>(intQuants, globalDofIdx);
if (!this->rockCompTransMultiplier_.empty()) if (!this->rockCompTransMultiplier_.empty())
this->rockCompTransMultiplier_[globalDofIdx] = problem.template rockCompTransMultiplier<Scalar>(intQuants, globalDofIdx); this->rockCompTransMultiplier_[globalDofIdx]
= problem.template rockCompTransMultiplier<Scalar>(intQuants, globalDofIdx);
const auto& matLawManager = problem.materialLawManager(); const auto& matLawManager = problem.materialLawManager();
if (matLawManager->enableHysteresis()) { if (matLawManager->enableHysteresis()) {
if (!this->pcSwMdcOw_.empty() && !this->krnSwMdcOw_.empty()) { if (!this->pcSwMdcOw_.empty() && !this->krnSwMdcOw_.empty()) {
matLawManager->oilWaterHysteresisParams( matLawManager->oilWaterHysteresisParams(
this->pcSwMdcOw_[globalDofIdx], this->pcSwMdcOw_[globalDofIdx], this->krnSwMdcOw_[globalDofIdx], globalDofIdx);
this->krnSwMdcOw_[globalDofIdx],
globalDofIdx);
} }
if (!this->pcSwMdcGo_.empty() && !this->krnSwMdcGo_.empty()) { if (!this->pcSwMdcGo_.empty() && !this->krnSwMdcGo_.empty()) {
matLawManager->gasOilHysteresisParams( matLawManager->gasOilHysteresisParams(
this->pcSwMdcGo_[globalDofIdx], this->pcSwMdcGo_[globalDofIdx], this->krnSwMdcGo_[globalDofIdx], globalDofIdx);
this->krnSwMdcGo_[globalDofIdx],
globalDofIdx);
} }
} }
if (!this->ppcw_.empty()) { if (!this->ppcw_.empty()) {
this->ppcw_[globalDofIdx] = matLawManager->oilWaterScaledEpsInfoDrainage(globalDofIdx).maxPcow; this->ppcw_[globalDofIdx] = matLawManager->oilWaterScaledEpsInfoDrainage(globalDofIdx).maxPcow;
//printf("ppcw_[%d] = %lg\n", globalDofIdx, ppcw_[globalDofIdx]); // printf("ppcw_[%d] = %lg\n", globalDofIdx, ppcw_[globalDofIdx]);
} }
// hack to make the intial output of rs and rv Ecl compatible. // hack to make the intial output of rs and rv Ecl compatible.
// For cells with swat == 1 Ecl outputs; rs = rsSat and rv=rvSat, in all but the initial step // For cells with swat == 1 Ecl outputs; rs = rsSat and rv=rvSat, in all but the initial step
@ -491,7 +499,8 @@ public:
// rs and rv with the values computed in the initially. // rs and rv with the values computed in the initially.
// Volume factors, densities and viscosities need to be recalculated with the updated rs and rv values. // Volume factors, densities and viscosities need to be recalculated with the updated rs and rv values.
// This can be removed when ebos has 100% controll over output // This can be removed when ebos has 100% controll over output
if (elemCtx.simulator().episodeIndex() < 0 && FluidSystem::phaseIsActive(oilPhaseIdx) && FluidSystem::phaseIsActive(gasPhaseIdx)) { if (elemCtx.simulator().episodeIndex() < 0 && FluidSystem::phaseIsActive(oilPhaseIdx)
&& FluidSystem::phaseIsActive(gasPhaseIdx)) {
const auto& fsInitial = problem.initialFluidState(globalDofIdx); const auto& fsInitial = problem.initialFluidState(globalDofIdx);
@ -510,30 +519,24 @@ public:
// re-compute the volume factors, viscosities and densities if asked for // re-compute the volume factors, viscosities and densities if asked for
if (!this->density_[oilPhaseIdx].empty()) if (!this->density_[oilPhaseIdx].empty())
this->density_[oilPhaseIdx][globalDofIdx] = FluidSystem::density(fsInitial, this->density_[oilPhaseIdx][globalDofIdx]
oilPhaseIdx, = FluidSystem::density(fsInitial, oilPhaseIdx, intQuants.pvtRegionIndex());
intQuants.pvtRegionIndex());
if (!this->density_[gasPhaseIdx].empty()) if (!this->density_[gasPhaseIdx].empty())
this->density_[gasPhaseIdx][globalDofIdx] = FluidSystem::density(fsInitial, this->density_[gasPhaseIdx][globalDofIdx]
gasPhaseIdx, = FluidSystem::density(fsInitial, gasPhaseIdx, intQuants.pvtRegionIndex());
intQuants.pvtRegionIndex());
if (!this->invB_[oilPhaseIdx].empty()) if (!this->invB_[oilPhaseIdx].empty())
this->invB_[oilPhaseIdx][globalDofIdx] = FluidSystem::inverseFormationVolumeFactor(fsInitial, this->invB_[oilPhaseIdx][globalDofIdx]
oilPhaseIdx, = FluidSystem::inverseFormationVolumeFactor(fsInitial, oilPhaseIdx, intQuants.pvtRegionIndex());
intQuants.pvtRegionIndex());
if (!this->invB_[gasPhaseIdx].empty()) if (!this->invB_[gasPhaseIdx].empty())
this->invB_[gasPhaseIdx][globalDofIdx] = FluidSystem::inverseFormationVolumeFactor(fsInitial, this->invB_[gasPhaseIdx][globalDofIdx]
gasPhaseIdx, = FluidSystem::inverseFormationVolumeFactor(fsInitial, gasPhaseIdx, intQuants.pvtRegionIndex());
intQuants.pvtRegionIndex());
if (!this->viscosity_[oilPhaseIdx].empty()) if (!this->viscosity_[oilPhaseIdx].empty())
this->viscosity_[oilPhaseIdx][globalDofIdx] = FluidSystem::viscosity(fsInitial, this->viscosity_[oilPhaseIdx][globalDofIdx]
oilPhaseIdx, = FluidSystem::viscosity(fsInitial, oilPhaseIdx, intQuants.pvtRegionIndex());
intQuants.pvtRegionIndex());
if (!this->viscosity_[gasPhaseIdx].empty()) if (!this->viscosity_[gasPhaseIdx].empty())
this->viscosity_[gasPhaseIdx][globalDofIdx] = FluidSystem::viscosity(fsInitial, this->viscosity_[gasPhaseIdx][globalDofIdx]
gasPhaseIdx, = FluidSystem::viscosity(fsInitial, gasPhaseIdx, intQuants.pvtRegionIndex());
intQuants.pvtRegionIndex());
} }
// Add fluid in Place values // Add fluid in Place values
@ -541,7 +544,7 @@ public:
// Adding block data // Adding block data
const auto cartesianIdx = elemCtx.simulator().vanguard().cartesianIndex(globalDofIdx); const auto cartesianIdx = elemCtx.simulator().vanguard().cartesianIndex(globalDofIdx);
for (auto& val: this->blockData_) { for (auto& val : this->blockData_) {
const auto& key = val.first; const auto& key = val.first;
assert(key.second > 0); assert(key.second > 0);
unsigned int cartesianIdxBlock = key.second - 1; unsigned int cartesianIdxBlock = key.second - 1;
@ -554,23 +557,21 @@ public:
val.second = getValue(fs.saturation(oilPhaseIdx)); val.second = getValue(fs.saturation(oilPhaseIdx));
else if (key.first == "BNSAT") else if (key.first == "BNSAT")
val.second = intQuants.solventSaturation().value(); val.second = intQuants.solventSaturation().value();
else if ((key.first == "BPR") || (key.first == "BPRESSUR")){ else if ((key.first == "BPR") || (key.first == "BPRESSUR")) {
if (FluidSystem::phaseIsActive(oilPhaseIdx)) if (FluidSystem::phaseIsActive(oilPhaseIdx))
val.second = getValue(fs.pressure(oilPhaseIdx)); val.second = getValue(fs.pressure(oilPhaseIdx));
else if (FluidSystem::phaseIsActive(gasPhaseIdx)) else if (FluidSystem::phaseIsActive(gasPhaseIdx))
val.second = getValue(fs.pressure(gasPhaseIdx)); val.second = getValue(fs.pressure(gasPhaseIdx));
else if (FluidSystem::phaseIsActive(waterPhaseIdx)) else if (FluidSystem::phaseIsActive(waterPhaseIdx))
val.second = getValue(fs.pressure(waterPhaseIdx)); val.second = getValue(fs.pressure(waterPhaseIdx));
} } else if ((key.first == "BTCNFHEA") || (key.first == "BTEMP")) {
else if ((key.first == "BTCNFHEA") || (key.first == "BTEMP")){ if (FluidSystem::phaseIsActive(oilPhaseIdx))
if (FluidSystem::phaseIsActive(oilPhaseIdx))
val.second = getValue(fs.temperature(oilPhaseIdx)); val.second = getValue(fs.temperature(oilPhaseIdx));
else if (FluidSystem::phaseIsActive(gasPhaseIdx)) else if (FluidSystem::phaseIsActive(gasPhaseIdx))
val.second = getValue(fs.temperature(gasPhaseIdx)); val.second = getValue(fs.temperature(gasPhaseIdx));
else if (FluidSystem::phaseIsActive(waterPhaseIdx)) else if (FluidSystem::phaseIsActive(waterPhaseIdx))
val.second = getValue(fs.temperature(waterPhaseIdx)); val.second = getValue(fs.temperature(waterPhaseIdx));
} } else if (key.first == "BWKR" || key.first == "BKRW")
else if (key.first == "BWKR" || key.first == "BKRW")
val.second = getValue(intQuants.relativePermeability(waterPhaseIdx)); val.second = getValue(intQuants.relativePermeability(waterPhaseIdx));
else if (key.first == "BGKR" || key.first == "BKRG") else if (key.first == "BGKR" || key.first == "BKRG")
val.second = getValue(intQuants.relativePermeability(gasPhaseIdx)); val.second = getValue(intQuants.relativePermeability(gasPhaseIdx));
@ -578,15 +579,15 @@ public:
val.second = getValue(intQuants.relativePermeability(oilPhaseIdx)); val.second = getValue(intQuants.relativePermeability(oilPhaseIdx));
else if (key.first == "BKROG") { else if (key.first == "BKROG") {
const auto& materialParams = problem.materialLawParams(elemCtx, dofIdx, /* timeIdx = */ 0); const auto& materialParams = problem.materialLawParams(elemCtx, dofIdx, /* timeIdx = */ 0);
const auto krog = MaterialLaw::template relpermOilInOilGasSystem<Evaluation>(materialParams, fs); const auto krog
= MaterialLaw::template relpermOilInOilGasSystem<Evaluation>(materialParams, fs);
val.second = getValue(krog); val.second = getValue(krog);
} } else if (key.first == "BKROW") {
else if (key.first == "BKROW") {
const auto& materialParams = problem.materialLawParams(elemCtx, dofIdx, /* timeIdx = */ 0); const auto& materialParams = problem.materialLawParams(elemCtx, dofIdx, /* timeIdx = */ 0);
const auto krow = MaterialLaw::template relpermOilInOilWaterSystem<Evaluation>(materialParams, fs); const auto krow
= MaterialLaw::template relpermOilInOilWaterSystem<Evaluation>(materialParams, fs);
val.second = getValue(krow); val.second = getValue(krow);
} } else if (key.first == "BWPC")
else if (key.first == "BWPC")
val.second = getValue(fs.pressure(oilPhaseIdx)) - getValue(fs.pressure(waterPhaseIdx)); val.second = getValue(fs.pressure(oilPhaseIdx)) - getValue(fs.pressure(waterPhaseIdx));
else if (key.first == "BGPC") else if (key.first == "BGPC")
val.second = getValue(fs.pressure(gasPhaseIdx)) - getValue(fs.pressure(oilPhaseIdx)); val.second = getValue(fs.pressure(gasPhaseIdx)) - getValue(fs.pressure(oilPhaseIdx));
@ -600,76 +601,56 @@ public:
val.second = getValue(fs.viscosity(gasPhaseIdx)); val.second = getValue(fs.viscosity(gasPhaseIdx));
else if (key.first == "BVOIL" || key.first == "BOVIS") else if (key.first == "BVOIL" || key.first == "BOVIS")
val.second = getValue(fs.viscosity(oilPhaseIdx)); val.second = getValue(fs.viscosity(oilPhaseIdx));
else if ((key.first == "BRPV") || else if ((key.first == "BRPV") || (key.first == "BOPV") || (key.first == "BWPV")
(key.first == "BOPV") || || (key.first == "BGPV")) {
(key.first == "BWPV") ||
(key.first == "BGPV"))
{
if (key.first == "BRPV") { if (key.first == "BRPV") {
val.second = 1.0; val.second = 1.0;
} } else if (key.first == "BOPV") {
else if (key.first == "BOPV") {
val.second = getValue(fs.saturation(oilPhaseIdx)); val.second = getValue(fs.saturation(oilPhaseIdx));
} } else if (key.first == "BWPV") {
else if (key.first == "BWPV") {
val.second = getValue(fs.saturation(waterPhaseIdx)); val.second = getValue(fs.saturation(waterPhaseIdx));
} } else {
else {
val.second = getValue(fs.saturation(gasPhaseIdx)); val.second = getValue(fs.saturation(gasPhaseIdx));
} }
// Include active pore-volume. // Include active pore-volume.
val.second *= elemCtx.simulator().model().dofTotalVolume(globalDofIdx) val.second *= elemCtx.simulator().model().dofTotalVolume(globalDofIdx)
* getValue(intQuants.porosity()); * getValue(intQuants.porosity());
} } else if (key.first == "BRS")
else if (key.first == "BRS")
val.second = getValue(fs.Rs()); val.second = getValue(fs.Rs());
else if (key.first == "BRV") else if (key.first == "BRV")
val.second = getValue(fs.Rv()); val.second = getValue(fs.Rv());
else if ((key.first == "BOIP") || else if ((key.first == "BOIP") || (key.first == "BOIPL") || (key.first == "BOIPG")
(key.first == "BOIPL") || || (key.first == "BGIP") || (key.first == "BGIPL") || (key.first == "BGIPG")
(key.first == "BOIPG") || || (key.first == "BWIP")) {
(key.first == "BGIP") ||
(key.first == "BGIPL") ||
(key.first == "BGIPG") ||
(key.first == "BWIP"))
{
if ((key.first == "BOIP") || (key.first == "BOIPL")) { if ((key.first == "BOIP") || (key.first == "BOIPL")) {
val.second = getValue(fs.invB(oilPhaseIdx)) val.second = getValue(fs.invB(oilPhaseIdx)) * getValue(fs.saturation(oilPhaseIdx));
* getValue(fs.saturation(oilPhaseIdx));
if (key.first == "BOIP") { if (key.first == "BOIP") {
val.second += getValue(fs.Rv()) * getValue(fs.invB(gasPhaseIdx)) val.second += getValue(fs.Rv()) * getValue(fs.invB(gasPhaseIdx))
* getValue(fs.saturation(gasPhaseIdx)); * getValue(fs.saturation(gasPhaseIdx));
} }
} } else if (key.first == "BOIPG") {
else if (key.first == "BOIPG") {
val.second = getValue(fs.Rv()) * getValue(fs.invB(gasPhaseIdx)) val.second = getValue(fs.Rv()) * getValue(fs.invB(gasPhaseIdx))
* getValue(fs.saturation(gasPhaseIdx)); * getValue(fs.saturation(gasPhaseIdx));
} } else if ((key.first == "BGIP") || (key.first == "BGIPG")) {
else if ((key.first == "BGIP") || (key.first == "BGIPG")) { val.second = getValue(fs.invB(gasPhaseIdx)) * getValue(fs.saturation(gasPhaseIdx));
val.second = getValue(fs.invB(gasPhaseIdx))
* getValue(fs.saturation(gasPhaseIdx));
if (key.first == "BGIP") { if (key.first == "BGIP") {
val.second += getValue(fs.Rs()) * getValue(fs.invB(oilPhaseIdx)) val.second += getValue(fs.Rs()) * getValue(fs.invB(oilPhaseIdx))
* getValue(fs.saturation(oilPhaseIdx)); * getValue(fs.saturation(oilPhaseIdx));
} }
} } else if (key.first == "BGIPL") {
else if (key.first == "BGIPL") {
val.second = getValue(fs.Rs()) * getValue(fs.invB(oilPhaseIdx)) val.second = getValue(fs.Rs()) * getValue(fs.invB(oilPhaseIdx))
* getValue(fs.saturation(oilPhaseIdx)); * getValue(fs.saturation(oilPhaseIdx));
} } else { // BWIP
else { // BWIP val.second = getValue(fs.invB(waterPhaseIdx)) * getValue(fs.saturation(waterPhaseIdx));
val.second = getValue(fs.invB(waterPhaseIdx))
* getValue(fs.saturation(waterPhaseIdx));
} }
// Include active pore-volume. // Include active pore-volume.
val.second *= elemCtx.simulator().model().dofTotalVolume(globalDofIdx) val.second *= elemCtx.simulator().model().dofTotalVolume(globalDofIdx)
* getValue(intQuants.porosity()); * getValue(intQuants.porosity());
} } else {
else {
std::string logstring = "Keyword '"; std::string logstring = "Keyword '";
logstring.append(key.first); logstring.append(key.first);
logstring.append("' is unhandled for output to file."); logstring.append("' is unhandled for output to file.");
@ -701,11 +682,12 @@ public:
// tracers // tracers
const auto& tracerModel = simulator_.problem().tracerModel(); const auto& tracerModel = simulator_.problem().tracerModel();
if (!this->tracerConcentrations_.empty()) { if (!this->tracerConcentrations_.empty()) {
for (int tracerIdx = 0; tracerIdx < tracerModel.numTracers(); tracerIdx++){ for (int tracerIdx = 0; tracerIdx < tracerModel.numTracers(); tracerIdx++) {
if (this->tracerConcentrations_[tracerIdx].empty()) if (this->tracerConcentrations_[tracerIdx].empty())
continue; continue;
this->tracerConcentrations_[tracerIdx][globalDofIdx] = tracerModel.tracerConcentration(tracerIdx, globalDofIdx); this->tracerConcentrations_[tracerIdx][globalDofIdx]
= tracerModel.tracerConcentration(tracerIdx, globalDofIdx);
} }
} }
} }
@ -740,33 +722,25 @@ public:
* to globally unique Cartesian cell/element index. * to globally unique Cartesian cell/element index.
*/ */
template <class ActiveIndex, class CartesianIndex> template <class ActiveIndex, class CartesianIndex>
void processFluxes(const ElementContext& elemCtx, void processFluxes(const ElementContext& elemCtx, ActiveIndex&& activeIndex, CartesianIndex&& cartesianIndex)
ActiveIndex&& activeIndex,
CartesianIndex&& cartesianIndex)
{ {
const auto identifyCell = [&activeIndex, &cartesianIndex](const Element& elem) const auto identifyCell = [&activeIndex, &cartesianIndex](const Element& elem) -> EclInterRegFlowMap::Cell {
-> EclInterRegFlowMap::Cell
{
const auto cellIndex = activeIndex(elem); const auto cellIndex = activeIndex(elem);
return { return {
static_cast<int>(cellIndex), static_cast<int>(cellIndex), cartesianIndex(cellIndex), elem.partitionType() == Dune::InteriorEntity};
cartesianIndex(cellIndex),
elem.partitionType() == Dune::InteriorEntity
};
}; };
const auto timeIdx = 0u; const auto timeIdx = 0u;
const auto& stencil = elemCtx.stencil(timeIdx); const auto& stencil = elemCtx.stencil(timeIdx);
const auto numInteriorFaces = elemCtx.numInteriorFaces(timeIdx); const auto numInteriorFaces = elemCtx.numInteriorFaces(timeIdx);
for (auto scvfIdx = 0*numInteriorFaces; scvfIdx < numInteriorFaces; ++scvfIdx) { for (auto scvfIdx = 0 * numInteriorFaces; scvfIdx < numInteriorFaces; ++scvfIdx) {
const auto& face = stencil.interiorFace(scvfIdx); const auto& face = stencil.interiorFace(scvfIdx);
const auto left = identifyCell(stencil.element(face.interiorIndex())); const auto left = identifyCell(stencil.element(face.interiorIndex()));
const auto right = identifyCell(stencil.element(face.exteriorIndex())); const auto right = identifyCell(stencil.element(face.exteriorIndex()));
const auto rates = this-> const auto rates = this->getComponentSurfaceRates(elemCtx, face.area(), scvfIdx, timeIdx);
getComponentSurfaceRates(elemCtx, face.area(), scvfIdx, timeIdx);
this->interRegionFlows_.addConnection(left, right, rates); this->interRegionFlows_.addConnection(left, right, rates);
} }
@ -802,40 +776,40 @@ public:
template <class FluidState> template <class FluidState>
void assignToFluidState(FluidState& fs, unsigned elemIdx) const void assignToFluidState(FluidState& fs, unsigned elemIdx) const
{ {
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) { for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
if (this->saturation_[phaseIdx].empty()) if (this->saturation_[phaseIdx].empty())
continue; continue;
fs.setSaturation(phaseIdx, this->saturation_[phaseIdx][elemIdx]); fs.setSaturation(phaseIdx, this->saturation_[phaseIdx][elemIdx]);
} }
if (!this->oilPressure_.empty()) { if (!this->fluidPressure_.empty()) {
// this assumes that capillary pressures only depend on the phase saturations // this assumes that capillary pressures only depend on the phase saturations
// and possibly on temperature. (this is always the case for ECL problems.) // and possibly on temperature. (this is always the case for ECL problems.)
std::array<Scalar, numPhases> pc = {0}; std::array<Scalar, numPhases> pc = {0};
const MaterialLawParams& matParams = simulator_.problem().materialLawParams(elemIdx); const MaterialLawParams& matParams = simulator_.problem().materialLawParams(elemIdx);
MaterialLaw::capillaryPressures(pc, matParams, fs); MaterialLaw::capillaryPressures(pc, matParams, fs);
Valgrind::CheckDefined(this->oilPressure_[elemIdx]); Valgrind::CheckDefined(this->fluidPressure_[elemIdx]);
Valgrind::CheckDefined(pc); Valgrind::CheckDefined(pc);
assert(FluidSystem::phaseIsActive(oilPhaseIdx)); assert(FluidSystem::phaseIsActive(oilPhaseIdx));
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
if (!FluidSystem::phaseIsActive(phaseIdx)) if (!FluidSystem::phaseIsActive(phaseIdx))
continue; continue;
fs.setPressure(phaseIdx, this->oilPressure_[elemIdx] + (pc[phaseIdx] - pc[oilPhaseIdx])); fs.setPressure(phaseIdx, this->fluidPressure_[elemIdx] + (pc[phaseIdx] - pc[oilPhaseIdx]));
} }
} }
if (!this->temperature_.empty()) if (!this->temperature_.empty())
fs.setTemperature(this->temperature_[elemIdx]); fs.setTemperature(this->temperature_[elemIdx]);
if (!this->rs_.empty()) if (!this->rs_.empty())
fs.setRs(this->rs_[elemIdx]); fs.setRs(this->rs_[elemIdx]);
if (!this->rsw_.empty()) if (!this->rsw_.empty())
fs.setRsw(this->rsw_[elemIdx]); fs.setRsw(this->rsw_[elemIdx]);
if (!this->rv_.empty()) if (!this->rv_.empty())
fs.setRv(this->rv_[elemIdx]); fs.setRv(this->rv_[elemIdx]);
if (!this->rvw_.empty()) if (!this->rvw_.empty())
fs.setRvw(this->rvw_[elemIdx]); fs.setRvw(this->rvw_[elemIdx]);
} }
void initHysteresisParams(Simulator& simulator, unsigned elemIdx) const void initHysteresisParams(Simulator& simulator, unsigned elemIdx) const
@ -848,35 +822,29 @@ public:
if (!this->pcSwMdcOw_.empty() && !this->krnSwMdcOw_.empty()) { if (!this->pcSwMdcOw_.empty() && !this->krnSwMdcOw_.empty()) {
matLawManager->setOilWaterHysteresisParams( matLawManager->setOilWaterHysteresisParams(
this->pcSwMdcOw_[elemIdx], this->pcSwMdcOw_[elemIdx], this->krnSwMdcOw_[elemIdx], elemIdx);
this->krnSwMdcOw_[elemIdx],
elemIdx);
} }
if (!this->pcSwMdcGo_.empty() && !this->krnSwMdcGo_.empty()) { if (!this->pcSwMdcGo_.empty() && !this->krnSwMdcGo_.empty()) {
matLawManager->setGasOilHysteresisParams( matLawManager->setGasOilHysteresisParams(
this->pcSwMdcGo_[elemIdx], this->pcSwMdcGo_[elemIdx], this->krnSwMdcGo_[elemIdx], elemIdx);
this->krnSwMdcGo_[elemIdx],
elemIdx);
} }
} }
if (simulator_.vanguard().eclState().fieldProps().has_double("SWATINIT")) { if (simulator_.vanguard().eclState().fieldProps().has_double("SWATINIT")) {
const auto& oilWaterScaledEpsInfoDrainage = const auto& oilWaterScaledEpsInfoDrainage
simulator.problem().materialLawManager()->oilWaterScaledEpsInfoDrainage(elemIdx); = simulator.problem().materialLawManager()->oilWaterScaledEpsInfoDrainage(elemIdx);
const_cast<EclEpsScalingPointsInfo<Scalar>&>(oilWaterScaledEpsInfoDrainage).maxPcow = this->ppcw_[elemIdx]; const_cast<EclEpsScalingPointsInfo<Scalar>&>(oilWaterScaledEpsInfoDrainage).maxPcow = this->ppcw_[elemIdx];
} }
} }
private: private:
bool isDefunctParallelWell(std::string wname) const override bool isDefunctParallelWell(std::string wname) const override
{ {
if (simulator_.gridView().comm().size()==1) if (simulator_.gridView().comm().size() == 1)
return false; return false;
const auto& parallelWells = simulator_.vanguard().parallelWells(); const auto& parallelWells = simulator_.vanguard().parallelWells();
std::pair<std::string,bool> value{wname, true}; std::pair<std::string, bool> value {wname, true};
auto candidate = std::lower_bound(parallelWells.begin(), parallelWells.end(), auto candidate = std::lower_bound(parallelWells.begin(), parallelWells.end(), value);
value);
return candidate == parallelWells.end() || *candidate != value; return candidate == parallelWells.end() || *candidate != value;
} }
@ -896,16 +864,14 @@ private:
// PORV, MINPV and friends). Also note that because of this, the porosity // PORV, MINPV and friends). Also note that because of this, the porosity
// returned by the intensive quantities can be outside of the physical // returned by the intensive quantities can be outside of the physical
// range [0, 1] in pathetic cases. // range [0, 1] in pathetic cases.
const auto totVolume = const auto totVolume = elemCtx.simulator().model().dofTotalVolume(globalDofIdx);
elemCtx.simulator().model().dofTotalVolume(globalDofIdx);
const double pv = totVolume * intQuants.porosity().value(); const double pv = totVolume * intQuants.porosity().value();
if (!this->pressureTimesHydrocarbonVolume_.empty() && !this->pressureTimesPoreVolume_.empty()) { if (!this->pressureTimesHydrocarbonVolume_.empty() && !this->pressureTimesPoreVolume_.empty()) {
assert(this->hydrocarbonPoreVolume_.size() == this->pressureTimesHydrocarbonVolume_.size()); assert(this->hydrocarbonPoreVolume_.size() == this->pressureTimesHydrocarbonVolume_.size());
assert(this->fip_[Inplace::Phase::PoreVolume].size() == this->pressureTimesPoreVolume_.size()); assert(this->fip_[Inplace::Phase::PoreVolume].size() == this->pressureTimesPoreVolume_.size());
this->fip_[Inplace::Phase::PoreVolume][globalDofIdx] = this->fip_[Inplace::Phase::PoreVolume][globalDofIdx] = totVolume * intQuants.referencePorosity();
totVolume * intQuants.referencePorosity();
this->dynamicPoreVolume_[globalDofIdx] = pv; this->dynamicPoreVolume_[globalDofIdx] = pv;
@ -919,10 +885,12 @@ private:
if (FluidSystem::phaseIsActive(oilPhaseIdx)) { if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
this->pressureTimesPoreVolume_[globalDofIdx] = getValue(fs.pressure(oilPhaseIdx)) * pv; this->pressureTimesPoreVolume_[globalDofIdx] = getValue(fs.pressure(oilPhaseIdx)) * pv;
this->pressureTimesHydrocarbonVolume_[globalDofIdx] = this->pressureTimesPoreVolume_[globalDofIdx] * hydrocarbon; this->pressureTimesHydrocarbonVolume_[globalDofIdx]
= this->pressureTimesPoreVolume_[globalDofIdx] * hydrocarbon;
} else if (FluidSystem::phaseIsActive(gasPhaseIdx)) { } else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
this->pressureTimesPoreVolume_[globalDofIdx] = getValue(fs.pressure(gasPhaseIdx)) * pv; this->pressureTimesPoreVolume_[globalDofIdx] = getValue(fs.pressure(gasPhaseIdx)) * pv;
this->pressureTimesHydrocarbonVolume_[globalDofIdx] = this->pressureTimesPoreVolume_[globalDofIdx] * hydrocarbon; this->pressureTimesHydrocarbonVolume_[globalDofIdx]
= this->pressureTimesPoreVolume_[globalDofIdx] * hydrocarbon;
} else if (FluidSystem::phaseIsActive(waterPhaseIdx)) { } else if (FluidSystem::phaseIsActive(waterPhaseIdx)) {
this->pressureTimesPoreVolume_[globalDofIdx] = getValue(fs.pressure(waterPhaseIdx)) * pv; this->pressureTimesPoreVolume_[globalDofIdx] = getValue(fs.pressure(waterPhaseIdx)) * pv;
} }
@ -983,7 +951,6 @@ private:
this->fip_[Inplace::Phase::GAS][globalDofIdx] += gasInPlaceLiquid; this->fip_[Inplace::Phase::GAS][globalDofIdx] += gasInPlaceLiquid;
} }
} }
} }
void createLocalRegion_(std::vector<int>& region) void createLocalRegion_(std::vector<int>& region)
@ -1011,86 +978,71 @@ private:
* *
* \return Surface level component flow rates. * \return Surface level component flow rates.
*/ */
data::InterRegFlowMap::FlowRates data::InterRegFlowMap::FlowRates getComponentSurfaceRates(const ElementContext& elemCtx,
getComponentSurfaceRates(const ElementContext& elemCtx, const Scalar faceArea,
const Scalar faceArea, const std::size_t scvfIdx,
const std::size_t scvfIdx, const std::size_t timeIdx) const
const std::size_t timeIdx) const
{ {
using Component = data::InterRegFlowMap::Component; using Component = data::InterRegFlowMap::Component;
auto rates = data::InterRegFlowMap::FlowRates{}; auto rates = data::InterRegFlowMap::FlowRates {};
const auto& extQuant = elemCtx.extensiveQuantities(scvfIdx, timeIdx); const auto& extQuant = elemCtx.extensiveQuantities(scvfIdx, timeIdx);
const auto alpha = getValue(extQuant.extrusionFactor()) * faceArea; const auto alpha = getValue(extQuant.extrusionFactor()) * faceArea;
if (FluidSystem::phaseIsActive(oilPhaseIdx)) { if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
const auto& up = elemCtx const auto& up = elemCtx.intensiveQuantities(extQuant.upstreamIndex(oilPhaseIdx), timeIdx);
.intensiveQuantities(extQuant.upstreamIndex(oilPhaseIdx), timeIdx);
using FluidState = std::remove_cv_t<std::remove_reference_t< using FluidState = std::remove_cv_t<std::remove_reference_t<decltype(up.fluidState())>>;
decltype(up.fluidState())>>;
const auto pvtReg = up.pvtRegionIndex(); const auto pvtReg = up.pvtRegionIndex();
const auto bO = getValue(getInvB_<FluidSystem, FluidState, Scalar> const auto bO = getValue(getInvB_<FluidSystem, FluidState, Scalar>(up.fluidState(), oilPhaseIdx, pvtReg));
(up.fluidState(), oilPhaseIdx, pvtReg));
const auto qO = alpha * bO * getValue(extQuant.volumeFlux(oilPhaseIdx)); const auto qO = alpha * bO * getValue(extQuant.volumeFlux(oilPhaseIdx));
rates[Component::Oil] += qO; rates[Component::Oil] += qO;
if (FluidSystem::phaseIsActive(gasPhaseIdx)) { if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
const auto Rs = getValue( const auto Rs = getValue(BlackOil::getRs_<FluidSystem, FluidState, Scalar>(up.fluidState(), pvtReg));
BlackOil::getRs_<FluidSystem, FluidState, Scalar>
(up.fluidState(), pvtReg));
rates[Component::Gas] += qO * Rs; rates[Component::Gas] += qO * Rs;
rates[Component::Disgas] += qO * Rs; rates[Component::Disgas] += qO * Rs;
} }
} }
if (FluidSystem::phaseIsActive(gasPhaseIdx)) { if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
const auto& up = elemCtx const auto& up = elemCtx.intensiveQuantities(extQuant.upstreamIndex(gasPhaseIdx), timeIdx);
.intensiveQuantities(extQuant.upstreamIndex(gasPhaseIdx), timeIdx);
using FluidState = std::remove_cv_t<std::remove_reference_t< using FluidState = std::remove_cv_t<std::remove_reference_t<decltype(up.fluidState())>>;
decltype(up.fluidState())>>;
const auto pvtReg = up.pvtRegionIndex(); const auto pvtReg = up.pvtRegionIndex();
const auto bG = getValue(getInvB_<FluidSystem, FluidState, Scalar> const auto bG = getValue(getInvB_<FluidSystem, FluidState, Scalar>(up.fluidState(), gasPhaseIdx, pvtReg));
(up.fluidState(), gasPhaseIdx, pvtReg));
const auto qG = alpha * bG * getValue(extQuant.volumeFlux(gasPhaseIdx)); const auto qG = alpha * bG * getValue(extQuant.volumeFlux(gasPhaseIdx));
rates[Component::Gas] += qG; rates[Component::Gas] += qG;
if (FluidSystem::phaseIsActive(oilPhaseIdx)) { if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
const auto Rv = getValue( const auto Rv = getValue(BlackOil::getRv_<FluidSystem, FluidState, Scalar>(up.fluidState(), pvtReg));
BlackOil::getRv_<FluidSystem, FluidState, Scalar>
(up.fluidState(), pvtReg));
rates[Component::Oil] += qG * Rv; rates[Component::Oil] += qG * Rv;
rates[Component::Vapoil] += qG * Rv; rates[Component::Vapoil] += qG * Rv;
} }
} }
if (FluidSystem::phaseIsActive(waterPhaseIdx)) { if (FluidSystem::phaseIsActive(waterPhaseIdx)) {
const auto& up = elemCtx const auto& up = elemCtx.intensiveQuantities(extQuant.upstreamIndex(waterPhaseIdx), timeIdx);
.intensiveQuantities(extQuant.upstreamIndex(waterPhaseIdx), timeIdx);
using FluidState = std::remove_cv_t<std::remove_reference_t< using FluidState = std::remove_cv_t<std::remove_reference_t<decltype(up.fluidState())>>;
decltype(up.fluidState())>>;
const auto pvtReg = up.pvtRegionIndex(); const auto pvtReg = up.pvtRegionIndex();
const auto bW = getValue(getInvB_<FluidSystem, FluidState, Scalar> const auto bW = getValue(getInvB_<FluidSystem, FluidState, Scalar>(up.fluidState(), waterPhaseIdx, pvtReg));
(up.fluidState(), waterPhaseIdx, pvtReg));
rates[Component::Water] += rates[Component::Water] += alpha * bW * getValue(extQuant.volumeFlux(waterPhaseIdx));
alpha * bW * getValue(extQuant.volumeFlux(waterPhaseIdx));
} }
return rates; return rates;