Added getEclType() to UnitSystem

This commit is contained in:
Joakim Hove
2017-01-11 15:46:39 +01:00
parent 4f076c4813
commit ef6def6511
3 changed files with 19 additions and 0 deletions

View File

@@ -364,6 +364,18 @@ namespace {
}
ert_ecl_unit_enum UnitSystem::getEclType() const {
switch ( m_unittype ) {
case UnitType::UNIT_TYPE_METRIC: return ECL_METRIC_UNITS;
case UnitType::UNIT_TYPE_FIELD: return ECL_FIELD_UNITS;
case UnitType::UNIT_TYPE_LAB: return ECL_LAB_UNITS;
default:
throw std::runtime_error("What has happened here?");
}
}
Dimension UnitSystem::parseFactor(const std::string& dimension) const {
std::vector<std::string> dimensionList;
boost::split(dimensionList , dimension , boost::is_any_of("*"));

View File

@@ -25,6 +25,8 @@
#include <vector>
#include <memory>
#include <ert/ecl/ecl_util.h>
#include <opm/parser/eclipse/Units/Dimension.hpp>
namespace Opm {
@@ -70,6 +72,7 @@ namespace Opm {
const std::string& getName() const;
UnitType getType() const;
ert_ecl_unit_enum getEclType( ) const;
void addDimension(const std::string& dimension, double SIfactor, double SIoffset = 0.0);
void addDimension( Dimension );

View File

@@ -142,6 +142,8 @@ BOOST_AUTO_TEST_CASE(CreateMetricSystem) {
BOOST_CHECK_EQUAL( Metric::Time , system.getDimension("Time").getSIScaling() );
BOOST_CHECK_EQUAL( Metric::Permeability , system.getDimension("Permeability").getSIScaling() );
BOOST_CHECK_EQUAL( Metric::Pressure , system.getDimension("Pressure").getSIScaling() );
BOOST_CHECK_EQUAL( system.getEclType( ) , ECL_METRIC_UNITS );
}
@@ -155,6 +157,8 @@ BOOST_AUTO_TEST_CASE(CreateFieldSystem) {
BOOST_CHECK_EQUAL( Field::Time , system.getDimension("Time").getSIScaling() );
BOOST_CHECK_EQUAL( Field::Permeability , system.getDimension("Permeability").getSIScaling() );
BOOST_CHECK_EQUAL( Field::Pressure , system.getDimension("Pressure").getSIScaling() );
BOOST_CHECK_EQUAL( system.getEclType( ) , ECL_FIELD_UNITS );
}