dimensionedType gets plain lookupOrDefault() static method

This commit is contained in:
Mark Olesen
2009-01-16 12:17:02 +01:00
parent 246d569c4d
commit b6b5eb17d7
2 changed files with 26 additions and 4 deletions

View File

@ -35,6 +35,20 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template <class Type>
dimensioned<Type> dimensioned<Type>::lookupOrDefault
(
const word& name,
const dictionary& dict,
const Type& defaultValue,
const dimensionSet& dims
)
{
Type value = dict.lookupOrDefault<Type>(name, defaultValue);
return dimensioned<Type>(name, dims, value);
}
template <class Type> template <class Type>
dimensioned<Type> dimensioned<Type>::lookupOrAddToDict dimensioned<Type> dimensioned<Type>::lookupOrAddToDict
( (

View File

@ -108,8 +108,17 @@ public:
//- Construct from an Istream with a given name and dimensions //- Construct from an Istream with a given name and dimensions
dimensioned(const word&, const dimensionSet&, Istream&); dimensioned(const word&, const dimensionSet&, Istream&);
//- Construct from dictionary, supplying default value so that if the //- Construct from dictionary, with default value.
// value is not found, it is added into the dictionary. static dimensioned<Type> lookupOrDefault
(
const word&,
const dictionary&,
const Type& defaultValue = pTraits<Type>::zero,
const dimensionSet& dims = dimless
);
//- Construct from dictionary, with default value.
// If the value is not found, it is added into the dictionary.
static dimensioned<Type> lookupOrAddToDict static dimensioned<Type> lookupOrAddToDict
( (
const word&, const word&,
@ -148,8 +157,7 @@ public:
//- Return transpose. //- Return transpose.
dimensioned<Type> T() const; dimensioned<Type> T() const;
//- Update the value of the dimensioned<Type> if it is found in the //- Update the value of dimensioned<Type> if found in the dictionary.
// dictionary
bool readIfPresent(const dictionary&); bool readIfPresent(const dictionary&);