44 static constexpr int numPhases = IndexTraits::numPhases;
45 static constexpr int numComponents = IndexTraits::numComponents;
47 static constexpr int waterPhaseIdx = IndexTraits::waterPhaseIdx;
48 static constexpr int oilPhaseIdx = IndexTraits::oilPhaseIdx;
49 static constexpr int gasPhaseIdx = IndexTraits::gasPhaseIdx;
51 static constexpr int waterCompIdx = IndexTraits::waterCompIdx;
52 static constexpr int oilCompIdx = IndexTraits::oilCompIdx;
53 static constexpr int gasCompIdx = IndexTraits::gasCompIdx;
57 [[nodiscard]] OPM_HOST_DEVICE
unsigned numActivePhases()
const {
58 return numActivePhases_;
61 [[nodiscard]] OPM_HOST_DEVICE
bool phaseIsActive(
unsigned phaseIdx)
const {
62 assert(phaseIdx < numPhases);
63 return phaseIsActive_[phaseIdx];
66 [[nodiscard]] OPM_HOST_DEVICE
short canonicalToActivePhaseIdx(
unsigned phaseIdx)
const {
67 if (!phaseIsActive(phaseIdx)) {
68 OPM_THROW(std::logic_error,
"Canonical phase " + std::to_string(phaseIdx) +
" is not active.");
70 return canonicalToActivePhaseIdx_[phaseIdx];
73 [[nodiscard]] OPM_HOST_DEVICE
short activeToCanonicalPhaseIdx(
unsigned activePhaseIdx)
const {
74 assert(activePhaseIdx< numActivePhases_);
75 return activeToCanonicalPhaseIdx_[activePhaseIdx];
78 [[nodiscard]] OPM_HOST_DEVICE
short activeToCanonicalCompIdx(
unsigned activeCompIdx)
const {
80 assert(numActivePhases_ <= numComponents);
81 if (activeCompIdx >= numActivePhases()) {
84 return activeToCanonicalCompIdx_[activeCompIdx];
87 [[nodiscard]] OPM_HOST_DEVICE
short canonicalToActiveCompIdx(
unsigned compIdx)
const {
88 assert(compIdx < numComponents);
89 return canonicalToActiveCompIdx_[compIdx];
92 [[nodiscard]] OPM_HOST_DEVICE
short activePhaseToActiveCompIdx(
unsigned activePhaseIdx)
const {
93 if (activePhaseIdx >= numActivePhases()) {
94 return activePhaseIdx;
96 const short canonicalPhaseIdx = activeToCanonicalPhaseIdx(activePhaseIdx);
97 const short canonicalCompIdx = IndexTraits::phaseToComponentIdx(canonicalPhaseIdx);
98 const short activeCompIdx = canonicalToActiveCompIdx(canonicalCompIdx);
102 [[nodiscard]] OPM_HOST_DEVICE
short activeCompToActivePhaseIdx(
unsigned activeCompIdx)
const {
103 if (activeCompIdx >= numActivePhases()) {
104 return activeCompIdx;
106 const short canonicalCompIdx = activeToCanonicalCompIdx(activeCompIdx);
107 const short canonicalPhaseIdx = IndexTraits::componentToPhaseIdx(canonicalCompIdx);
108 const short activePhaseIdx = canonicalToActivePhaseIdx(canonicalPhaseIdx);
109 return activePhaseIdx;
112 void initFromPhases(
const Phases& phases);
116 OPM_HOST_DEVICE
bool hasSolvent()
const noexcept {
120 OPM_HOST_DEVICE
bool hasPolymer()
const noexcept {
124 OPM_HOST_DEVICE
bool hasEnergy()
const noexcept {
128 OPM_HOST_DEVICE
bool hasPolymerMW()
const noexcept {
129 return has_polymermw;
132 OPM_HOST_DEVICE
bool hasFoam()
const noexcept {
136 OPM_HOST_DEVICE
bool hasBrine()
const noexcept {
140 OPM_HOST_DEVICE
bool hasZFraction()
const noexcept {
141 return has_zFraction;
144 OPM_HOST_DEVICE
bool hasBiofilm()
const noexcept {
148 OPM_HOST_DEVICE
bool hasMICP()
const noexcept {
152 OPM_HOST_DEVICE
bool hasCO2orH2Store()
const noexcept {
153 return has_co2_or_h2store;
158 unsigned char numActivePhases_ = 0;
159 std::array<bool, numPhases> phaseIsActive_;
160 std::array<short, numPhases> activeToCanonicalPhaseIdx_;
161 std::array<short, numPhases> canonicalToActivePhaseIdx_;
164 std::array<short, numComponents> activeToCanonicalCompIdx_;
165 std::array<short, numComponents> canonicalToActiveCompIdx_;
171 bool has_polymermw{};
174 bool has_zFraction{};
177 bool has_co2_or_h2store{};
180 void updateIndexMapping_();