UnitSystem string-description of a unit

Analoguous to to/from_si but for string-representation of the unit in
question.
This commit is contained in:
Jørgen Kvalsvik
2016-07-19 12:51:04 +02:00
parent 19aa54a7e1
commit c4e8149717
2 changed files with 50 additions and 0 deletions

View File

@@ -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);