From 80b8071e7550c32e305bea1637004b1a9cc18938 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 20 May 2010 08:24:55 +0200 Subject: [PATCH 01/22] ENH: add default control values to ease SIMPLE->PIMPLE transition - add const-ness for control variables - drop unused fluxGradp variable - use lookupOrDefault instead of found/lookup combination --- .../mhdFoam/readBPISOControls.H | 5 +-- .../readFluidMultiRegionSIMPLEControls.H | 28 ++++----------- .../readSolidMultiRegionSIMPLEControls.H | 10 +++--- .../readFluidMultiRegionPIMPLEControls.H | 10 +++--- .../fluid/readFluidMultiRegionPISOControls.H | 34 +++++++------------ .../chtMultiRegionFoam/readPIMPLEControls.H | 4 ++- .../solid/readSolidMultiRegionPISOControls.H | 8 ++--- .../pimpleDyMFoam/readControls.H | 19 ++++------- .../compressibleInterDyMFoam/readControls.H | 19 ++++------- .../multiphase/interDyMFoam/readControls.H | 15 +++----- .../readSolidDisplacementFoamControls.H | 3 +- .../general/include/readPIMPLEControls.H | 20 ++++++----- .../general/include/readPISOControls.H | 20 ++++++----- .../general/include/readSIMPLEControls.H | 15 ++++---- .../general/include/readTimeControls.H | 14 +++----- .../engineFoam/kivaTest/system/fvSolution | 1 - .../boundaryWallFunctions/system/fvSolution | 1 - .../system/fvSolution | 1 - 18 files changed, 93 insertions(+), 134 deletions(-) diff --git a/applications/solvers/electromagnetics/mhdFoam/readBPISOControls.H b/applications/solvers/electromagnetics/mhdFoam/readBPISOControls.H index 4363850cdf..5ddbdab95e 100644 --- a/applications/solvers/electromagnetics/mhdFoam/readBPISOControls.H +++ b/applications/solvers/electromagnetics/mhdFoam/readBPISOControls.H @@ -1,3 +1,4 @@ -const dictionary& Bpiso = mesh.solutionDict().subDict("BPISO"); + const dictionary& Bpiso = mesh.solutionDict().subDict("BPISO"); + + const int nBcorr = Bpiso.lookupOrDefault("nCorrectors", 1); -int nBcorr(readInt(Bpiso.lookup("nCorrectors"))); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H index 3054562d5d..e69527a97c 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H @@ -1,25 +1,11 @@ - dictionary simple = fluidRegions[i].solutionDict().subDict("SIMPLE"); + const dictionary& simple = fluidRegions[i].solutionDict().subDict("SIMPLE"); - int nNonOrthCorr = 0; - if (simple.found("nNonOrthogonalCorrectors")) - { - nNonOrthCorr = readInt(simple.lookup("nNonOrthogonalCorrectors")); - } + const int nNonOrthCorr = + simple.lookupOrDefault("nNonOrthogonalCorrectors", 0); - bool momentumPredictor = true; - if (simple.found("momentumPredictor")) - { - momentumPredictor = Switch(simple.lookup("momentumPredictor")); - } + const bool momentumPredictor = + simple.lookupOrDefault("momentumPredictor", true); - bool fluxGradp = false; - if (simple.found("fluxGradp")) - { - fluxGradp = Switch(simple.lookup("fluxGradp")); - } + const bool transonic = + simple.lookupOrDefault("transonic", false); - bool transonic = false; - if (simple.found("transonic")) - { - transonic = Switch(simple.lookup("transonic")); - } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/solid/readSolidMultiRegionSIMPLEControls.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/solid/readSolidMultiRegionSIMPLEControls.H index 22e9b177f1..e1d58d9f65 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/solid/readSolidMultiRegionSIMPLEControls.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/solid/readSolidMultiRegionSIMPLEControls.H @@ -1,7 +1,5 @@ - dictionary simple = solidRegions[i].solutionDict().subDict("SIMPLE"); + const dictionary& simple = solidRegions[i].solutionDict().subDict("SIMPLE"); + + const int nNonOrthCorr = + simple.lookupOrDefault("nNonOrthogonalCorrectors", 0); - int nNonOrthCorr = 0; - if (simple.found("nNonOrthogonalCorrectors")) - { - nNonOrthCorr = readInt(simple.lookup("nNonOrthogonalCorrectors")); - } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPIMPLEControls.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPIMPLEControls.H index 413c0225f0..0591b36623 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPIMPLEControls.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPIMPLEControls.H @@ -1,9 +1,11 @@ const dictionary& pimple = mesh.solutionDict().subDict("PIMPLE"); - int nCorr(readInt(pimple.lookup("nCorrectors"))); + const int nCorr = + pimple.lookupOrDefault("nCorrectors", 1); - int nNonOrthCorr = + const int nNonOrthCorr = pimple.lookupOrDefault("nNonOrthogonalCorrectors", 0); - bool momentumPredictor = - pimple.lookupOrDefault("momentumPredictor", true); + const bool momentumPredictor = + pimple.lookupOrDefault("momentumPredictor", true); + diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPISOControls.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPISOControls.H index 75d6d96d11..c03366ae7a 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPISOControls.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPISOControls.H @@ -1,27 +1,17 @@ - dictionary piso = fluidRegions[i].solutionDict().subDict("PISO"); + const dictionary& piso = fluidRegions[i].solutionDict().subDict("PISO"); - int nCorr(readInt(piso.lookup("nCorrectors"))); + const int nOuterCorr = + piso.lookupOrDefault("nOuterCorrectors", 1); - int nNonOrthCorr = 0; - if (piso.found("nNonOrthogonalCorrectors")) - { - nNonOrthCorr = readInt(piso.lookup("nNonOrthogonalCorrectors")); - } + const int nCorr = + piso.lookupOrDefault("nCorrectors", 1); - bool momentumPredictor = true; - if (piso.found("momentumPredictor")) - { - momentumPredictor = Switch(piso.lookup("momentumPredictor")); - } + const int nNonOrthCorr = + piso.lookupOrDefault("nNonOrthogonalCorrectors", 0); - bool transonic = false; - if (piso.found("transonic")) - { - transonic = Switch(piso.lookup("transonic")); - } + const bool momentumPredictor = + piso.lookupOrDefault("momentumPredictor", true); + + const bool transonic = + piso.lookupOrDefault("transonic", false); - int nOuterCorr = 1; - if (piso.found("nOuterCorrectors")) - { - nOuterCorr = readInt(piso.lookup("nOuterCorrectors")); - } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/readPIMPLEControls.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/readPIMPLEControls.H index 42793d9b9f..f6371c47cb 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/readPIMPLEControls.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/readPIMPLEControls.H @@ -4,4 +4,6 @@ const dictionary& pimple = solutionDict.subDict("PIMPLE"); - int nOuterCorr(readInt(pimple.lookup("nOuterCorrectors"))); + const int nOuterCorr = + pimple.lookupOrDefault("nOuterCorrectors", 1); + diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/readSolidMultiRegionPISOControls.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/readSolidMultiRegionPISOControls.H index ce6a1c5bb2..0c965a8322 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/readSolidMultiRegionPISOControls.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/readSolidMultiRegionPISOControls.H @@ -1,7 +1,5 @@ const dictionary& piso = solidRegions[i].solutionDict().subDict("PISO"); - int nNonOrthCorr = 0; - if (piso.found("nNonOrthogonalCorrectors")) - { - nNonOrthCorr = readInt(piso.lookup("nNonOrthogonalCorrectors")); - } + const int nNonOrthCorr = + piso.lookupOrDefault("nNonOrthogonalCorrectors", 0); + diff --git a/applications/solvers/incompressible/pimpleDyMFoam/readControls.H b/applications/solvers/incompressible/pimpleDyMFoam/readControls.H index 3bd20c5c5c..bee4e4d7b8 100644 --- a/applications/solvers/incompressible/pimpleDyMFoam/readControls.H +++ b/applications/solvers/incompressible/pimpleDyMFoam/readControls.H @@ -1,14 +1,9 @@ -# include "readTimeControls.H" -# include "readPIMPLEControls.H" + #include "readTimeControls.H" + #include "readPIMPLEControls.H" - bool correctPhi = false; - if (pimple.found("correctPhi")) - { - correctPhi = Switch(pimple.lookup("correctPhi")); - } + const bool correctPhi = + pimple.lookupOrDefault("correctPhi", false); + + const bool checkMeshCourantNo = + pimple.lookupOrDefault("checkMeshCourantNo", false); - bool checkMeshCourantNo = false; - if (pimple.found("checkMeshCourantNo")) - { - checkMeshCourantNo = Switch(pimple.lookup("checkMeshCourantNo")); - } diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/readControls.H b/applications/solvers/multiphase/compressibleInterDyMFoam/readControls.H index a2e4ef3747..11c3e8071e 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/readControls.H +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/readControls.H @@ -1,5 +1,5 @@ - #include "readPISOControls.H" - #include "readTimeControls.H" + #include "readPISOControls.H" + #include "readTimeControls.H" label nAlphaCorr ( @@ -19,14 +19,9 @@ << exit(FatalError); } - bool correctPhi = true; - if (piso.found("correctPhi")) - { - correctPhi = Switch(piso.lookup("correctPhi")); - } + const bool correctPhi = + piso.lookupOrDefault("correctPhi", true); + + const bool checkMeshCourantNo = + piso.lookupOrDefault("checkMeshCourantNo", false); - bool checkMeshCourantNo = false; - if (piso.found("checkMeshCourantNo")) - { - checkMeshCourantNo = Switch(piso.lookup("checkMeshCourantNo")); - } diff --git a/applications/solvers/multiphase/interDyMFoam/readControls.H b/applications/solvers/multiphase/interDyMFoam/readControls.H index 3640d73adc..8264a051c2 100644 --- a/applications/solvers/multiphase/interDyMFoam/readControls.H +++ b/applications/solvers/multiphase/interDyMFoam/readControls.H @@ -1,14 +1,9 @@ # include "readTimeControls.H" # include "readPISOControls.H" - bool correctPhi = true; - if (piso.found("correctPhi")) - { - correctPhi = Switch(piso.lookup("correctPhi")); - } + const bool correctPhi = + piso.lookupOrDefault("correctPhi", true); + + const bool checkMeshCourantNo = + piso.lookupOrDefault("checkMeshCourantNo", false); - bool checkMeshCourantNo = false; - if (piso.found("checkMeshCourantNo")) - { - checkMeshCourantNo = Switch(piso.lookup("checkMeshCourantNo")); - } diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/readSolidDisplacementFoamControls.H b/applications/solvers/stressAnalysis/solidDisplacementFoam/readSolidDisplacementFoamControls.H index 343b7bcaed..8b59cc497e 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/readSolidDisplacementFoamControls.H +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/readSolidDisplacementFoamControls.H @@ -1,5 +1,6 @@ const dictionary& stressControl = mesh.solutionDict().subDict("stressAnalysis"); -int nCorr(readInt(stressControl.lookup("nCorrectors"))); +const int nCorr = stressControl.lookupOrDefault("nCorrectors", 1); + scalar convergenceTolerance(readScalar(stressControl.lookup("D"))); Switch compactNormalStress(stressControl.lookup("compactNormalStress")); diff --git a/src/finiteVolume/cfdTools/general/include/readPIMPLEControls.H b/src/finiteVolume/cfdTools/general/include/readPIMPLEControls.H index 9de98ee20b..3d9fd3c7ec 100644 --- a/src/finiteVolume/cfdTools/general/include/readPIMPLEControls.H +++ b/src/finiteVolume/cfdTools/general/include/readPIMPLEControls.H @@ -1,13 +1,17 @@ - dictionary pimple = mesh.solutionDict().subDict("PIMPLE"); + const dictionary& pimple = mesh.solutionDict().subDict("PIMPLE"); - int nOuterCorr(readInt(pimple.lookup("nOuterCorrectors"))); - int nCorr(readInt(pimple.lookup("nCorrectors"))); + const int nOuterCorr = + pimple.lookupOrDefault("nOuterCorrectors", 1); - int nNonOrthCorr = + const int nCorr = + pimple.lookupOrDefault("nCorrectors", 1); + + const int nNonOrthCorr = pimple.lookupOrDefault("nNonOrthogonalCorrectors", 0); - bool momentumPredictor = - pimple.lookupOrDefault("momentumPredictor", true); + const bool momentumPredictor = + pimple.lookupOrDefault("momentumPredictor", true); + + const bool transonic = + pimple.lookupOrDefault("transonic", false); - bool transonic = - pimple.lookupOrDefault("transonic", false); diff --git a/src/finiteVolume/cfdTools/general/include/readPISOControls.H b/src/finiteVolume/cfdTools/general/include/readPISOControls.H index de763e00b0..850ee1401d 100644 --- a/src/finiteVolume/cfdTools/general/include/readPISOControls.H +++ b/src/finiteVolume/cfdTools/general/include/readPISOControls.H @@ -1,15 +1,17 @@ - dictionary piso = mesh.solutionDict().subDict("PISO"); + const dictionary& piso = mesh.solutionDict().subDict("PISO"); - int nCorr(readInt(piso.lookup("nCorrectors"))); + const int nOuterCorr = + piso.lookupOrDefault("nOuterCorrectors", 1); - int nNonOrthCorr = + const int nCorr = + piso.lookupOrDefault("nCorrectors", 1); + + const int nNonOrthCorr = piso.lookupOrDefault("nNonOrthogonalCorrectors", 0); - bool momentumPredictor = - piso.lookupOrDefault("momentumPredictor", true); + const bool momentumPredictor = + piso.lookupOrDefault("momentumPredictor", true); - bool transonic = - piso.lookupOrDefault("transonic", false); + const bool transonic = + piso.lookupOrDefault("transonic", false); - int nOuterCorr = - piso.lookupOrDefault("nOuterCorrectors", 1); diff --git a/src/finiteVolume/cfdTools/general/include/readSIMPLEControls.H b/src/finiteVolume/cfdTools/general/include/readSIMPLEControls.H index b3ea4bf674..6019876e11 100644 --- a/src/finiteVolume/cfdTools/general/include/readSIMPLEControls.H +++ b/src/finiteVolume/cfdTools/general/include/readSIMPLEControls.H @@ -1,14 +1,11 @@ - dictionary simple = mesh.solutionDict().subDict("SIMPLE"); + const dictionary& simple = mesh.solutionDict().subDict("SIMPLE"); - int nNonOrthCorr = + const int nNonOrthCorr = simple.lookupOrDefault("nNonOrthogonalCorrectors", 0); - bool momentumPredictor = - simple.lookupOrDefault("momentumPredictor", true); + const bool momentumPredictor = + simple.lookupOrDefault("momentumPredictor", true); - bool fluxGradp = - simple.lookupOrDefault("fluxGradp", false); - - bool transonic = - simple.lookupOrDefault("transonic", false); + const bool transonic = + simple.lookupOrDefault("transonic", false); diff --git a/src/finiteVolume/cfdTools/general/include/readTimeControls.H b/src/finiteVolume/cfdTools/general/include/readTimeControls.H index 1bedd17557..8255c9af4c 100644 --- a/src/finiteVolume/cfdTools/general/include/readTimeControls.H +++ b/src/finiteVolume/cfdTools/general/include/readTimeControls.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,15 +29,11 @@ Description \*---------------------------------------------------------------------------*/ -Switch adjustTimeStep -( - runTime.controlDict().lookup("adjustTimeStep") -); +const bool adjustTimeStep = + runTime.controlDict().lookupOrDefault("adjustTimeStep", false); -scalar maxCo -( - readScalar(runTime.controlDict().lookup("maxCo")) -); +scalar maxCo = + runTime.controlDict().lookupOrDefault("maxCo", 1.0); scalar maxDeltaT = runTime.controlDict().lookupOrDefault("maxDeltaT", GREAT); diff --git a/tutorials/combustion/engineFoam/kivaTest/system/fvSolution b/tutorials/combustion/engineFoam/kivaTest/system/fvSolution index 9c14f182e1..79eef886e4 100644 --- a/tutorials/combustion/engineFoam/kivaTest/system/fvSolution +++ b/tutorials/combustion/engineFoam/kivaTest/system/fvSolution @@ -46,7 +46,6 @@ PISO nCorrectors 2; nNonOrthogonalCorrectors 1; momentumPredictor yes; - fluxGradp no; } diff --git a/tutorials/incompressible/boundaryFoam/boundaryWallFunctions/system/fvSolution b/tutorials/incompressible/boundaryFoam/boundaryWallFunctions/system/fvSolution index a165f8313b..a5181189a7 100644 --- a/tutorials/incompressible/boundaryFoam/boundaryWallFunctions/system/fvSolution +++ b/tutorials/incompressible/boundaryFoam/boundaryWallFunctions/system/fvSolution @@ -63,7 +63,6 @@ PISO nCorrectors 2; nNonOrthogonalCorrectors 0; momentumPredictor yes; - fluxGradp no; } relaxationFactors diff --git a/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/system/fvSolution b/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/system/fvSolution index 0f80d7dab7..cc4a943f94 100644 --- a/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/system/fvSolution +++ b/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/system/fvSolution @@ -71,7 +71,6 @@ PISO nCorrectors 2; nNonOrthogonalCorrectors 0; momentumPredictor yes; - fluxGradp no; } relaxationFactors From 227631742ddf8242e7e6022ad18bd7604d50aff0 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 20 May 2010 08:42:07 +0200 Subject: [PATCH 02/22] ENH: add const-ness to pressureImplicitPorosity control --- .../rhoPorousSimpleFoam/createFields.H | 23 ++++++------------- .../porousSimpleFoam/createFields.H | 23 ++++++------------- 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/applications/solvers/compressible/rhoPorousSimpleFoam/createFields.H b/applications/solvers/compressible/rhoPorousSimpleFoam/createFields.H index 09b75191db..faa6108fb4 100644 --- a/applications/solvers/compressible/rhoPorousSimpleFoam/createFields.H +++ b/applications/solvers/compressible/rhoPorousSimpleFoam/createFields.H @@ -65,22 +65,13 @@ dimensionedScalar initialMass = fvc::domainIntegrate(rho); thermalPorousZones pZones(mesh); - Switch pressureImplicitPorosity(false); + // nUCorrectors used for pressureImplicitPorosity int nUCorr = 0; - if (pZones.size()) - { - // nUCorrectors for pressureImplicitPorosity - if (mesh.solutionDict().subDict("SIMPLE").found("nUCorrectors")) - { - nUCorr = readInt - ( - mesh.solutionDict().subDict("SIMPLE").lookup("nUCorrectors") - ); - } + const bool pressureImplicitPorosity = + ( + pZones.size() + && mesh.solutionDict().subDict("SIMPLE").readIfPresent("nUCorrectors", nUCorr) + && (nUCorr > 0) + ); - if (nUCorr > 0) - { - pressureImplicitPorosity = true; - } - } diff --git a/applications/solvers/incompressible/porousSimpleFoam/createFields.H b/applications/solvers/incompressible/porousSimpleFoam/createFields.H index 6861ae0005..7ce03c1967 100644 --- a/applications/solvers/incompressible/porousSimpleFoam/createFields.H +++ b/applications/solvers/incompressible/porousSimpleFoam/createFields.H @@ -43,22 +43,13 @@ porousZones pZones(mesh); - Switch pressureImplicitPorosity(false); + // nUCorrectors used for pressureImplicitPorosity int nUCorr = 0; - if (pZones.size()) - { - // nUCorrectors for pressureImplicitPorosity - if (mesh.solutionDict().subDict("SIMPLE").found("nUCorrectors")) - { - nUCorr = readInt - ( - mesh.solutionDict().subDict("SIMPLE").lookup("nUCorrectors") - ); - } + const bool pressureImplicitPorosity = + ( + pZones.size() + && mesh.solutionDict().subDict("SIMPLE").readIfPresent("nUCorrectors", nUCorr) + && (nUCorr > 0) + ); - if (nUCorr > 0) - { - pressureImplicitPorosity = true; - } - } From 9525d57d71d4db48ff82ac6094fbe24a312cd2bf Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 20 May 2010 08:52:45 +0200 Subject: [PATCH 03/22] 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 | 56 +++++++++---------- ...gidBodyDisplacementPointPatchVectorField.C | 4 +- 18 files changed, 114 insertions(+), 162 deletions(-) diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C index a6d98559a7..24ce0fe938 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& 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& iF, @@ -118,7 +114,7 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField } -smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField +Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField ( const smoluchowskiJumpTFvPatchScalarField& ptpsf, const DimensionedField& 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& 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("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 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 9f54c43ef3..13f8f02c9c 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 435bcb7745..2f4e267e5e 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 3b8c82c8e5..3f8a17b43e 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 8a12690581..5f800bcfed 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 b144e75758..0d90c2ab08 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 1341d8083d..d77552cf0c 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::names[] = +const char* Foam::NamedEnum::names[] = { "unknown", "rotational", @@ -54,9 +54,8 @@ const char* NamedEnum::names[] = "noOrdering" }; -const NamedEnum - cyclicPolyPatch::transformTypeNames; -} +const Foam::NamedEnum + Foam::cyclicPolyPatch::transformTypeNames; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/engine/engineMesh/fvMotionSolverEngineMesh/fvMotionSolverEngineMesh.C b/src/engine/engineMesh/fvMotionSolverEngineMesh/fvMotionSolverEngineMesh.C index a7d107a0fd..a9dc31ff22 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 17ce100ed6..e3caab294d 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 6b0dab3583..8153405f0b 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C @@ -80,10 +80,7 @@ freestreamFvPatchField::freestreamFvPatchField fvPatchField::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 82e21eea9d..ed0f8504c0 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 a54ef7f153..3bc5932634 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 348f9ce414..99b231f234 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 f4a887279e..03dda28ede 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("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 e53d7ae03f..f10b815b9d 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 cded55bcd7..5a75055df2 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 . 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) +// 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"); +// label start = xadj[cellI]; +// label end = xadj[cellI+1]; +// str << end-start; // -// 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++) +// 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 534044646f..95b7fd2549 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 . 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")); + OFstream str(mesh_.time().path() / mesh_.name() + ".grf"); - if (writeGraph) + 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"); + label start = xadj[cellI]; + label end = xadj[cellI+1]; + str << end-start; - 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++) + 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 8b248991d5..fdcfa25e1a 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")) From ff30e6b61a2de4aea19d3230c41a862fb0aa5e32 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 20 May 2010 14:17:18 +0200 Subject: [PATCH 04/22] STYLE: can use bool instead of Switch version of dictionary::lookupOrDefault - both versions handle the same input words. Only need the version when the destination variable is also a Switch and we need to output the word later. --- .../fluid/readFluidMultiRegionSIMPLEControls.H | 4 ++-- .../fluid/readFluidMultiRegionPIMPLEControls.H | 2 +- .../fluid/readFluidMultiRegionPISOControls.H | 4 ++-- .../solvers/incompressible/pimpleDyMFoam/readControls.H | 4 ++-- .../solvers/multiphase/bubbleFoam/createRASTurbulence.H | 2 +- .../multiphase/compressibleInterDyMFoam/readControls.H | 4 ++-- applications/solvers/multiphase/interDyMFoam/readControls.H | 4 ++-- applications/solvers/multiphase/settlingFoam/createFields.H | 2 +- applications/utilities/surface/surfaceSubset/surfaceSubset.C | 2 +- src/OpenFOAM/global/argList/argList.C | 3 +-- src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H | 3 +-- src/OpenFOAM/matrices/solution/solution.C | 2 +- src/OpenFOAM/matrices/solution/solution.H | 3 +-- .../cfdTools/general/include/readPIMPLEControls.H | 4 ++-- src/finiteVolume/cfdTools/general/include/readPISOControls.H | 4 ++-- .../cfdTools/general/include/readSIMPLEControls.H | 4 ++-- src/finiteVolume/cfdTools/general/include/readTimeControls.H | 2 +- .../coordinateRotation/EulerCoordinateRotation.C | 3 +-- .../coordinateRotation/STARCDCoordinateRotation.C | 3 +-- src/meshTools/coordinateSystems/cylindricalCS.C | 3 +-- src/meshTools/coordinateSystems/sphericalCS.C | 3 +-- 21 files changed, 29 insertions(+), 36 deletions(-) diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H index e69527a97c..f8a11b7159 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/readFluidMultiRegionSIMPLEControls.H @@ -4,8 +4,8 @@ simple.lookupOrDefault("nNonOrthogonalCorrectors", 0); const bool momentumPredictor = - simple.lookupOrDefault("momentumPredictor", true); + simple.lookupOrDefault("momentumPredictor", true); const bool transonic = - simple.lookupOrDefault("transonic", false); + simple.lookupOrDefault("transonic", false); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPIMPLEControls.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPIMPLEControls.H index 0591b36623..71e49a33a8 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPIMPLEControls.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPIMPLEControls.H @@ -7,5 +7,5 @@ pimple.lookupOrDefault("nNonOrthogonalCorrectors", 0); const bool momentumPredictor = - pimple.lookupOrDefault("momentumPredictor", true); + pimple.lookupOrDefault("momentumPredictor", true); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPISOControls.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPISOControls.H index c03366ae7a..1f8cdb82a3 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPISOControls.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPISOControls.H @@ -10,8 +10,8 @@ piso.lookupOrDefault("nNonOrthogonalCorrectors", 0); const bool momentumPredictor = - piso.lookupOrDefault("momentumPredictor", true); + piso.lookupOrDefault("momentumPredictor", true); const bool transonic = - piso.lookupOrDefault("transonic", false); + piso.lookupOrDefault("transonic", false); diff --git a/applications/solvers/incompressible/pimpleDyMFoam/readControls.H b/applications/solvers/incompressible/pimpleDyMFoam/readControls.H index bee4e4d7b8..8789bd0ab4 100644 --- a/applications/solvers/incompressible/pimpleDyMFoam/readControls.H +++ b/applications/solvers/incompressible/pimpleDyMFoam/readControls.H @@ -2,8 +2,8 @@ #include "readPIMPLEControls.H" const bool correctPhi = - pimple.lookupOrDefault("correctPhi", false); + pimple.lookupOrDefault("correctPhi", false); const bool checkMeshCourantNo = - pimple.lookupOrDefault("checkMeshCourantNo", false); + pimple.lookupOrDefault("checkMeshCourantNo", false); diff --git a/applications/solvers/multiphase/bubbleFoam/createRASTurbulence.H b/applications/solvers/multiphase/bubbleFoam/createRASTurbulence.H index 1ae6219fd6..cec2cc8bb3 100644 --- a/applications/solvers/multiphase/bubbleFoam/createRASTurbulence.H +++ b/applications/solvers/multiphase/bubbleFoam/createRASTurbulence.H @@ -96,7 +96,7 @@ ) ); - if (RASProperties.lookupOrDefault("printCoeffs", false)) + if (RASProperties.lookupOrDefault("printCoeffs", false)) { Info<< "kEpsilonCoeffs" << kEpsilonDict << nl << "wallFunctionCoeffs" << wallFunctionDict << endl; diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/readControls.H b/applications/solvers/multiphase/compressibleInterDyMFoam/readControls.H index 11c3e8071e..a5a2a183e5 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/readControls.H +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/readControls.H @@ -20,8 +20,8 @@ } const bool correctPhi = - piso.lookupOrDefault("correctPhi", true); + piso.lookupOrDefault("correctPhi", true); const bool checkMeshCourantNo = - piso.lookupOrDefault("checkMeshCourantNo", false); + piso.lookupOrDefault("checkMeshCourantNo", false); diff --git a/applications/solvers/multiphase/interDyMFoam/readControls.H b/applications/solvers/multiphase/interDyMFoam/readControls.H index 8264a051c2..10b09bf8ff 100644 --- a/applications/solvers/multiphase/interDyMFoam/readControls.H +++ b/applications/solvers/multiphase/interDyMFoam/readControls.H @@ -2,8 +2,8 @@ # include "readPISOControls.H" const bool correctPhi = - piso.lookupOrDefault("correctPhi", true); + piso.lookupOrDefault("correctPhi", true); const bool checkMeshCourantNo = - piso.lookupOrDefault("checkMeshCourantNo", false); + piso.lookupOrDefault("checkMeshCourantNo", false); diff --git a/applications/solvers/multiphase/settlingFoam/createFields.H b/applications/solvers/multiphase/settlingFoam/createFields.H index c8e05c4209..598b49bcc6 100644 --- a/applications/solvers/multiphase/settlingFoam/createFields.H +++ b/applications/solvers/multiphase/settlingFoam/createFields.H @@ -276,7 +276,7 @@ ) ); - if (RASProperties.lookupOrDefault("printCoeffs", false)) + if (RASProperties.lookupOrDefault("printCoeffs", false)) { Info<< "kEpsilonCoeffs" << kEpsilonDict << nl << "wallFunctionCoeffs" << wallFunctionDict << endl; diff --git a/applications/utilities/surface/surfaceSubset/surfaceSubset.C b/applications/utilities/surface/surfaceSubset/surfaceSubset.C index 3246358d9b..51255242ef 100644 --- a/applications/utilities/surface/surfaceSubset/surfaceSubset.C +++ b/applications/utilities/surface/surfaceSubset/surfaceSubset.C @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) ); const bool invertSelection = - meshSubsetDict.lookupOrDefault("invertSelection", false); + meshSubsetDict.lookupOrDefault("invertSelection", false); // Mark the cells for the subset diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 82c6ff47c9..6fc06a69cc 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -28,7 +28,6 @@ License #include "clock.H" #include "IFstream.H" #include "dictionary.H" -#include "Switch.H" #include "IOobject.H" #include "JobInfo.H" #include "labelList.H" @@ -564,7 +563,7 @@ Foam::argList::argList } // distributed data - if (decompDict.lookupOrDefault("distributed", false)) + if (decompDict.lookupOrDefault("distributed", false)) { fileNameList roots; decompDict.lookup("roots") >> roots; diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H index 54908a720d..d0287653cf 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H @@ -58,7 +58,6 @@ SourceFiles #include "labelField.H" #include "primitiveFields.H" #include "LUscalarMatrix.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -75,7 +74,7 @@ class GAMGSolver { // Private data - Switch cacheAgglomeration_; + bool cacheAgglomeration_; //- Number of pre-smoothing sweeps label nPreSweeps_; diff --git a/src/OpenFOAM/matrices/solution/solution.C b/src/OpenFOAM/matrices/solution/solution.C index 5aa40ae572..179641bea0 100644 --- a/src/OpenFOAM/matrices/solution/solution.C +++ b/src/OpenFOAM/matrices/solution/solution.C @@ -255,7 +255,7 @@ bool Foam::solution::read() if (dict.found("cache")) { cache_ = dict.subDict("cache"); - caching_ = cache_.lookupOrDefault("active", true); + caching_ = cache_.lookupOrDefault("active", true); } if (dict.found("relaxationFactors")) diff --git a/src/OpenFOAM/matrices/solution/solution.H b/src/OpenFOAM/matrices/solution/solution.H index a2e06b19de..8a24ca0eb4 100644 --- a/src/OpenFOAM/matrices/solution/solution.H +++ b/src/OpenFOAM/matrices/solution/solution.H @@ -36,7 +36,6 @@ SourceFiles #define solution_H #include "IOdictionary.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -57,7 +56,7 @@ class solution dictionary cache_; //- Switch for the caching mechanism - Switch caching_; + bool caching_; //- Dictionary of relaxation factors for all the fields dictionary relaxationFactors_; diff --git a/src/finiteVolume/cfdTools/general/include/readPIMPLEControls.H b/src/finiteVolume/cfdTools/general/include/readPIMPLEControls.H index 3d9fd3c7ec..7e88ec410b 100644 --- a/src/finiteVolume/cfdTools/general/include/readPIMPLEControls.H +++ b/src/finiteVolume/cfdTools/general/include/readPIMPLEControls.H @@ -10,8 +10,8 @@ pimple.lookupOrDefault("nNonOrthogonalCorrectors", 0); const bool momentumPredictor = - pimple.lookupOrDefault("momentumPredictor", true); + pimple.lookupOrDefault("momentumPredictor", true); const bool transonic = - pimple.lookupOrDefault("transonic", false); + pimple.lookupOrDefault("transonic", false); diff --git a/src/finiteVolume/cfdTools/general/include/readPISOControls.H b/src/finiteVolume/cfdTools/general/include/readPISOControls.H index 850ee1401d..61cb2f7a8c 100644 --- a/src/finiteVolume/cfdTools/general/include/readPISOControls.H +++ b/src/finiteVolume/cfdTools/general/include/readPISOControls.H @@ -10,8 +10,8 @@ piso.lookupOrDefault("nNonOrthogonalCorrectors", 0); const bool momentumPredictor = - piso.lookupOrDefault("momentumPredictor", true); + piso.lookupOrDefault("momentumPredictor", true); const bool transonic = - piso.lookupOrDefault("transonic", false); + piso.lookupOrDefault("transonic", false); diff --git a/src/finiteVolume/cfdTools/general/include/readSIMPLEControls.H b/src/finiteVolume/cfdTools/general/include/readSIMPLEControls.H index 6019876e11..26575dde41 100644 --- a/src/finiteVolume/cfdTools/general/include/readSIMPLEControls.H +++ b/src/finiteVolume/cfdTools/general/include/readSIMPLEControls.H @@ -4,8 +4,8 @@ simple.lookupOrDefault("nNonOrthogonalCorrectors", 0); const bool momentumPredictor = - simple.lookupOrDefault("momentumPredictor", true); + simple.lookupOrDefault("momentumPredictor", true); const bool transonic = - simple.lookupOrDefault("transonic", false); + simple.lookupOrDefault("transonic", false); diff --git a/src/finiteVolume/cfdTools/general/include/readTimeControls.H b/src/finiteVolume/cfdTools/general/include/readTimeControls.H index 8255c9af4c..60b2e20492 100644 --- a/src/finiteVolume/cfdTools/general/include/readTimeControls.H +++ b/src/finiteVolume/cfdTools/general/include/readTimeControls.H @@ -30,7 +30,7 @@ Description \*---------------------------------------------------------------------------*/ const bool adjustTimeStep = - runTime.controlDict().lookupOrDefault("adjustTimeStep", false); + runTime.controlDict().lookupOrDefault("adjustTimeStep", false); scalar maxCo = runTime.controlDict().lookupOrDefault("maxCo", 1.0); diff --git a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C index e9f9882c8b..68f3c272bf 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C @@ -25,7 +25,6 @@ License #include "EulerCoordinateRotation.H" -#include "Switch.H" #include "mathematicalConstants.H" #include "addToRunTimeSelectionTable.H" @@ -137,7 +136,7 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation rotation.component(vector::X), rotation.component(vector::Y), rotation.component(vector::Z), - dict.lookupOrDefault("degrees", true) + dict.lookupOrDefault("degrees", true) ); } diff --git a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C index c8277b9071..7bea35f466 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C @@ -25,7 +25,6 @@ License #include "STARCDCoordinateRotation.H" -#include "Switch.H" #include "mathematicalConstants.H" #include "addToRunTimeSelectionTable.H" @@ -138,7 +137,7 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation rotation.component(vector::X), rotation.component(vector::Y), rotation.component(vector::Z), - dict.lookupOrDefault("degrees", true) + dict.lookupOrDefault("degrees", true) ); } diff --git a/src/meshTools/coordinateSystems/cylindricalCS.C b/src/meshTools/coordinateSystems/cylindricalCS.C index 588397eeab..372e06cfc7 100644 --- a/src/meshTools/coordinateSystems/cylindricalCS.C +++ b/src/meshTools/coordinateSystems/cylindricalCS.C @@ -26,7 +26,6 @@ License #include "cylindricalCS.H" #include "one.H" -#include "Switch.H" #include "mathematicalConstants.H" #include "addToRunTimeSelectionTable.H" @@ -106,7 +105,7 @@ Foam::cylindricalCS::cylindricalCS ) : coordinateSystem(name, dict), - inDegrees_(dict.lookupOrDefault("degrees", true)) + inDegrees_(dict.lookupOrDefault("degrees", true)) {} diff --git a/src/meshTools/coordinateSystems/sphericalCS.C b/src/meshTools/coordinateSystems/sphericalCS.C index 40cf263088..9aa8343407 100644 --- a/src/meshTools/coordinateSystems/sphericalCS.C +++ b/src/meshTools/coordinateSystems/sphericalCS.C @@ -26,7 +26,6 @@ License #include "sphericalCS.H" #include "one.H" -#include "Switch.H" #include "mathematicalConstants.H" #include "addToRunTimeSelectionTable.H" @@ -106,7 +105,7 @@ Foam::sphericalCS::sphericalCS ) : coordinateSystem(name, dict), - inDegrees_(dict.lookupOrDefault("degrees", true)) + inDegrees_(dict.lookupOrDefault("degrees", true)) {} From 7e9adc7b31cda4b8cd476d14435f96873d884236 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 1 Jun 2010 09:23:47 +0200 Subject: [PATCH 05/22] ENH: add wmakeFindEmptyMake, -help option for wmakeFilesAndOptions wmakeFindEmptyMake: - Find 'Make/' directories without 'files' or 'options'. These typically correspond to (partially) removed applications. --- wmake/wmakeFilesAndOptions | 35 ++++++++++++++- wmake/wmakeFindEmptyMake | 87 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+), 1 deletion(-) create mode 100755 wmake/wmakeFindEmptyMake diff --git a/wmake/wmakeFilesAndOptions b/wmake/wmakeFilesAndOptions index 61984eea07..d2e8cf29c2 100755 --- a/wmake/wmakeFilesAndOptions +++ b/wmake/wmakeFilesAndOptions @@ -26,7 +26,7 @@ # wmakeFilesAndOptions # # Description -# Script to scan the current directory for directories and source files +# Scan current directory for directories and source files # and construct Make/files and Make/options # # Usage : wmakeFilesAndOptions @@ -34,6 +34,39 @@ #------------------------------------------------------------------------------ Script=${0##*/} +usage() { + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<. +# +# Script +# wmakeFindEmptyMake +# +# Description +# Find 'Make/' directories without 'files' or 'options'. +# These typically correspond to (partially) removed applications. +# +#------------------------------------------------------------------------------ +usage() { + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<&2 + echo "---------" 1>&2 + else + echo "skipping non-dir: $checkDir" 1>&2 + echo "----------------" 1>&2 + continue + fi + + find $checkDir -depth -type d -name Make -print | while read MakeDir + do + [ -f "$MakeDir/files" -o -f "$MakeDir/options" ] || echo $MakeDir + done +done + +#------------------------------------------------------------------------------ From 824df2c3789eb93234f983e7597d9a8e32c7c507 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 1 Jun 2010 10:14:56 +0200 Subject: [PATCH 06/22] ENH: add org-pdflatex to create pdf files --- bin/org-pdflatex | 1 + bin/tools/org-batch | 32 +++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) create mode 120000 bin/org-pdflatex diff --git a/bin/org-pdflatex b/bin/org-pdflatex new file mode 120000 index 0000000000..b7b47c1517 --- /dev/null +++ b/bin/org-pdflatex @@ -0,0 +1 @@ +tools/org-batch \ No newline at end of file diff --git a/bin/tools/org-batch b/bin/tools/org-batch index 90b60f0464..ae97370dbd 100755 --- a/bin/tools/org-batch +++ b/bin/tools/org-batch @@ -37,8 +37,9 @@ usage() { Usage: ${0##*/} [OPTIONS] file1 [.. fileN] options: - -html create html (default) - -latex create LaTeX + -html create html (default) + -latex create LaTeX + -pdflatex create pdf via pdflatex * Batch process emacs org-mode files to create html/LaTeX etc. @@ -49,8 +50,14 @@ USAGE # default is html export: mode=html +unset makePDF +echo "have $Script" case $Script in +*pdflatex) + mode=latex + makePDF=pdflatex + ;; *latex) mode=latex ;; @@ -59,7 +66,6 @@ case $Script in ;; esac - # parse options while [ "$#" -gt 0 ] do @@ -75,6 +81,11 @@ do mode=latex shift ;; + -pdflatex) + mode=latex + makePDF=pdflatex + shift + ;; -*) usage "unknown option: '$*'" ;; @@ -98,6 +109,21 @@ do then emacs --batch -l org --visit=$org \ --funcall org-export-as-$mode-batch + + # post-processing step to create pdf + case "$makePDF" in + pdflatex) + input="${org%.org}.tex" + + if [ -f "$input" ] + then + pdflatex "$input" + else + echo "No $input to convert to pdf" + fi + ;; + esac + else echo "File not found" fi From 35d3be771ebad93daf1912b18ccddd1195f29341 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 1 Jun 2010 10:19:11 +0200 Subject: [PATCH 07/22] STYLE: fix spelling, backslashes etc. in codingStyleGuide.org - now passes through LaTeX with fewer complaints. - added note about braces for 'case' statements. - could not formulate a sensible rule about when return statements need parentheses and when not. - did not update codingStyleGuide.pdf ... I don't even know if it should be part of the git repo at all --- doc/codingStyleGuide.org | 46 +++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/doc/codingStyleGuide.org b/doc/codingStyleGuide.org index 94a1b51536..589f946839 100644 --- a/doc/codingStyleGuide.org +++ b/doc/codingStyleGuide.org @@ -2,7 +2,7 @@ # #+TITLE: OpenFOAM C++ style guide #+AUTHOR: OpenCFD Ltd. -#+DATE: May 2010 +#+DATE: June 2010 #+LINK: http://www.opencfd.co.uk #+OPTIONS: author:nil ^:{} @@ -13,9 +13,12 @@ + The normal indentation is 4 spaces per logical level. + Use spaces for indentation, not tab characters. + Avoid trailing whitespace. - + The body of control statements (eg, =if=, =else=, =while=, etc). + + The body of control statements (eg, =if=, =else=, =while=, etc). is always delineated with brace brackets. A possible exception can be - made with =break= or =continue= as part of a control structure. + made in conjunction with =break= or =continue= as part of a control + structure. + + The body of =case= statements is usually delineated with brace brackets. + + A fall-through =case= should be commented as such. + stream output + =<<= is always four characters after the start of the stream, @@ -132,22 +135,25 @@ + Use two empty lines between functions *** Coding Practice - + passing data as arguments or return - Pass bool, label and scalar as copy, anything larger by reference. + + passing data as arguments or return values. + + Pass bool, label and scalar as copy, anything larger by reference. + const - Use everywhere it is applicable. + + Use everywhere it is applicable. - + variable initialisation using = - - : const className& variableName = otherClass.data(); + + variable initialisation using +#+BEGIN_EXAMPLE + const className& variableName = otherClass.data(); +#+END_EXAMPLE NOT - : const className& variableName(otherClass.data()); +#+BEGIN_EXAMPLE + const className& variableName(otherClass.data()); +#+END_EXAMPLE + virtual functions - If a class is virtual - make all derived classes virtual. + + If a class is virtual, make all derived classes virtual. *** Conditional Statements #+BEGIN_EXAMPLE @@ -169,7 +175,7 @@ } #+END_EXAMPLE - NOT (no space between =if= and =(=) + NOT (no space between =if= and =(= used) #+BEGIN_EXAMPLE if(condition) @@ -201,7 +207,7 @@ } #+END_EXAMPLE - NOT (no space between =for= and =(=) + NOT this (no space between =for= and =(= used) #+BEGIN_EXAMPLE for(i = 0; i < maxI; i++) @@ -349,7 +355,7 @@ * (k + t); #+END_EXAMPLE - This is sometime more legible when surrounded by extra parentheses: + This is sometimes more legible when surrounded by extra parentheses: #+BEGIN_EXAMPLE variableName = @@ -437,15 +443,15 @@ *** Doxygen Special Commands - Doxygen has a large number of special commands with a '\' prefix or a - (alternatively) an '@' prefix. + Doxygen has a large number of special commands with a =\= prefix or + (alternatively) an =@= prefix. - The '@' prefix form is recommended for most Doxygen specials, since it + The =@= prefix form is recommended for most Doxygen specials, since it has the advantage of standing out. It also happens to be what projects like gcc and VTK are using. - The '\' prefix form, however, looks a bit better for the '\n' newline - command and when escaping single characters - eg, '\@', '\<', '\>', etc. + The =\= prefix form, however, looks a bit better for the =\n= newline + command and when escaping single characters - eg, =\@=, =\<=, =\>=, etc. Since the filtering removes the leading 4 spaces within the blocks, the Doxygen commmands can be inserted within the block without problems. @@ -514,7 +520,7 @@ #+END_EXAMPLE -*** Documenting Typedefs and classes defined via macros +*** Documenting typedefs and classes defined via macros ... not yet properly resolved From 47f692db8cfa5bbffc7ae62357f2cfd5627234de Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 1 Jun 2010 16:53:15 +0200 Subject: [PATCH 08/22] ENH: add non-const access for lduMatrix::solverPerformance::solverName() - use it to report the correct solverName for vector/tensor fields --- src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H | 7 +++++++ src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C | 1 + 2 files changed, 8 insertions(+) diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H index 924c1e51f0..83b75ab24a 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H @@ -145,6 +145,13 @@ public: return solverName_; } + //- Return solver name + word& solverName() + { + return solverName_; + } + + //- Return initial residual scalar initialResidual() const { diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C index b4889660f6..fcf1a6a4b9 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C @@ -150,6 +150,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix::solve solverPerf.print(); solverPerfVec = max(solverPerfVec, solverPerf); + solverPerfVec.solverName() = solverPerf.solverName(); psi.internalField().replace(cmpt, psiCmpt); diag() = saveDiag; From d572f40c6359b5a42f85980c4cd4aadf9cb889a1 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 17 May 2010 12:56:30 +0200 Subject: [PATCH 09/22] ENH: allow retention of 'FoamFile' when reading dictionaries - used in expandDictionary --- .../expandDictionary/expandDictionary.C | 11 +- src/OpenFOAM/db/dictionary/dictionary.H | 11 +- src/OpenFOAM/db/dictionary/dictionaryIO.C | 155 ++++++++++-------- 3 files changed, 107 insertions(+), 70 deletions(-) diff --git a/applications/utilities/miscellaneous/expandDictionary/expandDictionary.C b/applications/utilities/miscellaneous/expandDictionary/expandDictionary.C index 08e8f29f24..86b1caec44 100644 --- a/applications/utilities/miscellaneous/expandDictionary/expandDictionary.C +++ b/applications/utilities/miscellaneous/expandDictionary/expandDictionary.C @@ -42,6 +42,12 @@ using namespace Foam; int main(int argc, char *argv[]) { + argList::addNote + ( + "Read the specified dictionary file, expand the macros etc. and write\n" + "the resulting dictionary to standard output." + ); + argList::noBanner(); argList::noParallel(); argList::validArgs.append("inputDict"); @@ -49,9 +55,10 @@ int main(int argc, char *argv[]) const string dictName = args[1]; - Info<<"//\n// expansion of dictionary " << dictName << "\n//\n"; + IOobject::writeBanner(Info) + <<"//\n// " << dictName << "\n//\n"; - dictionary(IFstream(dictName)()).write(Info, false); + dictionary(IFstream(dictName)(), true).write(Info, false); IOobject::writeDivider(Info); diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index c483aed557..3c3d504353 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -191,10 +191,14 @@ public: Istream& ); - //- Construct top-level dictionary from Istream, reading entries - // until EOF + //- Construct top-level dictionary from Istream, + // reading entries until EOF dictionary(Istream&); + //- Construct top-level dictionary from Istream, + // reading entries until EOF, optionally keeping the header + dictionary(Istream&, const bool keepHeader); + //- Construct as copy given the parent dictionary dictionary(const dictionary& parentDict, const dictionary&); @@ -441,6 +445,9 @@ public: //- Read dictionary from Istream bool read(Istream&); + //- Read dictionary from Istream, optionally keeping the header + bool read(Istream&, const bool keepHeader); + // Write diff --git a/src/OpenFOAM/db/dictionary/dictionaryIO.C b/src/OpenFOAM/db/dictionary/dictionaryIO.C index 1c452bafaf..54d2877da2 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryIO.C +++ b/src/OpenFOAM/db/dictionary/dictionaryIO.C @@ -28,68 +28,6 @@ License #include "inputModeEntry.H" #include "regExp.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -bool Foam::dictionary::read(Istream& is) -{ - if (!is.good()) - { - FatalIOErrorIn("dictionary::read(Istream&, const word&)", is) - << "Istream not OK for reading dictionary " - << exit(FatalIOError); - - return false; - } - - token currToken(is); - if (currToken != token::BEGIN_BLOCK) - { - is.putBack(currToken); - } - - while (!is.eof() && entry::New(*this, is)) - {} - - // Remove the FoamFile header entry if it exists - remove("FoamFile"); - - if (is.bad()) - { - Info<< "dictionary::read(Istream&, const word&) : " - << "Istream not OK after reading dictionary " << name() - << endl; - - return false; - } - - return true; -} - - -bool Foam::dictionary::substituteKeyword(const word& keyword) -{ - word varName = keyword(1, keyword.size()-1); - - // lookup the variable name in the given dictionary - const entry* ePtr = lookupEntryPtr(varName, true, true); - - // if defined insert its entries into this dictionary - if (ePtr != NULL) - { - const dictionary& addDict = ePtr->dict(); - - forAllConstIter(IDLList, addDict, iter) - { - add(iter()); - } - - return true; - } - - return false; -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::dictionary::dictionary @@ -118,12 +56,97 @@ Foam::dictionary::dictionary(Istream& is) } +Foam::dictionary::dictionary(Istream& is, const bool keepHeader) +: + dictionaryName(is.name()), + parent_(dictionary::null) +{ + // Reset input mode as this is a "top-level" dictionary + functionEntries::inputModeEntry::clear(); + + read(is, keepHeader); +} + + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + Foam::autoPtr Foam::dictionary::New(Istream& is) { return autoPtr(new dictionary(is)); } +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +bool Foam::dictionary::read(Istream& is, const bool keepHeader) +{ + if (!is.good()) + { + FatalIOErrorIn("dictionary::read(Istream&, bool)", is) + << "Istream not OK for reading dictionary " + << exit(FatalIOError); + + return false; + } + + token currToken(is); + if (currToken != token::BEGIN_BLOCK) + { + is.putBack(currToken); + } + + while (!is.eof() && entry::New(*this, is)) + {} + + // normally remove the FoamFile header entry if it exists + if (!keepHeader) + { + remove("FoamFile"); + } + + if (is.bad()) + { + Info<< "dictionary::read(Istream&, bool) : " + << "Istream not OK after reading dictionary " << name() + << endl; + + return false; + } + + return true; +} + + +bool Foam::dictionary::read(Istream& is) +{ + return this->read(is, false); +} + + +bool Foam::dictionary::substituteKeyword(const word& keyword) +{ + word varName = keyword(1, keyword.size()-1); + + // lookup the variable name in the given dictionary + const entry* ePtr = lookupEntryPtr(varName, true, true); + + // if defined insert its entries into this dictionary + if (ePtr != NULL) + { + const dictionary& addDict = ePtr->dict(); + + forAllConstIter(IDLList, addDict, iter) + { + add(iter()); + } + + return true; + } + + return false; +} + + // * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * * // Foam::Istream& Foam::operator>>(Istream& is, dictionary& dict) @@ -145,7 +168,7 @@ void Foam::dictionary::write(Ostream& os, bool subDict) const { if (subDict) { - os << nl << indent << token::BEGIN_BLOCK << incrIndent << nl; + os << nl << indent << token::BEGIN_BLOCK << incrIndent << nl; } forAllConstIter(IDLList, *this, iter) @@ -153,12 +176,12 @@ void Foam::dictionary::write(Ostream& os, bool subDict) const const entry& e = *iter; // Write entry - os << e; + os << e; // Add extra new line between entries for "top-level" dictionaries if (!subDict && parent() == dictionary::null && e != *last()) { - os << nl; + os << nl; } // Check stream before going to next entry. @@ -173,7 +196,7 @@ void Foam::dictionary::write(Ostream& os, bool subDict) const if (subDict) { - os << decrIndent << indent << token::END_BLOCK << endl; + os << decrIndent << indent << token::END_BLOCK << endl; } } From 59c0e8e24d98cc4002eb54c390d67d1096e0d79d Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 2 Jun 2010 09:13:48 +0200 Subject: [PATCH 10/22] STYLE: fix 'forAll (' -> 'forAll(' format (again) --- .../fluentMeshToFoam/create3DCellShape.C | 2 +- .../decomposePar/domainDecompositionMesh.C | 18 +++++++++--------- .../cyclicGAMGInterface/cyclicGAMGInterface.C | 6 +++--- .../processorCyclicPointPatch.C | 10 +++++----- .../polyMesh/globalMeshData/globalPoints.C | 2 +- .../meshes/polyMesh/polyMeshFromShapeMesh.C | 2 +- .../basic/InteractionLists/InteractionLists.C | 4 ++-- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/applications/utilities/mesh/conversion/fluentMeshToFoam/create3DCellShape.C b/applications/utilities/mesh/conversion/fluentMeshToFoam/create3DCellShape.C index ddf722d324..adcce3869d 100644 --- a/applications/utilities/mesh/conversion/fluentMeshToFoam/create3DCellShape.C +++ b/applications/utilities/mesh/conversion/fluentMeshToFoam/create3DCellShape.C @@ -90,7 +90,7 @@ cellShape create3DCellShape // make a list of outward-pointing faces labelListList localFaces(faceLabels.size()); - forAll (faceLabels, faceI) + forAll(faceLabels, faceI) { const label curFaceLabel = faceLabels[faceI]; diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecompositionMesh.C b/applications/utilities/parallelProcessing/decomposePar/domainDecompositionMesh.C index 46febf2b44..2cc678ce7a 100644 --- a/applications/utilities/parallelProcessing/decomposePar/domainDecompositionMesh.C +++ b/applications/utilities/parallelProcessing/decomposePar/domainDecompositionMesh.C @@ -130,7 +130,7 @@ void Foam::domainDecomposition::decomposeMesh() procFaceAddressing_.setSize(nProcs_); // Internal faces - forAll (neighbour, facei) + forAll(neighbour, facei) { if (cellToProc_[owner[facei]] == cellToProc_[neighbour[facei]]) { @@ -141,16 +141,16 @@ void Foam::domainDecomposition::decomposeMesh() // for all processors, set the size of start index and patch size // lists to the number of patches in the mesh - forAll (procPatchSize_, procI) + forAll(procPatchSize_, procI) { procPatchSize_[procI].setSize(patches.size()); procPatchStartIndex_[procI].setSize(patches.size()); } - forAll (patches, patchi) + forAll(patches, patchi) { // Reset size and start index for all processors - forAll (procPatchSize_, procI) + forAll(procPatchSize_, procI) { procPatchSize_[procI][patchi] = 0; procPatchStartIndex_[procI][patchi] = @@ -167,7 +167,7 @@ void Foam::domainDecomposition::decomposeMesh() const unallocLabelList& patchFaceCells = patches[patchi].faceCells(); - forAll (patchFaceCells, facei) + forAll(patchFaceCells, facei) { const label curProc = cellToProc_[patchFaceCells[facei]]; @@ -190,7 +190,7 @@ void Foam::domainDecomposition::decomposeMesh() const unallocLabelList& nbrPatchFaceCells = pp.neighbPatch().faceCells(); - forAll (patchFaceCells, facei) + forAll(patchFaceCells, facei) { const label curProc = cellToProc_[patchFaceCells[facei]]; const label nbrProc = cellToProc_[nbrPatchFaceCells[facei]]; @@ -216,7 +216,7 @@ void Foam::domainDecomposition::decomposeMesh() List > > interPatchFaces(nProcs_); // Processor boundaries from internal faces - forAll (neighbour, facei) + forAll(neighbour, facei) { label ownerProc = cellToProc_[owner[facei]]; label nbrProc = cellToProc_[neighbour[facei]]; @@ -249,7 +249,7 @@ void Foam::domainDecomposition::decomposeMesh() } // Processor boundaries from split cyclics - forAll (patches, patchi) + forAll(patches, patchi) { if (isA(patches[patchi])) { @@ -279,7 +279,7 @@ void Foam::domainDecomposition::decomposeMesh() } // Add faces with different owner and neighbour processors - forAll (patchFaceCells, facei) + forAll(patchFaceCells, facei) { const label ownerProc = cellToProc_[patchFaceCells[facei]]; const label nbrProc = cellToProc_[nbrPatchFaceCells[facei]]; diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaces/cyclicGAMGInterface/cyclicGAMGInterface.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaces/cyclicGAMGInterface/cyclicGAMGInterface.C index 2aac532ce1..29ab1a93a9 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaces/cyclicGAMGInterface/cyclicGAMGInterface.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaces/cyclicGAMGInterface/cyclicGAMGInterface.C @@ -76,7 +76,7 @@ Foam::cyclicGAMGInterface::cyclicGAMGInterface label nCoarseFaces = 0; - forAll (localRestrictAddressing, ffi) + forAll(localRestrictAddressing, ffi) { label curMaster = -1; label curSlave = -1; @@ -164,7 +164,7 @@ Foam::cyclicGAMGInterface::cyclicGAMGInterface if (owner()) { // On master side, the owner addressing is stored in table of contents - forAll (contents, masterI) + forAll(contents, masterI) { SLList