Add UnitSystem::from_si() and to_si based on string

This commit is contained in:
Joakim Hove
2021-11-24 08:48:56 +01:00
parent 685c8b06f2
commit 24a8c09956
2 changed files with 12 additions and 0 deletions

View File

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

View File

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