Add static method for conversion between unit system enums

This commit is contained in:
Joakim Hove
2018-10-16 00:12:53 +02:00
parent c81e5027c9
commit 5283611695
2 changed files with 13 additions and 7 deletions

View File

@@ -97,6 +97,7 @@ namespace Opm {
void to_si( measure, std::vector<double>& ) 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();

View File

@@ -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<std::string> dimensionList;