From c4e814971732bc25a07998345f014f50c331ddb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Tue, 19 Jul 2016 12:51:04 +0200 Subject: [PATCH] UnitSystem string-description of a unit Analoguous to to/from_si but for string-representation of the unit in question. --- opm/parser/eclipse/Units/UnitSystem.cpp | 48 +++++++++++++++++++++++++ opm/parser/eclipse/Units/UnitSystem.hpp | 2 ++ 2 files changed, 50 insertions(+) diff --git a/opm/parser/eclipse/Units/UnitSystem.cpp b/opm/parser/eclipse/Units/UnitSystem.cpp index 1b130caad..e594ffc92 100644 --- a/opm/parser/eclipse/Units/UnitSystem.cpp +++ b/opm/parser/eclipse/Units/UnitSystem.cpp @@ -77,6 +77,29 @@ namespace { Metric::ReservoirVolume / Metric::Time, Metric::Transmissibility, Metric::Mass, + 1, /* gas-oil ratio */ + 1, /* oil-gas ratio */ + 1, /* water cut */ + }; + + static constexpr const char* metric_names[] = { + "", + "M", + "DAY", + "KG/M3", + "BARSA", + "K", + "C", + "CP", + "MD", + "SM3", + "SM3", + "RM3", + "SM3/DAY", + "SM3/DAY", + "RM3/DAY", + "CPR3/DAY/BARS", + "KG" }; static const double to_field[] = { @@ -119,6 +142,25 @@ namespace { Field::Mass, }; + static constexpr const char* field_names[] = { + "", + "FT", + "DAY", + "LB/FT3", + "PSIA", + "R", + "F", + "CP", + "MD", + "STB", + "MSCF", + "RB", + "STB/DAY", + "MSCF/DAY", + "RB/DAY", + "CPRB/DAY/PSI", + "LB" + }; } UnitSystem::UnitSystem(const UnitType unit) : @@ -129,11 +171,13 @@ namespace { m_name = "Metric"; this->measure_table_from_si = to_metric; this->measure_table_to_si = from_metric; + this->unit_name_table = metric_names; break; case(UNIT_TYPE_FIELD): m_name = "Field"; this->measure_table_from_si = to_field; this->measure_table_to_si = from_field; + this->unit_name_table = field_names; break; case(UNIT_TYPE_LAB): m_name = "Lab"; @@ -263,6 +307,10 @@ namespace { return this->measure_table_to_si[ static_cast< int >( m ) ] * val; } + const char* UnitSystem::name( measure m ) const { + return this->unit_name_table[ static_cast< int >( m ) ]; + } + UnitSystem * UnitSystem::newMETRIC() { UnitSystem * system = new UnitSystem(UNIT_TYPE_METRIC); diff --git a/opm/parser/eclipse/Units/UnitSystem.hpp b/opm/parser/eclipse/Units/UnitSystem.hpp index 13a7fa381..819fcdf1a 100644 --- a/opm/parser/eclipse/Units/UnitSystem.hpp +++ b/opm/parser/eclipse/Units/UnitSystem.hpp @@ -72,6 +72,7 @@ namespace Opm { double from_si( measure, double ) const; double to_si( measure, double ) const; + const char* name( measure ) const; static UnitSystem * newMETRIC(); static UnitSystem * newFIELD(); @@ -83,6 +84,7 @@ namespace Opm { std::map > m_dimensions; const double* measure_table_from_si; const double* measure_table_to_si; + const char* const* unit_name_table; }; }