From 9525d57d71d4db48ff82ac6094fbe24a312cd2bf Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@Germany>
Date: Thu, 20 May 2010 08:52:45 +0200
Subject: [PATCH] STYLE: use readIfPresent instead of found/lookup combination

---
 .../T/smoluchowskiJumpTFvPatchScalarField.C   | 43 ++++++-------
 .../rhoCentralFoam/readFluxScheme.H           |  3 +-
 .../readThermophysicalProperties.H            | 14 +++--
 .../readThermodynamicProperties.H             | 15 +++--
 .../twoPhaseEulerFoam/createFields.H          |  4 +-
 .../decomposePar/domainDecomposition.C        |  6 +-
 .../constraint/cyclic/cyclicPolyPatch.C       |  9 ++-
 .../fvMotionSolverEngineMesh.C                |  5 +-
 .../layeredEngineMesh/layeredEngineMesh.C     |  5 +-
 .../freestream/freestreamFvPatchField.C       |  5 +-
 .../timeVaryingMappedFixedValueFvPatchField.C |  5 +-
 .../potential/potential/potential.C           |  8 +--
 .../layerParameters/layerParameters.C         | 11 +---
 .../meshRefinementProblemCells.C              |  8 +--
 .../refinementSurfaces/refinementSurfaces.C   | 19 +-----
 .../decompose/ptscotchDecomp/ptscotchDecomp.C | 56 ++++++++---------
 .../decompose/scotchDecomp/scotchDecomp.C     | 60 +++++++++----------
 ...gidBodyDisplacementPointPatchVectorField.C |  4 +-
 18 files changed, 116 insertions(+), 164 deletions(-)

diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C
index a6d98559a75..24ce0fe938d 100644
--- a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C
+++ b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C
@@ -29,14 +29,9 @@ License
 #include "volFields.H"
 #include "mathematicalConstants.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
+Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
 (
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF
@@ -52,7 +47,8 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
     valueFraction() = 0.0;
 }
 
-smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
+
+Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
 (
     const smoluchowskiJumpTFvPatchScalarField& ptf,
     const fvPatch& p,
@@ -67,7 +63,7 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
 {}
 
 
-smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
+Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
 (
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF,
@@ -118,7 +114,7 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
 }
 
 
-smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
+Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
 (
     const smoluchowskiJumpTFvPatchScalarField& ptpsf,
     const DimensionedField<scalar, volMesh>& iF
@@ -134,7 +130,7 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 // Map from self
-void smoluchowskiJumpTFvPatchScalarField::autoMap
+void Foam::smoluchowskiJumpTFvPatchScalarField::autoMap
 (
     const fvPatchFieldMapper& m
 )
@@ -144,7 +140,7 @@ void smoluchowskiJumpTFvPatchScalarField::autoMap
 
 
 // Reverse-map the given fvPatchField onto this fvPatchField
-void smoluchowskiJumpTFvPatchScalarField::rmap
+void Foam::smoluchowskiJumpTFvPatchScalarField::rmap
 (
     const fvPatchField<scalar>& ptf,
     const labelList& addr
@@ -155,7 +151,7 @@ void smoluchowskiJumpTFvPatchScalarField::rmap
 
 
 // Update the coefficients associated with the patch field
-void smoluchowskiJumpTFvPatchScalarField::updateCoeffs()
+void Foam::smoluchowskiJumpTFvPatchScalarField::updateCoeffs()
 {
     if (updated())
     {
@@ -174,11 +170,16 @@ void smoluchowskiJumpTFvPatchScalarField::updateCoeffs()
     // Prandtl number reading consistent with rhoCentralFoam
     const dictionary& thermophysicalProperties =
         db().lookupObject<IOdictionary>("thermophysicalProperties");
-    dimensionedScalar Pr = dimensionedScalar("Pr", dimless, 1.0);
-    if (thermophysicalProperties.found("Pr"))
-    {
-        Pr = thermophysicalProperties.lookup("Pr");
-    }
+
+    dimensionedScalar Pr
+    (
+        dimensionedScalar::lookupOrDefault
+        (
+            "Pr",
+            thermophysicalProperties,
+            1.0
+        )
+    );
 
     Field<scalar> C2 = pmu/prho
         *sqrt(ppsi*constant::mathematical::piByTwo)
@@ -197,7 +198,7 @@ void smoluchowskiJumpTFvPatchScalarField::updateCoeffs()
 
 
 // Write
-void smoluchowskiJumpTFvPatchScalarField::write(Ostream& os) const
+void Foam::smoluchowskiJumpTFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
     os.writeKeyword("accommodationCoeff")
@@ -211,10 +212,12 @@ void smoluchowskiJumpTFvPatchScalarField::write(Ostream& os) const
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+namespace Foam
+{
+
 makePatchTypeField(fvPatchScalarField, smoluchowskiJumpTFvPatchScalarField);
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+}
 
-} // End namespace Foam
 
 // ************************************************************************* //
diff --git a/applications/solvers/compressible/rhoCentralFoam/readFluxScheme.H b/applications/solvers/compressible/rhoCentralFoam/readFluxScheme.H
index 9f54c43ef33..13f8f02c9c6 100644
--- a/applications/solvers/compressible/rhoCentralFoam/readFluxScheme.H
+++ b/applications/solvers/compressible/rhoCentralFoam/readFluxScheme.H
@@ -1,7 +1,6 @@
 word fluxScheme("Kurganov");
-if (mesh.schemesDict().found("fluxScheme"))
+if (mesh.schemesDict().readIfPresent("fluxScheme", fluxScheme))
 {
-    fluxScheme = word(mesh.schemesDict().lookup("fluxScheme"));
     if ((fluxScheme == "Tadmor") || (fluxScheme == "Kurganov"))
     {
         Info<< "fluxScheme: " << fluxScheme << endl;
diff --git a/applications/solvers/compressible/rhoCentralFoam/readThermophysicalProperties.H b/applications/solvers/compressible/rhoCentralFoam/readThermophysicalProperties.H
index 435bcb7745e..2f4e267e5ed 100644
--- a/applications/solvers/compressible/rhoCentralFoam/readThermophysicalProperties.H
+++ b/applications/solvers/compressible/rhoCentralFoam/readThermophysicalProperties.H
@@ -14,9 +14,13 @@ IOdictionary thermophysicalProperties
     )
 );
 
-dimensionedScalar Pr = dimensionedScalar("Pr", dimless, 1.0);
+dimensionedScalar Pr
+(
+    dimensionedScalar::lookupOrDefault
+    (
+        "Pr",
+        thermophysicalProperties,
+        1.0
+    )
+);
 
-if (thermophysicalProperties.found("Pr"))
-{
-    Pr = thermophysicalProperties.lookup("Pr");
-}
diff --git a/applications/solvers/compressible/rhopSonicFoam/readThermodynamicProperties.H b/applications/solvers/compressible/rhopSonicFoam/readThermodynamicProperties.H
index 3b8c82c8e59..3f8a17b43e2 100644
--- a/applications/solvers/compressible/rhopSonicFoam/readThermodynamicProperties.H
+++ b/applications/solvers/compressible/rhopSonicFoam/readThermodynamicProperties.H
@@ -26,8 +26,13 @@
 
     dimensionedScalar gamma = Cp/Cv;
 
-    dimensionedScalar Pr = dimensionedScalar("Pr", dimless, 1.0);
-    if (thermodynamicProperties.found("Pr"))
-    {
-        Pr = thermodynamicProperties.lookup("Pr");
-    }
+    dimensionedScalar Pr
+    (
+        dimensionedScalar::lookupOrDefault
+        (
+            "Pr",
+            thermodynamicProperties,
+            1.0
+        )
+    );
+
diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/createFields.H b/applications/solvers/multiphase/twoPhaseEulerFoam/createFields.H
index 8a126905810..5f800bcfeda 100644
--- a/applications/solvers/multiphase/twoPhaseEulerFoam/createFields.H
+++ b/applications/solvers/multiphase/twoPhaseEulerFoam/createFields.H
@@ -175,10 +175,8 @@
     );
 
     word dragPhase("blended");
-    if (interfacialProperties.found("dragPhase"))
+    if (interfacialProperties.readIfPresent("dragPhase", dragPhase))
     {
-        dragPhase = word(interfacialProperties.lookup("dragPhase"));
-
         bool validDrag =
             dragPhase == "a" || dragPhase == "b" || dragPhase == "blended";
 
diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C
index b144e757583..0d90c2ab086 100644
--- a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C
+++ b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C
@@ -110,11 +110,7 @@ Foam::domainDecomposition::domainDecomposition(const IOobject& io)
     procProcessorPatchStartIndex_(nProcs_),
     cyclicParallel_(false)
 {
-    if (decompositionDict_.found("distributed"))
-    {
-        Switch distributed(decompositionDict_.lookup("distributed"));
-        distributed_ = distributed;
-    }
+    decompositionDict_.readIfPresent("distributed", distributed_);
 }
 
 
diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C
index 1341d8083da..d77552cf0ce 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C
@@ -43,10 +43,10 @@ namespace Foam
 
     addToRunTimeSelectionTable(polyPatch, cyclicPolyPatch, word);
     addToRunTimeSelectionTable(polyPatch, cyclicPolyPatch, dictionary);
-
+}
 
 template<>
-const char* NamedEnum<cyclicPolyPatch::transformType, 4>::names[] =
+const char* Foam::NamedEnum<Foam::cyclicPolyPatch::transformType, 4>::names[] =
 {
     "unknown",
     "rotational",
@@ -54,9 +54,8 @@ const char* NamedEnum<cyclicPolyPatch::transformType, 4>::names[] =
     "noOrdering"
 };
 
-const NamedEnum<cyclicPolyPatch::transformType, 4>
-    cyclicPolyPatch::transformTypeNames;
-}
+const Foam::NamedEnum<Foam::cyclicPolyPatch::transformType, 4>
+    Foam::cyclicPolyPatch::transformTypeNames;
 
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/engine/engineMesh/fvMotionSolverEngineMesh/fvMotionSolverEngineMesh.C b/src/engine/engineMesh/fvMotionSolverEngineMesh/fvMotionSolverEngineMesh.C
index a7d107a0fda..a9dc31ff229 100644
--- a/src/engine/engineMesh/fvMotionSolverEngineMesh/fvMotionSolverEngineMesh.C
+++ b/src/engine/engineMesh/fvMotionSolverEngineMesh/fvMotionSolverEngineMesh.C
@@ -45,10 +45,7 @@ Foam::fvMotionSolverEngineMesh::fvMotionSolverEngineMesh(const IOobject& io)
     pistonLayers_("pistonLayers", dimLength, 0.0),
     motionSolver_(*this, engineDB_.engineDict().lookup("motionSolver"))
 {
-    if (engineDB_.engineDict().found("pistonLayers"))
-    {
-        engineDB_.engineDict().lookup("pistonLayers") >> pistonLayers_;
-    }
+    engineDB_.engineDict().readIfPresent("pistonLayers", pistonLayers_);
 }
 
 
diff --git a/src/engine/engineMesh/layeredEngineMesh/layeredEngineMesh.C b/src/engine/engineMesh/layeredEngineMesh/layeredEngineMesh.C
index 17ce100ed67..e3caab294d6 100644
--- a/src/engine/engineMesh/layeredEngineMesh/layeredEngineMesh.C
+++ b/src/engine/engineMesh/layeredEngineMesh/layeredEngineMesh.C
@@ -44,10 +44,7 @@ Foam::layeredEngineMesh::layeredEngineMesh(const IOobject& io)
     engineMesh(io),
     pistonLayers_("pistonLayers", dimLength, 0.0)
 {
-    if (engineDB_.engineDict().found("pistonLayers"))
-    {
-        engineDB_.engineDict().lookup("pistonLayers") >> pistonLayers_;
-    }
+    engineDB_.engineDict().readIfPresent("pistonLayers", pistonLayers_);
 }
 
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C
index 6b0dab35833..8153405f0ba 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C
@@ -80,10 +80,7 @@ freestreamFvPatchField<Type>::freestreamFvPatchField
         fvPatchField<Type>::operator=(freestreamValue());
     }
 
-    if (dict.found("phi"))
-    {
-        dict.lookup("phi") >> this->phiName_;
-    }
+    dict.readIfPresent("phi", this->phiName_);
 }
 
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C
index 82e21eea9db..ed0f8504c0f 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C
@@ -130,10 +130,7 @@ timeVaryingMappedFixedValueFvPatchField
             << endl;
     }
 
-    if (dict.found("fieldTableName"))
-    {
-        dict.lookup("fieldTableName") >> fieldTableName_;
-    }
+    dict.readIfPresent("fieldTableName", fieldTableName_);
 
     if (dict.found("value"))
     {
diff --git a/src/lagrangian/molecularDynamics/potential/potential/potential.C b/src/lagrangian/molecularDynamics/potential/potential/potential.C
index a54ef7f153d..3bc59326341 100644
--- a/src/lagrangian/molecularDynamics/potential/potential/potential.C
+++ b/src/lagrangian/molecularDynamics/potential/potential/potential.C
@@ -229,18 +229,12 @@ void Foam::potential::potential::readPotentialDict()
 
     if (potentialDict.found("external"))
     {
-
         Info<< nl << "Reading external forces:" << endl;
 
         const dictionary& externalDict = potentialDict.subDict("external");
 
-        // *********************************************************************
         // gravity
-
-        if (externalDict.found("gravity"))
-        {
-            gravity_ = externalDict.lookup("gravity");
-        }
+        externalDict.readIfPresent("gravity", gravity_);
     }
 
     Info<< nl << tab << "gravity = " << gravity_ << endl;
diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C
index 348f9ce4142..99b231f2345 100644
--- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C
+++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C
@@ -218,10 +218,7 @@ Foam::layerParameters::layerParameters
             << endl;
     }
 
-    if (dict.found("nRelaxedIter"))
-    {
-        dict.lookup("nRelaxedIter") >> nRelaxedIter_;
-    }
+    dict.readIfPresent("nRelaxedIter", nRelaxedIter_);
 
     if (nLayerIter_ < 0 || nRelaxedIter_ < 0)
     {
@@ -303,10 +300,8 @@ Foam::layerParameters::layerParameters
             << endl;
     }
 
-    if (dict.found("nRelaxedIter"))
-    {
-        dict.lookup("nRelaxedIter") >> nRelaxedIter_;
-    }
+    dict.readIfPresent("nRelaxedIter", nRelaxedIter_);
+
     if (nLayerIter_ < 0 || nRelaxedIter_ < 0)
     {
         FatalErrorIn("layerParameters::layerParameters(..)")
diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C
index f4a887279ea..03dda28ede7 100644
--- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C
+++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C
@@ -522,11 +522,9 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
     // Collapse checking parameters
-    scalar volFraction = -1;
-    if (motionDict.found("minVolCollapseRatio"))
-    {
-        volFraction = readScalar(motionDict.lookup("minVolCollapseRatio"));
-    }
+    const scalar volFraction =
+        motionDict.lookupOrDefault<scalar>("minVolCollapseRatio", -1);
+
     const bool checkCollapse = (volFraction > 0);
     scalar minArea = -1;
     scalar maxNonOrtho = -1;
diff --git a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C
index e53d7ae03f8..f10b815b9d5 100644
--- a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C
+++ b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C
@@ -151,17 +151,10 @@ Foam::refinementSurfaces::refinementSurfaces
         }
 
         // Global perpendicular angle
-        if (dict.found("perpendicularAngle"))
-        {
-            globalAngle[surfI] = readScalar(dict.lookup("perpendicularAngle"));
-        }
+        dict.readIfPresent("perpendicularAngle", globalAngle[surfI]);
 
         //// Global patch name per surface
-        //if (dict.found("patchType"))
-        //{
-        //    dict.lookup("patchType") >> globalPatchType[surfI];
-        //}
-
+        //dict.readIfPresent("patchType", globalPatchType[surfI]);
 
         if (dict.found("regions"))
         {
@@ -446,13 +439,7 @@ Foam::refinementSurfaces::refinementSurfaces
             }
 
             // Global perpendicular angle
-            if (dict.found("perpendicularAngle"))
-            {
-                globalAngle[surfI] = readScalar
-                (
-                    dict.lookup("perpendicularAngle")
-                );
-            }
+            dict.readIfPresent("perpendicularAngle", globalAngle[surfI]);
 
             if (dict.found("regions"))
             {
diff --git a/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C
index cded55bcd7a..5a75055df2b 100644
--- a/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C
+++ b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C
@@ -22,8 +22,8 @@ License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
     From scotch forum:
- 	
-    By: Francois PELLEGRINI RE: Graph mapping 'strategy' string [ reply ]  
+
+    By: Francois PELLEGRINI RE: Graph mapping 'strategy' string [ reply ]
     2008-08-22 10:09 Strategy handling in Scotch is a bit tricky. In order
     not to be confused, you must have a clear view of how they are built.
     Here are some rules:
@@ -178,45 +178,39 @@ Foam::label Foam::ptscotchDecomp::decompose
 //        const dictionary& scotchCoeffs =
 //            decompositionDict_.subDict("ptscotchCoeffs");
 //
-//        if (scotchCoeffs.found("writeGraph"))
+//        if (scotchCoeffs.lookupOrDefault("writeGraph", false))
 //        {
-//            Switch writeGraph(scotchCoeffs.lookup("writeGraph"));
+//            OFstream str(mesh_.time().path() / mesh_.name() + ".grf");
 //
-//            if (writeGraph)
-//            {
-//                OFstream str(mesh_.time().path() / mesh_.name() + ".grf");
+//            Info<< "Dumping Scotch graph file to " << str.name() << endl
+//                << "Use this in combination with gpart." << endl;
 //
-//                Info<< "Dumping Scotch graph file to " << str.name() << endl
-//                    << "Use this in combination with gpart." << endl;
+//            label version = 0;
+//            str << version << nl;
+//            // Numer of vertices
+//            str << xadj.size()-1 << ' ' << adjncy.size() << nl;
+//            // Numbering starts from 0
+//            label baseval = 0;
+//            // Has weights?
+//            label hasEdgeWeights = 0;
+//            label hasVertexWeights = 0;
+//            label numericflag = 10*hasEdgeWeights+hasVertexWeights;
+//            str << baseval << ' ' << numericflag << nl;
+//            for (label cellI = 0; cellI < xadj.size()-1; cellI++)
+//            {
+//                label start = xadj[cellI];
+//                label end = xadj[cellI+1];
+//                str << end-start;
 //
-//                label version = 0;
-//                str << version << nl;
-//                // Numer of vertices
-//                str << xadj.size()-1 << ' ' << adjncy.size() << nl;
-//                // Numbering starts from 0
-//                label baseval = 0;
-//                // Has weights?
-//                label hasEdgeWeights = 0;
-//                label hasVertexWeights = 0;
-//                label numericflag = 10*hasEdgeWeights+hasVertexWeights;
-//                str << baseval << ' ' << numericflag << nl;
-//                for (label cellI = 0; cellI < xadj.size()-1; cellI++)
+//                for (label i = start; i < end; i++)
 //                {
-//                    label start = xadj[cellI];
-//                    label end = xadj[cellI+1];
-//                    str << end-start;
-//
-//                    for (label i = start; i < end; i++)
-//                    {
-//                        str << ' ' << adjncy[i];
-//                    }
-//                    str << nl;
+//                    str << ' ' << adjncy[i];
 //                }
+//                str << nl;
 //            }
 //        }
 //    }
 
-
     // Strategy
     // ~~~~~~~~
 
diff --git a/src/parallel/decompose/scotchDecomp/scotchDecomp.C b/src/parallel/decompose/scotchDecomp/scotchDecomp.C
index 534044646f0..95b7fd25490 100644
--- a/src/parallel/decompose/scotchDecomp/scotchDecomp.C
+++ b/src/parallel/decompose/scotchDecomp/scotchDecomp.C
@@ -22,8 +22,8 @@ License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
     From scotch forum:
- 	
-    By: Francois PELLEGRINI RE: Graph mapping 'strategy' string [ reply ]  
+
+    By: Francois PELLEGRINI RE: Graph mapping 'strategy' string [ reply ]
     2008-08-22 10:09 Strategy handling in Scotch is a bit tricky. In order
     not to be confused, you must have a clear view of how they are built.
     Here are some rules:
@@ -178,40 +178,35 @@ Foam::label Foam::scotchDecomp::decompose
         const dictionary& scotchCoeffs =
             decompositionDict_.subDict("scotchCoeffs");
 
-        if (scotchCoeffs.found("writeGraph"))
+        if (scotchCoeffs.lookupOrDefault("writeGraph", false))
         {
-            Switch writeGraph(scotchCoeffs.lookup("writeGraph"));
-
-            if (writeGraph)
+            OFstream str(mesh_.time().path() / mesh_.name() + ".grf");
+
+            Info<< "Dumping Scotch graph file to " << str.name() << endl
+                << "Use this in combination with gpart." << endl;
+
+            label version = 0;
+            str << version << nl;
+            // Numer of vertices
+            str << xadj.size()-1 << ' ' << adjncy.size() << nl;
+            // Numbering starts from 0
+            label baseval = 0;
+            // Has weights?
+            label hasEdgeWeights = 0;
+            label hasVertexWeights = 0;
+            label numericflag = 10*hasEdgeWeights+hasVertexWeights;
+            str << baseval << ' ' << numericflag << nl;
+            for (label cellI = 0; cellI < xadj.size()-1; cellI++)
             {
-                OFstream str(mesh_.time().path() / mesh_.name() + ".grf");
-
-                Info<< "Dumping Scotch graph file to " << str.name() << endl
-                    << "Use this in combination with gpart." << endl;
-
-                label version = 0;
-                str << version << nl;
-                // Numer of vertices
-                str << xadj.size()-1 << ' ' << adjncy.size() << nl;
-                // Numbering starts from 0
-                label baseval = 0;
-                // Has weights?
-                label hasEdgeWeights = 0;
-                label hasVertexWeights = 0;
-                label numericflag = 10*hasEdgeWeights+hasVertexWeights;
-                str << baseval << ' ' << numericflag << nl;
-                for (label cellI = 0; cellI < xadj.size()-1; cellI++)
+                label start = xadj[cellI];
+                label end = xadj[cellI+1];
+                str << end-start;
+
+                for (label i = start; i < end; i++)
                 {
-                    label start = xadj[cellI];
-                    label end = xadj[cellI+1];
-                    str << end-start;
-
-                    for (label i = start; i < end; i++)
-                    {
-                        str << ' ' << adjncy[i];
-                    }
-                    str << nl;
+                    str << ' ' << adjncy[i];
                 }
+                str << nl;
             }
         }
     }
@@ -229,7 +224,6 @@ Foam::label Foam::scotchDecomp::decompose
         const dictionary& scotchCoeffs =
             decompositionDict_.subDict("scotchCoeffs");
 
-
         string strategy;
         if (scotchCoeffs.readIfPresent("strategy", strategy))
         {
diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C
index 8b248991d5c..fdcfa25e1a6 100644
--- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C
+++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C
@@ -76,11 +76,9 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
         rhoInf_ = readScalar(dict.lookup("rhoInf"));
     }
 
-    if (dict.found("g"))
+    if (dict.readIfPresent("g", g_))
     {
         lookupGravity_ = -2;
-
-        g_ = dict.lookup("g");
     }
 
     if (!dict.found("value"))
-- 
GitLab