diff --git a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C index ff51e2c613..9c1200e30b 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 +dimensioned dimensioned::lookupOrDefault +( + const word& name, + const dictionary& dict, + const Type& defaultValue, + const dimensionSet& dims +) +{ + Type value = dict.lookupOrDefault(name, defaultValue); + return dimensioned(name, dims, value); +} + + template dimensioned dimensioned::lookupOrAddToDict ( diff --git a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H index a4fbaf2c17..1ad252955a 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 lookupOrDefault + ( + const word&, + const dictionary&, + const Type& defaultValue = pTraits::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 lookupOrAddToDict ( const word&, @@ -148,8 +157,7 @@ public: //- Return transpose. dimensioned T() const; - //- Update the value of the dimensioned if it is found in the - // dictionary + //- Update the value of dimensioned if found in the dictionary. bool readIfPresent(const dictionary&);