Added method Runspec::eclPhaseMask( )

This commit is contained in:
Joakim Hove
2017-01-11 13:46:51 +01:00
parent d4c7d6f92e
commit 4f076c4813
3 changed files with 17 additions and 2 deletions

View File

@@ -19,6 +19,8 @@
#include <ostream>
#include <type_traits>
#include <ert/ecl/ecl_util.h>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
@@ -84,4 +86,14 @@ const EndpointScaling& Runspec::endpointScaling() const noexcept {
return this->endscale;
}
/*
Returns an integer in the range 0...7 which can be used to indicate
available phases in Eclipse restart and init files.
*/
int Runspec::eclPhaseMask( ) const noexcept {
return ( active_phases.active( Phase::WATER ) ? ECL_WATER_PHASE : 0 )
| ( active_phases.active( Phase::OIL ) ? ECL_OIL_PHASE : 0 )
| ( active_phases.active( Phase::GAS ) ? ECL_GAS_PHASE : 0 );
}
}

View File

@@ -46,7 +46,6 @@ class Phases {
bool active( Phase ) const noexcept;
size_t size() const noexcept;
private:
std::bitset< 4 > bits;
};
@@ -59,8 +58,9 @@ class Runspec {
const Phases& phases() const noexcept;
const Tabdims& tabdims() const noexcept;
const EndpointScaling& endpointScaling() const noexcept;
int eclPhaseMask( ) const noexcept;
private:
private:
Phases active_phases;
Tabdims m_tabdims;
EndpointScaling endscale;

View File

@@ -21,6 +21,8 @@ along with OPM. If not, see <http://www.gnu.org/licenses/>.
#include <boost/test/unit_test.hpp>
#include <ert/ecl/ecl_util.h>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
@@ -57,6 +59,7 @@ BOOST_AUTO_TEST_CASE(TwoPhase) {
BOOST_CHECK( phases.active( Phase::OIL ) );
BOOST_CHECK( !phases.active( Phase::GAS ) );
BOOST_CHECK( phases.active( Phase::WATER ) );
BOOST_CHECK_EQUAL( ECL_OIL_PHASE + ECL_WATER_PHASE , runspec.eclPhaseMask( ));
}
BOOST_AUTO_TEST_CASE(ThreePhase) {