diff --git a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C index ff51e2c6132fa5d6a860b3785c5eae5956529d23..9c1200e30bd2ea7dd81d24d4e3279c4ce6118c9e 100644 --- a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C +++ b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C @@ -35,6 +35,20 @@ namespace Foam // * * * * * * * * * * * * * * 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> dimensioned<Type> dimensioned<Type>::lookupOrAddToDict ( diff --git a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H index a4fbaf2c17c4ab3f2872c1ec4bf38c4226d7e623..1ad252955a3e7430c78c7b0ff84c5f78beeffa9c 100644 --- a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H +++ b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H @@ -108,8 +108,17 @@ public: //- Construct from an Istream with a given name and dimensions dimensioned(const word&, const dimensionSet&, Istream&); - //- Construct from dictionary, supplying default value so that if the - // value is not found, it is added into the dictionary. + //- Construct from dictionary, with default value. + 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 ( const word&, @@ -148,8 +157,7 @@ public: //- Return transpose. dimensioned<Type> T() const; - //- Update the value of the dimensioned<Type> if it is found in the - // dictionary + //- Update the value of dimensioned<Type> if found in the dictionary. bool readIfPresent(const dictionary&);