unitConversion Class Reference

Unit conversion structure. Contains the associated dimensions and the multiplier with which to convert values. More...

Inheritance diagram for unitConversion:
Collaboration diagram for unitConversion:

Public Types

enum  { nDimlessUnits = 2 }
 Define an enumeration for the number of dimensionless units. More...
 
enum  dimlessUnitType { FRACTION , ANGLE }
 Define an enumeration for the names of the dimensionless unit. More...
 

Public Member Functions

 ClassName ("unitConversion")
 Run time type information. More...
 
 unitConversion (const dimensionSet &, const scalar fraction, const scalar angle, const scalar multiplier)
 Construct from components. More...
 
 unitConversion (const dimensionSet &)
 Construct from a dimension set. No dimensionless units. Unity. More...
 
 unitConversion (const unitConversion &)=default
 Copy constructor. More...
 
 unitConversion (unitConversion &&)=default
 Move constructor. More...
 
 unitConversion (Istream &is)
 Construct from stream. More...
 
const dimensionSetdimensions () const
 Access the dimensions. More...
 
template<class T >
T toStandard (const T &) const
 Convert a value to standard units. More...
 
template<class T >
List< TtoStandard (const List< T > &) const
 Convert a list of values to standard units. More...
 
template<class T >
tmp< Field< T > > toStandard (const Field< T > &) const
 Convert a field of values to standard units. More...
 
template<class T >
tmp< Field< T > > toStandard (const tmp< Field< T >> &) const
 Convert a tmp field of values to standard units. More...
 
template<class T >
void makeStandard (T &) const
 Convert a value to standard units. More...
 
template<class T >
void makeStandard (List< T > &) const
 Convert a list of values to standard units. More...
 
template<class T >
T toUser (const T &) const
 Convert a value to user units. More...
 
template<class T >
List< TtoUser (const List< T > &) const
 Convert a list of values to user units. More...
 
template<class T >
tmp< Field< T > > toUser (const Field< T > &) const
 Convert a field of values to user units. More...
 
template<class T >
tmp< Field< T > > toUser (const tmp< Field< T >> &) const
 Convert a tmp field of values to user units. More...
 
bool any () const
 Return whether this is the "any" unit. I.e., the case where. More...
 
bool none () const
 Return whether this is the "none" unit. I.e., the case where unit. More...
 
bool standard () const
 Return whether this unit is standard. I.e., is its multiplier one? More...
 
void reset (const unitConversion &)
 Reset the unit conversion. More...
 
void read (const word &keyword, const dictionary &)
 Update. More...
 
bool readIfPresent (const word &keyword, const dictionary &)
 Update if found in the dictionary. More...
 
bool readIfPresent (Istream &is)
 Update if found on the stream. More...
 
bool readIfPresent (const word &keyword, const dictionary &, Istream &is)
 Update if found on the dictionary stream. More...
 
InfoProxy< unitConversioninfo () const
 Return info proxy. More...
 
void operator= (const unitConversion &)=delete
 Disallow default bitwise assignment. More...
 
void operator= (const unitConversion &&)=delete
 Disallow default bitwise move assignment. More...
 
template<class T >
Foam::List< TtoStandard (const List< T > &l) const
 
template<class T >
Foam::tmp< Foam::Field< T > > toStandard (const Field< T > &f) const
 
template<class T >
Foam::tmp< Foam::Field< T > > toStandard (const tmp< Field< T >> &tf) const
 
template<class T >
Foam::List< TtoUser (const List< T > &l) const
 
template<class T >
Foam::tmp< Foam::Field< T > > toUser (const Field< T > &f) const
 
template<class T >
Foam::tmp< Foam::Field< T > > toUser (const tmp< Field< T >> &tf) const
 

Static Public Attributes

static const NamedEnum< dimlessUnitType, 2 > dimlessUnitTypeNames_
 Names of the dimensionless units. More...
 
static const scalar smallExponent = rootSmall
 A small exponent with which to perform inexact comparisons. More...
 

Friends

unitConversion pow (const unitConversion &, const scalar)
 Raise to a power. More...
 
const unitConversionoperator+ (const unitConversion &, const unitConversion &)
 Combine. More...
 
unitConversion operator* (const unitConversion &, const unitConversion &)
 Multiply. More...
 
unitConversion operator/ (const unitConversion &, const unitConversion &)
 Divide. More...
 
Istreamoperator>> (Istream &, unitConversion &)
 Read from stream. More...
 
Ostreamoperator<< (Ostream &, const unitConversion &)
 Write to stream. More...
 
Ostreamoperator<< (Ostream &, const InfoProxy< unitConversion > &)
 Write info to stream. More...
 

Detailed Description

Unit conversion structure. Contains the associated dimensions and the multiplier with which to convert values.

Source files

Definition at line 67 of file unitConversion.H.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Define an enumeration for the number of dimensionless units.

Enumerator
nDimlessUnits 

Definition at line 74 of file unitConversion.H.

◆ dimlessUnitType

Define an enumeration for the names of the dimensionless unit.

exponents

Enumerator
FRACTION 
ANGLE 

Definition at line 81 of file unitConversion.H.

Constructor & Destructor Documentation

◆ unitConversion() [1/5]

unitConversion ( const dimensionSet dimensions,
const scalar  fraction,
const scalar  angle,
const scalar  multiplier 
)

Construct from components.

Definition at line 90 of file unitConversion.C.

References unitConversion::ANGLE, and unitConversion::FRACTION.

◆ unitConversion() [2/5]

unitConversion ( const dimensionSet dimensions)

Construct from a dimension set. No dimensionless units. Unity.

multiplier.

Definition at line 106 of file unitConversion.C.

References unitConversion::ANGLE, and unitConversion::FRACTION.

◆ unitConversion() [3/5]

unitConversion ( const unitConversion )
default

Copy constructor.

◆ unitConversion() [4/5]

unitConversion ( unitConversion &&  )
default

Move constructor.

◆ unitConversion() [5/5]

Construct from stream.

Definition at line 32 of file unitConversionIO.C.

Member Function Documentation

◆ ClassName()

ClassName ( "unitConversion"  )

Run time type information.

◆ dimensions()

const Foam::dimensionSet & dimensions ( ) const
inline

Access the dimensions.

Definition at line 31 of file unitConversionI.H.

◆ toStandard() [1/7]

T toStandard ( const T t) const

Convert a value to standard units.

Definition at line 31 of file unitConversionTemplates.C.

References unitConversion::standard().

Referenced by Foam::degToRad().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toStandard() [2/7]

List<T> toStandard ( const List< T > &  ) const

Convert a list of values to standard units.

◆ toStandard() [3/7]

tmp<Field<T> > toStandard ( const Field< T > &  ) const

Convert a field of values to standard units.

◆ toStandard() [4/7]

tmp<Field<T> > toStandard ( const tmp< Field< T >> &  ) const

Convert a tmp field of values to standard units.

◆ makeStandard() [1/2]

void makeStandard ( T t) const

Convert a value to standard units.

Definition at line 66 of file unitConversionTemplates.C.

◆ makeStandard() [2/2]

void makeStandard ( List< T > &  l) const

Convert a list of values to standard units.

Definition at line 76 of file unitConversionTemplates.C.

References forAll.

◆ toUser() [1/7]

T toUser ( const T t) const

Convert a value to user units.

Definition at line 89 of file unitConversionTemplates.C.

Referenced by greyMean::aCont(), wideBand::aCont(), Foam::radToDeg(), and Foam::writeEntry().

Here is the caller graph for this function:

◆ toUser() [2/7]

List<T> toUser ( const List< T > &  ) const

Convert a list of values to user units.

◆ toUser() [3/7]

tmp<Field<T> > toUser ( const Field< T > &  ) const

Convert a field of values to user units.

◆ toUser() [4/7]

tmp<Field<T> > toUser ( const tmp< Field< T >> &  ) const

Convert a tmp field of values to user units.

◆ any()

bool any ( ) const
inline

Return whether this is the "any" unit. I.e., the case where.

dimensions and dimensionless units are not checked, and any conversion is permitted.

Definition at line 37 of file unitConversionI.H.

◆ none()

bool none ( ) const
inline

Return whether this is the "none" unit. I.e., the case where unit.

conversions are prohibited.

Definition at line 43 of file unitConversionI.H.

◆ standard()

bool standard ( ) const
inline

Return whether this unit is standard. I.e., is its multiplier one?

Definition at line 49 of file unitConversionI.H.

References Foam::any().

Referenced by unitConversion::toStandard().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void reset ( const unitConversion units)

Reset the unit conversion.

Definition at line 118 of file unitConversion.C.

References unitConversion::nDimlessUnits, and Foam::units().

Referenced by Foam::operator>>(), and unitConversions::unitConversions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read()

void read ( const word keyword,
const dictionary dict 
)

Update.

Definition at line 43 of file unitConversionIO.C.

References Foam::abort(), dict, Foam::FatalIOError, FatalIOErrorInFunction, dictionary::lookup(), and Foam::units().

Referenced by namedUnitConversion::read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readIfPresent() [1/3]

bool readIfPresent ( const word keyword,
const dictionary dict 
)

Update if found in the dictionary.

Definition at line 59 of file unitConversionIO.C.

References Foam::abort(), dict, Foam::endl(), Foam::FatalIOError, FatalIOErrorInFunction, IOInfoInFunction, dictionary::lookupEntryPtr(), entry::stream(), Foam::units(), and dictionary::writeOptionalEntries.

Referenced by namedUnitConversion::readIfPresent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readIfPresent() [2/3]

bool readIfPresent ( Istream is)

Update if found on the stream.

Definition at line 98 of file unitConversionIO.C.

References Foam::abort(), Foam::any(), token::BEGIN_SQR, Foam::endl(), Foam::FatalIOError, FatalIOErrorInFunction, Foam::Info, unitConversion::info(), IOstream::lineNumber(), IOstream::name(), and Istream::putBack().

Here is the call graph for this function:

◆ readIfPresent() [3/3]

bool readIfPresent ( const word keyword,
const dictionary dict,
Istream is 
)

Update if found on the dictionary stream.

Definition at line 128 of file unitConversionIO.C.

References Foam::abort(), Foam::any(), token::BEGIN_SQR, dict, Foam::endl(), Foam::FatalIOError, FatalIOErrorInFunction, Foam::Info, unitConversion::info(), dictionaryName::name(), and Istream::putBack().

Here is the call graph for this function:

◆ info()

InfoProxy<unitConversion> info ( ) const
inline

Return info proxy.

Definition at line 231 of file unitConversion.H.

Referenced by unitConversion::readIfPresent().

Here is the caller graph for this function:

◆ operator=() [1/2]

void operator= ( const unitConversion )
delete

Disallow default bitwise assignment.

◆ operator=() [2/2]

void operator= ( const unitConversion &&  )
delete

Disallow default bitwise move assignment.

◆ toStandard() [5/7]

Foam::List<T> toStandard ( const List< T > &  l) const

Definition at line 38 of file unitConversionTemplates.C.

References forAll, and List< T >::size().

Here is the call graph for this function:

◆ toStandard() [6/7]

Foam::tmp<Foam::Field<T> > toStandard ( const Field< T > &  f) const

Definition at line 51 of file unitConversionTemplates.C.

References f().

Here is the call graph for this function:

◆ toStandard() [7/7]

Foam::tmp<Foam::Field<T> > toStandard ( const tmp< Field< T >> &  tf) const

Definition at line 59 of file unitConversionTemplates.C.

References tf.

◆ toUser() [5/7]

Foam::List<T> toUser ( const List< T > &  l) const

Definition at line 96 of file unitConversionTemplates.C.

References forAll, and List< T >::size().

Here is the call graph for this function:

◆ toUser() [6/7]

Foam::tmp<Foam::Field<T> > toUser ( const Field< T > &  f) const

Definition at line 109 of file unitConversionTemplates.C.

References f().

Here is the call graph for this function:

◆ toUser() [7/7]

Foam::tmp<Foam::Field<T> > toUser ( const tmp< Field< T >> &  tf) const

Definition at line 117 of file unitConversionTemplates.C.

References tf.

Friends And Related Function Documentation

◆ pow

unitConversion pow ( const unitConversion ,
const  scalar 
)
friend

Raise to a power.

◆ operator+

const unitConversion& operator+ ( const unitConversion ,
const unitConversion  
)
friend

Combine.

◆ operator*

unitConversion operator* ( const unitConversion ,
const unitConversion  
)
friend

Multiply.

◆ operator/

unitConversion operator/ ( const unitConversion ,
const unitConversion  
)
friend

Divide.

◆ operator>>

Istream& operator>> ( Istream ,
unitConversion  
)
friend

Read from stream.

◆ operator<< [1/2]

Ostream& operator<< ( Ostream ,
const unitConversion  
)
friend

Write to stream.

◆ operator<< [2/2]

Ostream& operator<< ( Ostream ,
const InfoProxy< unitConversion > &   
)
friend

Write info to stream.

Member Data Documentation

◆ dimlessUnitTypeNames_

const Foam::NamedEnum< Foam::unitConversion::dimlessUnitType, 2 > dimlessUnitTypeNames_
static

Names of the dimensionless units.

Definition at line 88 of file unitConversion.H.

Referenced by Foam::operator<<().

◆ smallExponent

const scalar smallExponent = rootSmall
static

A small exponent with which to perform inexact comparisons.

Definition at line 94 of file unitConversion.H.

Referenced by Foam::operator<<().


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