2012-01-05 02:34:05 -06: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 04:29:42 -05:00
|
|
|
#include <opm/core/props/BlackoilPhases.hpp>
|
2015-10-08 04:42:15 -05:00
|
|
|
#include <opm/common/ErrorMacros.hpp>
|
2012-01-05 02:34:05 -06:00
|
|
|
|
2014-01-24 05:01:54 -06:00
|
|
|
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
2014-01-10 06:43:02 -06:00
|
|
|
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
2016-11-01 05:37:27 -05:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
|
2014-01-10 06:43:02 -06:00
|
|
|
|
2012-01-05 02:34:05 -06:00
|
|
|
|
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
2014-01-10 06:43:02 -06:00
|
|
|
/// Looks at presence of WATER, OIL and GAS keywords in state object
|
|
|
|
/// to determine active phases.
|
2016-10-13 09:03:35 -05:00
|
|
|
inline PhaseUsage phaseUsageFromDeck(const Opm::EclipseState& eclipseState)
|
2014-01-10 06:43:02 -06:00
|
|
|
{
|
|
|
|
PhaseUsage pu;
|
|
|
|
std::fill(pu.phase_used, pu.phase_used + BlackoilPhases::MaxNumPhases, 0);
|
|
|
|
|
2016-11-01 05:37:27 -05:00
|
|
|
const auto& phase = eclipseState.runspec().phases();
|
2014-01-10 06:43:02 -06:00
|
|
|
// Discover phase usage.
|
2016-11-01 05:37:27 -05:00
|
|
|
if (phase.active(Phase::WATER)) {
|
2014-01-10 06:43:02 -06:00
|
|
|
pu.phase_used[BlackoilPhases::Aqua] = 1;
|
|
|
|
}
|
2016-11-01 05:37:27 -05:00
|
|
|
if (phase.active(Phase::OIL)) {
|
2014-01-10 06:43:02 -06:00
|
|
|
pu.phase_used[BlackoilPhases::Liquid] = 1;
|
|
|
|
}
|
2016-11-01 05:37:27 -05:00
|
|
|
if (phase.active(Phase::GAS)) {
|
2014-01-10 06:43:02 -06:00
|
|
|
pu.phase_used[BlackoilPhases::Vapour] = 1;
|
|
|
|
}
|
|
|
|
pu.num_phases = 0;
|
|
|
|
for (int i = 0; i < BlackoilPhases::MaxNumPhases; ++i) {
|
2012-01-05 02:34:05 -06:00
|
|
|
pu.phase_pos[i] = pu.num_phases;
|
|
|
|
pu.num_phases += pu.phase_used[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only 2 or 3 phase systems handled.
|
|
|
|
if (pu.num_phases < 2 || pu.num_phases > 3) {
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Cannot handle cases with " << pu.num_phases << " phases.");
|
2012-01-05 02:34:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// We need oil systems, since we do not support the keywords needed for
|
|
|
|
// water-gas systems.
|
|
|
|
if (!pu.phase_used[BlackoilPhases::Liquid]) {
|
2013-08-28 06:59:03 -05:00
|
|
|
OPM_THROW(std::runtime_error, "Cannot handle cases with no OIL, i.e. water-gas systems.");
|
2012-01-05 02:34:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return pu;
|
|
|
|
}
|
|
|
|
|
2014-01-24 05:01:54 -06:00
|
|
|
/// Looks at presence of WATER, OIL and GAS keywords in deck
|
|
|
|
/// to determine active phases.
|
2016-10-13 09:03:35 -05:00
|
|
|
inline PhaseUsage phaseUsageFromDeck(const Opm::Deck& deck)
|
2014-01-24 05:01:54 -06:00
|
|
|
{
|
|
|
|
PhaseUsage pu;
|
|
|
|
std::fill(pu.phase_used, pu.phase_used + BlackoilPhases::MaxNumPhases, 0);
|
|
|
|
|
2016-11-01 05:37:27 -05:00
|
|
|
Runspec runspec( deck );
|
|
|
|
const auto& phase = runspec.phases();
|
|
|
|
|
2014-01-24 05:01:54 -06:00
|
|
|
// Discover phase usage.
|
2016-11-01 05:37:27 -05:00
|
|
|
if (phase.active( Phase::WATER )) {
|
2014-01-24 05:01:54 -06:00
|
|
|
pu.phase_used[BlackoilPhases::Aqua] = 1;
|
|
|
|
}
|
2016-11-01 05:37:27 -05:00
|
|
|
if (phase.active( Phase::OIL )) {
|
2014-01-24 05:01:54 -06:00
|
|
|
pu.phase_used[BlackoilPhases::Liquid] = 1;
|
|
|
|
}
|
2016-11-01 05:37:27 -05:00
|
|
|
if (phase.active( Phase::GAS )) {
|
2014-01-24 05:01:54 -06:00
|
|
|
pu.phase_used[BlackoilPhases::Vapour] = 1;
|
|
|
|
}
|
|
|
|
pu.num_phases = 0;
|
|
|
|
for (int i = 0; i < BlackoilPhases::MaxNumPhases; ++i) {
|
2016-04-20 11:03:47 -05:00
|
|
|
if (pu.phase_used[i]) {
|
|
|
|
pu.phase_pos[i] = pu.num_phases;
|
|
|
|
pu.num_phases += 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//Set to ridiculous value on purpose: should never be used
|
2016-04-21 09:17:54 -05:00
|
|
|
pu.phase_pos[i] = 2000000000;
|
2016-04-20 11:03:47 -05:00
|
|
|
}
|
2014-01-24 05:01:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Only 2 or 3 phase systems handled.
|
|
|
|
if (pu.num_phases < 2 || pu.num_phases > 3) {
|
|
|
|
OPM_THROW(std::runtime_error, "Cannot handle cases with " << pu.num_phases << " phases.");
|
|
|
|
}
|
|
|
|
|
|
|
|
// We need oil systems, since we do not support the keywords needed for
|
|
|
|
// water-gas systems.
|
|
|
|
if (!pu.phase_used[BlackoilPhases::Liquid]) {
|
|
|
|
OPM_THROW(std::runtime_error, "Cannot handle cases with no OIL, i.e. water-gas systems.");
|
|
|
|
}
|
|
|
|
|
|
|
|
return pu;
|
|
|
|
}
|
|
|
|
|
2012-01-05 02:34:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // OPM_PHASEUSAGEFROMDECK_HEADER_INCLUDED
|