use dictionary::readIfPresent wherever reasonable

This commit is contained in:
Mark Olesen
2008-07-20 14:07:49 +02:00
parent 7f9631634d
commit a48bc8746a
33 changed files with 129 additions and 337 deletions

View File

@ -83,10 +83,7 @@ bool Foam::IOobject::readHeader(Istream& is)
} }
// The note entry is optional // The note entry is optional
if (headerDict.found("note")) headerDict.readIfPresent("note", note_);
{
note_ = string(headerDict.lookup("note"));
}
} }
else else
{ {

View File

@ -49,7 +49,6 @@ bool Foam::IOobject::writeHeader(Ostream& os) const
<< " format " << os.format() << ";\n" << " format " << os.format() << ";\n"
<< " class " << type() << ";\n"; << " class " << type() << ";\n";
// outdent for visibility and more space
if (note().size()) if (note().size())
{ {
os << " note " << note() << ";\n"; os << " note " << note() << ";\n";

View File

@ -101,14 +101,12 @@ void Foam::Time::setControls()
{ {
// default is to resume calculation from "latestTime" // default is to resume calculation from "latestTime"
word startFrom("latestTime"); word startFrom("latestTime");
if (controlDict_.found("startFrom"))
{ controlDict_.readIfPresent("startFrom", startFrom);
controlDict_.lookup("startFrom") >> startFrom;
}
if (startFrom == "startTime") if (startFrom == "startTime")
{ {
startTime_ = readScalar(controlDict_.lookup("startTime")); controlDict_.lookup("startTime") >> startTime_;
} }
else else
{ {
@ -158,7 +156,7 @@ void Foam::Time::setControls()
FatalErrorIn("Time::setControls()") FatalErrorIn("Time::setControls()")
<< "Start time is not the same for all processors" << nl << "Start time is not the same for all processors" << nl
<< "processor " << Pstream::myProcNo() << " has startTime " << "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_; deltaT0_ = deltaTSave_;
} }
if (timeDict.found("index")) if (timeDict.readIfPresent("index", startTimeIndex_))
{ {
timeDict.lookup("index") >> startTimeIndex_;
timeIndex_ = startTimeIndex_; timeIndex_ = startTimeIndex_;
} }
} }
@ -503,20 +499,9 @@ void Foam::Time::setTime(const instant& inst, const label newIndex)
) )
); );
if (timeDict.found("deltaT")) timeDict.readIfPresent("deltaT", deltaT_);
{ timeDict.readIfPresent("deltaT0", deltaT0_);
deltaT_ = readScalar(timeDict.lookup("deltaT")); timeDict.readIfPresent("index", timeIndex_);
}
if (timeDict.found("deltaT0"))
{
deltaT0_ = readScalar(timeDict.lookup("deltaT0"));
}
if (timeDict.found("index"))
{
timeIndex_ = readLabel(timeDict.lookup("index"));
}
} }
@ -647,7 +632,7 @@ Foam::Time& Foam::Time::operator++()
case wcRunTime: case wcRunTime:
case wcAdjustableRunTime: case wcAdjustableRunTime:
{ {
label outputTimeIndex = label outputTimeIndex =
label(((value() - startTime_) + 0.5*deltaT_)/writeInterval_); label(((value() - startTime_) + 0.5*deltaT_)/writeInterval_);
if (outputTimeIndex > outputTimeIndex_) if (outputTimeIndex > outputTimeIndex_)

View File

@ -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) if (writeControl_ == wcTimeStep && label(writeInterval_) < 1)
{ {
FatalIOErrorIn("Time::readDict()", controlDict_) FatalIOErrorIn("Time::readDict()", controlDict_)
@ -60,10 +58,8 @@ void Foam::Time::readDict()
controlDict_.lookup("writeFrequency") >> writeInterval_; controlDict_.lookup("writeFrequency") >> writeInterval_;
} }
if (controlDict_.found("purgeWrite")) if (controlDict_.readIfPresent("purgeWrite", purgeWrite_))
{ {
purgeWrite_ = readInt(controlDict_.lookup("purgeWrite"));
if (purgeWrite_ < 0) if (purgeWrite_ < 0)
{ {
WarningIn("Time::readDict()") WarningIn("Time::readDict()")
@ -106,10 +102,7 @@ void Foam::Time::readDict()
} }
} }
if (controlDict_.found("timePrecision")) controlDict_.readIfPresent("timePrecision", precision_);
{
precision_ = readLabel(controlDict_.lookup("timePrecision"));
}
// stopAt at 'endTime' or a specified value // stopAt at 'endTime' or a specified value
// if nothing is specified, the endTime is zero // if nothing is specified, the endTime is zero
@ -119,18 +112,14 @@ void Foam::Time::readDict()
if (stopAt_ == saEndTime) if (stopAt_ == saEndTime)
{ {
endTime_ = readScalar(controlDict_.lookup("endTime")); controlDict_.lookup("endTime") >> endTime_;
} }
else else
{ {
endTime_ = GREAT; endTime_ = GREAT;
} }
} }
else if (controlDict_.found("endTime")) else if (!controlDict_.readIfPresent("endTime", endTime_))
{
endTime_ = readScalar(controlDict_.lookup("endTime"));
}
else
{ {
endTime_ = 0; endTime_ = 0;
} }
@ -175,10 +164,7 @@ void Foam::Time::readDict()
); );
} }
if (controlDict_.found("graphFormat")) controlDict_.readIfPresent("graphFormat", graphFormat_);
{
graphFormat_ = word(controlDict_.lookup("graphFormat"));
}
if (controlDict_.found("runTimeModifiable")) if (controlDict_.found("runTimeModifiable"))
{ {

View File

@ -87,8 +87,7 @@ class lduMatrix
public: public:
//- Class returned by the solver //- Class returned by the solver, containing performance statistics
// containing performance statistics
class solverPerformance class solverPerformance
{ {
word solverName_; word solverName_;
@ -237,16 +236,6 @@ public:
// Protected Member Functions // Protected Member Functions
//- Read a control parameter from controlDict
template<class T>
inline void readControl
(
const dictionary& controlDict,
T& control,
const word& controlName
);
//- Read the control parameters from the controlDict_ //- Read the control parameters from the controlDict_
virtual void readControls(); virtual void readControls();
@ -318,7 +307,6 @@ public:
Istream& solverData Istream& solverData
); );
// Selectors // Selectors
//- Return a new solver //- Return a new solver
@ -333,6 +321,7 @@ public:
); );
// Destructor // Destructor
virtual ~solver() virtual ~solver()
@ -749,7 +738,7 @@ public:
const lduInterfaceFieldPtrsList&, const lduInterfaceFieldPtrsList&,
const direction cmpt const direction cmpt
) const; ) const;
//- Matrix transpose multiplication with updated interfaces. //- Matrix transpose multiplication with updated interfaces.
void Tmul void Tmul
( (
@ -800,7 +789,7 @@ public:
scalarField& result, scalarField& result,
const direction cmpt const direction cmpt
) const; ) const;
//- Update interfaced interfaces for matrix operations //- Update interfaced interfaces for matrix operations
void updateMatrixInterfaces void updateMatrixInterfaces
( (
@ -810,7 +799,7 @@ public:
scalarField& result, scalarField& result,
const direction cmpt const direction cmpt
) const; ) const;
template<class Type> template<class Type>
tmp<Field<Type> > H(const Field<Type>&) const; tmp<Field<Type> > H(const Field<Type>&) const;

View File

@ -171,9 +171,9 @@ Foam::lduMatrix::solver::solver
void Foam::lduMatrix::solver::readControls() void Foam::lduMatrix::solver::readControls()
{ {
readControl(controlDict_, maxIter_, "maxIter"); controlDict_.readIfPresent("maxIter", maxIter_);
readControl(controlDict_, tolerance_, "tolerance"); controlDict_.readIfPresent("tolerance", tolerance_);
readControl(controlDict_, relTol_, "relTol"); controlDict_.readIfPresent("relTol", relTol_);
} }

View File

@ -31,21 +31,6 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class T>
inline void Foam::lduMatrix::solver::readControl
(
const dictionary& controlDict,
T& control,
const word& controlName
)
{
if (controlDict.found(controlName))
{
controlDict.lookup(controlName) >> control;
}
}
template<class Type> template<class Type>
Foam::tmp<Foam::Field<Type> > Foam::lduMatrix::H(const Field<Type>& psi) const Foam::tmp<Foam::Field<Type> > Foam::lduMatrix::H(const Field<Type>& psi) const
{ {

View File

@ -75,7 +75,7 @@ Foam::GAMGPreconditioner::~GAMGPreconditioner()
void Foam::GAMGPreconditioner::readControls() void Foam::GAMGPreconditioner::readControls()
{ {
GAMGSolver::readControls(); GAMGSolver::readControls();
readControl(controlDict_, nVcycles_, "nVcycles"); controlDict_.readIfPresent("nVcycles", nVcycles_);
} }

View File

@ -154,13 +154,12 @@ void Foam::GAMGSolver::readControls()
{ {
lduMatrix::solver::readControls(); lduMatrix::solver::readControls();
readControl(controlDict_, cacheAgglomeration_, "cacheAgglomeration"); controlDict_.readIfPresent("cacheAgglomeration", cacheAgglomeration_);
controlDict_.readIfPresent("nPreSweeps", nPreSweeps_);
readControl(controlDict_, nPreSweeps_, "nPreSweeps"); controlDict_.readIfPresent("nPostSweeps", nPostSweeps_);
readControl(controlDict_, nPostSweeps_, "nPostSweeps"); controlDict_.readIfPresent("nFinestSweeps", nFinestSweeps_);
readControl(controlDict_, nFinestSweeps_, "nFinestSweeps"); controlDict_.readIfPresent("scaleCorrection", scaleCorrection_);
readControl(controlDict_, scaleCorrection_, "scaleCorrection"); controlDict_.readIfPresent("directSolveCoarsest", directSolveCoarsest_);
readControl(controlDict_, directSolveCoarsest_, "directSolveCoarsest");
} }

View File

@ -72,7 +72,7 @@ Foam::smoothSolver::smoothSolver
void Foam::smoothSolver::readControls() void Foam::smoothSolver::readControls()
{ {
lduMatrix::solver::readControls(); lduMatrix::solver::readControls();
readControl(controlDict_, nSweeps_, "nSweeps"); controlDict_.readIfPresent("nSweeps", nSweeps_);
} }

View File

@ -97,7 +97,7 @@ public:
const dictionary& solverDict(const word& name) const; const dictionary& solverDict(const word& name) const;
//- Return the stream of solver parameters for the given field //- 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; ITstream& solver(const word& name) const;

View File

@ -52,10 +52,7 @@ Foam::patchIdentifier::patchIdentifier
name_(name), name_(name),
boundaryIndex_(index) boundaryIndex_(index)
{ {
if (dict.found("physicalType")) dict.readIfPresent("physicalType", physicalType_);
{
dict.lookup("physicalType") >> physicalType_;
}
} }

View File

@ -622,10 +622,8 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
rotationAxis_(vector::zero), rotationAxis_(vector::zero),
rotationCentre_(point::zero) rotationCentre_(point::zero)
{ {
if (dict.found("featureCos")) dict.readIfPresent("featureCos", featureCos_);
{
dict.lookup("featureCos") >> featureCos_;
}
if (dict.found("transform")) if (dict.found("transform"))
{ {
transform_ = transformTypeNames.read(dict.lookup("transform")); transform_ = transformTypeNames.read(dict.lookup("transform"));

View File

@ -27,14 +27,9 @@ License
#include "polyPatch.H" #include "polyPatch.H"
#include "dictionary.H" #include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
autoPtr<polyPatch> polyPatch::New Foam::autoPtr<Foam::polyPatch> Foam::polyPatch::New
( (
const word& patchType, const word& patchType,
const word& name, const word& name,
@ -72,7 +67,7 @@ autoPtr<polyPatch> polyPatch::New
} }
autoPtr<polyPatch> polyPatch::New Foam::autoPtr<Foam::polyPatch> Foam::polyPatch::New
( (
const word& name, const word& name,
const dictionary& dict, const dictionary& dict,
@ -89,10 +84,7 @@ autoPtr<polyPatch> polyPatch::New
word patchType(dict.lookup("type")); word patchType(dict.lookup("type"));
if (dict.found("geometricType")) dict.readIfPresent("geometricType", patchType);
{
dict.lookup("geometricType") >> patchType;
}
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(patchType); dictionaryConstructorTablePtr_->find(patchType);
@ -124,8 +116,4 @@ autoPtr<polyPatch> polyPatch::New
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -77,19 +77,14 @@ void Foam::preservePatchTypes
const dictionary& patchDict = const dictionary& patchDict =
patchDictionary.subDict(patchNames[patchi]); patchDictionary.subDict(patchNames[patchi]);
patchTypes[patchi] = word(patchDict.lookup("type")); patchDict.lookup("type") >> patchTypes[patchi];
if (patchDict.found("geometricType")) patchDict.readIfPresent("geometricType", patchTypes[patchi]);
{ patchDict.readIfPresent
patchTypes[patchi] = (
word(patchDict.lookup("geometricType")); "physicalType",
} patchPhysicalTypes[patchi]
);
if (patchDict.found("physicalType"))
{
patchPhysicalTypes[patchi] =
word(patchDict.lookup("physicalType"));
}
} }
} }
@ -98,10 +93,7 @@ void Foam::preservePatchTypes
const dictionary& patchDict = const dictionary& patchDict =
patchDictionary.subDict(defaultFacesName); patchDictionary.subDict(defaultFacesName);
if (patchDict.found("geometricType")) patchDict.readIfPresent("geometricType", defaultFacesType);
{
defaultFacesType = word(patchDict.lookup("geometricType"));
}
} }
} }

View File

@ -175,9 +175,7 @@ Foam::layerParameters::layerParameters
featureAngle_(readScalar(dict.lookup("featureAngle"))), featureAngle_(readScalar(dict.lookup("featureAngle"))),
concaveAngle_ concaveAngle_
( (
dict.found("concaveAngle") dict.lookupOrDefault("concaveAngle", defaultConcaveAngle)
? readScalar(dict.lookup("concaveAngle"))
: defaultConcaveAngle
), ),
nGrow_(readLabel(dict.lookup("nGrow"))), nGrow_(readLabel(dict.lookup("nGrow"))),
nSmoothSurfaceNormals_ nSmoothSurfaceNormals_
@ -242,9 +240,7 @@ Foam::layerParameters::layerParameters
featureAngle_(readScalar(dict.lookup("featureAngle"))), featureAngle_(readScalar(dict.lookup("featureAngle"))),
concaveAngle_ concaveAngle_
( (
dict.found("concaveAngle") dict.lookupOrDefault("concaveAngle", defaultConcaveAngle)
? readScalar(dict.lookup("concaveAngle"))
: defaultConcaveAngle
), ),
nGrow_(readLabel(dict.lookup("nGrow"))), nGrow_(readLabel(dict.lookup("nGrow"))),
nSmoothSurfaceNormals_ nSmoothSurfaceNormals_

View File

@ -171,14 +171,10 @@ void Foam::ensightPart::reconstruct(Istream& is)
forAll(elementTypes(), elemI) forAll(elementTypes(), elemI)
{ {
word key(elementTypes()[elemI]); word key(elementTypes()[elemI]);
if (dict.found(key))
{ elemLists_[elemI].clear();
dict.lookup(key) >> elemLists_[elemI]; dict.readIfPresent(key, elemLists_[elemI]);
}
else
{
elemLists_[elemI].clear();
}
size_ += elemLists_[elemI].size(); size_ += elemLists_[elemI].size();
} }

View File

@ -745,17 +745,17 @@ void Foam::meshReaders::STARCD::readBoundary(const fileName& inputName)
iter != boundaryRegion_.end() iter != boundaryRegion_.end()
) )
{ {
if (iter().found("BoundaryType")) foundType = iter().readIfPresent
{ (
iter().lookup("BoundaryType") >> patchTypes_[patchI]; "BoundaryType",
foundType = true; patchTypes_[patchI]
} );
if (iter().found("Label")) foundName = iter().readIfPresent
{ (
iter().lookup("Label") >> patchNames_[patchI]; "Label",
foundName = true; patchNames_[patchI]
} );
} }
// consistent names, in long form and in lowercase // consistent names, in long form and in lowercase

View File

@ -69,7 +69,7 @@ Foam::label Foam::metisDecomp::decompose
// Method of decomposition // Method of decomposition
// recursive: multi-level recursive bisection (default) // recursive: multi-level recursive bisection (default)
// k-way: multi-level k-way // k-way: multi-level k-way
word method("k-way"); word method("k-way");
// decomposition options. 0 = use defaults // decomposition options. 0 = use defaults
@ -88,15 +88,12 @@ Foam::label Foam::metisDecomp::decompose
// Check for user supplied weights and decomp options // Check for user supplied weights and decomp options
if (decompositionDict_.found("metisCoeffs")) if (decompositionDict_.found("metisCoeffs"))
{ {
dictionary metisDecompCoeffs const dictionary& metisCoeffs =
( decompositionDict_.subDict("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") if (method != "recursive" && method != "k-way")
{ {
FatalErrorIn("metisDecomp::decompose()") FatalErrorIn("metisDecomp::decompose()")
@ -106,14 +103,12 @@ Foam::label Foam::metisDecomp::decompose
<< exit(FatalError); << exit(FatalError);
} }
Info<< "metisDecomp : Using Metis options " << options Info<< "metisDecomp : Using Metis method " << method
<< endl << endl; << nl << endl;
} }
if (metisDecompCoeffs.found("options")) if (metisCoeffs.readIfPresent("options", options))
{ {
metisDecompCoeffs.lookup("options") >> options;
if (options.size() != 5) if (options.size() != 5)
{ {
FatalErrorIn("metisDecomp::decompose()") FatalErrorIn("metisDecomp::decompose()")
@ -124,12 +119,11 @@ Foam::label Foam::metisDecomp::decompose
} }
Info<< "metisDecomp : Using Metis options " << options 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); processorWeights /= sum(processorWeights);
if (processorWeights.size() != nProcessors_) 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; Info<< "metisDecomp : Using cell-based weights." << endl;
word cellWeightsFile
(
metisDecompCoeffs.lookup("cellWeightsFile")
);
IOList<int> cellIOWeights IOList<int> cellIOWeights
( (
IOobject IOobject
( (
cellWeightsFile, weightsFile,
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::MUST_READ, IOobject::MUST_READ,
@ -174,20 +163,15 @@ Foam::label Foam::metisDecomp::decompose
} }
//- faceWeights disabled. Only makes sense for cellCells from mesh. //- 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; // Info<< "metisDecomp : Using face-based weights." << endl;
// //
// word faceWeightsFile
// (
// metisDecompCoeffs.lookup("faceWeightsFile")
// );
//
// IOList<int> weights // IOList<int> weights
// ( // (
// IOobject // IOobject
// ( // (
// faceWeightsFile, // weightsFile,
// mesh_.time().timeName(), // mesh_.time().timeName(),
// mesh_, // mesh_,
// IOobject::MUST_READ, // IOobject::MUST_READ,
@ -366,7 +350,7 @@ Foam::labelList Foam::metisDecomp::decompose(const pointField& points)
// number of internal faces // number of internal faces
label nInternalFaces = 2*mesh_.nInternalFaces(); 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 // internal faces
const polyBoundaryMesh& pbm = mesh_.boundaryMesh(); const polyBoundaryMesh& pbm = mesh_.boundaryMesh();

View File

@ -516,26 +516,20 @@ Foam::labelList Foam::parMetisDecomp::decompose(const pointField& points)
// Check for user supplied weights and decomp options // Check for user supplied weights and decomp options
if (decompositionDict_.found("metisCoeffs")) if (decompositionDict_.found("metisCoeffs"))
{ {
dictionary parMetisDecompCoeffs const dictionary& metisCoeffs =
( decompositionDict_.subDict("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 " Info<< "parMetisDecomp : Using cell-based weights read from "
<< cellWeightsFile << endl; << weightsFile << endl;
labelIOField cellIOWeights labelIOField cellIOWeights
( (
IOobject IOobject
( (
cellWeightsFile, weightsFile,
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::MUST_READ, 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 " Info<< "parMetisDecomp : Using face-based weights read from "
<< faceWeightsFile << endl; << weightsFile << endl;
labelIOField weights labelIOField weights
( (
IOobject IOobject
( (
faceWeightsFile, weightsFile,
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::MUST_READ, 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 Info<< "Using Metis options " << options
<< endl << endl; << nl << endl;
if (options.size() != 3) if (options.size() != 3)
{ {
@ -835,26 +822,20 @@ Foam::labelList Foam::parMetisDecomp::decompose
// Check for user supplied weights and decomp options // Check for user supplied weights and decomp options
if (decompositionDict_.found("metisCoeffs")) if (decompositionDict_.found("metisCoeffs"))
{ {
dictionary parMetisDecompCoeffs const dictionary& metisCoeffs =
( decompositionDict_.subDict("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 " Info<< "parMetisDecomp : Using cell-based weights read from "
<< cellWeightsFile << endl; << weightsFile << endl;
labelIOField cellIOWeights labelIOField cellIOWeights
( (
IOobject IOobject
( (
cellWeightsFile, weightsFile,
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::MUST_READ, IOobject::MUST_READ,
@ -877,21 +858,16 @@ Foam::labelList Foam::parMetisDecomp::decompose
} }
//- faceWeights disabled. Only makes sense for cellCells from mesh. //- 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 " // Info<< "parMetisDecomp : Using face-based weights read from "
// << faceWeightsFile << endl; // << weightsFile << endl;
// //
// labelIOField weights // labelIOField weights
// ( // (
// IOobject // IOobject
// ( // (
// faceWeightsFile, // weightsFile,
// mesh_.time().timeName(), // mesh_.time().timeName(),
// mesh_, // mesh_,
// IOobject::MUST_READ, // 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 Info<< "Using Metis options " << options
<< endl << endl; << nl << endl;
if (options.size() != 3) if (options.size() != 3)
{ {

View File

@ -102,14 +102,7 @@ Foam::scalar Foam::layerAdditionRemoval::readOldThickness
const dictionary& dict const dictionary& dict
) )
{ {
if (dict.found("oldLayerThickness")) dict.lookupOrDefault("oldLayerThickness", -1.0);
{
return readScalar(dict.lookup("oldLayerThickness"));
}
else
{
return -1.0;
}
} }
@ -279,7 +272,7 @@ bool Foam::layerAdditionRemoval::changeTopology() const
<< "Layer thickness: min: " << minDelta << "Layer thickness: min: " << minDelta
<< " max: " << maxDelta << " avg: " << avgDelta << " max: " << maxDelta << " avg: " << avgDelta
<< " old thickness: " << oldLayerThickness_ << nl << " old thickness: " << oldLayerThickness_ << nl
<< "Removal threshold: " << minLayerThickness_ << "Removal threshold: " << minLayerThickness_
<< " addition threshold: " << maxLayerThickness_ << endl; << " addition threshold: " << maxLayerThickness_ << endl;
} }
@ -295,7 +288,7 @@ bool Foam::layerAdditionRemoval::changeTopology() const
} }
// No topological changes allowed before first mesh motion // No topological changes allowed before first mesh motion
// //
oldLayerThickness_ = avgDelta; oldLayerThickness_ = avgDelta;
topologicalChange = false; topologicalChange = false;
@ -314,7 +307,7 @@ bool Foam::layerAdditionRemoval::changeTopology() const
// At this point, info about moving the old mesh // At this point, info about moving the old mesh
// in a way to collapse the cells in the removed // in a way to collapse the cells in the removed
// layer is available. Not sure what to do with // layer is available. Not sure what to do with
// it. // it.
if (debug) if (debug)
{ {

View File

@ -84,23 +84,11 @@ Foam::engineTime::engineTime
stroke_(dimensionedScalar("stroke", dimLength, 0)), stroke_(dimensionedScalar("stroke", dimLength, 0)),
clearance_(dimensionedScalar("clearance", dimLength, 0)) clearance_(dimensionedScalar("clearance", dimLength, 0))
{ {
// the geometric parameters are not strictly required for Time // geometric parameters are not strictly required for Time
if (dict_.found("conRodLength")) dict_.readIfPresent("conRodLength", conRodLength_);
{ dict_.readIfPresent("bore", bore_);
dict_.lookup("conRodLength") >> conRodLength_; dict_.readIfPresent("stroke", stroke_);
} dict_.readIfPresent("clearance", clearance_);
if (dict_.found("bore"))
{
dict_.lookup("bore") >> bore_;
}
if (dict_.found("stroke"))
{
dict_.lookup("stroke") >> stroke_;
}
if (dict_.found("clearance"))
{
dict_.lookup("clearance") >> clearance_;
}
timeAdjustment(); timeAdjustment();

View File

@ -342,11 +342,11 @@ public:
//- Relax matrix (for steady-state solution). //- Relax matrix (for steady-state solution).
// alpha = 1 : diagonally equal // alpha = 1 : diagonally equal
// alpha < 1 : ,, dominant // alpha < 1 : diagonally dominant
// alpha = 0 : do nothing // alpha = 0 : do nothing
void relax(const scalar alpha); void relax(const scalar alpha);
//- Relax matrix (for steadty-state solution). //- Relax matrix (for steady-state solution).
// alpha is read from controlDict // alpha is read from controlDict
void relax(); void relax();

View File

@ -162,10 +162,7 @@ Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New
// default type is self (alias: "axes") // default type is self (alias: "axes")
word rotType(typeName_()); word rotType(typeName_());
if (dict.found("type")) dict.readIfPresent("type", rotType);
{
dict.lookup("type") >> rotType;
}
// can (must) construct base class directly // can (must) construct base class directly
if (rotType == typeName_() || rotType == "axes") if (rotType == typeName_() || rotType == "axes")

View File

@ -176,12 +176,7 @@ Foam::searchableSurfaces::searchableSurfaces
const dictionary& dict = topDict.subDict(key); const dictionary& dict = topDict.subDict(key);
names_[surfI] = key; names_[surfI] = key;
dict.readIfPresent("name", names_[surfI]);
if (dict.found("name"))
{
dict.lookup("name") >> names_[surfI];
}
// Make IOobject with correct name // Make IOobject with correct name
autoPtr<IOobject> namedIO(io.clone()); autoPtr<IOobject> namedIO(io.clone());

View File

@ -34,25 +34,10 @@ License
template<class OutputFilter> template<class OutputFilter>
void Foam::OutputFilterFunctionObject<OutputFilter>::readDict() void Foam::OutputFilterFunctionObject<OutputFilter>::readDict()
{ {
if (dict_.found("region")) dict_.readIfPresent("region", regionName_);
{ dict_.readIfPresent("dictionary", dictName_);
dict_.lookup("region") >> regionName_; dict_.readIfPresent("interval", interval_);
} dict_.readIfPresent("enabled", execution_);
if (dict_.found("dictionary"))
{
dict_.lookup("dictionary") >> dictName_;
}
if (dict_.found("interval"))
{
dict_.lookup("interval") >> interval_;
}
if (dict_.found("enabled"))
{
dict_.lookup("enabled") >> execution_;
}
} }

View File

@ -289,16 +289,10 @@ void Foam::sampledSets::read(const dictionary& dict)
fieldNames_ = wordList(dict_.lookup("fields")); fieldNames_ = wordList(dict_.lookup("fields"));
interpolationScheme_ = "cell"; interpolationScheme_ = "cell";
if (dict_.found("interpolationScheme")) dict_.readIfPresent("interpolationScheme", interpolationScheme_);
{
dict_.lookup("interpolationScheme") >> interpolationScheme_;
}
writeFormat_ = "null"; writeFormat_ = "null";
if (dict_.found("setFormat")) dict_.readIfPresent("setFormat", writeFormat_);
{
dict_.lookup("setFormat") >> writeFormat_;
}
scalarFields_.clear(); scalarFields_.clear();
vectorFields_.clear(); vectorFields_.clear();

View File

@ -156,9 +156,8 @@ Foam::sampledPlane::sampledPlane
label zoneId = -1; label zoneId = -1;
if (dict.found("zone")) if (dict.readIfPresent("zone", zoneName_))
{ {
dict.lookup("zone") >> zoneName_;
zoneId = mesh.cellZones().findZoneID(zoneName_); zoneId = mesh.cellZones().findZoneID(zoneName_);
if (debug && zoneId < 0) if (debug && zoneId < 0)
{ {

View File

@ -188,10 +188,7 @@ Foam::sampledSurface::sampledSurface
CfPtr_(NULL), CfPtr_(NULL),
area_(-1) area_(-1)
{ {
if (dict.found("name")) dict.readIfPresent("name", name_);
{
dict.lookup("name") >> name_;
}
} }

View File

@ -327,16 +327,10 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
fieldNames_ = wordList(dict.lookup("fields")); fieldNames_ = wordList(dict.lookup("fields"));
interpolationScheme_ = "cell"; interpolationScheme_ = "cell";
if (dict.found("interpolationScheme")) dict.readIfPresent("interpolationScheme", interpolationScheme_);
{
dict.lookup("interpolationScheme") >> interpolationScheme_;
}
writeFormat_ = "null"; writeFormat_ = "null";
if (dict.found("surfaceFormat")) dict.readIfPresent("surfaceFormat", writeFormat_);
{
dict.lookup("surfaceFormat") >> writeFormat_;
}
PtrList<sampledSurface> newList PtrList<sampledSurface> newList

View File

@ -46,10 +46,7 @@ Foam::autoPtr<Foam::chemistryReader> Foam::chemistryReader::New
word chemistryReaderTypeName("chemkinReader"); word chemistryReaderTypeName("chemkinReader");
// otherwise use the specified reader // otherwise use the specified reader
if (thermoDict.found("chemistryReader")) thermoDict.readIfPresent("chemistryReader", chemistryReaderTypeName);
{
thermoDict.lookup("chemistryReader") >> chemistryReaderTypeName;
}
Info<< "Selecting chemistryReader " << chemistryReaderTypeName << endl; Info<< "Selecting chemistryReader " << chemistryReaderTypeName << endl;

View File

@ -88,10 +88,7 @@ LESModel::LESModel
delta_(LESdelta::New("delta", U.mesh(), *this)) delta_(LESdelta::New("delta", U.mesh(), *this))
{ {
if (found("k0")) readIfPresent("k0", k0_);
{
lookup("k0") >> k0_;
}
} }
@ -117,10 +114,7 @@ bool LESModel::read()
delta_().read(*this); delta_().read(*this);
if (found("k0")) readIfPresent("k0", k0_);
{
lookup("k0") >> k0_;
}
return true; return true;
} }

View File

@ -87,10 +87,7 @@ LESModel::LESModel
delta_(LESdelta::New("delta", U.mesh(), *this)) delta_(LESdelta::New("delta", U.mesh(), *this))
{ {
if (found("k0")) readIfPresent("k0", k0_);
{
lookup("k0") >> k0_;
}
} }
@ -117,10 +114,7 @@ bool LESModel::read()
delta_().read(*this); delta_().read(*this);
if (found("k0")) readIfPresent("k0", k0_);
{
lookup("k0") >> k0_;
}
return true; return true;
} }