diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index 7e89dc8286..677d9754b7 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -30,9 +30,9 @@ Description of values (e.g. words and numbers). The dictionary class is the base class for IOdictionary. - It serves the purpose of a bootstrap dictionary for the objectRegistry - data dictionaries, since unlike the IOdictionary class, it does not use - a objectRegistry itself to work. + It also serves as a bootstrap dictionary for the objectRegistry data + dictionaries since, unlike the IOdictionary class, it does not use an + objectRegistry itself to work. ToDo A merge() member function with a non-const dictionary parameter. @@ -199,25 +199,31 @@ public: //- Find and return a T, if not found return the given default value // If recursive search parent dictionaries template - T lookupOrDefault(const word&, const T&, bool recursive=false) const; + T lookupOrDefault + ( + const word&, + const T&, + bool recursive=false + ) const; //- Find and return a T, if not found return the given default value, - // and add to dictionary. If recusive search parent dictionaries + // and add to dictionary. If recursive search parent dictionaries template T lookupOrAddDefault ( const word&, const T&, - bool recusive=false + bool recursive=false ); //- Find an entry if present, and assign to T + // Returns true if the entry was found template - void readIfPresent + bool readIfPresent ( const word&, T&, - bool recusive=false + bool recursive=false ) const; //- Check if entry is a sub-dictionary diff --git a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C index fe06648d5d..1b40cbefd5 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C +++ b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C @@ -54,40 +54,42 @@ template T Foam::dictionary::lookupOrAddDefault ( const word& keyword, - const T& deft, - bool recusive + const T& deflt, + bool recursive ) { - const entry* ePtr = lookupEntryPtr(keyword, recusive); + const entry* entryPtr = lookupEntryPtr(keyword, recursive); - if (ePtr == NULL) + if (entryPtr == NULL) { - entry* defPtr = new primitiveEntry(keyword, deft); - append(defPtr); - hashedEntries_.insert(defPtr->keyword(), defPtr); - - return deft; + add(new primitiveEntry(keyword, deflt)); + return deflt; } else { - return pTraits(ePtr->stream()); + return pTraits(entryPtr->stream()); } } template -void Foam::dictionary::readIfPresent +bool Foam::dictionary::readIfPresent ( - const word& keyword, - T& deft, - bool recusive + const word& k, + T& val, + bool recursive ) const { - const entry* ePtr = lookupEntryPtr(keyword, recusive); + const entry* entryPtr = lookupEntryPtr(k, recursive); - if (ePtr != NULL) + if (entryPtr == NULL) { - ePtr->stream() >> deft; + return false; + } + else + { + entryPtr->stream() >> val; + return true; } } diff --git a/src/Pstream/mpi/IPread.C b/src/Pstream/mpi/IPread.C index f00f322bab..90fc19b13c 100644 --- a/src/Pstream/mpi/IPread.C +++ b/src/Pstream/mpi/IPread.C @@ -61,7 +61,7 @@ Foam::IPstream::IPstream MPI_Status status; - // If the buffer size is not specified probe the incomming message + // If the buffer size is not specified, probe the incomming message // and set it if (!bufSize) { @@ -181,8 +181,7 @@ Foam::label Foam::IPstream::read ( "IPstream::read" "(const int fromProcNo, char* buf, std::streamsize bufSize)" - ) << "Unsupported communications type " - << Pstream::commsTypeNames[commsType] + ) << "Unsupported communications type " << commsType << Foam::abort(FatalError); return 0; diff --git a/src/Pstream/mpi/OPwrite.C b/src/Pstream/mpi/OPwrite.C index 4f69ef3f75..6f37386d16 100644 --- a/src/Pstream/mpi/OPwrite.C +++ b/src/Pstream/mpi/OPwrite.C @@ -119,8 +119,7 @@ bool Foam::OPstream::write ( "OPstream::write" "(const int fromProcNo, char* buf, std::streamsize bufSize)" - ) << "Unsupported communications type " - << Pstream::commsTypeNames[commsType] + ) << "Unsupported communications type " << commsType << Foam::abort(FatalError); } diff --git a/src/turbulenceModels/RAS/compressible/turbulenceModel/turbulenceModel.C b/src/turbulenceModels/RAS/compressible/turbulenceModel/turbulenceModel.C index e2c6ed90c3..b4c41aaf80 100644 --- a/src/turbulenceModels/RAS/compressible/turbulenceModel/turbulenceModel.C +++ b/src/turbulenceModels/RAS/compressible/turbulenceModel/turbulenceModel.C @@ -123,9 +123,9 @@ tmp turbulenceModel::yPlus(const label patchNo) const if (typeid(curPatch) == typeid(wallFvPatch)) { - dimensionedScalar Cmu(turbulenceModelCoeffs_.lookup("Cmu")); + scalar Cmu(turbulenceModelCoeffs_.lookup("Cmu")); - Yp = pow(Cmu.value(), 0.25) + Yp = pow(Cmu, 0.25) *y_[patchNo] *sqrt(k()().boundaryField()[patchNo].patchInternalField()) /( @@ -164,32 +164,14 @@ bool turbulenceModel::read() lookup("turbulence") >> turbulence_; turbulenceModelCoeffs_ = subDict(type() + "Coeffs"); - kappa_ = dimensionedScalar - ( - subDict("wallFunctionCoeffs").lookup("kappa") - ).value(); - - E_ = dimensionedScalar - ( - subDict("wallFunctionCoeffs").lookup("E") - ).value(); + subDict("wallFunctionCoeffs").lookup("kappa") >> kappa_; + subDict("wallFunctionCoeffs").lookup("E") >> E_; yPlusLam_ = yPlusLam(kappa_, E_); - if (found("k0")) - { - lookup("k0") >> k0_; - } - - if (found("epsilon0")) - { - lookup("epsilon0") >> epsilon0_; - } - - if (found("epsilonSmall")) - { - lookup("epsilonSmall") >> epsilonSmall_; - } + readIfPresent("k0", k0_); + readIfPresent("epsilon0", epsilon0_); + readIfPresent("epsilonSmall", epsilonSmall_); return true; } diff --git a/src/turbulenceModels/RAS/incompressible/turbulenceModel/turbulenceModel.C b/src/turbulenceModels/RAS/incompressible/turbulenceModel/turbulenceModel.C index 7c157e8940..a139bbefd9 100644 --- a/src/turbulenceModels/RAS/incompressible/turbulenceModel/turbulenceModel.C +++ b/src/turbulenceModels/RAS/incompressible/turbulenceModel/turbulenceModel.C @@ -123,9 +123,9 @@ tmp turbulenceModel::yPlus(const label patchNo) const if (typeid(curPatch) == typeid(wallFvPatch)) { - dimensionedScalar Cmu(turbulenceModelCoeffs_.lookup("Cmu")); + scalar Cmu(turbulenceModelCoeffs_.lookup("Cmu")); - Yp = pow(Cmu.value(), 0.25)*y_[patchNo] + Yp = pow(Cmu, 0.25)*y_[patchNo] *sqrt(k()().boundaryField()[patchNo].patchInternalField()) /nu().boundaryField()[patchNo]; } @@ -161,32 +161,14 @@ bool turbulenceModel::read() lookup("turbulence") >> turbulence_; turbulenceModelCoeffs_ = subDict(type() + "Coeffs"); - kappa_ = dimensionedScalar - ( - subDict("wallFunctionCoeffs").lookup("kappa") - ).value(); - - E_ = dimensionedScalar - ( - subDict("wallFunctionCoeffs").lookup("E") - ).value(); + subDict("wallFunctionCoeffs").lookup("kappa") >> kappa_; + subDict("wallFunctionCoeffs").lookup("E") >> E_; yPlusLam_ = yPlusLam(kappa_, E_); - if (found("k0")) - { - lookup("k0") >> k0_; - } - - if (found("epsilon0")) - { - lookup("epsilon0") >> epsilon0_; - } - - if (found("epsilonSmall")) - { - lookup("epsilonSmall") >> epsilonSmall_; - } + readIfPresent("k0", k0_); + readIfPresent("epsilon0", epsilon0_); + readIfPresent("epsilonSmall", epsilonSmall_); return true; }