FEDEM Solver  R8.0
Source code of the dynamics solver
Classes | Public Member Functions | Private Types | Private Attributes | Friends | List of all members
FFaUnitCalculator Class Reference

Class holding a set of unit conversions for physical properties. More...

#include <FFaUnitCalculator.H>

Classes

struct  SingleUnit
 Struct representing a single unit conversion. More...
 

Public Member Functions

 FFaUnitCalculator (const char *n=NULL)
 Default constructor. More...
 
bool isValid () const
 Returns true if *this is valid, i.e., name is defined. More...
 
bool operator== (const FFaUnitCalculator &cal) const
 Equality operator. More...
 
const std::string & getName () const
 Returns the name of the unit calculator. More...
 
const std::string & getOrigUnits () const
 Returns the name of the original unit set. More...
 
const std::string & getConvUnits () const
 Returns the name of the converted-to unit set. More...
 
template<class T >
bool convert (T &value, const std::string &aName) const
 Converts a named physical property. More...
 
bool convert (double &value, const std::string &aName, int prec) const
 Conversion with rounding to prec significant digits. More...
 
template<class T >
bool inverse (T &value, const std::string &aName) const
 Reversed conversion for a named physical property. More...
 
double convFactor (const std::string &aName) const
 Returns the conversion factor for a named physical property. More...
 
std::string origUnitName (const std::string &aName) const
 Returns the original unit name for a named physical property. More...
 
std::string convUnitName (const std::string &aName) const
 Returns the converted-to unit name for a named physical property. More...
 
void addConversion (const std::string &propName, double sf, const std::string &origUnit="", const std::string &convUnit="")
 Adds a unit conversion to the set of conversion rules. More...
 

Private Types

using SingleUnitMap = std::map< std::string, SingleUnit >
 Convenience type alias. More...
 
using SingleUnitIter = SingleUnitMap::const_iterator
 Convenience type alias. More...
 

Private Attributes

std::string name
 Name of the unit calculator. More...
 
std::string origGroup
 Name of the original unit set. More...
 
std::string convGroup
 Name of the converted-to unit set. More...
 
SingleUnitMap myConvFactors
 Unit converter container. More...
 

Friends

std::ostream & operator<< (std::ostream &, const FFaUnitCalculator &)
 Global printing operator. More...
 
std::istream & operator>> (std::istream &, FFaUnitCalculator &)
 Global reading operator. More...
 

Detailed Description

Class holding a set of unit conversions for physical properties.

Member Typedef Documentation

◆ SingleUnitIter

using FFaUnitCalculator::SingleUnitIter = SingleUnitMap::const_iterator
private

Convenience type alias.

◆ SingleUnitMap

using FFaUnitCalculator::SingleUnitMap = std::map<std::string,SingleUnit>
private

Convenience type alias.

Constructor & Destructor Documentation

◆ FFaUnitCalculator()

FFaUnitCalculator::FFaUnitCalculator ( const char *  n = NULL)
inlineexplicit

Default constructor.

Member Function Documentation

◆ addConversion()

void FFaUnitCalculator::addConversion ( const std::string &  propName,
double  sf,
const std::string &  origUnit = "",
const std::string &  convUnit = "" 
)

Adds a unit conversion to the set of conversion rules.

Parameters
[in]propNameName of the physical property to convert
[in]sfConversion factor for the property parameter
[in]origUnitOriginal unit name for the property parameter
[in]convUnitConverted-to unit name for the property parameter

◆ convert() [1/2]

bool FFaUnitCalculator::convert ( double &  value,
const std::string &  aName,
int  prec 
) const

Conversion with rounding to prec significant digits.

◆ convert() [2/2]

template<class T >
bool FFaUnitCalculator::convert ( T &  value,
const std::string &  aName 
) const
inline

Converts a named physical property.

◆ convFactor()

double FFaUnitCalculator::convFactor ( const std::string &  aName) const
inline

Returns the conversion factor for a named physical property.

◆ convUnitName()

std::string FFaUnitCalculator::convUnitName ( const std::string &  aName) const
inline

Returns the converted-to unit name for a named physical property.

◆ getConvUnits()

const std::string& FFaUnitCalculator::getConvUnits ( ) const
inline

Returns the name of the converted-to unit set.

◆ getName()

const std::string& FFaUnitCalculator::getName ( ) const
inline

Returns the name of the unit calculator.

◆ getOrigUnits()

const std::string& FFaUnitCalculator::getOrigUnits ( ) const
inline

Returns the name of the original unit set.

◆ inverse()

template<class T >
bool FFaUnitCalculator::inverse ( T &  value,
const std::string &  aName 
) const
inline

Reversed conversion for a named physical property.

◆ isValid()

bool FFaUnitCalculator::isValid ( ) const
inline

Returns true if *this is valid, i.e., name is defined.

◆ operator==()

bool FFaUnitCalculator::operator== ( const FFaUnitCalculator &  cal) const

Equality operator.

◆ origUnitName()

std::string FFaUnitCalculator::origUnitName ( const std::string &  aName) const
inline

Returns the original unit name for a named physical property.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  ,
const FFaUnitCalculator &   
)
friend

Global printing operator.

◆ operator>>

std::istream& operator>> ( std::istream &  ,
FFaUnitCalculator &   
)
friend

Global reading operator.

Member Data Documentation

◆ convGroup

std::string FFaUnitCalculator::convGroup
private

Name of the converted-to unit set.

◆ myConvFactors

SingleUnitMap FFaUnitCalculator::myConvFactors
private

Unit converter container.

◆ name

std::string FFaUnitCalculator::name
private

Name of the unit calculator.

◆ origGroup

std::string FFaUnitCalculator::origGroup
private

Name of the original unit set.


The documentation for this class was generated from the following files: