From c12d8c2e5daa05561023aae4ccdf9457efbe5e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 5 Jan 2012 09:34:05 +0100 Subject: [PATCH] Moved active phase determination into own function. --- .../fluid/blackoil/BlackoilPvtProperties.hpp | 8 ++- .../fluid/blackoil/phaseUsageFromDeck.hpp | 71 +++++++++++++++++++ 2 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 opm/core/fluid/blackoil/phaseUsageFromDeck.hpp diff --git a/opm/core/fluid/blackoil/BlackoilPvtProperties.hpp b/opm/core/fluid/blackoil/BlackoilPvtProperties.hpp index 680f65481..fbb744d4e 100644 --- a/opm/core/fluid/blackoil/BlackoilPvtProperties.hpp +++ b/opm/core/fluid/blackoil/BlackoilPvtProperties.hpp @@ -43,6 +43,10 @@ namespace Opm class BlackoilPvtProperties : public BlackoilPhases { public: + /// Default constructor. + BlackoilPvtProperties(); + + /// Initialize from deck. void init(const Dune::EclipseGridParser& deck); /// Number of active phases. @@ -99,9 +103,7 @@ namespace Opm BlackoilPvtProperties(const BlackoilPvtProperties&); BlackoilPvtProperties& operator=(const BlackoilPvtProperties&); - int num_phases_; - int phase_used_[MaxNumPhases]; - int phase_pos_[MaxNumPhases]; + PhaseUsage phase_usage_; int region_number_; diff --git a/opm/core/fluid/blackoil/phaseUsageFromDeck.hpp b/opm/core/fluid/blackoil/phaseUsageFromDeck.hpp new file mode 100644 index 000000000..910f38ba1 --- /dev/null +++ b/opm/core/fluid/blackoil/phaseUsageFromDeck.hpp @@ -0,0 +1,71 @@ +/* + 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 . +*/ + +#ifndef OPM_PHASEUSAGEFROMDECK_HEADER_INCLUDED +#define OPM_PHASEUSAGEFROMDECK_HEADER_INCLUDED + + +#include +#include + + +namespace Opm +{ + + + /// Looks at presence of WATER, OIL and GAS keywords in deck + /// to determine active phases. + PhaseUsage phaseUsageFromDeck(const Dune::EclipseGridParser& deck) + { + PhaseUsage pu; + std::fill(pu.phase_used, pu.phase_used + BlackoilPhases::MaxNumPhases, 0); + + // Discover phase usage. + if (deck.hasField("WATER")) { + pu.phase_used[BlackoilPhases::Aqua] = 1; + } + if (deck.hasField("OIL")) { + pu.phase_used[BlackoilPhases::Liquid] = 1; + } + if (deck.hasField("GAS")) { + pu.phase_used[BlackoilPhases::Vapour] = 1; + } + pu.num_phases = 0; + for (int i = 0; i < BlackoilPhases::MaxNumPhases; ++i) { + 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) { + THROW("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]) { + THROW("Cannot handle cases with no OIL, i.e. water-gas systems."); + } + + return pu; + } + +} + +#endif // OPM_PHASEUSAGEFROMDECK_HEADER_INCLUDED