Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
a48bc874
Commit
a48bc874
authored
Jul 20, 2008
by
Mark Olesen
Browse files
use dictionary::readIfPresent wherever reasonable
parent
7f963163
Changes
33
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/db/IOobject/IOobjectReadHeader.C
View file @
a48bc874
...
...
@@ -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
{
...
...
src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C
View file @
a48bc874
...
...
@@ -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
"
;
...
...
src/OpenFOAM/db/Time/Time.C
View file @
a48bc874
...
...
@@ -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_
)
...
...
src/OpenFOAM/db/Time/TimeIO.C
View file @
a48bc874
...
...
@@ -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"
))
{
...
...
src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H
View file @
a48bc874
...
...
@@ -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
;
...
...
src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C
View file @
a48bc874
...
...
@@ -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
_
);
}
...
...
src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C
View file @
a48bc874
...
...
@@ -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
{
...
...
src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C
View file @
a48bc874
...
...
@@ -75,7 +75,7 @@ Foam::GAMGPreconditioner::~GAMGPreconditioner()
void
Foam
::
GAMGPreconditioner
::
readControls
()
{
GAMGSolver
::
readControls
();
readControl
(
controlDict_
,
nVcycles
_
,
"
nVcycles
"
);
controlDict_
.
readIfPresent
(
"
nVcycles
"
,
nVcycles
_
);
}
...
...
src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C
View file @
a48bc874
...
...
@@ -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_
);
}
...
...
src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C
View file @
a48bc874
...
...
@@ -72,7 +72,7 @@ Foam::smoothSolver::smoothSolver
void
Foam
::
smoothSolver
::
readControls
()
{
lduMatrix
::
solver
::
readControls
();
readControl
(
controlDict_
,
nSweeps
_
,
"
nSweeps
"
);
controlDict_
.
readIfPresent
(
"
nSweeps
"
,
nSweeps
_
);
}
...
...
src/OpenFOAM/matrices/solution/solution.H
View file @
a48bc874
...
...
@@ -97,7 +97,7 @@ public:
const
dictionary
&
solverDict
(
const
word
&
name
)
const
;
//- Return the stream of solver parameters for the given field
//
(Provided for b
ackward compatibility only
)
//
@deprecated B
ackward compatibility only
- should use solverDict
ITstream
&
solver
(
const
word
&
name
)
const
;
...
...
src/OpenFOAM/meshes/patchIdentifier/patchIdentifier.C
View file @
a48bc874
...
...
@@ -52,10 +52,7 @@ Foam::patchIdentifier::patchIdentifier
name_
(
name
),
boundaryIndex_
(
index
)
{
if
(
dict
.
found
(
"physicalType"
))
{
dict
.
lookup
(
"physicalType"
)
>>
physicalType_
;
}
dict
.
readIfPresent
(
"physicalType"
,
physicalType_
);
}
...
...
src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C
View file @
a48bc874
...
...
@@ -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"
));
...
...
src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/newPolyPatch.C
View file @
a48bc874
...
...
@@ -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
// ************************************************************************* //
src/OpenFOAM/meshes/preservePatchTypes/preservePatchTypes.C
View file @
a48bc874
...
...
@@ -77,19 +77,14 @@ void Foam::preservePatchTypes
const
dictionary
&
patchDict
=
patchDictionary
.
subDict
(
patchNames
[
patchi
]);
patchTypes
[
patchi
]
=
word
(
patchDict
.
lookup
(
"type"
));
if
(
patchDict
.
found
(
"geometricType"
))
{
patchTypes
[
patchi
]
=
word
(
patchDict
.
lookup
(
"geometricType"
));
}
if
(
patchDict
.
found
(
"physicalType"
))
{
patchPhysicalTypes
[
patchi
]
=
word
(
patchDict
.
lookup
(
"physicalType"
));
}
patchDict
.
lookup
(
"type"
)
>>
patchTypes
[
patchi
];
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
);
}
}
...
...
src/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C
View file @
a48bc874
...
...
@@ -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_
...
...
src/conversion/ensight/part/ensightPart.C
View file @
a48bc874
...
...
@@ -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
();
}
...
...
src/conversion/meshReader/starcd/STARCDMeshReader.C
View file @
a48bc874
...
...
@@ -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
;
}
if
(
iter
().
found
(
"Label"
))
{
iter
().
lookup
(
"Label"
)
>>
patchNames_
[
patchI
];
foundName
=
true
;
}
foundType
=
iter
().
readIfPresent
(
"BoundaryType"
,
patchTypes_
[
patchI
]
);
foundName
=
iter
().
readIfPresent
(
"Label"
,
patchNames_
[
patchI
]
);
}
// consistent names, in long form and in lowercase
...
...
src/decompositionAgglomeration/decompositionMethods/metisDecomp/metisDecomp.C
View file @
a48bc874
...
...
@@ -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
(
metis
Decomp
Coeffs
.
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
<<
end
l
<<
endl
;
Info
<<
"metisDecomp : Using Metis
method
"
<<
method
<<
n
l
<<
endl
;
}
if
(
metis
Decomp
Coeffs
.
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
<<
end
l
<<
endl
;
<<
n
l
<<
endl
;
}
if
(
metis
Decomp
Coeffs
.
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
(
metis
Decomp
Coeffs
.
found
(
"cellWeightsFile"
))
if
(
metisCoeffs
.
readIfPresent
(
"cellWeightsFile"
,
weightsFile
))
{
Info
<<
"metisDecomp : Using cell-based weights."
<<
endl
;
word
cellWeightsFile
(
metisDecompCoeffs
.
lookup
(
"cellWeightsFile"
)
);
IOList
<
int
>
cellIOWeights
(
IOobject
(
cellW
eightsFile
,
w
eightsFile
,
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 (metis
Decomp
Coeffs.
found
("faceWeightsFile"))
//if (metisCoeffs.
readIfPresent
("faceWeightsFile"
, weightsFile
))
//{
// Info<< "metisDecomp : Using face-based weights." << endl;
//
// word faceWeightsFile
// (
// metisDecompCoeffs.lookup("faceWeightsFile")
// );
//