From 52836116953c90a2d0c4b6743739427ace43be00 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Tue, 16 Oct 2018 00:12:53 +0200 Subject: [PATCH] Add static method for conversion between unit system enums --- opm/parser/eclipse/Units/UnitSystem.hpp | 1 + src/opm/parser/eclipse/Units/UnitSystem.cpp | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/opm/parser/eclipse/Units/UnitSystem.hpp b/opm/parser/eclipse/Units/UnitSystem.hpp index 711e54605..5b4f3724b 100644 --- a/opm/parser/eclipse/Units/UnitSystem.hpp +++ b/opm/parser/eclipse/Units/UnitSystem.hpp @@ -97,6 +97,7 @@ namespace Opm { void to_si( measure, std::vector& ) const; const char* name( measure ) const; + static ert_ecl_unit_enum ecl_units(UnitType opm_unit); static UnitSystem newMETRIC(); static UnitSystem newFIELD(); static UnitSystem newLAB(); diff --git a/src/opm/parser/eclipse/Units/UnitSystem.cpp b/src/opm/parser/eclipse/Units/UnitSystem.cpp index 6ee8936fe..fc668089e 100644 --- a/src/opm/parser/eclipse/Units/UnitSystem.cpp +++ b/src/opm/parser/eclipse/Units/UnitSystem.cpp @@ -797,19 +797,24 @@ 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; - case UnitType::UNIT_TYPE_PVT_M: return ECL_PVT_M_UNITS; - case UnitType::UNIT_TYPE_INPUT: throw std::runtime_error("UNIT_TYPE_INPUT has no counterpart in the ert_ecl_unit_enum type."); + ert_ecl_unit_enum UnitSystem::ecl_units(UnitSystem::UnitType opm_type) { + switch ( opm_type ) { + 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; + case UnitType::UNIT_TYPE_PVT_M: return ECL_PVT_M_UNITS; + case UnitType::UNIT_TYPE_INPUT: throw std::runtime_error("UNIT_TYPE_INPUT has no counterpart in the ert_ecl_unit_enum type."); default: throw std::runtime_error("What has happened here?"); } } + ert_ecl_unit_enum UnitSystem::getEclType() const { + return UnitSystem::ecl_units( this->m_unittype ); + } + + Dimension UnitSystem::parseFactor(const std::string& dimension) const { std::vector dimensionList;