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
if (headerDict.found("note"))
{
note_ = string(headerDict.lookup("note"));
}
headerDict.readIfPresent("note", note_);
}
else
{

View File

@ -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";

View File

@ -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_)

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)
{
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"))
{

View File

@ -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<class T>
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<class Type>
tmp<Field<Type> > H(const Field<Type>&) const;

View File

@ -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_);
}

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>
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()
{
GAMGSolver::readControls();
readControl(controlDict_, nVcycles_, "nVcycles");
controlDict_.readIfPresent("nVcycles", nVcycles_);
}

View File

@ -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_);
}

View File

@ -72,7 +72,7 @@ Foam::smoothSolver::smoothSolver
void Foam::smoothSolver::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;
//- 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;

View File

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

View File

@ -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"));

View File

@ -27,14 +27,9 @@ License
#include "polyPatch.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
autoPtr<polyPatch> polyPatch::New
Foam::autoPtr<Foam::polyPatch> Foam::polyPatch::New
(
const word& patchType,
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 dictionary& dict,
@ -89,10 +84,7 @@ autoPtr<polyPatch> 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> polyPatch::New
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -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);
}
}

View File

@ -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_

View File

@ -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();
}

View File

@ -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

View File

@ -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<int> 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<int> 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();

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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();

View File

@ -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();

View File

@ -162,10 +162,7 @@ Foam::autoPtr<Foam::coordinateRotation> 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")

View File

@ -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<IOobject> namedIO(io.clone());

View File

@ -34,25 +34,10 @@ License
template<class OutputFilter>
void Foam::OutputFilterFunctionObject<OutputFilter>::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_);
}

View File

@ -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();

View File

@ -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)
{

View File

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

View File

@ -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<sampledSurface> newList

View File

@ -46,10 +46,7 @@ Foam::autoPtr<Foam::chemistryReader> 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;

View File

@ -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;
}

View File

@ -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;
}