mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-26 19:46:24 -06:00
phaseUsageFromDeck: move to separate compile unit
This commit is contained in:
parent
0cb0971673
commit
541ebdde13
@ -23,6 +23,7 @@
|
||||
# originally generated with the command:
|
||||
# find opm -name '*.c*' -printf '\t%p\n' | sort
|
||||
list (APPEND MAIN_SOURCE_FILES
|
||||
opm/core/props/phaseUsageFromDeck.cpp
|
||||
opm/core/props/satfunc/RelpermDiagnostics.cpp
|
||||
opm/simulators/timestepping/SimulatorReport.cpp
|
||||
opm/simulators/flow/KeywordValidation.cpp
|
||||
|
164
opm/core/props/phaseUsageFromDeck.cpp
Normal file
164
opm/core/props/phaseUsageFromDeck.cpp
Normal file
@ -0,0 +1,164 @@
|
||||
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <opm/core/props/phaseUsageFromDeck.hpp>
|
||||
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
|
||||
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
PhaseUsage phaseUsage(const Phases& phases)
|
||||
{
|
||||
PhaseUsage pu;
|
||||
pu.phase_used.fill(0);
|
||||
|
||||
// Discover phase usage.
|
||||
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);
|
||||
|
||||
pu.num_phases = 0;
|
||||
int numActivePhases = 0;
|
||||
for (int phaseIdx = 0; phaseIdx < BlackoilPhases::MaxNumPhases; ++phaseIdx) {
|
||||
if (!pu.phase_used[phaseIdx]) {
|
||||
pu.phase_pos[phaseIdx] = -1;
|
||||
}
|
||||
else {
|
||||
pu.phase_pos[phaseIdx] = numActivePhases;
|
||||
++ numActivePhases;
|
||||
pu.num_phases = numActivePhases;
|
||||
}
|
||||
}
|
||||
|
||||
// We need oil systems, since we do not support the keywords needed for
|
||||
// water-gas systems.
|
||||
if (!pu.phase_used[BlackoilPhases::Liquid] && !(pu.num_phases == 1)) {
|
||||
OPM_THROW(std::runtime_error, "Cannot handle cases with no OIL, i.e. water-gas systems.");
|
||||
}
|
||||
|
||||
// Add solvent info
|
||||
pu.has_solvent = phases.active(Phase::SOLVENT);
|
||||
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;
|
||||
}
|
||||
else
|
||||
pu.phase_pos[BlackoilPhases::Solvent] = -1;
|
||||
|
||||
// Add polymer info
|
||||
pu.has_polymer = phases.active(Phase::POLYMER);
|
||||
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;
|
||||
}
|
||||
else
|
||||
pu.phase_pos[BlackoilPhases::Polymer] = -1;
|
||||
|
||||
// Add energy info
|
||||
pu.has_energy = phases.active(Phase::ENERGY);
|
||||
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;
|
||||
}
|
||||
else
|
||||
pu.phase_pos[BlackoilPhases::Energy] = -1;
|
||||
|
||||
// Add polymer molecular weight related
|
||||
pu.has_polymermw = phases.active(Phase::POLYMW);
|
||||
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;
|
||||
|
||||
// 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;
|
||||
|
||||
// Add brine info
|
||||
pu.has_brine = phases.active(Phase::BRINE);
|
||||
if (pu.has_brine) {
|
||||
pu.phase_pos[BlackoilPhases::Brine] = numActivePhases;
|
||||
++ numActivePhases;
|
||||
}
|
||||
else
|
||||
pu.phase_pos[BlackoilPhases::Brine] = -1;
|
||||
|
||||
// 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;
|
||||
|
||||
|
||||
return pu;
|
||||
}
|
||||
|
||||
PhaseUsage phaseUsageFromDeck(const Opm::EclipseState& eclipseState)
|
||||
{
|
||||
const auto& phases = eclipseState.runspec().phases();
|
||||
|
||||
return phaseUsage(phases);
|
||||
}
|
||||
|
||||
/// Looks at presence of WATER, OIL and GAS keywords in deck
|
||||
/// to determine active phases.
|
||||
PhaseUsage phaseUsageFromDeck(const Opm::Deck& deck)
|
||||
{
|
||||
Runspec runspec( deck );
|
||||
const auto& phases = runspec.phases();
|
||||
|
||||
return phaseUsage(phases);
|
||||
}
|
||||
|
||||
}
|
@ -22,148 +22,23 @@
|
||||
#define OPM_PHASEUSAGEFROMDECK_HEADER_INCLUDED
|
||||
|
||||
#include <opm/core/props/BlackoilPhases.hpp>
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
|
||||
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
class Deck;
|
||||
class EclipseState;
|
||||
class Phases;
|
||||
|
||||
/// Determine the active phases
|
||||
inline PhaseUsage phaseUsage(const Phases& phases) {
|
||||
PhaseUsage pu;
|
||||
pu.phase_used.fill(0);
|
||||
|
||||
// Discover phase usage.
|
||||
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);
|
||||
|
||||
pu.num_phases = 0;
|
||||
int numActivePhases = 0;
|
||||
for (int phaseIdx = 0; phaseIdx < BlackoilPhases::MaxNumPhases; ++phaseIdx) {
|
||||
if (!pu.phase_used[phaseIdx]) {
|
||||
pu.phase_pos[phaseIdx] = -1;
|
||||
}
|
||||
else {
|
||||
pu.phase_pos[phaseIdx] = numActivePhases;
|
||||
++ numActivePhases;
|
||||
pu.num_phases = numActivePhases;
|
||||
}
|
||||
}
|
||||
|
||||
// We need oil systems, since we do not support the keywords needed for
|
||||
// water-gas systems.
|
||||
if (!pu.phase_used[BlackoilPhases::Liquid] && !(pu.num_phases == 1)) {
|
||||
OPM_THROW(std::runtime_error, "Cannot handle cases with no OIL, i.e. water-gas systems.");
|
||||
}
|
||||
|
||||
// Add solvent info
|
||||
pu.has_solvent = phases.active(Phase::SOLVENT);
|
||||
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;
|
||||
}
|
||||
else
|
||||
pu.phase_pos[BlackoilPhases::Solvent] = -1;
|
||||
|
||||
// Add polymer info
|
||||
pu.has_polymer = phases.active(Phase::POLYMER);
|
||||
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;
|
||||
}
|
||||
else
|
||||
pu.phase_pos[BlackoilPhases::Polymer] = -1;
|
||||
|
||||
// Add energy info
|
||||
pu.has_energy = phases.active(Phase::ENERGY);
|
||||
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;
|
||||
}
|
||||
else
|
||||
pu.phase_pos[BlackoilPhases::Energy] = -1;
|
||||
|
||||
// Add polymer molecular weight related
|
||||
pu.has_polymermw = phases.active(Phase::POLYMW);
|
||||
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;
|
||||
|
||||
// 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;
|
||||
|
||||
// Add brine info
|
||||
pu.has_brine = phases.active(Phase::BRINE);
|
||||
if (pu.has_brine) {
|
||||
pu.phase_pos[BlackoilPhases::Brine] = numActivePhases;
|
||||
++ numActivePhases;
|
||||
}
|
||||
else
|
||||
pu.phase_pos[BlackoilPhases::Brine] = -1;
|
||||
|
||||
// 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;
|
||||
|
||||
|
||||
return pu;
|
||||
}
|
||||
PhaseUsage phaseUsage(const Phases& phases);
|
||||
|
||||
/// 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);
|
||||
}
|
||||
PhaseUsage phaseUsageFromDeck(const Opm::EclipseState& eclipseState);
|
||||
|
||||
/// Looks at presence of WATER, OIL and GAS keywords in deck
|
||||
/// to determine active phases.
|
||||
inline PhaseUsage phaseUsageFromDeck(const Opm::Deck& deck)
|
||||
{
|
||||
Runspec runspec( deck );
|
||||
const auto& phases = runspec.phases();
|
||||
|
||||
return phaseUsage(phases);
|
||||
}
|
||||
|
||||
PhaseUsage phaseUsageFromDeck(const Opm::Deck& deck);
|
||||
}
|
||||
|
||||
#endif // OPM_PHASEUSAGEFROMDECK_HEADER_INCLUDED
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
|
Loading…
Reference in New Issue
Block a user