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:
@@ -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);
|
||||
|
||||
|
||||
@@ -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<std::string , std::shared_ptr<const Dimension> > m_dimensions;
|
||||
const double* measure_table_from_si;
|
||||
const double* measure_table_to_si;
|
||||
const char* const* unit_name_table;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user