2017-12-06 16:12:00 +01:00
|
|
|
|
2012-01-05 09:34:05 +01:00
|
|
|
/*
|
|
|
|
|
Copyright 2012 SINTEF ICT, Applied Mathematics.
|
|
|
|
|
|
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef OPM_PHASEUSAGEFROMDECK_HEADER_INCLUDED
|
|
|
|
|
#define OPM_PHASEUSAGEFROMDECK_HEADER_INCLUDED
|
|
|
|
|
|
2013-03-14 10:29:42 +01:00
|
|
|
#include <opm/core/props/BlackoilPhases.hpp>
|
2015-10-08 11:42:15 +02:00
|
|
|
#include <opm/common/ErrorMacros.hpp>
|
2012-01-05 09:34:05 +01:00
|
|
|
|
2014-01-24 12:01:54 +01:00
|
|
|
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
2014-01-10 13:43:02 +01:00
|
|
|
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
2016-11-01 11:37:27 +01:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
|
2014-01-10 13:43:02 +01:00
|
|
|
|
2012-01-05 09:34:05 +01:00
|
|
|
|
|
|
|
|
namespace Opm
|
|
|
|
|
{
|
2018-11-27 14:38:50 +01:00
|
|
|
/// Determine the active phases
|
|
|
|
|
inline PhaseUsage phaseUsage(const Phases& phases) {
|
2014-01-10 13:43:02 +01:00
|
|
|
PhaseUsage pu;
|
2017-12-06 16:12:00 +01:00
|
|
|
std::fill(pu.phase_used, pu.phase_used + BlackoilPhases::MaxNumPhases + BlackoilPhases::NumCryptoPhases, 0);
|
2014-01-10 13:43:02 +01:00
|
|
|
|
|
|
|
|
// Discover phase usage.
|
2018-11-27 14:38:50 +01:00
|
|
|
pu.phase_used[BlackoilPhases::Aqua] = phases.active(Phase::WATER);
|
|
|
|
|
pu.phase_used[BlackoilPhases::Liquid] = phases.active(Phase::OIL);
|
|
|
|
|
pu.phase_used[BlackoilPhases::Vapour] = phases.active(Phase::GAS);
|
2017-12-06 16:12:00 +01:00
|
|
|
|
2014-01-10 13:43:02 +01:00
|
|
|
pu.num_phases = 0;
|
2017-11-19 13:03:26 +01:00
|
|
|
int numActivePhases = 0;
|
|
|
|
|
for (int phaseIdx = 0; phaseIdx < BlackoilPhases::MaxNumPhases; ++phaseIdx) {
|
2017-12-06 16:12:00 +01:00
|
|
|
if (!pu.phase_used[phaseIdx]) {
|
2017-11-19 13:03:26 +01:00
|
|
|
pu.phase_pos[phaseIdx] = -1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
pu.phase_pos[phaseIdx] = numActivePhases;
|
|
|
|
|
++ numActivePhases;
|
|
|
|
|
pu.num_phases = numActivePhases;
|
|
|
|
|
}
|
2012-01-05 09:34:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We need oil systems, since we do not support the keywords needed for
|
|
|
|
|
// water-gas systems.
|
2019-10-09 15:24:23 +02:00
|
|
|
if (!pu.phase_used[BlackoilPhases::Liquid] && !(pu.num_phases == 1)) {
|
2013-08-28 13:59:03 +02:00
|
|
|
OPM_THROW(std::runtime_error, "Cannot handle cases with no OIL, i.e. water-gas systems.");
|
2012-01-05 09:34:05 +01:00
|
|
|
}
|
|
|
|
|
|
2017-05-03 10:54:06 +02:00
|
|
|
// Add solvent info
|
2018-11-27 14:38:50 +01:00
|
|
|
pu.has_solvent = phases.active(Phase::SOLVENT);
|
2017-12-06 16:12:00 +01:00
|
|
|
if (pu.has_solvent) {
|
|
|
|
|
// this is quite a hack: even though solvent is not considered as in
|
|
|
|
|
// MaxNumPhases and pu.num_phases because this would break a lot of
|
|
|
|
|
// assumptions in old code, it is nevertheless an index to be translated
|
|
|
|
|
// to. solvent and solvent are even larger hacks because not even this can be
|
|
|
|
|
// done for them.
|
|
|
|
|
pu.phase_pos[BlackoilPhases::Solvent] = numActivePhases;
|
|
|
|
|
++ numActivePhases;
|
2017-05-03 10:54:06 +02:00
|
|
|
}
|
2017-12-06 16:12:00 +01:00
|
|
|
else
|
|
|
|
|
pu.phase_pos[BlackoilPhases::Solvent] = -1;
|
2017-05-03 10:54:06 +02:00
|
|
|
|
2017-12-06 16:12:00 +01:00
|
|
|
// Add polymer info
|
2018-11-27 14:38:50 +01:00
|
|
|
pu.has_polymer = phases.active(Phase::POLYMER);
|
2017-12-06 16:12:00 +01:00
|
|
|
if (pu.has_polymer) {
|
|
|
|
|
// this is quite a hack: even though polymer is not considered as in
|
|
|
|
|
// MaxNumPhases and pu.num_phases because this would break a lot of
|
|
|
|
|
// assumptions in old code, it is nevertheless an index to be translated
|
|
|
|
|
// to. polymer and solvent are even larger hacks because not even this can be
|
|
|
|
|
// done for them.
|
|
|
|
|
pu.phase_pos[BlackoilPhases::Polymer] = numActivePhases;
|
|
|
|
|
++ numActivePhases;
|
2017-06-16 13:40:29 +02:00
|
|
|
}
|
2017-12-06 16:12:00 +01:00
|
|
|
else
|
|
|
|
|
pu.phase_pos[BlackoilPhases::Polymer] = -1;
|
2017-06-16 13:40:29 +02:00
|
|
|
|
2017-11-19 13:03:26 +01:00
|
|
|
// Add energy info
|
2018-11-27 14:38:50 +01:00
|
|
|
pu.has_energy = phases.active(Phase::ENERGY);
|
2017-11-19 13:03:26 +01:00
|
|
|
if (pu.has_energy) {
|
|
|
|
|
// this is quite a hack: even though energy is not considered as in
|
|
|
|
|
// MaxNumPhases and pu.num_phases because this would break a lot of
|
|
|
|
|
// assumptions in old code, it is nevertheless an index to be translated
|
|
|
|
|
// to. polymer and solvent are even larger hacks because not even this can be
|
|
|
|
|
// done for them.
|
|
|
|
|
pu.phase_pos[BlackoilPhases::Energy] = numActivePhases;
|
|
|
|
|
++ numActivePhases;
|
|
|
|
|
}
|
2017-12-06 16:12:00 +01:00
|
|
|
else
|
|
|
|
|
pu.phase_pos[BlackoilPhases::Energy] = -1;
|
|
|
|
|
|
2018-11-27 15:04:21 +01:00
|
|
|
// Add polymer molecular weight related
|
2018-11-28 10:41:39 +01:00
|
|
|
pu.has_polymermw = phases.active(Phase::POLYMW);
|
2018-11-27 15:04:21 +01:00
|
|
|
if (pu.has_polymermw) {
|
|
|
|
|
if (!pu.has_polymer) {
|
|
|
|
|
OPM_THROW(std::runtime_error, "pu.has_polymermw is true while pu.has_polymer is false");
|
|
|
|
|
}
|
|
|
|
|
pu.phase_pos[BlackoilPhases::PolymerMW] = numActivePhases;
|
|
|
|
|
++ numActivePhases;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
pu.phase_pos[BlackoilPhases::PolymerMW] = -1;
|
|
|
|
|
|
2019-07-04 09:50:08 +02:00
|
|
|
// Add foam info
|
|
|
|
|
pu.has_foam = phases.active(Phase::FOAM);
|
|
|
|
|
if (pu.has_foam) {
|
|
|
|
|
pu.phase_pos[BlackoilPhases::Foam] = numActivePhases;
|
|
|
|
|
++ numActivePhases;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
pu.phase_pos[BlackoilPhases::Foam] = -1;
|
|
|
|
|
|
2019-12-03 17:48:17 +01:00
|
|
|
// Add brine info
|
|
|
|
|
pu.has_brine = phases.active(Phase::BRINE);
|
|
|
|
|
if (pu.has_brine) {
|
|
|
|
|
pu.phase_pos[BlackoilPhases::Brine] = numActivePhases;
|
2019-11-07 09:39:42 +01:00
|
|
|
++ numActivePhases;
|
|
|
|
|
}
|
|
|
|
|
else
|
2019-12-03 17:48:17 +01:00
|
|
|
pu.phase_pos[BlackoilPhases::Brine] = -1;
|
2019-11-07 09:39:42 +01:00
|
|
|
|
2020-10-10 16:20:25 +02:00
|
|
|
// Add zFraction info
|
|
|
|
|
pu.has_zFraction = phases.active(Phase::ZFRACTION);
|
|
|
|
|
if (pu.has_zFraction) {
|
|
|
|
|
pu.phase_pos[BlackoilPhases::ZFraction] = numActivePhases;
|
|
|
|
|
++ numActivePhases;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
pu.phase_pos[BlackoilPhases::ZFraction] = -1;
|
|
|
|
|
|
|
|
|
|
|
2012-01-05 09:34:05 +01:00
|
|
|
return pu;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-27 14:38:50 +01:00
|
|
|
/// Looks at presence of WATER, OIL and GAS keywords in state object
|
|
|
|
|
/// to determine active phases.
|
|
|
|
|
inline PhaseUsage phaseUsageFromDeck(const Opm::EclipseState& eclipseState)
|
|
|
|
|
{
|
|
|
|
|
const auto& phases = eclipseState.runspec().phases();
|
|
|
|
|
|
|
|
|
|
return phaseUsage(phases);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-24 12:01:54 +01:00
|
|
|
/// Looks at presence of WATER, OIL and GAS keywords in deck
|
|
|
|
|
/// to determine active phases.
|
2016-10-13 16:03:35 +02:00
|
|
|
inline PhaseUsage phaseUsageFromDeck(const Opm::Deck& deck)
|
2014-01-24 12:01:54 +01:00
|
|
|
{
|
2016-11-01 11:37:27 +01:00
|
|
|
Runspec runspec( deck );
|
2018-11-27 14:38:50 +01:00
|
|
|
const auto& phases = runspec.phases();
|
2014-01-24 12:01:54 +01:00
|
|
|
|
2018-11-27 14:38:50 +01:00
|
|
|
return phaseUsage(phases);
|
2014-01-24 12:01:54 +01:00
|
|
|
}
|
|
|
|
|
|
2012-01-05 09:34:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // OPM_PHASEUSAGEFROMDECK_HEADER_INCLUDED
|