Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion opm/material/fluidsystems/PhaseUsageInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include <opm/input/eclipse/EclipseState/Phase.hpp>

#include <algorithm>
#include <cassert>
#include <stdexcept>

#include <fmt/format.h>
Expand Down Expand Up @@ -92,6 +91,24 @@ void PhaseUsageInfo<IndexTraits>::initFromState(const EclipseState& eclState)
has_biofilm = eclState.runspec().biof();
has_micp = eclState.runspec().micp();
has_co2_or_h2store = eclState.runspec().co2Storage() || eclState.runspec().h2Storage();
enable_dissolved_gas_ = eclState.getSimulationConfig().hasDISGAS();
enable_vaporized_oil_ = eclState.getSimulationConfig().hasVAPOIL();
enable_vaporized_water_ = eclState.getSimulationConfig().hasVAPWAT();
const bool disgasw = eclState.getSimulationConfig().hasDISGASW();
if (disgasw) {
if (has_co2_or_h2store) {
enable_dissolved_gas_in_water_ = true;
} else if (eclState.runspec().co2Sol() || eclState.runspec().h2Sol()) {
// For CO2SOL and H2SOL the dissolved gas in water is added in the solvent model
// The HC gas is not allowed to dissolve into water.
// For most HC gases this is a reasonable assumption.
OpmLog::info("CO2SOL/H2SOL is activated together with DISGASW.\n"
"Only CO2/H2 is allowed to dissolve into water");
} else {
OPM_THROW(std::runtime_error,
"DISGASW is only supported in combination with CO2STORE, H2STORE, CO2SOL, or H2SOL.");
}
}
}

template <typename IndexTraits>
Expand Down Expand Up @@ -129,9 +146,15 @@ void PhaseUsageInfo<IndexTraits>::initFromPhases(const Phases& phases) {
has_zFraction = phases.active(Phase::ZFRACTION);

this->updateIndexMapping_();
this->updateIndices_();
}
#endif

template <typename IndexTraits>
void PhaseUsageInfo<IndexTraits>::updateIndices_() {
contiSolventEqIdx_ = has_solvent ? numActivePhases_ : -1000;
}

// Explicit template instantiations for commonly used IndexTraits
template class PhaseUsageInfo<BlackOilDefaultFluidSystemIndices>;

Expand Down
31 changes: 31 additions & 0 deletions opm/material/fluidsystems/PhaseUsageInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,26 @@ class PhaseUsageInfo {
return has_co2_or_h2store;
}

bool enableDissolvedGas() const noexcept {
return enable_dissolved_gas_;
}

bool enableVaporizedOil() const noexcept {
return enable_vaporized_oil_;
}

bool enableVaporizedWater() const noexcept {
return enable_vaporized_water_;
}

bool enableDissolvedGasInWater() const noexcept {
return enable_dissolved_gas_in_water_;
}

int contiSolventEqIdx() const noexcept {
return contiSolventEqIdx_;
}

private:
// only account for the three main phases: oil, water, gas
unsigned char numActivePhases_ = 0;
Expand All @@ -177,9 +197,20 @@ class PhaseUsageInfo {
bool has_micp{};
bool has_co2_or_h2store{};

bool enable_dissolved_gas_{};
bool enable_vaporized_oil_{};
bool enable_vaporized_water_{};
bool enable_dissolved_gas_in_water_{};


int contiSolventEqIdx_ = -1000;

// updating the mapping between active and canonical phase indices
void updateIndexMapping_();

// update equation indices
void updateIndices_();

void reset_();

};
Expand Down