diff --git a/src/OpenFOAM/db/IOobject/IOobjectReadHeader.C b/src/OpenFOAM/db/IOobject/IOobjectReadHeader.C index 3564ae9ab1..966ef84136 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectReadHeader.C +++ b/src/OpenFOAM/db/IOobject/IOobjectReadHeader.C @@ -83,10 +83,7 @@ bool Foam::IOobject::readHeader(Istream& is) } // The note entry is optional - if (headerDict.found("note")) - { - note_ = string(headerDict.lookup("note")); - } + headerDict.readIfPresent("note", note_); } else { diff --git a/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C b/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C index cbf7800606..20030c2ea5 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C +++ b/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C @@ -49,7 +49,6 @@ bool Foam::IOobject::writeHeader(Ostream& os) const << " format " << os.format() << ";\n" << " class " << type() << ";\n"; - // outdent for visibility and more space if (note().size()) { os << " note " << note() << ";\n"; diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index f0948b77de..dd1e944067 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -101,14 +101,12 @@ void Foam::Time::setControls() { // default is to resume calculation from "latestTime" word startFrom("latestTime"); - if (controlDict_.found("startFrom")) - { - controlDict_.lookup("startFrom") >> startFrom; - } + + controlDict_.readIfPresent("startFrom", startFrom); if (startFrom == "startTime") { - startTime_ = readScalar(controlDict_.lookup("startTime")); + controlDict_.lookup("startTime") >> startTime_; } else { @@ -158,7 +156,7 @@ void Foam::Time::setControls() FatalErrorIn("Time::setControls()") << "Start time is not the same for all processors" << nl << "processor " << Pstream::myProcNo() << " has startTime " - << startTime_ << exit(FatalError); + << startTime_ << exit(FatalError); } } @@ -176,15 +174,13 @@ void Foam::Time::setControls() ) ); - if (timeDict.found("deltaT")) + if (timeDict.readIfPresent("deltaT", deltaTSave_)) { - deltaTSave_ = readScalar(timeDict.lookup("deltaT")); deltaT0_ = deltaTSave_; } - if (timeDict.found("index")) + if (timeDict.readIfPresent("index", startTimeIndex_)) { - timeDict.lookup("index") >> startTimeIndex_; timeIndex_ = startTimeIndex_; } } @@ -503,20 +499,9 @@ void Foam::Time::setTime(const instant& inst, const label newIndex) ) ); - if (timeDict.found("deltaT")) - { - deltaT_ = readScalar(timeDict.lookup("deltaT")); - } - - if (timeDict.found("deltaT0")) - { - deltaT0_ = readScalar(timeDict.lookup("deltaT0")); - } - - if (timeDict.found("index")) - { - timeIndex_ = readLabel(timeDict.lookup("index")); - } + timeDict.readIfPresent("deltaT", deltaT_); + timeDict.readIfPresent("deltaT0", deltaT0_); + timeDict.readIfPresent("index", timeIndex_); } @@ -647,7 +632,7 @@ Foam::Time& Foam::Time::operator++() case wcRunTime: case wcAdjustableRunTime: { - label outputTimeIndex = + label outputTimeIndex = label(((value() - startTime_) + 0.5*deltaT_)/writeInterval_); if (outputTimeIndex > outputTimeIndex_) diff --git a/src/OpenFOAM/db/Time/TimeIO.C b/src/OpenFOAM/db/Time/TimeIO.C index 45eaefed64..fc3ad8857c 100644 --- a/src/OpenFOAM/db/Time/TimeIO.C +++ b/src/OpenFOAM/db/Time/TimeIO.C @@ -44,10 +44,8 @@ void Foam::Time::readDict() ); } - if (controlDict_.found("writeInterval")) + if (controlDict_.readIfPresent("writeInterval", writeInterval_)) { - controlDict_.lookup("writeInterval") >> writeInterval_; - if (writeControl_ == wcTimeStep && label(writeInterval_) < 1) { FatalIOErrorIn("Time::readDict()", controlDict_) @@ -60,10 +58,8 @@ void Foam::Time::readDict() controlDict_.lookup("writeFrequency") >> writeInterval_; } - if (controlDict_.found("purgeWrite")) + if (controlDict_.readIfPresent("purgeWrite", purgeWrite_)) { - purgeWrite_ = readInt(controlDict_.lookup("purgeWrite")); - if (purgeWrite_ < 0) { WarningIn("Time::readDict()") @@ -106,10 +102,7 @@ void Foam::Time::readDict() } } - if (controlDict_.found("timePrecision")) - { - precision_ = readLabel(controlDict_.lookup("timePrecision")); - } + controlDict_.readIfPresent("timePrecision", precision_); // stopAt at 'endTime' or a specified value // if nothing is specified, the endTime is zero @@ -119,18 +112,14 @@ void Foam::Time::readDict() if (stopAt_ == saEndTime) { - endTime_ = readScalar(controlDict_.lookup("endTime")); + controlDict_.lookup("endTime") >> endTime_; } else { endTime_ = GREAT; } } - else if (controlDict_.found("endTime")) - { - endTime_ = readScalar(controlDict_.lookup("endTime")); - } - else + else if (!controlDict_.readIfPresent("endTime", endTime_)) { endTime_ = 0; } @@ -175,10 +164,7 @@ void Foam::Time::readDict() ); } - if (controlDict_.found("graphFormat")) - { - graphFormat_ = word(controlDict_.lookup("graphFormat")); - } + controlDict_.readIfPresent("graphFormat", graphFormat_); if (controlDict_.found("runTimeModifiable")) { diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H index 2d89ac4e79..33fcda639d 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H @@ -87,8 +87,7 @@ class lduMatrix public: - //- Class returned by the solver - // containing performance statistics + //- Class returned by the solver, containing performance statistics class solverPerformance { word solverName_; @@ -237,16 +236,6 @@ public: // Protected Member Functions - //- Read a control parameter from controlDict - template - inline void readControl - ( - const dictionary& controlDict, - T& control, - const word& controlName - ); - - //- Read the control parameters from the controlDict_ virtual void readControls(); @@ -318,7 +307,6 @@ public: Istream& solverData ); - // Selectors //- Return a new solver @@ -333,6 +321,7 @@ public: ); + // Destructor virtual ~solver() @@ -749,7 +738,7 @@ public: const lduInterfaceFieldPtrsList&, const direction cmpt ) const; - + //- Matrix transpose multiplication with updated interfaces. void Tmul ( @@ -800,7 +789,7 @@ public: scalarField& result, const direction cmpt ) const; - + //- Update interfaced interfaces for matrix operations void updateMatrixInterfaces ( @@ -810,7 +799,7 @@ public: scalarField& result, const direction cmpt ) const; - + template tmp > H(const Field&) const; diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C index 4db27fde04..19fd2435a0 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C @@ -171,9 +171,9 @@ Foam::lduMatrix::solver::solver void Foam::lduMatrix::solver::readControls() { - readControl(controlDict_, maxIter_, "maxIter"); - readControl(controlDict_, tolerance_, "tolerance"); - readControl(controlDict_, relTol_, "relTol"); + controlDict_.readIfPresent("maxIter", maxIter_); + controlDict_.readIfPresent("tolerance", tolerance_); + controlDict_.readIfPresent("relTol", relTol_); } diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C index 50767e741e..6209d81c86 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C @@ -31,21 +31,6 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -template -inline void Foam::lduMatrix::solver::readControl -( - const dictionary& controlDict, - T& control, - const word& controlName -) -{ - if (controlDict.found(controlName)) - { - controlDict.lookup(controlName) >> control; - } -} - - template Foam::tmp > Foam::lduMatrix::H(const Field& psi) const { diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C index 2042ac6ac3..cfd2f4513e 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C @@ -75,7 +75,7 @@ Foam::GAMGPreconditioner::~GAMGPreconditioner() void Foam::GAMGPreconditioner::readControls() { GAMGSolver::readControls(); - readControl(controlDict_, nVcycles_, "nVcycles"); + controlDict_.readIfPresent("nVcycles", nVcycles_); } diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C index fa13572601..f8a29ba241 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C @@ -154,13 +154,12 @@ void Foam::GAMGSolver::readControls() { lduMatrix::solver::readControls(); - readControl(controlDict_, cacheAgglomeration_, "cacheAgglomeration"); - - readControl(controlDict_, nPreSweeps_, "nPreSweeps"); - readControl(controlDict_, nPostSweeps_, "nPostSweeps"); - readControl(controlDict_, nFinestSweeps_, "nFinestSweeps"); - readControl(controlDict_, scaleCorrection_, "scaleCorrection"); - readControl(controlDict_, directSolveCoarsest_, "directSolveCoarsest"); + controlDict_.readIfPresent("cacheAgglomeration", cacheAgglomeration_); + controlDict_.readIfPresent("nPreSweeps", nPreSweeps_); + controlDict_.readIfPresent("nPostSweeps", nPostSweeps_); + controlDict_.readIfPresent("nFinestSweeps", nFinestSweeps_); + controlDict_.readIfPresent("scaleCorrection", scaleCorrection_); + controlDict_.readIfPresent("directSolveCoarsest", directSolveCoarsest_); } diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C b/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C index c07a626ec3..6b7c1cbcc3 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C @@ -72,7 +72,7 @@ Foam::smoothSolver::smoothSolver void Foam::smoothSolver::readControls() { lduMatrix::solver::readControls(); - readControl(controlDict_, nSweeps_, "nSweeps"); + controlDict_.readIfPresent("nSweeps", nSweeps_); } diff --git a/src/OpenFOAM/matrices/solution/solution.H b/src/OpenFOAM/matrices/solution/solution.H index 7b295cc18a..3d455fdecc 100644 --- a/src/OpenFOAM/matrices/solution/solution.H +++ b/src/OpenFOAM/matrices/solution/solution.H @@ -97,7 +97,7 @@ public: const dictionary& solverDict(const word& name) const; //- Return the stream of solver parameters for the given field - // (Provided for backward compatibility only) + // @deprecated Backward compatibility only - should use solverDict ITstream& solver(const word& name) const; diff --git a/src/OpenFOAM/meshes/patchIdentifier/patchIdentifier.C b/src/OpenFOAM/meshes/patchIdentifier/patchIdentifier.C index bdbde0c06f..c0d90270df 100644 --- a/src/OpenFOAM/meshes/patchIdentifier/patchIdentifier.C +++ b/src/OpenFOAM/meshes/patchIdentifier/patchIdentifier.C @@ -52,10 +52,7 @@ Foam::patchIdentifier::patchIdentifier name_(name), boundaryIndex_(index) { - if (dict.found("physicalType")) - { - dict.lookup("physicalType") >> physicalType_; - } + dict.readIfPresent("physicalType", physicalType_); } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C index e753d53d8a..96928eab87 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C @@ -622,10 +622,8 @@ Foam::cyclicPolyPatch::cyclicPolyPatch rotationAxis_(vector::zero), rotationCentre_(point::zero) { - if (dict.found("featureCos")) - { - dict.lookup("featureCos") >> featureCos_; - } + dict.readIfPresent("featureCos", featureCos_); + if (dict.found("transform")) { transform_ = transformTypeNames.read(dict.lookup("transform")); diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/newPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/newPolyPatch.C index 67a3e2886b..fde52b3e75 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/newPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/newPolyPatch.C @@ -27,14 +27,9 @@ License #include "polyPatch.H" #include "dictionary.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -autoPtr polyPatch::New +Foam::autoPtr Foam::polyPatch::New ( const word& patchType, const word& name, @@ -72,7 +67,7 @@ autoPtr polyPatch::New } -autoPtr polyPatch::New +Foam::autoPtr Foam::polyPatch::New ( const word& name, const dictionary& dict, @@ -89,10 +84,7 @@ autoPtr polyPatch::New word patchType(dict.lookup("type")); - if (dict.found("geometricType")) - { - dict.lookup("geometricType") >> patchType; - } + dict.readIfPresent("geometricType", patchType); dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTablePtr_->find(patchType); @@ -124,8 +116,4 @@ autoPtr polyPatch::New } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/preservePatchTypes/preservePatchTypes.C b/src/OpenFOAM/meshes/preservePatchTypes/preservePatchTypes.C index 2f46854f6f..7c6aecf8f4 100644 --- a/src/OpenFOAM/meshes/preservePatchTypes/preservePatchTypes.C +++ b/src/OpenFOAM/meshes/preservePatchTypes/preservePatchTypes.C @@ -77,19 +77,14 @@ void Foam::preservePatchTypes const dictionary& patchDict = patchDictionary.subDict(patchNames[patchi]); - patchTypes[patchi] = word(patchDict.lookup("type")); + patchDict.lookup("type") >> patchTypes[patchi]; - if (patchDict.found("geometricType")) - { - patchTypes[patchi] = - word(patchDict.lookup("geometricType")); - } - - if (patchDict.found("physicalType")) - { - patchPhysicalTypes[patchi] = - word(patchDict.lookup("physicalType")); - } + patchDict.readIfPresent("geometricType", patchTypes[patchi]); + patchDict.readIfPresent + ( + "physicalType", + patchPhysicalTypes[patchi] + ); } } @@ -98,10 +93,7 @@ void Foam::preservePatchTypes const dictionary& patchDict = patchDictionary.subDict(defaultFacesName); - if (patchDict.found("geometricType")) - { - defaultFacesType = word(patchDict.lookup("geometricType")); - } + patchDict.readIfPresent("geometricType", defaultFacesType); } } diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C index a2fd5ca976..17ad2db042 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C @@ -175,9 +175,7 @@ Foam::layerParameters::layerParameters featureAngle_(readScalar(dict.lookup("featureAngle"))), concaveAngle_ ( - dict.found("concaveAngle") - ? readScalar(dict.lookup("concaveAngle")) - : defaultConcaveAngle + dict.lookupOrDefault("concaveAngle", defaultConcaveAngle) ), nGrow_(readLabel(dict.lookup("nGrow"))), nSmoothSurfaceNormals_ @@ -242,9 +240,7 @@ Foam::layerParameters::layerParameters featureAngle_(readScalar(dict.lookup("featureAngle"))), concaveAngle_ ( - dict.found("concaveAngle") - ? readScalar(dict.lookup("concaveAngle")) - : defaultConcaveAngle + dict.lookupOrDefault("concaveAngle", defaultConcaveAngle) ), nGrow_(readLabel(dict.lookup("nGrow"))), nSmoothSurfaceNormals_ diff --git a/src/conversion/ensight/part/ensightPart.C b/src/conversion/ensight/part/ensightPart.C index 5ccb17e820..ff870658f6 100644 --- a/src/conversion/ensight/part/ensightPart.C +++ b/src/conversion/ensight/part/ensightPart.C @@ -171,14 +171,10 @@ void Foam::ensightPart::reconstruct(Istream& is) forAll(elementTypes(), elemI) { word key(elementTypes()[elemI]); - if (dict.found(key)) - { - dict.lookup(key) >> elemLists_[elemI]; - } - else - { - elemLists_[elemI].clear(); - } + + elemLists_[elemI].clear(); + dict.readIfPresent(key, elemLists_[elemI]); + size_ += elemLists_[elemI].size(); } diff --git a/src/conversion/meshReader/starcd/STARCDMeshReader.C b/src/conversion/meshReader/starcd/STARCDMeshReader.C index 751be41c57..084a792704 100644 --- a/src/conversion/meshReader/starcd/STARCDMeshReader.C +++ b/src/conversion/meshReader/starcd/STARCDMeshReader.C @@ -745,17 +745,17 @@ void Foam::meshReaders::STARCD::readBoundary(const fileName& inputName) iter != boundaryRegion_.end() ) { - if (iter().found("BoundaryType")) - { - iter().lookup("BoundaryType") >> patchTypes_[patchI]; - foundType = true; - } + foundType = iter().readIfPresent + ( + "BoundaryType", + patchTypes_[patchI] + ); - if (iter().found("Label")) - { - iter().lookup("Label") >> patchNames_[patchI]; - foundName = true; - } + foundName = iter().readIfPresent + ( + "Label", + patchNames_[patchI] + ); } // consistent names, in long form and in lowercase diff --git a/src/decompositionAgglomeration/decompositionMethods/metisDecomp/metisDecomp.C b/src/decompositionAgglomeration/decompositionMethods/metisDecomp/metisDecomp.C index 964556f074..74804f4e75 100644 --- a/src/decompositionAgglomeration/decompositionMethods/metisDecomp/metisDecomp.C +++ b/src/decompositionAgglomeration/decompositionMethods/metisDecomp/metisDecomp.C @@ -69,7 +69,7 @@ Foam::label Foam::metisDecomp::decompose // Method of decomposition // recursive: multi-level recursive bisection (default) - // k-way: multi-level k-way + // k-way: multi-level k-way word method("k-way"); // decomposition options. 0 = use defaults @@ -88,15 +88,12 @@ Foam::label Foam::metisDecomp::decompose // Check for user supplied weights and decomp options if (decompositionDict_.found("metisCoeffs")) { - dictionary metisDecompCoeffs - ( - decompositionDict_.subDict("metisCoeffs") - ); + const dictionary& metisCoeffs = + decompositionDict_.subDict("metisCoeffs"); + word weightsFile; - if (metisDecompCoeffs.found("method")) + if (metisCoeffs.readIfPresent("method", method)) { - metisDecompCoeffs.lookup("method") >> method; - if (method != "recursive" && method != "k-way") { FatalErrorIn("metisDecomp::decompose()") @@ -106,14 +103,12 @@ Foam::label Foam::metisDecomp::decompose << exit(FatalError); } - Info<< "metisDecomp : Using Metis options " << options - << endl << endl; + Info<< "metisDecomp : Using Metis method " << method + << nl << endl; } - if (metisDecompCoeffs.found("options")) + if (metisCoeffs.readIfPresent("options", options)) { - metisDecompCoeffs.lookup("options") >> options; - if (options.size() != 5) { FatalErrorIn("metisDecomp::decompose()") @@ -124,12 +119,11 @@ Foam::label Foam::metisDecomp::decompose } Info<< "metisDecomp : Using Metis options " << options - << endl << endl; + << nl << endl; } - if (metisDecompCoeffs.found("processorWeights")) + if (metisCoeffs.readIfPresent("processorWeights", processorWeights)) { - metisDecompCoeffs.lookup("processorWeights") >> processorWeights; processorWeights /= sum(processorWeights); if (processorWeights.size() != nProcessors_) @@ -142,20 +136,15 @@ Foam::label Foam::metisDecomp::decompose } } - if (metisDecompCoeffs.found("cellWeightsFile")) + if (metisCoeffs.readIfPresent("cellWeightsFile", weightsFile)) { Info<< "metisDecomp : Using cell-based weights." << endl; - word cellWeightsFile - ( - metisDecompCoeffs.lookup("cellWeightsFile") - ); - IOList cellIOWeights ( IOobject ( - cellWeightsFile, + weightsFile, mesh_.time().timeName(), mesh_, IOobject::MUST_READ, @@ -174,20 +163,15 @@ Foam::label Foam::metisDecomp::decompose } //- faceWeights disabled. Only makes sense for cellCells from mesh. - //if (metisDecompCoeffs.found("faceWeightsFile")) + //if (metisCoeffs.readIfPresent("faceWeightsFile", weightsFile)) //{ // Info<< "metisDecomp : Using face-based weights." << endl; // - // word faceWeightsFile - // ( - // metisDecompCoeffs.lookup("faceWeightsFile") - // ); - // // IOList weights // ( // IOobject // ( - // faceWeightsFile, + // weightsFile, // mesh_.time().timeName(), // mesh_, // IOobject::MUST_READ, @@ -366,7 +350,7 @@ Foam::labelList Foam::metisDecomp::decompose(const pointField& points) // number of internal faces label nInternalFaces = 2*mesh_.nInternalFaces(); - // Check the boundary for coupled patches and add to the number of + // Check the boundary for coupled patches and add to the number of // internal faces const polyBoundaryMesh& pbm = mesh_.boundaryMesh(); diff --git a/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C b/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C index 38a03e392a..a5778bcdf0 100644 --- a/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C +++ b/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C @@ -516,26 +516,20 @@ Foam::labelList Foam::parMetisDecomp::decompose(const pointField& points) // Check for user supplied weights and decomp options if (decompositionDict_.found("metisCoeffs")) { - dictionary parMetisDecompCoeffs - ( - decompositionDict_.subDict("metisCoeffs") - ); + const dictionary& metisCoeffs = + decompositionDict_.subDict("metisCoeffs"); + word weightsFile; - if (parMetisDecompCoeffs.found("cellWeightsFile")) + if (metisCoeffs.readIfPresent("cellWeightsFile", weightsFile)) { - word cellWeightsFile - ( - parMetisDecompCoeffs.lookup("cellWeightsFile") - ); - Info<< "parMetisDecomp : Using cell-based weights read from " - << cellWeightsFile << endl; + << weightsFile << endl; labelIOField cellIOWeights ( IOobject ( - cellWeightsFile, + weightsFile, mesh_.time().timeName(), mesh_, IOobject::MUST_READ, @@ -554,21 +548,16 @@ Foam::labelList Foam::parMetisDecomp::decompose(const pointField& points) } } - if (parMetisDecompCoeffs.found("faceWeightsFile")) + if (metisCoeffs.readIfPresent("faceWeightsFile", weightsFile)) { - word faceWeightsFile - ( - parMetisDecompCoeffs.lookup("faceWeightsFile") - ); - Info<< "parMetisDecomp : Using face-based weights read from " - << faceWeightsFile << endl; + << weightsFile << endl; labelIOField weights ( IOobject ( - faceWeightsFile, + weightsFile, mesh_.time().timeName(), mesh_, IOobject::MUST_READ, @@ -621,12 +610,10 @@ Foam::labelList Foam::parMetisDecomp::decompose(const pointField& points) } } - if (parMetisDecompCoeffs.found("options")) + if (metisCoeffs.readIfPresent("options", options)) { - parMetisDecompCoeffs.lookup("options") >> options; - Info<< "Using Metis options " << options - << endl << endl; + << nl << endl; if (options.size() != 3) { @@ -835,26 +822,20 @@ Foam::labelList Foam::parMetisDecomp::decompose // Check for user supplied weights and decomp options if (decompositionDict_.found("metisCoeffs")) { - dictionary parMetisDecompCoeffs - ( - decompositionDict_.subDict("metisCoeffs") - ); + const dictionary& metisCoeffs = + decompositionDict_.subDict("metisCoeffs"); + word weightsFile; - if (parMetisDecompCoeffs.found("cellWeightsFile")) + if (metisCoeffs.readIfPresent("cellWeightsFile", weightsFile)) { - word cellWeightsFile - ( - parMetisDecompCoeffs.lookup("cellWeightsFile") - ); - Info<< "parMetisDecomp : Using cell-based weights read from " - << cellWeightsFile << endl; + << weightsFile << endl; labelIOField cellIOWeights ( IOobject ( - cellWeightsFile, + weightsFile, mesh_.time().timeName(), mesh_, IOobject::MUST_READ, @@ -877,21 +858,16 @@ Foam::labelList Foam::parMetisDecomp::decompose } //- faceWeights disabled. Only makes sense for cellCells from mesh. - //if (parMetisDecompCoeffs.found("faceWeightsFile")) + //if (metisCoeffs.readIfPresent("faceWeightsFile", weightsFile)) //{ - // word faceWeightsFile - // ( - // parMetisDecompCoeffs.lookup("faceWeightsFile") - // ); - // // Info<< "parMetisDecomp : Using face-based weights read from " - // << faceWeightsFile << endl; + // << weightsFile << endl; // // labelIOField weights // ( // IOobject // ( - // faceWeightsFile, + // weightsFile, // mesh_.time().timeName(), // mesh_, // IOobject::MUST_READ, @@ -944,12 +920,10 @@ Foam::labelList Foam::parMetisDecomp::decompose // } //} - if (parMetisDecompCoeffs.found("options")) + if (metisCoeffs.readIfPresent("options", options)) { - parMetisDecompCoeffs.lookup("options") >> options; - Info<< "Using Metis options " << options - << endl << endl; + << nl << endl; if (options.size() != 3) { diff --git a/src/dynamicMesh/layerAdditionRemoval/layerAdditionRemoval.C b/src/dynamicMesh/layerAdditionRemoval/layerAdditionRemoval.C index 2835bee5cd..c90ad7e878 100644 --- a/src/dynamicMesh/layerAdditionRemoval/layerAdditionRemoval.C +++ b/src/dynamicMesh/layerAdditionRemoval/layerAdditionRemoval.C @@ -102,14 +102,7 @@ Foam::scalar Foam::layerAdditionRemoval::readOldThickness const dictionary& dict ) { - if (dict.found("oldLayerThickness")) - { - return readScalar(dict.lookup("oldLayerThickness")); - } - else - { - return -1.0; - } + dict.lookupOrDefault("oldLayerThickness", -1.0); } @@ -279,7 +272,7 @@ bool Foam::layerAdditionRemoval::changeTopology() const << "Layer thickness: min: " << minDelta << " max: " << maxDelta << " avg: " << avgDelta << " old thickness: " << oldLayerThickness_ << nl - << "Removal threshold: " << minLayerThickness_ + << "Removal threshold: " << minLayerThickness_ << " addition threshold: " << maxLayerThickness_ << endl; } @@ -295,7 +288,7 @@ bool Foam::layerAdditionRemoval::changeTopology() const } // No topological changes allowed before first mesh motion - // + // oldLayerThickness_ = avgDelta; topologicalChange = false; @@ -314,7 +307,7 @@ bool Foam::layerAdditionRemoval::changeTopology() const // At this point, info about moving the old mesh // in a way to collapse the cells in the removed // layer is available. Not sure what to do with - // it. + // it. if (debug) { diff --git a/src/engine/engineTime/engineTime.C b/src/engine/engineTime/engineTime.C index 7be803d320..edbd350388 100644 --- a/src/engine/engineTime/engineTime.C +++ b/src/engine/engineTime/engineTime.C @@ -84,23 +84,11 @@ Foam::engineTime::engineTime stroke_(dimensionedScalar("stroke", dimLength, 0)), clearance_(dimensionedScalar("clearance", dimLength, 0)) { - // the geometric parameters are not strictly required for Time - if (dict_.found("conRodLength")) - { - dict_.lookup("conRodLength") >> conRodLength_; - } - if (dict_.found("bore")) - { - dict_.lookup("bore") >> bore_; - } - if (dict_.found("stroke")) - { - dict_.lookup("stroke") >> stroke_; - } - if (dict_.found("clearance")) - { - dict_.lookup("clearance") >> clearance_; - } + // geometric parameters are not strictly required for Time + dict_.readIfPresent("conRodLength", conRodLength_); + dict_.readIfPresent("bore", bore_); + dict_.readIfPresent("stroke", stroke_); + dict_.readIfPresent("clearance", clearance_); timeAdjustment(); diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H index 44e66e3cb7..f9c82a2d58 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H @@ -342,11 +342,11 @@ public: //- Relax matrix (for steady-state solution). // alpha = 1 : diagonally equal - // alpha < 1 : ,, dominant + // alpha < 1 : diagonally dominant // alpha = 0 : do nothing void relax(const scalar alpha); - //- Relax matrix (for steadty-state solution). + //- Relax matrix (for steady-state solution). // alpha is read from controlDict void relax(); diff --git a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C index e01f39c97d..649013fdf1 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C @@ -162,10 +162,7 @@ Foam::autoPtr Foam::coordinateRotation::New // default type is self (alias: "axes") word rotType(typeName_()); - if (dict.found("type")) - { - dict.lookup("type") >> rotType; - } + dict.readIfPresent("type", rotType); // can (must) construct base class directly if (rotType == typeName_() || rotType == "axes") diff --git a/src/meshTools/searchableSurface/searchableSurfaces.C b/src/meshTools/searchableSurface/searchableSurfaces.C index 9689744fca..cd7171ed5e 100644 --- a/src/meshTools/searchableSurface/searchableSurfaces.C +++ b/src/meshTools/searchableSurface/searchableSurfaces.C @@ -176,12 +176,7 @@ Foam::searchableSurfaces::searchableSurfaces const dictionary& dict = topDict.subDict(key); names_[surfI] = key; - - if (dict.found("name")) - { - dict.lookup("name") >> names_[surfI]; - } - + dict.readIfPresent("name", names_[surfI]); // Make IOobject with correct name autoPtr namedIO(io.clone()); diff --git a/src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.C b/src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.C index df3598e953..ee7c3c6ef1 100644 --- a/src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.C +++ b/src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.C @@ -34,25 +34,10 @@ License template void Foam::OutputFilterFunctionObject::readDict() { - if (dict_.found("region")) - { - dict_.lookup("region") >> regionName_; - } - - if (dict_.found("dictionary")) - { - dict_.lookup("dictionary") >> dictName_; - } - - if (dict_.found("interval")) - { - dict_.lookup("interval") >> interval_; - } - - if (dict_.found("enabled")) - { - dict_.lookup("enabled") >> execution_; - } + dict_.readIfPresent("region", regionName_); + dict_.readIfPresent("dictionary", dictName_); + dict_.readIfPresent("interval", interval_); + dict_.readIfPresent("enabled", execution_); } diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.C b/src/sampling/sampledSet/sampledSets/sampledSets.C index 1877e39df5..7c1e86fd01 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSets.C +++ b/src/sampling/sampledSet/sampledSets/sampledSets.C @@ -289,16 +289,10 @@ void Foam::sampledSets::read(const dictionary& dict) fieldNames_ = wordList(dict_.lookup("fields")); interpolationScheme_ = "cell"; - if (dict_.found("interpolationScheme")) - { - dict_.lookup("interpolationScheme") >> interpolationScheme_; - } + dict_.readIfPresent("interpolationScheme", interpolationScheme_); writeFormat_ = "null"; - if (dict_.found("setFormat")) - { - dict_.lookup("setFormat") >> writeFormat_; - } + dict_.readIfPresent("setFormat", writeFormat_); scalarFields_.clear(); vectorFields_.clear(); diff --git a/src/sampling/sampledSurface/plane/sampledPlane.C b/src/sampling/sampledSurface/plane/sampledPlane.C index 7a9dfdd641..d3a7f799f8 100644 --- a/src/sampling/sampledSurface/plane/sampledPlane.C +++ b/src/sampling/sampledSurface/plane/sampledPlane.C @@ -156,9 +156,8 @@ Foam::sampledPlane::sampledPlane label zoneId = -1; - if (dict.found("zone")) + if (dict.readIfPresent("zone", zoneName_)) { - dict.lookup("zone") >> zoneName_; zoneId = mesh.cellZones().findZoneID(zoneName_); if (debug && zoneId < 0) { diff --git a/src/sampling/sampledSurface/sampledSurface/sampledSurface.C b/src/sampling/sampledSurface/sampledSurface/sampledSurface.C index a9418c8046..8d5c60df91 100644 --- a/src/sampling/sampledSurface/sampledSurface/sampledSurface.C +++ b/src/sampling/sampledSurface/sampledSurface/sampledSurface.C @@ -188,10 +188,7 @@ Foam::sampledSurface::sampledSurface CfPtr_(NULL), area_(-1) { - if (dict.found("name")) - { - dict.lookup("name") >> name_; - } + dict.readIfPresent("name", name_); } diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C index b3aff7e235..4fb6b6c43b 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C @@ -327,16 +327,10 @@ void Foam::sampledSurfaces::read(const dictionary& dict) fieldNames_ = wordList(dict.lookup("fields")); interpolationScheme_ = "cell"; - if (dict.found("interpolationScheme")) - { - dict.lookup("interpolationScheme") >> interpolationScheme_; - } + dict.readIfPresent("interpolationScheme", interpolationScheme_); writeFormat_ = "null"; - if (dict.found("surfaceFormat")) - { - dict.lookup("surfaceFormat") >> writeFormat_; - } + dict.readIfPresent("surfaceFormat", writeFormat_); PtrList newList diff --git a/src/thermophysicalModels/combustion/chemistryReaders/chemistryReader/chemistryReader.C b/src/thermophysicalModels/combustion/chemistryReaders/chemistryReader/chemistryReader.C index 6f278a7f71..be4c7b6eae 100644 --- a/src/thermophysicalModels/combustion/chemistryReaders/chemistryReader/chemistryReader.C +++ b/src/thermophysicalModels/combustion/chemistryReaders/chemistryReader/chemistryReader.C @@ -46,10 +46,7 @@ Foam::autoPtr Foam::chemistryReader::New word chemistryReaderTypeName("chemkinReader"); // otherwise use the specified reader - if (thermoDict.found("chemistryReader")) - { - thermoDict.lookup("chemistryReader") >> chemistryReaderTypeName; - } + thermoDict.readIfPresent("chemistryReader", chemistryReaderTypeName); Info<< "Selecting chemistryReader " << chemistryReaderTypeName << endl; diff --git a/src/turbulenceModels/LES/compressible/LESModel/LESModel.C b/src/turbulenceModels/LES/compressible/LESModel/LESModel.C index 841d116e62..8591c4c7b4 100644 --- a/src/turbulenceModels/LES/compressible/LESModel/LESModel.C +++ b/src/turbulenceModels/LES/compressible/LESModel/LESModel.C @@ -88,10 +88,7 @@ LESModel::LESModel delta_(LESdelta::New("delta", U.mesh(), *this)) { - if (found("k0")) - { - lookup("k0") >> k0_; - } + readIfPresent("k0", k0_); } @@ -117,10 +114,7 @@ bool LESModel::read() delta_().read(*this); - if (found("k0")) - { - lookup("k0") >> k0_; - } + readIfPresent("k0", k0_); return true; } diff --git a/src/turbulenceModels/LES/incompressible/LESModel/LESModel.C b/src/turbulenceModels/LES/incompressible/LESModel/LESModel.C index 7be12ff448..4eefbe2d60 100644 --- a/src/turbulenceModels/LES/incompressible/LESModel/LESModel.C +++ b/src/turbulenceModels/LES/incompressible/LESModel/LESModel.C @@ -87,10 +87,7 @@ LESModel::LESModel delta_(LESdelta::New("delta", U.mesh(), *this)) { - if (found("k0")) - { - lookup("k0") >> k0_; - } + readIfPresent("k0", k0_); } @@ -117,10 +114,7 @@ bool LESModel::read() delta_().read(*this); - if (found("k0")) - { - lookup("k0") >> k0_; - } + readIfPresent("k0", k0_); return true; }