Add UnitSystem::from_si() and to_si based on string
This commit is contained in:
@@ -110,6 +110,8 @@ namespace Opm {
|
||||
|
||||
Dimension parse(const std::string& dimension) const;
|
||||
|
||||
double from_si( const std::string& dimension, double );
|
||||
double to_si( const std::string& dimension, double );
|
||||
double from_si( measure, double ) const;
|
||||
double to_si( measure, double ) const;
|
||||
void from_si( measure, std::vector<double>& ) const;
|
||||
|
||||
@@ -1437,6 +1437,16 @@ namespace {
|
||||
+ this->measure_table_to_si_offset[ static_cast< int >( m ) ];
|
||||
}
|
||||
|
||||
double UnitSystem::from_si( const std::string& dimension, double value) {
|
||||
const auto& dim = this->parse(dimension);
|
||||
return dim.convertSiToRaw(value);
|
||||
}
|
||||
|
||||
double UnitSystem::to_si( const std::string& dimension, double value) {
|
||||
const auto& dim = this->parse(dimension);
|
||||
return dim.convertRawToSi(value);
|
||||
}
|
||||
|
||||
void UnitSystem::from_si( measure m, std::vector<double>& data ) const {
|
||||
double factor = this->measure_table_from_si[ static_cast< int >( m ) ];
|
||||
double offset = this->measure_table_to_si_offset[ static_cast< int >( m ) ];
|
||||
|
||||
Reference in New Issue
Block a user