unitSet Class Reference

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

Inheritance diagram for unitSet:
Collaboration diagram for unitSet:

Classes

struct  makeStandardOp
 Functor to convert to standard. More...
 
struct  makeUserOp
 Functor to convert to user. More...
 

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 ("unitSet")
 Run time type information. More...
 
 unitSet (const dimensionSet &, const scalar fraction, const scalar angle, const scalar multiplier)
 Construct from components. More...
 
 unitSet (const dimensionSet &)
 Construct from a dimension set. No dimensionless units. Unity. More...
 
 unitSet (const unitSet &)=default
 Copy constructor. More...
 
 unitSet (unitSet &&)=default
 Move constructor. More...
 
 unitSet (Istream &is)
 Construct from stream. More...
 
const dimensionSetdimensions () const
 Access the dimensions. More...
 
bool dimensionless () const
 Return true if it is dimensionless. More...
 
template<class T >
T toStandard (const T &) const
 Convert a value to standard units. More...
 
template<class T >
void makeStandard (T &) const
 Convert a value to standard units. More...
 
template<class T >
T toUser (const T &) const
 Convert a value to user units. More...
 
template<class T >
void makeUser (T &) const
 Convert a value 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 unitSet &)
 Reset the unit conversion. More...
 
void read (const word &keyword, const dictionary &)
 Update. More...
 
void read (Istream &is)
 Update. More...
 
void read (const word &keyword, const dictionary &, Istream &is)
 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< unitSetinfo () const
 Return info proxy. More...
 
scalar operator[] (const dimensionSet::dimensionType type) const
 Access the dimension exponents. More...
 
scalar operator[] (const dimlessUnitType type) const
 Access the dimensionless unit exponents. More...
 
void operator= (const unitSet &)=delete
 Disallow default bitwise assignment. More...
 
void operator= (const unitSet &&)=delete
 Disallow default bitwise move assignment. More...
 

Static Public Member Functions

static unitSet newUnitless ()
 Return a new "unitless" unit set. More...
 
static unitSet newAny ()
 Return a new "any" unit set. More...
 
static unitSet newNone ()
 Return a new "none" unit set. More...
 

Static Public Attributes

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

Friends

unitSet pow (const unitSet &, const scalar)
 Raise to a power. More...
 
const unitSetoperator+ (const unitSet &, const unitSet &)
 Combine. More...
 
unitSet operator* (const unitSet &, const unitSet &)
 Multiply. More...
 
unitSet operator/ (const unitSet &, const unitSet &)
 Divide. More...
 
Istreamoperator>> (Istream &, unitSet &)
 Read from stream. More...
 
Ostreamoperator<< (Ostream &, const unitSet &)
 Write to stream. More...
 
Ostreamoperator<< (Ostream &, const InfoProxy< unitSet > &)
 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 unitSet.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 unitSet.H.

◆ dimlessUnitType

Define an enumeration for the names of the dimensionless unit.

exponents

Enumerator
FRACTION 
ANGLE 

Definition at line 81 of file unitSet.H.

Constructor & Destructor Documentation

◆ unitSet() [1/5]

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

Construct from components.

Definition at line 89 of file unitSet.C.

References unitSet::ANGLE, Foam::units::fraction, and unitSet::FRACTION.

Referenced by unitSet::newUnitless().

Here is the caller graph for this function:

◆ unitSet() [2/5]

unitSet ( const dimensionSet dimensions)

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

multiplier.

Definition at line 105 of file unitSet.C.

References unitSet::ANGLE, and unitSet::FRACTION.

◆ unitSet() [3/5]

unitSet ( const unitSet )
default

Copy constructor.

◆ unitSet() [4/5]

unitSet ( unitSet &&  )
default

Move constructor.

◆ unitSet() [5/5]

unitSet ( Istream is)

Construct from stream.

Definition at line 33 of file unitSetIO.C.

Member Function Documentation

◆ ClassName()

ClassName ( "unitSet"  )

Run time type information.

◆ newUnitless()

Foam::unitSet newUnitless ( )
inlinestatic

Return a new "unitless" unit set.

Definition at line 30 of file unitSetI.H.

References unitSet::unitSet().

Here is the call graph for this function:

◆ newAny()

Foam::unitSet newAny ( )
inlinestatic

Return a new "any" unit set.

Definition at line 36 of file unitSetI.H.

Referenced by Foam::readAndConvert().

Here is the caller graph for this function:

◆ newNone()

Foam::unitSet newNone ( )
inlinestatic

Return a new "none" unit set.

Definition at line 42 of file unitSetI.H.

◆ dimensions()

const Foam::dimensionSet & dimensions ( ) const
inline

Access the dimensions.

Definition at line 50 of file unitSetI.H.

Referenced by Foam::dimensionedConstant().

Here is the caller graph for this function:

◆ dimensionless()

bool dimensionless ( ) const
inline

Return true if it is dimensionless.

Definition at line 56 of file unitSetI.H.

◆ toStandard()

T toStandard ( const T t) const

Convert a value to standard units.

Definition at line 33 of file unitSetTemplates.C.

References unitSet::standard().

Referenced by TableReader< Coordinate, Value >::convertRead(), Foam::degToRad(), and Foam::dimensionedConstant().

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

◆ makeStandard()

void makeStandard ( T t) const

Convert a value to standard units.

Definition at line 40 of file unitSetTemplates.C.

Referenced by unitSet::makeStandardOp::operator()().

Here is the caller graph for this function:

◆ toUser()

T toUser ( const T t) const

Convert a value to user units.

Definition at line 50 of file unitSetTemplates.C.

Referenced by greyMean::aCont(), wideBand::aCont(), TableReader< Coordinate, Value >::convertWrite(), Foam::radToDeg(), and cyclicTransform::str().

Here is the caller graph for this function:

◆ makeUser()

void makeUser ( T t) const

Convert a value to user units.

Definition at line 57 of file unitSetTemplates.C.

Referenced by unitSet::makeUserOp::operator()().

Here is the caller graph for this function:

◆ 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 62 of file unitSetI.H.

Referenced by Foam::operator<<(), and Foam::pow().

Here is the caller graph for this function:

◆ none()

bool none ( ) const
inline

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

conversions are prohibited.

Definition at line 68 of file unitSetI.H.

Referenced by Foam::operator<<(), and Foam::pow().

Here is the caller graph for this function:

◆ standard()

bool standard ( ) const
inline

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

Definition at line 74 of file unitSetI.H.

References Foam::any().

Referenced by Foam::assertNoConvertUnits(), unitSet::toStandard(), and Foam::writeEntry().

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

◆ reset()

void reset ( const unitSet units)

Reset the unit conversion.

Definition at line 117 of file unitSet.C.

References unitSet::nDimlessUnits.

Referenced by Foam::operator>>(), Foam::units::setLength(), and unitSets::unitSets().

Here is the caller graph for this function:

◆ read() [1/3]

void read ( const word keyword,
const dictionary dict 
)

Update.

Definition at line 44 of file unitSetIO.C.

References Foam::abort(), dict, Foam::FatalIOError, FatalIOErrorInFunction, unitSet::info(), dictionary::lookup(), and dictionaryName::name().

Referenced by namedUnitSet::read().

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

◆ read() [2/3]

void read ( Istream is)

Update.

Definition at line 63 of file unitSetIO.C.

References Foam::abort(), Foam::FatalIOError, FatalIOErrorInFunction, and unitSet::info().

Here is the call graph for this function:

◆ read() [3/3]

void read ( const word keyword,
const dictionary dict,
Istream is 
)

Update.

Definition at line 81 of file unitSetIO.C.

References Foam::abort(), dict, Foam::FatalIOError, FatalIOErrorInFunction, unitSet::info(), and dictionaryName::name().

Here is the call graph for this function:

◆ readIfPresent() [1/3]

bool readIfPresent ( const word keyword,
const dictionary dict 
)

Update if found in the dictionary.

Definition at line 105 of file unitSetIO.C.

References Foam::abort(), dict, Foam::FatalIOError, FatalIOErrorInFunction, unitSet::info(), dictionary::lookupEntryPtr(), dictionaryName::name(), and entry::stream().

Referenced by Field< tensor >::clone(), Foam::readAndConvert(), namedUnitSet::readIfPresent(), and Field< tensor >::rmap().

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 139 of file unitSetIO.C.

References Foam::abort(), Foam::any(), token::BEGIN_SQR, Foam::endl(), Foam::FatalIOError, FatalIOErrorInFunction, Foam::Info, unitSet::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 171 of file unitSetIO.C.

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

Here is the call graph for this function:

◆ info()

InfoProxy<unitSet> info ( ) const
inline

Return info proxy.

Definition at line 228 of file unitSet.H.

Referenced by unitSet::read(), and unitSet::readIfPresent().

Here is the caller graph for this function:

◆ operator[]() [1/2]

Foam::scalar operator[] ( const dimensionSet::dimensionType  type) const
inline

Access the dimension exponents.

Definition at line 82 of file unitSetI.H.

References Foam::type().

Here is the call graph for this function:

◆ operator[]() [2/2]

Foam::scalar operator[] ( const dimlessUnitType  type) const
inline

Access the dimensionless unit exponents.

Definition at line 91 of file unitSetI.H.

References Foam::type().

Here is the call graph for this function:

◆ operator=() [1/2]

void operator= ( const unitSet )
delete

Disallow default bitwise assignment.

◆ operator=() [2/2]

void operator= ( const unitSet &&  )
delete

Disallow default bitwise move assignment.

Friends And Related Function Documentation

◆ pow

unitSet pow ( const unitSet ,
const  scalar 
)
friend

Raise to a power.

◆ operator+

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

Combine.

◆ operator*

unitSet operator* ( const unitSet ,
const unitSet  
)
friend

Multiply.

◆ operator/

unitSet operator/ ( const unitSet ,
const unitSet  
)
friend

Divide.

◆ operator>>

Istream& operator>> ( Istream ,
unitSet  
)
friend

Read from stream.

◆ operator<< [1/2]

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

Write to stream.

◆ operator<< [2/2]

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

Write info to stream.

Member Data Documentation

◆ dimlessUnitTypeNames_

const Foam::NamedEnum< Foam::unitSet::dimlessUnitType, 2 > & dimlessUnitTypeNames_ = dimlessUnitTypeNamesPtr_()
static

Names of the dimensionless units.

Definition at line 88 of file unitSet.H.

Referenced by Foam::operator<<().

◆ smallExponent

const Foam::scalar smallExponent = rootSmall
static

A small exponent with which to perform inexact comparisons.

Definition at line 94 of file unitSet.H.

Referenced by Foam::operator<<().


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