From 4b60453cf12d2205419cfb85bd1184b893990372 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 18 Feb 2009 08:57:10 +0100 Subject: [PATCH 01/25] use while (runTime.loop() { .. } where possible in solvers - change system/controlDict to use functions {..} instead of functions (..); * This is internally more efficient - fixed formatting of system/controlDict functions entry - pedantic change: use 'return 0' instead of 'return(0)' in the applications, since return is a C/C++ keyword, not a function. --- applications/solvers/DNS/dnsFoam/dnsFoam.C | 5 ++- .../kinematicParcelFoam/kinematicParcelFoam.C | 6 ++-- .../basic/laplacianFoam/laplacianFoam.C | 5 ++- .../basic/potentialFoam/potentialFoam.C | 2 +- .../scalarTransportFoam/scalarTransportFoam.C | 5 ++- .../solvers/combustion/PDRFoam/PDRFoam.C | 2 +- .../combustion/PDRFoam/PDRFoamAutoRefine.C | 2 +- .../solvers/combustion/XiFoam/XiFoam.C | 2 +- .../coldEngineFoam/coldEngineFoam.C | 2 +- .../dieselEngineFoam/dieselEngineFoam.C | 2 +- .../combustion/dieselFoam/dieselFoam.C | 2 +- .../combustion/engineFoam/engineFoam.C | 2 +- .../combustion/reactingFoam/reactingFoam.C | 2 +- .../rhoCentralFoam/rhoCentralFoam.C | 2 +- .../compressible/rhoPisoFoam/rhoPisoFoam.C | 2 +- .../rhoPorousSimpleFoam/rhoPorousSimpleFoam.C | 3 +- .../rhoSimpleFoam/rhoSimpleFoam.C | 3 +- .../compressible/rhoSonicFoam/rhoSonicFoam.C | 5 ++- .../rhopSonicFoam/rhopSonicFoam.C | 5 ++- .../compressible/sonicDyMFoam/sonicDyMFoam.C | 5 ++- .../compressible/sonicFoam/sonicFoam.C | 5 ++- .../sonicLiquidFoam/sonicLiquidFoam.C | 5 ++- .../electrostaticFoam/electrostaticFoam.C | 5 ++- .../electromagnetics/mhdFoam/mhdFoam.C | 5 ++- .../financial/financialFoam/financialFoam.C | 5 ++- .../buoyantBoussinesqPisoFoam.C | 3 +- .../buoyantBoussinesqSimpleFoam.C | 3 +- .../buoyantSimpleFoam/buoyantSimpleFoam.C | 3 +- .../buoyantSimpleRadiationFoam.C | 3 +- .../chtMultiRegionFoam/chtMultiRegionFoam.C | 2 +- .../boundaryFoam/boundaryFoam.C | 5 ++- .../incompressible/channelFoam/channelFoam.C | 5 ++- .../solvers/incompressible/icoFoam/icoFoam.C | 5 ++- .../nonNewtonianIcoFoam/nonNewtonianIcoFoam.C | 5 ++- .../pimpleDyMFoam/pimpleDyMFoam.C | 2 +- .../incompressible/pisoFoam/pisoFoam.C | 5 ++- .../shallowWaterFoam/shallowWaterFoam.C | 2 +- .../incompressible/simpleFoam/simpleFoam.C | 5 ++- .../mdEquilibrationFoam/mdEquilibrationFoam.C | 5 ++- .../solvers/molecularDynamics/mdFoam/mdFoam.C | 5 ++- .../multiphase/bubbleFoam/bubbleFoam.C | 5 ++- .../cavitatingFoam/cavitatingFoam.C | 2 +- .../compressibleInterDyMFoam.C | 2 +- .../compressibleInterFoam.C | 2 +- .../multiphase/interDyMFoam/interDyMFoam.C | 2 +- .../solvers/multiphase/interFoam/interFoam.C | 2 +- .../interPhaseChangeFoam.C | 2 +- .../multiphaseInterFoam/multiphaseInterFoam.C | 2 +- .../multiphase/settlingFoam/settlingFoam.C | 5 ++- .../twoLiquidMixingFoam/twoLiquidMixingFoam.C | 5 ++- .../twoPhaseEulerFoam/twoPhaseEulerFoam.C | 2 +- .../solidDisplacementFoam.C | 5 ++- .../solidEquilibriumDisplacementFoam.C | 5 ++- applications/test/Gstream/GsTest.C | 2 +- applications/test/LduMatrix/LduMatrixTest3.C | 5 ++- applications/test/Map/MapTest.C | 2 +- applications/test/dataEntry/testDataEntry.C | 2 +- applications/test/graphXi/graphXi.C | 2 +- applications/test/maxMem/maxMem.C | 2 +- .../test/nearWallDist-wave/testWallDist2.C | 3 +- applications/test/parallel/parallelTest.C | 2 +- applications/test/pointField/testPointField.C | 2 +- .../test/slicedField/slicedFieldTest.C | 2 +- .../sphericalTensorFieldTest.C | 2 +- .../symmTensorField/symmTensorFieldTest.C | 2 +- applications/test/tensor/tensorTest.C | 2 +- applications/test/triTet/triTet.C | 2 +- applications/test/volField/volFieldTest.C | 2 +- .../volPointInterpolationTest.C | 2 +- .../estimateScalarError/estimateScalarError.C | 2 +- .../icoErrorEstimate/icoErrorEstimate.C | 2 +- .../icoMomentError/icoMomentError.C | 2 +- .../momentScalarError/momentScalarError.C | 2 +- .../mesh/conversion/sammToFoam/sammToFoam.C | 2 +- .../mesh/conversion/starToFoam/starToFoam.C | 2 +- .../generation/snappyHexMesh/snappyHexMesh.C | 2 +- .../mesh/manipulation/attachMesh/attachMesh.C | 2 +- .../mesh/manipulation/checkMesh/checkMesh.C | 2 +- .../manipulation/deformedGeom/deformedGeom.C | 2 +- .../manipulation/flattenMesh/flattenMesh.C | 2 +- .../mergeOrSplitBaffles/mergeOrSplitBaffles.C | 2 +- .../moveDynamicMesh/moveDynamicMesh.C | 3 +- .../moveEngineMesh/moveEngineMesh.C | 5 ++- .../mesh/manipulation/moveMesh/moveMesh.C | 3 +- .../transformPoints/transformPoints.C | 2 +- .../mesh/manipulation/zipUpMesh/zipUpMesh.C | 2 +- .../decomposePar/decomposePar.C | 2 +- .../engineCompRatio/engineCompRatio.C | 2 +- .../postProcessing/miscellaneous/ptot/ptot.C | 2 +- .../postProcessing/miscellaneous/wdot/wdot.C | 2 +- .../scalarField/pPrime2/pPrime2.C | 2 +- .../stressComponents/stressComponents.C | 2 +- .../utilities/postProcessing/turbulence/R/R.C | 2 +- .../createTurbulenceFields.C | 2 +- .../applyBoundaryLayer/applyBoundaryLayer.C | 2 +- .../utilities/preProcessing/boxTurb/boxTurb.C | 2 +- .../preProcessing/engineSwirl/engineSwirl.C | 2 +- .../adiabaticFlameT/adiabaticFlameT.C | 2 +- .../equilibriumFlameT/equilibriumFlameT.C | 2 +- .../mixtureAdiabaticFlameT.C | 2 +- src/OpenFOAM/primitives/random/random.c | 2 +- .../field/fieldAverage/controlDict | 19 +++++----- .../rhoPisoTwinParcelFoam.C | 2 +- .../analyticalCylinder/analyticalCylinder.C | 2 +- .../XiFoam/les/pitzDaily/system/controlDict | 22 ++++++------ .../XiFoam/les/pitzDaily3D/system/controlDict | 22 ++++++------ .../les/pitzDaily/system/controlDict | 22 ++++++------ .../ras/nacaAirfoil/system/controlDict | 21 ++++++++++- .../hotRoom/setHotRoom/setHotRoom.C | 2 +- .../MRFSimpleFoam/MRFSimpleFoam.C | 5 ++- .../channelFoam/channel395/system/controlDict | 27 +++++++++++++- .../pimpleFoam/t-junction/system/controlDict | 18 +++++++++- .../pisoFoam/les/pitzDaily/system/controlDict | 30 ++++++++-------- .../pitzDailyDirectMapped/system/controlDict | 30 ++++++++-------- .../simpleSRFFoam/simpleSRFFoam.C | 5 ++- .../les/throttle/system/controlDict | 28 +++++++-------- .../les/throttle3D/system/controlDict | 28 +++++++-------- .../sloshingTank2D/system/controlDict | 24 ++++++------- .../sloshingTank2D3DoF/system/controlDict | 24 ++++++------- .../sloshingTank3D/system/controlDict | 12 +++---- .../sloshingTank3D3DoF/system/controlDict | 12 +++---- .../sloshingTank3D6DoF/system/controlDict | 12 +++---- .../twoPhaseEulerFoam/bed/system/controlDict | 35 ++++++++++--------- .../twoPhaseEulerFoam/bed2/system/controlDict | 35 ++++++++++--------- .../bubbleColumn/system/controlDict | 35 ++++++++++--------- 125 files changed, 398 insertions(+), 367 deletions(-) diff --git a/applications/solvers/DNS/dnsFoam/dnsFoam.C b/applications/solvers/DNS/dnsFoam/dnsFoam.C index cc41c03969..ca4e0dcb58 100644 --- a/applications/solvers/DNS/dnsFoam/dnsFoam.C +++ b/applications/solvers/DNS/dnsFoam/dnsFoam.C @@ -55,9 +55,8 @@ int main(int argc, char *argv[]) Info<< nl << "Starting time loop" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPISOControls.H" @@ -123,7 +122,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/Lagrangian/kinematicParcelFoam/kinematicParcelFoam.C b/applications/solvers/Lagrangian/kinematicParcelFoam/kinematicParcelFoam.C index e9f223faad..786146219b 100644 --- a/applications/solvers/Lagrangian/kinematicParcelFoam/kinematicParcelFoam.C +++ b/applications/solvers/Lagrangian/kinematicParcelFoam/kinematicParcelFoam.C @@ -53,10 +53,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; - Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Evolving " << kinematicCloud.name() << endl; @@ -72,7 +70,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/basic/laplacianFoam/laplacianFoam.C b/applications/solvers/basic/laplacianFoam/laplacianFoam.C index 5b56c72a8c..7f1a7a00a5 100644 --- a/applications/solvers/basic/laplacianFoam/laplacianFoam.C +++ b/applications/solvers/basic/laplacianFoam/laplacianFoam.C @@ -48,9 +48,8 @@ int main(int argc, char *argv[]) Info<< "\nCalculating temperature distribution\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readSIMPLEControls.H" @@ -72,7 +71,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/basic/potentialFoam/potentialFoam.C b/applications/solvers/basic/potentialFoam/potentialFoam.C index f5ec1ec364..9d2073bf2e 100644 --- a/applications/solvers/basic/potentialFoam/potentialFoam.C +++ b/applications/solvers/basic/potentialFoam/potentialFoam.C @@ -108,7 +108,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/basic/scalarTransportFoam/scalarTransportFoam.C b/applications/solvers/basic/scalarTransportFoam/scalarTransportFoam.C index ad0107319f..df0ccb8209 100644 --- a/applications/solvers/basic/scalarTransportFoam/scalarTransportFoam.C +++ b/applications/solvers/basic/scalarTransportFoam/scalarTransportFoam.C @@ -50,9 +50,8 @@ int main(int argc, char *argv[]) # include "CourantNo.H" - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readSIMPLEControls.H" @@ -72,7 +71,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/combustion/PDRFoam/PDRFoam.C b/applications/solvers/combustion/PDRFoam/PDRFoam.C index ded711f718..89a7b7f956 100644 --- a/applications/solvers/combustion/PDRFoam/PDRFoam.C +++ b/applications/solvers/combustion/PDRFoam/PDRFoam.C @@ -130,7 +130,7 @@ scalar StCoNum = 0.0; Info<< "\n end\n"; - return(0); + return 0; } diff --git a/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C b/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C index 53ae8af8be..1320b19d31 100644 --- a/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C +++ b/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C @@ -195,7 +195,7 @@ scalar StCoNum = 0.0; Info<< "\n end\n"; - return(0); + return 0; } diff --git a/applications/solvers/combustion/XiFoam/XiFoam.C b/applications/solvers/combustion/XiFoam/XiFoam.C index 52f513bfb9..d18ef0d2f4 100644 --- a/applications/solvers/combustion/XiFoam/XiFoam.C +++ b/applications/solvers/combustion/XiFoam/XiFoam.C @@ -120,7 +120,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/combustion/coldEngineFoam/coldEngineFoam.C b/applications/solvers/combustion/coldEngineFoam/coldEngineFoam.C index 0e57e0b00b..ddb4c35530 100644 --- a/applications/solvers/combustion/coldEngineFoam/coldEngineFoam.C +++ b/applications/solvers/combustion/coldEngineFoam/coldEngineFoam.C @@ -94,7 +94,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/combustion/dieselEngineFoam/dieselEngineFoam.C b/applications/solvers/combustion/dieselEngineFoam/dieselEngineFoam.C index b62adb9ffc..927afe9bc2 100644 --- a/applications/solvers/combustion/dieselEngineFoam/dieselEngineFoam.C +++ b/applications/solvers/combustion/dieselEngineFoam/dieselEngineFoam.C @@ -132,7 +132,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/combustion/dieselFoam/dieselFoam.C b/applications/solvers/combustion/dieselFoam/dieselFoam.C index 4c41a0db2d..31d034bc57 100644 --- a/applications/solvers/combustion/dieselFoam/dieselFoam.C +++ b/applications/solvers/combustion/dieselFoam/dieselFoam.C @@ -124,7 +124,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/combustion/engineFoam/engineFoam.C b/applications/solvers/combustion/engineFoam/engineFoam.C index b9b4f140bd..a835e8ea42 100644 --- a/applications/solvers/combustion/engineFoam/engineFoam.C +++ b/applications/solvers/combustion/engineFoam/engineFoam.C @@ -128,7 +128,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/combustion/reactingFoam/reactingFoam.C b/applications/solvers/combustion/reactingFoam/reactingFoam.C index 6d1a9d2caa..e915818bdc 100644 --- a/applications/solvers/combustion/reactingFoam/reactingFoam.C +++ b/applications/solvers/combustion/reactingFoam/reactingFoam.C @@ -97,7 +97,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C b/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C index 59b0c9e99e..502406d132 100644 --- a/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C +++ b/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C @@ -220,7 +220,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } // ************************************************************************* // diff --git a/applications/solvers/compressible/rhoPisoFoam/rhoPisoFoam.C b/applications/solvers/compressible/rhoPisoFoam/rhoPisoFoam.C index 26d388ab24..c349e7520e 100644 --- a/applications/solvers/compressible/rhoPisoFoam/rhoPisoFoam.C +++ b/applications/solvers/compressible/rhoPisoFoam/rhoPisoFoam.C @@ -88,7 +88,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/compressible/rhoPorousSimpleFoam/rhoPorousSimpleFoam.C b/applications/solvers/compressible/rhoPorousSimpleFoam/rhoPorousSimpleFoam.C index b1b11a7cec..0cd144fce2 100644 --- a/applications/solvers/compressible/rhoPorousSimpleFoam/rhoPorousSimpleFoam.C +++ b/applications/solvers/compressible/rhoPorousSimpleFoam/rhoPorousSimpleFoam.C @@ -51,9 +51,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readSIMPLEControls.H" diff --git a/applications/solvers/compressible/rhoSimpleFoam/rhoSimpleFoam.C b/applications/solvers/compressible/rhoSimpleFoam/rhoSimpleFoam.C index d985abe25d..bf6a9f24f3 100644 --- a/applications/solvers/compressible/rhoSimpleFoam/rhoSimpleFoam.C +++ b/applications/solvers/compressible/rhoSimpleFoam/rhoSimpleFoam.C @@ -49,9 +49,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; #include "readSIMPLEControls.H" diff --git a/applications/solvers/compressible/rhoSonicFoam/rhoSonicFoam.C b/applications/solvers/compressible/rhoSonicFoam/rhoSonicFoam.C index b4bdc9e493..0571ee5082 100644 --- a/applications/solvers/compressible/rhoSonicFoam/rhoSonicFoam.C +++ b/applications/solvers/compressible/rhoSonicFoam/rhoSonicFoam.C @@ -47,9 +47,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; surfaceScalarField phiv @@ -124,7 +123,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/compressible/rhopSonicFoam/rhopSonicFoam.C b/applications/solvers/compressible/rhopSonicFoam/rhopSonicFoam.C index b3f1c8e06d..7cd692b71d 100644 --- a/applications/solvers/compressible/rhopSonicFoam/rhopSonicFoam.C +++ b/applications/solvers/compressible/rhopSonicFoam/rhopSonicFoam.C @@ -53,9 +53,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.value() << nl << endl; # include "readPISOControls.H" @@ -187,7 +186,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/compressible/sonicDyMFoam/sonicDyMFoam.C b/applications/solvers/compressible/sonicDyMFoam/sonicDyMFoam.C index 593bc742cf..57b15a0f9b 100644 --- a/applications/solvers/compressible/sonicDyMFoam/sonicDyMFoam.C +++ b/applications/solvers/compressible/sonicDyMFoam/sonicDyMFoam.C @@ -52,9 +52,8 @@ int main(int argc, char *argv[]) autoPtr motionPtr = motionSolver::New(mesh); - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; #include "readPISOControls.H" @@ -134,7 +133,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/compressible/sonicFoam/sonicFoam.C b/applications/solvers/compressible/sonicFoam/sonicFoam.C index 741141c1c4..6ff7960798 100644 --- a/applications/solvers/compressible/sonicFoam/sonicFoam.C +++ b/applications/solvers/compressible/sonicFoam/sonicFoam.C @@ -49,9 +49,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; #include "readPISOControls.H" @@ -127,7 +126,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/compressible/sonicLiquidFoam/sonicLiquidFoam.C b/applications/solvers/compressible/sonicLiquidFoam/sonicLiquidFoam.C index 87dcf947b0..0324da8299 100644 --- a/applications/solvers/compressible/sonicLiquidFoam/sonicLiquidFoam.C +++ b/applications/solvers/compressible/sonicLiquidFoam/sonicLiquidFoam.C @@ -50,9 +50,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPISOControls.H" @@ -118,7 +117,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/electromagnetics/electrostaticFoam/electrostaticFoam.C b/applications/solvers/electromagnetics/electrostaticFoam/electrostaticFoam.C index 11daf2e0b4..ff0b3ad21a 100644 --- a/applications/solvers/electromagnetics/electrostaticFoam/electrostaticFoam.C +++ b/applications/solvers/electromagnetics/electrostaticFoam/electrostaticFoam.C @@ -47,9 +47,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting iteration loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Iteration = " << runTime.timeName() << nl << endl; solve @@ -73,7 +72,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C b/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C index e121150c7a..d89b636d04 100644 --- a/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C +++ b/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C @@ -71,9 +71,8 @@ int main(int argc, char *argv[]) Info<< nl << "Starting time loop" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; # include "readPISOControls.H" # include "readBPISOControls.H" @@ -163,7 +162,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/financial/financialFoam/financialFoam.C b/applications/solvers/financial/financialFoam/financialFoam.C index 9edd07a8d0..86c18e2ac4 100644 --- a/applications/solvers/financial/financialFoam/financialFoam.C +++ b/applications/solvers/financial/financialFoam/financialFoam.C @@ -55,9 +55,8 @@ int main(int argc, char *argv[]) Info<< "Starting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; delta == fvc::grad(V)().component(Foam::vector::X); solve @@ -85,7 +84,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C index 1a9f023253..bd0ce2ac37 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C +++ b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C @@ -69,9 +69,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readTimeControls.H" diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C index c8e62813e8..26e732cf9c 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C +++ b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C @@ -66,9 +66,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readSIMPLEControls.H" diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C b/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C index e9c48b937f..d91b6398f2 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C @@ -51,9 +51,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readSIMPLEControls.H" diff --git a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C index 21e4912ae7..5996e6be23 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C +++ b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C @@ -54,9 +54,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readSIMPLEControls.H" diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C index 8a19fd0264..faff0edba0 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C @@ -105,7 +105,7 @@ int main(int argc, char *argv[]) Info << "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C b/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C index 2360fb6677..ab10aab8d4 100644 --- a/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C +++ b/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C @@ -58,9 +58,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; fvVectorMatrix divR = turbulence->divDevReff(U); @@ -145,7 +144,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/incompressible/channelFoam/channelFoam.C b/applications/solvers/incompressible/channelFoam/channelFoam.C index 94d8f4acd4..009a300161 100644 --- a/applications/solvers/incompressible/channelFoam/channelFoam.C +++ b/applications/solvers/incompressible/channelFoam/channelFoam.C @@ -51,9 +51,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; #include "readPISOControls.H" @@ -149,7 +148,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/incompressible/icoFoam/icoFoam.C b/applications/solvers/incompressible/icoFoam/icoFoam.C index d8c549668f..9ac6bd4fa6 100644 --- a/applications/solvers/incompressible/icoFoam/icoFoam.C +++ b/applications/solvers/incompressible/icoFoam/icoFoam.C @@ -48,9 +48,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPISOControls.H" @@ -108,7 +107,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/incompressible/nonNewtonianIcoFoam/nonNewtonianIcoFoam.C b/applications/solvers/incompressible/nonNewtonianIcoFoam/nonNewtonianIcoFoam.C index f949b39cfc..c5d2b0576c 100644 --- a/applications/solvers/incompressible/nonNewtonianIcoFoam/nonNewtonianIcoFoam.C +++ b/applications/solvers/incompressible/nonNewtonianIcoFoam/nonNewtonianIcoFoam.C @@ -49,9 +49,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPISOControls.H" @@ -111,7 +110,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/incompressible/pimpleDyMFoam/pimpleDyMFoam.C b/applications/solvers/incompressible/pimpleDyMFoam/pimpleDyMFoam.C index aee117ab6e..b705d2bbb7 100644 --- a/applications/solvers/incompressible/pimpleDyMFoam/pimpleDyMFoam.C +++ b/applications/solvers/incompressible/pimpleDyMFoam/pimpleDyMFoam.C @@ -165,7 +165,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/incompressible/pisoFoam/pisoFoam.C b/applications/solvers/incompressible/pisoFoam/pisoFoam.C index 95b4bc0843..555e6e0cfe 100644 --- a/applications/solvers/incompressible/pisoFoam/pisoFoam.C +++ b/applications/solvers/incompressible/pisoFoam/pisoFoam.C @@ -52,9 +52,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPISOControls.H" @@ -139,7 +138,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/incompressible/shallowWaterFoam/shallowWaterFoam.C b/applications/solvers/incompressible/shallowWaterFoam/shallowWaterFoam.C index 4b9c231180..162d81ddaa 100644 --- a/applications/solvers/incompressible/shallowWaterFoam/shallowWaterFoam.C +++ b/applications/solvers/incompressible/shallowWaterFoam/shallowWaterFoam.C @@ -156,7 +156,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/incompressible/simpleFoam/simpleFoam.C b/applications/solvers/incompressible/simpleFoam/simpleFoam.C index ec0515aa19..b5ac02c563 100644 --- a/applications/solvers/incompressible/simpleFoam/simpleFoam.C +++ b/applications/solvers/incompressible/simpleFoam/simpleFoam.C @@ -49,9 +49,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readSIMPLEControls.H" @@ -78,7 +77,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/molecularDynamics/mdEquilibrationFoam/mdEquilibrationFoam.C b/applications/solvers/molecularDynamics/mdEquilibrationFoam/mdEquilibrationFoam.C index 8d61f2ebe7..a124288dc5 100644 --- a/applications/solvers/molecularDynamics/mdEquilibrationFoam/mdEquilibrationFoam.C +++ b/applications/solvers/molecularDynamics/mdEquilibrationFoam/mdEquilibrationFoam.C @@ -52,9 +52,8 @@ int main(int argc, char *argv[]) Info << "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; nAveragingSteps++; @@ -82,5 +81,5 @@ int main(int argc, char *argv[]) Info << "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/molecularDynamics/mdFoam/mdFoam.C b/applications/solvers/molecularDynamics/mdFoam/mdFoam.C index a1c13246e3..287065754e 100644 --- a/applications/solvers/molecularDynamics/mdFoam/mdFoam.C +++ b/applications/solvers/molecularDynamics/mdFoam/mdFoam.C @@ -50,9 +50,8 @@ int main(int argc, char *argv[]) Info << "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; nAveragingSteps++; @@ -78,5 +77,5 @@ int main(int argc, char *argv[]) Info << "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/multiphase/bubbleFoam/bubbleFoam.C b/applications/solvers/multiphase/bubbleFoam/bubbleFoam.C index 4a6f845fd8..66df8cfb9f 100644 --- a/applications/solvers/multiphase/bubbleFoam/bubbleFoam.C +++ b/applications/solvers/multiphase/bubbleFoam/bubbleFoam.C @@ -53,9 +53,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readBubbleFoamControls.H" @@ -90,7 +89,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C b/applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C index 81bceab2e5..12a8f4d499 100644 --- a/applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C +++ b/applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C @@ -89,7 +89,7 @@ int main(int argc, char *argv[]) Info<< "\n end \n"; - return(0); + return 0; } diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/compressibleInterDyMFoam.C b/applications/solvers/multiphase/compressibleInterDyMFoam/compressibleInterDyMFoam.C index 5696f9420e..65afde39c2 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/compressibleInterDyMFoam.C +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/compressibleInterDyMFoam.C @@ -139,7 +139,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C index bfac075aec..ff5a669123 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C @@ -99,7 +99,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C b/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C index 8f55efd8de..0386e6625c 100644 --- a/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C +++ b/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C @@ -138,7 +138,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/multiphase/interFoam/interFoam.C b/applications/solvers/multiphase/interFoam/interFoam.C index 512086c9b5..7d2048037a 100644 --- a/applications/solvers/multiphase/interFoam/interFoam.C +++ b/applications/solvers/multiphase/interFoam/interFoam.C @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeFoam.C b/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeFoam.C index e2040bc107..d50dcc0b0e 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeFoam.C +++ b/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeFoam.C @@ -106,7 +106,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseInterFoam.C b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseInterFoam.C index 25a77af89d..d0626cbf05 100644 --- a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseInterFoam.C +++ b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseInterFoam.C @@ -94,7 +94,7 @@ int main(int argc, char *argv[]) Info<< "\n end \n"; - return(0); + return 0; } diff --git a/applications/solvers/multiphase/settlingFoam/settlingFoam.C b/applications/solvers/multiphase/settlingFoam/settlingFoam.C index a43dd5408b..ad8dbe3646 100644 --- a/applications/solvers/multiphase/settlingFoam/settlingFoam.C +++ b/applications/solvers/multiphase/settlingFoam/settlingFoam.C @@ -57,9 +57,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPISOControls.H" @@ -93,7 +92,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/multiphase/twoLiquidMixingFoam/twoLiquidMixingFoam.C b/applications/solvers/multiphase/twoLiquidMixingFoam/twoLiquidMixingFoam.C index dbc8b2774f..be8eea9061 100644 --- a/applications/solvers/multiphase/twoLiquidMixingFoam/twoLiquidMixingFoam.C +++ b/applications/solvers/multiphase/twoLiquidMixingFoam/twoLiquidMixingFoam.C @@ -52,9 +52,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPISOControls.H" @@ -87,7 +86,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseEulerFoam.C b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseEulerFoam.C index 6bc7f9738b..ce3fb2aa55 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseEulerFoam.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseEulerFoam.C @@ -108,7 +108,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/stressAnalysis/solidDisplacementFoam/solidDisplacementFoam.C b/applications/solvers/stressAnalysis/solidDisplacementFoam/solidDisplacementFoam.C index afa3c66001..4574ef7f1c 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/solidDisplacementFoam.C +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/solidDisplacementFoam.C @@ -57,9 +57,8 @@ int main(int argc, char *argv[]) Info<< "\nCalculating displacement field\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Iteration: " << runTime.value() << nl << endl; # include "readSolidDisplacementFoamControls.H" @@ -133,7 +132,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/solidEquilibriumDisplacementFoam.C b/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/solidEquilibriumDisplacementFoam.C index 00a98b2531..4c14b00cc6 100644 --- a/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/solidEquilibriumDisplacementFoam.C +++ b/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/solidEquilibriumDisplacementFoam.C @@ -55,9 +55,8 @@ int main(int argc, char *argv[]) Info<< "\nCalculating displacement field\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Iteration: " << runTime.value() << nl << endl; # include "readSteadyStressFoamControls.H" @@ -90,7 +89,7 @@ int main(int argc, char *argv[]) Info<< "\n end \n"; - return(0); + return 0; } diff --git a/applications/test/Gstream/GsTest.C b/applications/test/Gstream/GsTest.C index 8589674e70..61e3581ae5 100644 --- a/applications/test/Gstream/GsTest.C +++ b/applications/test/Gstream/GsTest.C @@ -43,5 +43,5 @@ int main() } while (wind.waitForEvent()); - return(0); + return 0; } diff --git a/applications/test/LduMatrix/LduMatrixTest3.C b/applications/test/LduMatrix/LduMatrixTest3.C index 729bc59329..4e9ab70b0c 100644 --- a/applications/test/LduMatrix/LduMatrixTest3.C +++ b/applications/test/LduMatrix/LduMatrixTest3.C @@ -53,9 +53,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPISOControls.H" @@ -143,7 +142,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/test/Map/MapTest.C b/applications/test/Map/MapTest.C index f382803c5b..7fb05e76a5 100644 --- a/applications/test/Map/MapTest.C +++ b/applications/test/Map/MapTest.C @@ -79,7 +79,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/test/dataEntry/testDataEntry.C b/applications/test/dataEntry/testDataEntry.C index ed6cd4ce82..7a7dd94552 100644 --- a/applications/test/dataEntry/testDataEntry.C +++ b/applications/test/dataEntry/testDataEntry.C @@ -82,7 +82,7 @@ int main(int argc, char *argv[]) << " int(f(x)) lim(x0->x1) = " << dataEntry().integrate(x0, x1) << nl << endl; - return(0); + return 0; } diff --git a/applications/test/graphXi/graphXi.C b/applications/test/graphXi/graphXi.C index e366cdc3a4..2c3a5750f3 100644 --- a/applications/test/graphXi/graphXi.C +++ b/applications/test/graphXi/graphXi.C @@ -60,7 +60,7 @@ int main() Info<< "end" << endl; - return(0); + return 0; } diff --git a/applications/test/maxMem/maxMem.C b/applications/test/maxMem/maxMem.C index 0a43faa157..590c542ee9 100644 --- a/applications/test/maxMem/maxMem.C +++ b/applications/test/maxMem/maxMem.C @@ -28,5 +28,5 @@ int main(int argc, char *argv[]) cout << "allocated " << i*nBytes/(1024U*1024U) << " Mbytes" << endl; } - return(0); + return 0; } diff --git a/applications/test/nearWallDist-wave/testWallDist2.C b/applications/test/nearWallDist-wave/testWallDist2.C index 304cdba3d6..8666e0905c 100644 --- a/applications/test/nearWallDist-wave/testWallDist2.C +++ b/applications/test/nearWallDist-wave/testWallDist2.C @@ -120,9 +120,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << endl; diff --git a/applications/test/parallel/parallelTest.C b/applications/test/parallel/parallelTest.C index 953870c8e9..bf8440ece6 100644 --- a/applications/test/parallel/parallelTest.C +++ b/applications/test/parallel/parallelTest.C @@ -103,7 +103,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/test/pointField/testPointField.C b/applications/test/pointField/testPointField.C index 4f9f3cede6..8087dbaa48 100644 --- a/applications/test/pointField/testPointField.C +++ b/applications/test/pointField/testPointField.C @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/test/slicedField/slicedFieldTest.C b/applications/test/slicedField/slicedFieldTest.C index 12779c7d92..a82b4ac712 100644 --- a/applications/test/slicedField/slicedFieldTest.C +++ b/applications/test/slicedField/slicedFieldTest.C @@ -107,7 +107,7 @@ int main(int argc, char *argv[]) Info<< Sf << endl; - return(0); + return 0; } diff --git a/applications/test/sphericalTensorField/sphericalTensorFieldTest.C b/applications/test/sphericalTensorField/sphericalTensorFieldTest.C index e6a62d4d3f..17c85c1bb6 100644 --- a/applications/test/sphericalTensorField/sphericalTensorFieldTest.C +++ b/applications/test/sphericalTensorField/sphericalTensorFieldTest.C @@ -46,7 +46,7 @@ int main(int argc, char *argv[]) Info<< ((sf1 + sf2) & (sf1 + sf2)) << endl; - return(0); + return 0; } diff --git a/applications/test/symmTensorField/symmTensorFieldTest.C b/applications/test/symmTensorField/symmTensorFieldTest.C index f3b6757d03..c98b8dc476 100644 --- a/applications/test/symmTensorField/symmTensorFieldTest.C +++ b/applications/test/symmTensorField/symmTensorFieldTest.C @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) Info<< symm(tf1) << endl; - return(0); + return 0; } diff --git a/applications/test/tensor/tensorTest.C b/applications/test/tensor/tensorTest.C index 4530bc7657..efc7824dd6 100644 --- a/applications/test/tensor/tensorTest.C +++ b/applications/test/tensor/tensorTest.C @@ -65,5 +65,5 @@ int main() Info<< (symm(t7) && t7) - (0.5*(t7 + t7.T()) && t7) << endl; Info<< (t7 && symm(t7)) - (t7 && 0.5*(t7 + t7.T())) << endl; - return(0); + return 0; } diff --git a/applications/test/triTet/triTet.C b/applications/test/triTet/triTet.C index 53b9cd1399..5c850a4377 100644 --- a/applications/test/triTet/triTet.C +++ b/applications/test/triTet/triTet.C @@ -36,5 +36,5 @@ int main() Info<< "tet circumRadius = " << tetrahedron(a, b, c, d).circumRadius() << endl; - return(0); + return 0; } diff --git a/applications/test/volField/volFieldTest.C b/applications/test/volField/volFieldTest.C index e72cc87c98..3b7dafef8e 100644 --- a/applications/test/volField/volFieldTest.C +++ b/applications/test/volField/volFieldTest.C @@ -94,7 +94,7 @@ int main(int argc, char *argv[]) solve(fvm::ddt(st) + fvm::div(phi, st) - fvm::laplacian(st)); - return(0); + return 0; } diff --git a/applications/test/volPointInterpolation/volPointInterpolationTest.C b/applications/test/volPointInterpolation/volPointInterpolationTest.C index d222b14525..07329ac349 100644 --- a/applications/test/volPointInterpolation/volPointInterpolationTest.C +++ b/applications/test/volPointInterpolation/volPointInterpolationTest.C @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) pointVectorField pU(pInterp.interpolate(U)); pU.write(); - return(0); + return 0; } diff --git a/applications/utilities/errorEstimation/estimateScalarError/estimateScalarError.C b/applications/utilities/errorEstimation/estimateScalarError/estimateScalarError.C index 78a0b779dc..c90594ff24 100644 --- a/applications/utilities/errorEstimation/estimateScalarError/estimateScalarError.C +++ b/applications/utilities/errorEstimation/estimateScalarError/estimateScalarError.C @@ -134,7 +134,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/utilities/errorEstimation/icoErrorEstimate/icoErrorEstimate.C b/applications/utilities/errorEstimation/icoErrorEstimate/icoErrorEstimate.C index 0542bab893..5ce860640d 100644 --- a/applications/utilities/errorEstimation/icoErrorEstimate/icoErrorEstimate.C +++ b/applications/utilities/errorEstimation/icoErrorEstimate/icoErrorEstimate.C @@ -131,7 +131,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/utilities/errorEstimation/icoMomentError/icoMomentError.C b/applications/utilities/errorEstimation/icoMomentError/icoMomentError.C index d9fbec8785..5810d64ca7 100644 --- a/applications/utilities/errorEstimation/icoMomentError/icoMomentError.C +++ b/applications/utilities/errorEstimation/icoMomentError/icoMomentError.C @@ -190,7 +190,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/utilities/errorEstimation/momentScalarError/momentScalarError.C b/applications/utilities/errorEstimation/momentScalarError/momentScalarError.C index d9d18722e6..b1e1395bda 100644 --- a/applications/utilities/errorEstimation/momentScalarError/momentScalarError.C +++ b/applications/utilities/errorEstimation/momentScalarError/momentScalarError.C @@ -186,7 +186,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/utilities/mesh/conversion/sammToFoam/sammToFoam.C b/applications/utilities/mesh/conversion/sammToFoam/sammToFoam.C index dade6a0e45..d676581a57 100644 --- a/applications/utilities/mesh/conversion/sammToFoam/sammToFoam.C +++ b/applications/utilities/mesh/conversion/sammToFoam/sammToFoam.C @@ -69,7 +69,7 @@ int main(int argc, char *argv[]) Info<< nl << "End" << nl << endl; - return(0); + return 0; } diff --git a/applications/utilities/mesh/conversion/starToFoam/starToFoam.C b/applications/utilities/mesh/conversion/starToFoam/starToFoam.C index 92d718f085..2f7d9c8980 100644 --- a/applications/utilities/mesh/conversion/starToFoam/starToFoam.C +++ b/applications/utilities/mesh/conversion/starToFoam/starToFoam.C @@ -69,7 +69,7 @@ int main(int argc, char *argv[]) Info<< nl << "End" << nl << endl; - return(0); + return 0; } diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index 1fab34ce94..706866bd2a 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -435,7 +435,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/utilities/mesh/manipulation/attachMesh/attachMesh.C b/applications/utilities/mesh/manipulation/attachMesh/attachMesh.C index 1f9a898d43..52e0f2ae56 100644 --- a/applications/utilities/mesh/manipulation/attachMesh/attachMesh.C +++ b/applications/utilities/mesh/manipulation/attachMesh/attachMesh.C @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C index 21e0d7c1cc..74ab53432a 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C @@ -142,7 +142,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/utilities/mesh/manipulation/deformedGeom/deformedGeom.C b/applications/utilities/mesh/manipulation/deformedGeom/deformedGeom.C index d05cd1a0e2..7b64177da5 100644 --- a/applications/utilities/mesh/manipulation/deformedGeom/deformedGeom.C +++ b/applications/utilities/mesh/manipulation/deformedGeom/deformedGeom.C @@ -99,7 +99,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/utilities/mesh/manipulation/flattenMesh/flattenMesh.C b/applications/utilities/mesh/manipulation/flattenMesh/flattenMesh.C index 92bf820c3e..998929c3b0 100644 --- a/applications/utilities/mesh/manipulation/flattenMesh/flattenMesh.C +++ b/applications/utilities/mesh/manipulation/flattenMesh/flattenMesh.C @@ -98,7 +98,7 @@ int main(int argc, char *argv[]) Info << "Writing points into directory " << points.path() << nl << endl; points.write(); - return(0); + return 0; } diff --git a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C b/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C index 7f694438e9..f883c3138b 100644 --- a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C +++ b/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C @@ -377,7 +377,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C b/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C index 64d65e3aff..e024ecda58 100644 --- a/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C +++ b/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C @@ -46,9 +46,8 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createDynamicFvMesh.H" - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << endl; mesh.update(); diff --git a/applications/utilities/mesh/manipulation/moveEngineMesh/moveEngineMesh.C b/applications/utilities/mesh/manipulation/moveEngineMesh/moveEngineMesh.C index a10782b553..c47fa9ec17 100644 --- a/applications/utilities/mesh/manipulation/moveEngineMesh/moveEngineMesh.C +++ b/applications/utilities/mesh/manipulation/moveEngineMesh/moveEngineMesh.C @@ -47,9 +47,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.theta() << " CA-deg\n" << endl; mesh.move(); @@ -63,7 +62,7 @@ int main(int argc, char *argv[]) Info<< "\n end\n"; - return(0); + return 0; } diff --git a/applications/utilities/mesh/manipulation/moveMesh/moveMesh.C b/applications/utilities/mesh/manipulation/moveMesh/moveMesh.C index 82e6e45a75..d590763229 100644 --- a/applications/utilities/mesh/manipulation/moveMesh/moveMesh.C +++ b/applications/utilities/mesh/manipulation/moveMesh/moveMesh.C @@ -46,9 +46,8 @@ int main(int argc, char *argv[]) autoPtr motionPtr = motionSolver::New(mesh); - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << endl; mesh.movePoints(motionPtr->newPoints()); diff --git a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C index 4b50082e10..f9bd650d15 100644 --- a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C +++ b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C @@ -203,7 +203,7 @@ int main(int argc, char *argv[]) Info << "Writing points into directory " << points.path() << nl << endl; points.write(); - return(0); + return 0; } diff --git a/applications/utilities/mesh/manipulation/zipUpMesh/zipUpMesh.C b/applications/utilities/mesh/manipulation/zipUpMesh/zipUpMesh.C index 179ff05bf9..d134767702 100644 --- a/applications/utilities/mesh/manipulation/zipUpMesh/zipUpMesh.C +++ b/applications/utilities/mesh/manipulation/zipUpMesh/zipUpMesh.C @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index a7328cb487..fff19e006d 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -723,7 +723,7 @@ int main(int argc, char *argv[]) Info<< "\nEnd.\n" << endl; - return(0); + return 0; } diff --git a/applications/utilities/postProcessing/miscellaneous/engineCompRatio/engineCompRatio.C b/applications/utilities/postProcessing/miscellaneous/engineCompRatio/engineCompRatio.C index b6acc7806f..34ebbc75dc 100644 --- a/applications/utilities/postProcessing/miscellaneous/engineCompRatio/engineCompRatio.C +++ b/applications/utilities/postProcessing/miscellaneous/engineCompRatio/engineCompRatio.C @@ -92,7 +92,7 @@ int main(int argc, char *argv[]) Info << "Vmax/Vmin = " << Vmax/Vmin << endl; Info << "\n end\n"; - return(0); + return 0; } diff --git a/applications/utilities/postProcessing/miscellaneous/ptot/ptot.C b/applications/utilities/postProcessing/miscellaneous/ptot/ptot.C index 6d09449696..bb41fb60d4 100644 --- a/applications/utilities/postProcessing/miscellaneous/ptot/ptot.C +++ b/applications/utilities/postProcessing/miscellaneous/ptot/ptot.C @@ -145,7 +145,7 @@ int main(int argc, char *argv[]) Info<< endl; } - return(0); + return 0; } diff --git a/applications/utilities/postProcessing/miscellaneous/wdot/wdot.C b/applications/utilities/postProcessing/miscellaneous/wdot/wdot.C index 4ae3b13ac9..79f23de3e7 100644 --- a/applications/utilities/postProcessing/miscellaneous/wdot/wdot.C +++ b/applications/utilities/postProcessing/miscellaneous/wdot/wdot.C @@ -124,7 +124,7 @@ int main(int argc, char *argv[]) wdot.write(); } - return(0); + return 0; } diff --git a/applications/utilities/postProcessing/scalarField/pPrime2/pPrime2.C b/applications/utilities/postProcessing/scalarField/pPrime2/pPrime2.C index 14e722f621..6729389218 100644 --- a/applications/utilities/postProcessing/scalarField/pPrime2/pPrime2.C +++ b/applications/utilities/postProcessing/scalarField/pPrime2/pPrime2.C @@ -112,7 +112,7 @@ int main(int argc, char *argv[]) Info<< endl; } - return(0); + return 0; } diff --git a/applications/utilities/postProcessing/stressField/stressComponents/stressComponents.C b/applications/utilities/postProcessing/stressField/stressComponents/stressComponents.C index 723250e3cc..2c481b8927 100644 --- a/applications/utilities/postProcessing/stressField/stressComponents/stressComponents.C +++ b/applications/utilities/postProcessing/stressField/stressComponents/stressComponents.C @@ -222,7 +222,7 @@ int main(int argc, char *argv[]) Info<< "End" << endl; - return(0); + return 0; } diff --git a/applications/utilities/postProcessing/turbulence/R/R.C b/applications/utilities/postProcessing/turbulence/R/R.C index 65cbcc94e8..3beeb70878 100644 --- a/applications/utilities/postProcessing/turbulence/R/R.C +++ b/applications/utilities/postProcessing/turbulence/R/R.C @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) Info<< "End" << endl; - return(0); + return 0; } diff --git a/applications/utilities/postProcessing/turbulence/createTurbulenceFields/createTurbulenceFields.C b/applications/utilities/postProcessing/turbulence/createTurbulenceFields/createTurbulenceFields.C index 345548b9d2..5e15aff046 100644 --- a/applications/utilities/postProcessing/turbulence/createTurbulenceFields/createTurbulenceFields.C +++ b/applications/utilities/postProcessing/turbulence/createTurbulenceFields/createTurbulenceFields.C @@ -133,7 +133,7 @@ int main(int argc, char *argv[]) Info<< "\nEnd\n" << endl; - return(0); + return 0; } diff --git a/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C b/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C index f904d1f899..dac7cd0393 100644 --- a/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C +++ b/applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C @@ -204,7 +204,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/applications/utilities/preProcessing/boxTurb/boxTurb.C b/applications/utilities/preProcessing/boxTurb/boxTurb.C index 03e3f77aff..32ae05fa6c 100644 --- a/applications/utilities/preProcessing/boxTurb/boxTurb.C +++ b/applications/utilities/preProcessing/boxTurb/boxTurb.C @@ -72,7 +72,7 @@ int main(int argc, char *argv[]) Info<< "end" << endl; - return(0); + return 0; } diff --git a/applications/utilities/preProcessing/engineSwirl/engineSwirl.C b/applications/utilities/preProcessing/engineSwirl/engineSwirl.C index 6009a08575..e9171c330c 100644 --- a/applications/utilities/preProcessing/engineSwirl/engineSwirl.C +++ b/applications/utilities/preProcessing/engineSwirl/engineSwirl.C @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) Info << "\n end\n"; - return(0); + return 0; } diff --git a/applications/utilities/thermophysical/adiabaticFlameT/adiabaticFlameT.C b/applications/utilities/thermophysical/adiabaticFlameT/adiabaticFlameT.C index 0e294be647..e893520b06 100644 --- a/applications/utilities/thermophysical/adiabaticFlameT/adiabaticFlameT.C +++ b/applications/utilities/thermophysical/adiabaticFlameT/adiabaticFlameT.C @@ -186,7 +186,7 @@ int main(int argc, char *argv[]) Info<< nl << "end" << endl; - return(0); + return 0; } diff --git a/applications/utilities/thermophysical/equilibriumFlameT/equilibriumFlameT.C b/applications/utilities/thermophysical/equilibriumFlameT/equilibriumFlameT.C index 8d8b9f5e6e..c2186b642d 100644 --- a/applications/utilities/thermophysical/equilibriumFlameT/equilibriumFlameT.C +++ b/applications/utilities/thermophysical/equilibriumFlameT/equilibriumFlameT.C @@ -273,7 +273,7 @@ int main(int argc, char *argv[]) Info<< nl << "end" << endl; - return(0); + return 0; } diff --git a/applications/utilities/thermophysical/mixtureAdiabaticFlameT/mixtureAdiabaticFlameT.C b/applications/utilities/thermophysical/mixtureAdiabaticFlameT/mixtureAdiabaticFlameT.C index 8b65251fd9..277a4e787f 100644 --- a/applications/utilities/thermophysical/mixtureAdiabaticFlameT/mixtureAdiabaticFlameT.C +++ b/applications/utilities/thermophysical/mixtureAdiabaticFlameT/mixtureAdiabaticFlameT.C @@ -119,7 +119,7 @@ int main(int argc, char *argv[]) Info << "Adiabatic flame temperature of mixture " << rMix.name() << " = " << products.TH(reactants.H(T0), 1000.0) << " K" << endl; - return(0); + return 0; } diff --git a/src/OpenFOAM/primitives/random/random.c b/src/OpenFOAM/primitives/random/random.c index 71273fc485..5421390cf0 100644 --- a/src/OpenFOAM/primitives/random/random.c +++ b/src/OpenFOAM/primitives/random/random.c @@ -248,7 +248,7 @@ initstate(seed, arg_state, n) if (n < BREAK_0) { (void)fprintf(stderr, "random: not enough state (%d bytes); ignored.\n", n); - return(0); + return 0; } if (n < BREAK_1) { rand_type = TYPE_0; diff --git a/src/postProcessing/functionObjects/field/fieldAverage/controlDict b/src/postProcessing/functionObjects/field/fieldAverage/controlDict index e45d47eb26..f9f34b9c05 100644 --- a/src/postProcessing/functionObjects/field/fieldAverage/controlDict +++ b/src/postProcessing/functionObjects/field/fieldAverage/controlDict @@ -45,7 +45,7 @@ timePrecision 6; runTimeModifiable yes; functions -( +{ fieldAverage1 { // Type of functionObject @@ -54,23 +54,24 @@ functions // Where to load it from (if not already in solver) functionObjectLibs ("libfieldAverage.so"); - // Fields to be averaged - runTime modifiable + // Fields to be averaged - runTime modifiable fields ( U { - mean on; - prime2Mean on; - base time; + mean on; + prime2Mean on; + base time; } + p { - mean on; - prime2Mean on; - base time; + mean on; + prime2Mean on; + base time; } ); } -); +} // ************************************************************************* // diff --git a/tutorials/Lagrangian/rhoPisoTwinParcelFoam/rhoPisoTwinParcelFoam/rhoPisoTwinParcelFoam.C b/tutorials/Lagrangian/rhoPisoTwinParcelFoam/rhoPisoTwinParcelFoam/rhoPisoTwinParcelFoam.C index 0028a30b5b..1082636303 100644 --- a/tutorials/Lagrangian/rhoPisoTwinParcelFoam/rhoPisoTwinParcelFoam/rhoPisoTwinParcelFoam.C +++ b/tutorials/Lagrangian/rhoPisoTwinParcelFoam/rhoPisoTwinParcelFoam/rhoPisoTwinParcelFoam.C @@ -107,7 +107,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/tutorials/basic/potentialFoam/cylinder/analyticalCylinder/analyticalCylinder.C b/tutorials/basic/potentialFoam/cylinder/analyticalCylinder/analyticalCylinder.C index 2b862843f0..5c3b671271 100644 --- a/tutorials/basic/potentialFoam/cylinder/analyticalCylinder/analyticalCylinder.C +++ b/tutorials/basic/potentialFoam/cylinder/analyticalCylinder/analyticalCylinder.C @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) Info<< "end" << endl; - return(0); + return 0; } // ************************************************************************* // diff --git a/tutorials/combustion/XiFoam/les/pitzDaily/system/controlDict b/tutorials/combustion/XiFoam/les/pitzDaily/system/controlDict index 0d13ac7ba5..bc4e09f514 100644 --- a/tutorials/combustion/XiFoam/les/pitzDaily/system/controlDict +++ b/tutorials/combustion/XiFoam/les/pitzDaily/system/controlDict @@ -48,31 +48,31 @@ adjustTimeStep yes; maxCo 0.5; functions -( +{ fieldAverage1 { - type fieldAverage; + type fieldAverage; functionObjectLibs ( "libfieldFunctionObjects.so" ); - enabled true; - outputControl outputTime; + enabled true; + outputControl outputTime; fields ( U { - mean on; - prime2Mean on; - base time; + mean on; + prime2Mean on; + base time; } p { - mean on; - prime2Mean on; - base time; + mean on; + prime2Mean on; + base time; } ); } -); +} // ************************************************************************* // diff --git a/tutorials/combustion/XiFoam/les/pitzDaily3D/system/controlDict b/tutorials/combustion/XiFoam/les/pitzDaily3D/system/controlDict index 693d3e125f..c507917d6c 100644 --- a/tutorials/combustion/XiFoam/les/pitzDaily3D/system/controlDict +++ b/tutorials/combustion/XiFoam/les/pitzDaily3D/system/controlDict @@ -48,31 +48,31 @@ adjustTimeStep yes; maxCo 0.5; functions -( +{ fieldAverage1 { - type fieldAverage; + type fieldAverage; functionObjectLibs ( "libfieldFunctionObjects.so" ); - enabled true; - outputControl outputTime; + enabled true; + outputControl outputTime; fields ( U { - mean on; - prime2Mean on; - base time; + mean on; + prime2Mean on; + base time; } p { - mean on; - prime2Mean on; - base time; + mean on; + prime2Mean on; + base time; } ); } -); +} // ************************************************************************* // diff --git a/tutorials/compressible/rhoPisoFoam/les/pitzDaily/system/controlDict b/tutorials/compressible/rhoPisoFoam/les/pitzDaily/system/controlDict index c211c964ae..3fccde63c4 100644 --- a/tutorials/compressible/rhoPisoFoam/les/pitzDaily/system/controlDict +++ b/tutorials/compressible/rhoPisoFoam/les/pitzDaily/system/controlDict @@ -44,31 +44,31 @@ timePrecision 6; runTimeModifiable yes; functions -( +{ fieldAverage1 { - type fieldAverage; + type fieldAverage; functionObjectLibs ( "libfieldFunctionObjects.so" ); - enabled true; - outputControl outputTime; + enabled true; + outputControl outputTime; fields ( U { - mean on; - prime2Mean on; - base time; + mean on; + prime2Mean on; + base time; } p { - mean on; - prime2Mean on; - base time; + mean on; + prime2Mean on; + base time; } ); } -); +} // ************************************************************************* // diff --git a/tutorials/compressible/sonicFoam/ras/nacaAirfoil/system/controlDict b/tutorials/compressible/sonicFoam/ras/nacaAirfoil/system/controlDict index 2fe2edf6fa..ce2e9218c9 100644 --- a/tutorials/compressible/sonicFoam/ras/nacaAirfoil/system/controlDict +++ b/tutorials/compressible/sonicFoam/ras/nacaAirfoil/system/controlDict @@ -43,7 +43,26 @@ timePrecision 6; runTimeModifiable yes; -functions ( forces { type forceCoeffs ; functionObjectLibs ( "libforces.so" ) ; patches ( WALL10 ) ; pName p ; UName U ; log true ; rhoInf 1 ; CofR ( 0 0 0 ) ; liftDir ( -0.239733 0.970839 0 ) ; dragDir ( 0.970839 0.239733 0 ) ; pitchAxis ( 0 0 1 ) ; magUInf 618.022 ; lRef 1 ; Aref 1 ; } ); +functions +{ + forces + { + type forceCoeffs; + functionObjectLibs ( "libforces.so" ); + patches ( WALL10 ); + pName p; + UName U; + log true; + rhoInf 1; + CofR ( 0 0 0 ); + liftDir ( -0.239733 0.970839 0 ); + dragDir ( 0.970839 0.239733 0 ); + pitchAxis ( 0 0 1 ); + magUInf 618.022; + lRef 1; + Aref 1; + } +} // ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/setHotRoom/setHotRoom.C b/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/setHotRoom/setHotRoom.C index 7a039df40d..aca68d4e1f 100644 --- a/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/setHotRoom/setHotRoom.C +++ b/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/setHotRoom/setHotRoom.C @@ -88,7 +88,7 @@ forAll(Tpatches, patchI) Info<< "End\n" << endl; - return(0); + return 0; } } diff --git a/tutorials/incompressible/MRFSimpleFoam/MRFSimpleFoam/MRFSimpleFoam.C b/tutorials/incompressible/MRFSimpleFoam/MRFSimpleFoam/MRFSimpleFoam.C index 9fc36826fe..004a92b45f 100644 --- a/tutorials/incompressible/MRFSimpleFoam/MRFSimpleFoam/MRFSimpleFoam.C +++ b/tutorials/incompressible/MRFSimpleFoam/MRFSimpleFoam/MRFSimpleFoam.C @@ -52,9 +52,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readSIMPLEControls.H" @@ -123,7 +122,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/tutorials/incompressible/channelFoam/channel395/system/controlDict b/tutorials/incompressible/channelFoam/channel395/system/controlDict index 2ca28c29a1..7af5dca9b6 100644 --- a/tutorials/incompressible/channelFoam/channel395/system/controlDict +++ b/tutorials/incompressible/channelFoam/channel395/system/controlDict @@ -43,7 +43,32 @@ timePrecision 6; runTimeModifiable yes; -functions ( fieldAverage1 { type fieldAverage ; functionObjectLibs ( "libfieldFunctionObjects.so" ) ; enabled true ; outputControl outputTime ; fields ( U { mean on ; prime2Mean on ; base time ; } p { mean on ; prime2Mean on ; base time ; } ) ; } ); +functions +{ + fieldAverage1 + { + type fieldAverage; + functionObjectLibs ( "libfieldFunctionObjects.so" ); + enabled true; + outputControl outputTime; + fields + ( + U + { + mean on; + prime2Mean on; + base time; + } + + p + { + mean on; + prime2Mean on; + base time; + } + ); + } +} // ************************************************************************* // diff --git a/tutorials/incompressible/pimpleFoam/t-junction/system/controlDict b/tutorials/incompressible/pimpleFoam/t-junction/system/controlDict index e312fcb839..a5ba827eec 100644 --- a/tutorials/incompressible/pimpleFoam/t-junction/system/controlDict +++ b/tutorials/incompressible/pimpleFoam/t-junction/system/controlDict @@ -47,7 +47,23 @@ adjustTimeStep yes; maxCo 5; -functions ( probes { type probes ; functionObjectLibs ( "libsampling.so" ) ; name probes ; probeLocations ( ( 1e-06 0 0.01 ) ( 0.21 -0.20999 0.01 ) ( 0.21 0.20999 0.01 ) ( 0.21 0 0.01 ) ) ; fields ( p U ) ; } ); +functions +{ + probes + { + type probes; + name probes; + functionObjectLibs ( "libsampling.so" ); + probeLocations + ( + ( 1e-06 0 0.01 ) + ( 0.21 -0.20999 0.01 ) + ( 0.21 0.20999 0.01 ) + ( 0.21 0 0.01 ) + ); + fields ( p U ); + } +} // ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/pitzDaily/system/controlDict b/tutorials/incompressible/pisoFoam/les/pitzDaily/system/controlDict index ba9c0f1c40..a4b46af8cc 100644 --- a/tutorials/incompressible/pisoFoam/les/pitzDaily/system/controlDict +++ b/tutorials/incompressible/pisoFoam/les/pitzDaily/system/controlDict @@ -44,14 +44,14 @@ timePrecision 6; runTimeModifiable yes; functions -( +{ probes1 { - type probes; + type probes; functionObjectLibs ( "libsampling.so" ); - enabled true; - outputControl timeStep; - outputInterval 1; + enabled true; + outputControl timeStep; + outputInterval 1; probeLocations ( ( 0.0254 0.0253 0 ) @@ -71,28 +71,28 @@ functions fieldAverage1 { - type fieldAverage; + type fieldAverage; functionObjectLibs ( "libfieldFunctionObjects.so" ); - enabled true; - outputControl outputTime; + enabled true; + outputControl outputTime; fields ( U { - mean on; - prime2Mean on; - base time; + mean on; + prime2Mean on; + base time; } p { - mean on; - prime2Mean on; - base time; + mean on; + prime2Mean on; + base time; } ); } -); +} // ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/pitzDailyDirectMapped/system/controlDict b/tutorials/incompressible/pisoFoam/les/pitzDailyDirectMapped/system/controlDict index 2f1e1a9074..4f36f59c28 100644 --- a/tutorials/incompressible/pisoFoam/les/pitzDailyDirectMapped/system/controlDict +++ b/tutorials/incompressible/pisoFoam/les/pitzDailyDirectMapped/system/controlDict @@ -44,14 +44,14 @@ timePrecision 6; runTimeModifiable yes; functions -( +{ probes1 { - type probes; + type probes; functionObjectLibs ( "libsampling.so" ); - enabled true; - outputControl timeStep; - outputInterval 1; + enabled true; + outputControl timeStep; + outputInterval 1; probeLocations ( ( 0.0254 0.0253 0 ) @@ -70,28 +70,28 @@ functions fieldAverage1 { - type fieldAverage; + type fieldAverage; functionObjectLibs ( "libfieldFunctionObjects.so" ); - enabled true; - outputControl outputTime; + enabled true; + outputControl outputTime; fields ( U { - mean on; - prime2Mean on; - base time; + mean on; + prime2Mean on; + base time; } p { - mean on; - prime2Mean on; - base time; + mean on; + prime2Mean on; + base time; } ); } -); +} // ************************************************************************* // diff --git a/tutorials/incompressible/simpleSRFFoam/simpleSRFFoam/simpleSRFFoam.C b/tutorials/incompressible/simpleSRFFoam/simpleSRFFoam/simpleSRFFoam.C index fecc4cb717..e0cc1cef1a 100644 --- a/tutorials/incompressible/simpleSRFFoam/simpleSRFFoam/simpleSRFFoam.C +++ b/tutorials/incompressible/simpleSRFFoam/simpleSRFFoam/simpleSRFFoam.C @@ -53,9 +53,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readSIMPLEControls.H" @@ -99,7 +98,7 @@ int main(int argc, char *argv[]) Info<< "End\n" << endl; - return(0); + return 0; } diff --git a/tutorials/multiphase/cavitatingFoam/les/throttle/system/controlDict b/tutorials/multiphase/cavitatingFoam/les/throttle/system/controlDict index 073ada6caa..2ba1fabc2b 100644 --- a/tutorials/multiphase/cavitatingFoam/les/throttle/system/controlDict +++ b/tutorials/multiphase/cavitatingFoam/les/throttle/system/controlDict @@ -48,38 +48,38 @@ maxCo 0.5; maxAcousticCo 50; functions -( +{ fieldAverage1 { - type fieldAverage; + type fieldAverage; functionObjectLibs ( "libfieldFunctionObjects.so" ); - enabled false; - outputControl outputTime; + enabled false; + outputControl outputTime; fields ( U { - mean on; - prime2Mean off; - base time; + mean on; + prime2Mean off; + base time; } p { - mean on; - prime2Mean off; - base time; + mean on; + prime2Mean off; + base time; } gamma { - mean on; - prime2Mean off; - base time; + mean on; + prime2Mean off; + base time; } ); } -); +} // ************************************************************************* // diff --git a/tutorials/multiphase/cavitatingFoam/les/throttle3D/system/controlDict b/tutorials/multiphase/cavitatingFoam/les/throttle3D/system/controlDict index 0b3c876486..c87d60631d 100644 --- a/tutorials/multiphase/cavitatingFoam/les/throttle3D/system/controlDict +++ b/tutorials/multiphase/cavitatingFoam/les/throttle3D/system/controlDict @@ -48,38 +48,38 @@ maxCo 0.5; maxAcousticCo 50; functions -( +{ fieldAverage1 { - type fieldAverage; + type fieldAverage; functionObjectLibs ( "libfieldFunctionObjects.so" ); - enabled false; - outputControl outputTime; + enabled false; + outputControl outputTime; fields ( U { - mean on; - prime2Mean off; - base time; + mean on; + prime2Mean off; + base time; } p { - mean on; - prime2Mean off; - base time ; + mean on; + prime2Mean off; + base time; } gamma { - mean on; - prime2Mean off; - base time; + mean on; + prime2Mean off; + base time; } ); } -); +} // ************************************************************************* // diff --git a/tutorials/multiphase/interDyMFoam/sloshingTank2D/system/controlDict b/tutorials/multiphase/interDyMFoam/sloshingTank2D/system/controlDict index f533a54408..e4a69588f6 100644 --- a/tutorials/multiphase/interDyMFoam/sloshingTank2D/system/controlDict +++ b/tutorials/multiphase/interDyMFoam/sloshingTank2D/system/controlDict @@ -50,13 +50,13 @@ maxCo 0.5; maxDeltaT 1; functions -( +{ probes { - type probes; - outputControl timeStep; - outputInterval 1; - name probes; + type probes; + name probes; + outputControl timeStep; + outputInterval 1; probeLocations ( ( 0 9.95 19.77 ) @@ -70,11 +70,11 @@ functions wallPressure { - type surfaces; + type surfaces; functionObjectLibs ( "libsampling.so" ); - outputControl timeStep; - outputInterval 10; - surfaceFormat raw; + outputControl timeStep; + outputInterval 10; + surfaceFormat raw; fields ( p @@ -84,13 +84,13 @@ functions ( walls { - type patch; - patchName walls; + type patch; + patchName walls; triangulate false; } ); } -); +} // ************************************************************************* // diff --git a/tutorials/multiphase/interDyMFoam/sloshingTank2D3DoF/system/controlDict b/tutorials/multiphase/interDyMFoam/sloshingTank2D3DoF/system/controlDict index a4e44f2de3..9fe32ebf04 100644 --- a/tutorials/multiphase/interDyMFoam/sloshingTank2D3DoF/system/controlDict +++ b/tutorials/multiphase/interDyMFoam/sloshingTank2D3DoF/system/controlDict @@ -50,13 +50,13 @@ maxCo 0.5; maxDeltaT 1; functions -( +{ probes { - type probes; - outputControl timeStep; - outputInterval 10; - name probes; + type probes; + name probes; + outputControl timeStep; + outputInterval 10; probeLocations ( ( 0 9.95 19.77 ) @@ -70,11 +70,11 @@ functions wallPressure { - type surfaces; + type surfaces; functionObjectLibs ( "libsampling.so" ); - outputControl timeStep; - outputInterval 10; - surfaceFormat raw; + outputControl timeStep; + outputInterval 10; + surfaceFormat raw; fields ( p @@ -83,13 +83,13 @@ functions ( walls { - type patch; - patchName walls; + type patch; + patchName walls; triangulate false; } ); } -); +} // ************************************************************************* // diff --git a/tutorials/multiphase/interDyMFoam/sloshingTank3D/system/controlDict b/tutorials/multiphase/interDyMFoam/sloshingTank3D/system/controlDict index 1b122632d3..5823d9fbbd 100644 --- a/tutorials/multiphase/interDyMFoam/sloshingTank3D/system/controlDict +++ b/tutorials/multiphase/interDyMFoam/sloshingTank3D/system/controlDict @@ -50,13 +50,13 @@ maxCo 0.5; maxDeltaT 1; functions -( +{ probes { - type probes; - outputControl timeStep; - outputInterval 1; - name probes; + type probes; + name probes; + outputControl timeStep; + outputInterval 1; probeLocations ( ( 0 9.95 19.77 ) @@ -67,7 +67,7 @@ functions p ); } -); +} // ************************************************************************* // diff --git a/tutorials/multiphase/interDyMFoam/sloshingTank3D3DoF/system/controlDict b/tutorials/multiphase/interDyMFoam/sloshingTank3D3DoF/system/controlDict index 1b122632d3..5823d9fbbd 100644 --- a/tutorials/multiphase/interDyMFoam/sloshingTank3D3DoF/system/controlDict +++ b/tutorials/multiphase/interDyMFoam/sloshingTank3D3DoF/system/controlDict @@ -50,13 +50,13 @@ maxCo 0.5; maxDeltaT 1; functions -( +{ probes { - type probes; - outputControl timeStep; - outputInterval 1; - name probes; + type probes; + name probes; + outputControl timeStep; + outputInterval 1; probeLocations ( ( 0 9.95 19.77 ) @@ -67,7 +67,7 @@ functions p ); } -); +} // ************************************************************************* // diff --git a/tutorials/multiphase/interDyMFoam/sloshingTank3D6DoF/system/controlDict b/tutorials/multiphase/interDyMFoam/sloshingTank3D6DoF/system/controlDict index 1b122632d3..5823d9fbbd 100644 --- a/tutorials/multiphase/interDyMFoam/sloshingTank3D6DoF/system/controlDict +++ b/tutorials/multiphase/interDyMFoam/sloshingTank3D6DoF/system/controlDict @@ -50,13 +50,13 @@ maxCo 0.5; maxDeltaT 1; functions -( +{ probes { - type probes; - outputControl timeStep; - outputInterval 1; - name probes; + type probes; + name probes; + outputControl timeStep; + outputInterval 1; probeLocations ( ( 0 9.95 19.77 ) @@ -67,7 +67,7 @@ functions p ); } -); +} // ************************************************************************* // diff --git a/tutorials/multiphase/twoPhaseEulerFoam/bed/system/controlDict b/tutorials/multiphase/twoPhaseEulerFoam/bed/system/controlDict index 766cb87595..8fc8f27669 100644 --- a/tutorials/multiphase/twoPhaseEulerFoam/bed/system/controlDict +++ b/tutorials/multiphase/twoPhaseEulerFoam/bed/system/controlDict @@ -50,41 +50,44 @@ maxCo 0.5; maxDeltaT 1; functions -( +{ fieldAverage1 { - type fieldAverage; + type fieldAverage; functionObjectLibs ( "libfieldFunctionObjects.so" ); - outputControl outputTime; + outputControl outputTime; fields ( Ua { - mean on; - prime2Mean off; - base time; + mean on; + prime2Mean off; + base time; } + Ub { - mean on; - prime2Mean off; - base time; + mean on; + prime2Mean off; + base time; } + alpha { - mean on; - prime2Mean off; - base time; + mean on; + prime2Mean off; + base time; } + p { - mean on; - prime2Mean off; - base time; + mean on; + prime2Mean off; + base time; } ); } -); +} // ************************************************************************* // diff --git a/tutorials/multiphase/twoPhaseEulerFoam/bed2/system/controlDict b/tutorials/multiphase/twoPhaseEulerFoam/bed2/system/controlDict index e4d35359ad..d5eaba87fe 100644 --- a/tutorials/multiphase/twoPhaseEulerFoam/bed2/system/controlDict +++ b/tutorials/multiphase/twoPhaseEulerFoam/bed2/system/controlDict @@ -50,41 +50,44 @@ maxCo 0.9; maxDeltaT 1e-05; functions -( +{ fieldAverage1 { - type fieldAverage; + type fieldAverage; functionObjectLibs ( "libfieldFunctionObjects.so" ); - outputControl outputTime; + outputControl outputTime; fields ( Ua { - mean on; - prime2Mean off; - base time; + mean on; + prime2Mean off; + base time; } + Ub { - mean on; - prime2Mean off; - base time; + mean on; + prime2Mean off; + base time; } + alpha { - mean on; - prime2Mean off; - base time; + mean on; + prime2Mean off; + base time; } + p { - mean on; - prime2Mean off; - base time; + mean on; + prime2Mean off; + base time; } ); } -); +} // ************************************************************************* // diff --git a/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/system/controlDict b/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/system/controlDict index d0f78bb505..1b724308f1 100644 --- a/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/system/controlDict +++ b/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/system/controlDict @@ -50,41 +50,44 @@ maxCo 0.5; maxDeltaT 1; functions -( +{ fieldAverage1 { - type fieldAverage; + type fieldAverage; functionObjectLibs ( "libfieldFunctionObjects.so" ); - outputControl outputTime; + outputControl outputTime; fields ( Ua { - mean on; - prime2Mean off; - base time; + mean on; + prime2Mean off; + base time; } + Ub { - mean on; - prime2Mean off; - base time; + mean on; + prime2Mean off; + base time; } + alpha { - mean on; - prime2Mean off; - base time; + mean on; + prime2Mean off; + base time; } + p { - mean on; - prime2Mean off; - base time; + mean on; + prime2Mean off; + base time; } ); } -); +} // ************************************************************************* // From 2b58eb62088a0c653a2c1cec874667c84fa80539 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 25 Feb 2009 10:35:10 +0100 Subject: [PATCH 02/25] Allow SubField construct from UList w/o extra size specification - this allows SubField for unallocated storage in PrimitivePatch --- .../containers/Lists/SubList/SubListI.H | 6 +-- src/OpenFOAM/fields/Fields/Field/Field.C | 40 +++++++++---------- src/OpenFOAM/fields/Fields/Field/Field.H | 2 +- src/OpenFOAM/fields/Fields/Field/SubField.H | 23 +++++------ src/OpenFOAM/fields/Fields/Field/SubFieldI.H | 17 ++++++-- 5 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/OpenFOAM/containers/Lists/SubList/SubListI.H b/src/OpenFOAM/containers/Lists/SubList/SubListI.H index 0eb7a33c8f..60a378b053 100644 --- a/src/OpenFOAM/containers/Lists/SubList/SubListI.H +++ b/src/OpenFOAM/containers/Lists/SubList/SubListI.H @@ -53,9 +53,9 @@ inline Foam::SubList::SubList { # ifdef FULLDEBUG - // Artificially allowing the start of a zero-sized subList to be + // Artificially allow the start of a zero-sized subList to be // one past the end of the original list. - if (subSize > 0) + if (subSize) { list.checkStart(startIndex); list.checkSize(startIndex + subSize); @@ -84,7 +84,7 @@ inline const Foam::SubList& Foam::SubList::null() template inline Foam::SubList::operator const Foam::List&() const { - return *reinterpret_cast*>(this); + return *reinterpret_cast< const List* >(this); } diff --git a/src/OpenFOAM/fields/Fields/Field/Field.C b/src/OpenFOAM/fields/Fields/Field/Field.C index 59d8f1a516..8441d258a1 100644 --- a/src/OpenFOAM/fields/Fields/Field/Field.C +++ b/src/OpenFOAM/fields/Fields/Field/Field.C @@ -177,9 +177,9 @@ Field::Field(const typename Field::subField& sf) template -Field::Field(const UList& tl) +Field::Field(const UList& list) : - List(tl) + List(list) {} @@ -232,8 +232,7 @@ Field::Field FatalIOErrorIn ( "Field::Field" - "(const word& keyword, " - "const dictionary& dict, const label s)", + "(const word& keyword, const dictionary&, const label)", dict ) << "size " << this->size() << " is not equal to the given value of " << s @@ -245,8 +244,7 @@ Field::Field FatalIOErrorIn ( "Field::Field" - "(const word& keyword, " - "const dictionary& dict, const label s)", + "(const word& keyword, const dictionary&, const label)", dict ) << "expected keyword 'uniform' or 'nonuniform', found " << firstToken.wordToken() @@ -260,8 +258,7 @@ Field::Field IOWarningIn ( "Field::Field" - "(const word& keyword, const dictionary& dict, " - "const label s)", + "(const word& keyword, const dictionary&, const label)", dict ) << "expected keyword 'uniform' or 'nonuniform', " "assuming deprecated Field format from " @@ -277,10 +274,9 @@ Field::Field FatalIOErrorIn ( "Field::Field" - "(const word& keyword, " - "const dictionary& dict, const label s)", + "(const word& keyword, const dictionary&, const label)", dict - ) << "extected keyword 'uniform' or 'nonuniform', found " + ) << "expected keyword 'uniform' or 'nonuniform', found " << firstToken.info() << exit(FatalIOError); } @@ -371,7 +367,7 @@ void Field::map forAll(f, i) { - const labelList& localAddrs = mapAddressing[i]; + const labelList& localAddrs = mapAddressing[i]; const scalarList& localWeights = mapWeights[i]; f[i] = pTraits::zero; @@ -622,37 +618,37 @@ void Field::writeEntry(const word& keyword, Ostream& os) const // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template -void Field::operator=(const Field& f) +void Field::operator=(const Field& rhs) { - if (this == &f) + if (this == &rhs) { FatalErrorIn("Field::operator=(const Field&)") << "attempted assignment to self" << abort(FatalError); } - List::operator=(f); + List::operator=(rhs); } template -void Field::operator=(const SubField& sf) +void Field::operator=(const SubField& rhs) { - List::operator=(sf); + List::operator=(rhs); } template -void Field::operator=(const UList& ul) +void Field::operator=(const UList& rhs) { - List::operator=(ul); + List::operator=(rhs); } template -void Field::operator=(const tmp& tf) +void Field::operator=(const tmp& rhs) { - if (this == &(tf())) + if (this == &(rhs())) { FatalErrorIn("Field::operator=(const tmp&)") << "attempted assignment to self" @@ -660,7 +656,7 @@ void Field::operator=(const tmp& tf) } // This is dodgy stuff, don't try it at home. - Field* fieldPtr = tf.ptr(); + Field* fieldPtr = rhs.ptr(); List::transfer(*fieldPtr); delete fieldPtr; } diff --git a/src/OpenFOAM/fields/Fields/Field/Field.H b/src/OpenFOAM/fields/Fields/Field/Field.H index 78078a01c8..e56e463371 100644 --- a/src/OpenFOAM/fields/Fields/Field/Field.H +++ b/src/OpenFOAM/fields/Fields/Field/Field.H @@ -120,7 +120,7 @@ public: //- Construct given size and initial value Field(const label, const Type&); - //- Construct as copy of a UList + //- Construct as copy of a UList\ explicit Field(const UList&); //- Construct by transferring the List contents diff --git a/src/OpenFOAM/fields/Fields/Field/SubField.H b/src/OpenFOAM/fields/Fields/Field/SubField.H index c237a19d70..f1eecd23cf 100644 --- a/src/OpenFOAM/fields/Fields/Field/SubField.H +++ b/src/OpenFOAM/fields/Fields/Field/SubField.H @@ -68,20 +68,20 @@ public: // Constructors - //- Construct from UnallocatedField and SubField size - inline SubField - ( - const SubList& slist - ); + //- Construct from a SubList + inline SubField(const SubList&); - //- Construct from UnallocatedField and SubField size + //- Construct from a UList\, using the entire size + explicit inline SubField(const UList&); + + //- Construct from a UList\ with a given size inline SubField ( const UList& list, const label subSize ); - //- Construct from UnallocatedField, start and end indices + //- Construct from a UList\ with a given size and start index inline SubField ( const UList& list, @@ -90,10 +90,7 @@ public: ); //- Construct as copy - inline SubField - ( - const SubField& sfield - ); + inline SubField(const SubField&); // Member functions @@ -110,10 +107,10 @@ public: // Member operators - //- Assignment from UList operator. Takes linear time. + //- Assignment via UList operator. Takes linear time. inline void operator=(const SubField&); - //- Allow cast to a const Field& + //- Allow cast to a const Field\& inline operator const Field&() const; }; diff --git a/src/OpenFOAM/fields/Fields/Field/SubFieldI.H b/src/OpenFOAM/fields/Fields/Field/SubFieldI.H index 53de564475..ae9e016ec4 100644 --- a/src/OpenFOAM/fields/Fields/Field/SubFieldI.H +++ b/src/OpenFOAM/fields/Fields/Field/SubFieldI.H @@ -29,12 +29,23 @@ License template inline Foam::SubField::SubField ( - const SubList& slist + const SubList& list ) : - SubList(slist) + SubList(list) {} + +template +inline Foam::SubField::SubField +( + const UList& list +) +: + SubList(list, list.size()) +{} + + template inline Foam::SubField::SubField ( @@ -108,7 +119,7 @@ inline void Foam::SubField::operator=(const SubField& rhs) template inline Foam::SubField::operator const Foam::Field&() const { - return *(reinterpret_cast*>(this)); + return *reinterpret_cast< const Field* >(this); } From bb804cc36a80515ebbb342236e2f1c24056b42ed Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 25 Feb 2009 10:47:43 +0100 Subject: [PATCH 03/25] Bug-fix in the dimensionedScalar argument list http://openfoam.cfd-online.com/cgi-bin/forum/show.cgi?126/11287 --- .../GeometricScalarField/GeometricScalarField.C | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricScalarField/GeometricScalarField.C b/src/OpenFOAM/fields/GeometricFields/GeometricScalarField/GeometricScalarField.C index 70f738fcfb..fa6a2a58d0 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricScalarField/GeometricScalarField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricScalarField/GeometricScalarField.C @@ -154,7 +154,7 @@ tmp > pow pow ( gsf1.dimensions(), - dimensionedScalar("1", 1.0, gsf2.dimensions()) + dimensionedScalar("1", gsf2.dimensions(), 1.0) ) ) ); @@ -183,7 +183,7 @@ tmp > pow pow ( gsf1.dimensions(), - dimensionedScalar("1", 1.0, gsf2.dimensions()) + dimensionedScalar("1", gsf2.dimensions(), 1.0) ) ) ); @@ -214,7 +214,7 @@ tmp > pow pow ( gsf1.dimensions(), - dimensionedScalar("1", 1.0, gsf2.dimensions()) + dimensionedScalar("1", gsf2.dimensions(), 1.0) ) ) ); @@ -247,7 +247,7 @@ tmp > pow pow ( gsf1.dimensions(), - dimensionedScalar("1", 1.0, gsf2.dimensions()) + dimensionedScalar("1", gsf2.dimensions(), 1.0) ) ) ); From 9c8432a00200b7083e05c812646fa65b485a4842 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 25 Feb 2009 11:17:06 +0100 Subject: [PATCH 04/25] regIOobject: make checkIn(), checkOut() return bool --- src/OpenFOAM/db/regIOobject/regIOobject.C | 41 ++++++++++--------- src/OpenFOAM/db/regIOobject/regIOobject.H | 22 +++++----- src/OpenFOAM/db/regIOobject/regIOobjectI.H | 6 +-- .../db/regIOobject/regIOobjectWrite.C | 5 ++- 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.C b/src/OpenFOAM/db/regIOobject/regIOobject.C index 611dd5a923..6fba693043 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobject.C +++ b/src/OpenFOAM/db/regIOobject/regIOobject.C @@ -107,6 +107,7 @@ Foam::regIOobject::~regIOobject() if (isPtr_) { delete isPtr_; + isPtr_ = NULL; } // Check out of objectRegistry if not owned by the registry @@ -120,47 +121,47 @@ Foam::regIOobject::~regIOobject() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::regIOobject::checkIn() +bool Foam::regIOobject::checkIn() { if (!registered_) { - // Attempt to register object with objectRegistry - if (!db().checkIn(*this)) + // multiple checkin of same object is disallowed - this would mess up + // any mapping + registered_ = db().checkIn(*this); + + // checkin on defaultRegion is allowed to fail, since subsetted meshes + // are created with the same name as their originating mesh + if (!registered_ && debug && name() != polyMesh::defaultRegion) { - // Disallow checkin of same object twice since would mess up - // any mapping. - // Check on defaultRegion is needed to prevent subsetted meshes - // (which are created with same name as their originating mesh) - // from upsetting this. - if (debug && name() != polyMesh::defaultRegion) - { - WarningIn("regIOobject::checkIn()") - << "failed to register object " << objectPath() + WarningIn("regIOobject::checkIn()") + << "failed to register object " << objectPath() << " the name already exists in the objectRegistry" - << endl; - } - } - else - { - registered_ = true; + << endl; } } + + return registered_; } -void Foam::regIOobject::checkOut() +bool Foam::regIOobject::checkOut() { if (registered_) { - db().checkOut(*this); registered_ = false; + return db().checkOut(*this); } + + return false; } // Rename object and re-register with objectRegistry under new name void Foam::regIOobject::rename(const word& newName) { + // TODO: verify that this works properly with unregistered objects + // I suspect that it incorrectly registers them + // Check out of objectRegistry checkOut(); diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.H b/src/OpenFOAM/db/regIOobject/regIOobject.H index 80829fa864..6b50fd7842 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobject.H +++ b/src/OpenFOAM/db/regIOobject/regIOobject.H @@ -49,7 +49,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class regIOobject Declaration + Class regIOobject Declaration \*---------------------------------------------------------------------------*/ class regIOobject @@ -115,13 +115,13 @@ public: // Registration - //- Register object with registry - void checkIn(); + //- Add object to registry + bool checkIn(); - //- Check-out object from registry - void checkOut(); + //- Remove object from registry + bool checkOut(); - //- Is this object owned by the registry + //- Is this object owned by the registry? inline bool ownedByRegistry() const; //- Transfer ownership of this object to its registry @@ -130,12 +130,12 @@ public: //- Transfer ownership of the given object pointer to its registry // and return reference to object. template - inline static Type& store(Type* tPtr); + inline static Type& store(Type*); //- Transfer ownership of the given object pointer to its registry // and return reference to object. template - inline static Type& store(autoPtr& atPtr); + inline static Type& store(autoPtr&); //- Release ownership of this object from its registry inline void release(); @@ -179,9 +179,9 @@ public: //- Write using given format, version and compression virtual bool writeObject ( - IOstream::streamFormat fmt, - IOstream::versionNumber ver, - IOstream::compressionType cmp + IOstream::streamFormat, + IOstream::versionNumber, + IOstream::compressionType ) const; //- Write using setting from DB diff --git a/src/OpenFOAM/db/regIOobject/regIOobjectI.H b/src/OpenFOAM/db/regIOobject/regIOobjectI.H index cef96647f7..467127e0aa 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobjectI.H +++ b/src/OpenFOAM/db/regIOobject/regIOobjectI.H @@ -43,7 +43,7 @@ inline Type& Foam::regIOobject::store(Type* tPtr) { if (!tPtr) { - FatalErrorIn("Type& store(Type*)") + FatalErrorIn("Type& regIOobject::store(Type*)") << "object deallocated" << abort(FatalError); } @@ -63,13 +63,13 @@ inline Type& Foam::regIOobject::store(autoPtr& atPtr) { FatalErrorIn ( - "Type& store(autoPtr&)" + "Type& regIOobject::store(autoPtr&)" ) << "object deallocated" << abort(FatalError); } tPtr->regIOobject::ownedByRegistry_ = true; - + return *tPtr; } diff --git a/src/OpenFOAM/db/regIOobject/regIOobjectWrite.C b/src/OpenFOAM/db/regIOobject/regIOobjectWrite.C index 1ca027b247..6eef1b8aff 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobjectWrite.C +++ b/src/OpenFOAM/db/regIOobject/regIOobjectWrite.C @@ -91,7 +91,7 @@ bool regIOobject::writeObject // Try opening an OFstream for object OFstream os(objectPath(), fmt, ver, cmp); - // If this has failed, return (leave error handling to Ostream class) + // If any of these fail, return (leave error handling to Ostream class) if (!os.good()) { return false; @@ -108,7 +108,8 @@ bool regIOobject::writeObject return false; } - os << "\n\n// ************************************************************************* //" + os << "\n\n" + "// ************************************************************************* //" << endl; osGood = os.good(); From e562aecb73a663da7fe9f777ef7e00e5c478cc4a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 25 Feb 2009 18:58:48 +0100 Subject: [PATCH 05/25] HashTable performance: find(), found() check nElmts_ instead of tableSize_ - much better performance on empty tables (4-6x speedup), neutral performance change on filled tables. Since tableSize_ is non-zero when nElmts_ is, there is no modulus zero problem. --- .../test/PackedList2/PackedListTest2.C | 22 +++++++++++++- .../containers/HashTables/HashSet/HashSet.C | 20 ++++++------- .../HashTables/HashTable/HashTable.C | 30 +++++++++---------- .../HashTables/HashTable/HashTableI.H | 24 +++++++++++---- .../HashTables/HashTable/HashTableIO.C | 9 ++++-- .../StaticHashTable/StaticHashTable.C | 30 +++++++++++-------- .../StaticHashTable/StaticHashTableI.H | 2 +- .../StaticHashTable/StaticHashTableIO.C | 5 +++- 8 files changed, 94 insertions(+), 48 deletions(-) diff --git a/applications/test/PackedList2/PackedListTest2.C b/applications/test/PackedList2/PackedListTest2.C index 22282058ac..78f0f9f914 100644 --- a/applications/test/PackedList2/PackedListTest2.C +++ b/applications/test/PackedList2/PackedListTest2.C @@ -32,6 +32,7 @@ Description #include "boolList.H" #include "PackedBoolList.H" #include "HashSet.H" +#include "StaticHashTable.H" #include "cpuTime.H" #include @@ -55,11 +56,14 @@ int main(int argc, char *argv[]) labelHashSet emptyHash; labelHashSet fullHash(1000); - for(label i = 0; i < n; i++) + for (label i = 0; i < n; i++) { fullHash.insert(i); } + // don't use fullStaticHash, it's too slow + StaticHashTable > emptyStaticHash; + cpuTime timer; for (label iter = 0; iter < nIters; ++iter) @@ -235,6 +239,22 @@ int main(int argc, char *argv[]) Info<< " sum " << sum << endl; + // Read empty static hash + sum = 0; + for (label iter = 0; iter < nIters; ++iter) + { + forAll(unpacked, i) + { + sum += emptyStaticHash.found(i); + } + } + Info<< "Reading empty StaticHash:" << timer.cpuTimeIncrement() + << " s" << endl; + Info<< " sum " << sum << endl; + + + Info<< "Starting write tests" << endl; + // // Write // diff --git a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C index 6bf84e0c55..d63921f95b 100644 --- a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C +++ b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C @@ -33,14 +33,14 @@ License template template -Foam::HashSet::HashSet(const HashTable& ht) +Foam::HashSet::HashSet(const HashTable& h) : - HashTable(ht.size()) + HashTable(h.size()) { for ( - typename HashTable::const_iterator cit = ht.begin(); - cit != ht.end(); + typename HashTable::const_iterator cit = h.cbegin(); + cit != h.cend(); ++cit ) { @@ -62,7 +62,7 @@ template bool Foam::HashSet::operator==(const HashSet& rhs) const { // Are all lhs elements in rhs? - for (const_iterator iter = this->begin(); iter != this->end(); ++iter) + for (const_iterator iter = this->cbegin(); iter != this->cend(); ++iter) { if (!rhs.found(iter.key())) { @@ -71,7 +71,7 @@ bool Foam::HashSet::operator==(const HashSet& rhs) const } // Are all rhs elements in lhs? - for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter) + for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter) { if (!found(iter.key())) { @@ -94,7 +94,7 @@ template void Foam::HashSet::operator|=(const HashSet& rhs) { // Add rhs elements into lhs - for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter) + for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter) { insert(iter.key()); } @@ -105,7 +105,7 @@ template void Foam::HashSet::operator&=(const HashSet& rhs) { // Remove elements not also found in rhs - for (iterator iter = this->begin(); iter != this->end(); ++iter) + for (iterator iter = this->cbegin(); iter != this->cend(); ++iter) { if (!rhs.found(iter.key())) { @@ -119,7 +119,7 @@ template void Foam::HashSet::operator^=(const HashSet& rhs) { // Add missed rhs elements, remove duplicate elements - for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter) + for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter) { if (found(iter.key())) { @@ -138,7 +138,7 @@ template void Foam::HashSet::operator-=(const HashSet& rhs) { // Remove rhs elements from lhs - for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter) + for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter) { erase(iter.key()); } diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C index 3ed474b32d..e1def941d6 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C @@ -71,7 +71,7 @@ Foam::HashTable::HashTable(const HashTable& ht) table_[hashIdx] = 0; } - for (const_iterator iter = ht.begin(); iter != ht.end(); ++iter) + for (const_iterator iter = ht.cbegin(); iter != ht.cend(); ++iter) { insert(iter.key(), *iter); } @@ -113,9 +113,9 @@ Foam::HashTable::~HashTable() template bool Foam::HashTable::found(const Key& key) const { - if (tableSize_) + if (nElmts_) { - label hashIdx = Hash()(key, tableSize_); + const label hashIdx = Hash()(key, tableSize_); for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_) { @@ -145,9 +145,9 @@ Foam::HashTable::find const Key& key ) { - if (tableSize_) + if (nElmts_) { - label hashIdx = Hash()(key, tableSize_); + const label hashIdx = Hash()(key, tableSize_); for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_) { @@ -177,7 +177,7 @@ Foam::HashTable::find const Key& key ) const { - if (tableSize_) + if (nElmts_) { label hashIdx = Hash()(key, tableSize_); @@ -198,7 +198,7 @@ Foam::HashTable::find } # endif - return end(); + return cend(); } @@ -209,7 +209,7 @@ Foam::List Foam::HashTable::toc() const List tofc(nElmts_); label i = 0; - for (const_iterator iter = begin(); iter != end(); ++iter) + for (const_iterator iter = cbegin(); iter != cend(); ++iter) { tofc[i++] = iter.key(); } @@ -351,7 +351,7 @@ bool Foam::HashTable::erase(const iterator& cit) else { // No previous found. Mark with special value which is - // - not end() + // - not end()/cend() // - handled by operator++ it.elmtPtr_ = reinterpret_cast(this); it.hashIndex_ = -1; @@ -466,7 +466,7 @@ void Foam::HashTable::resize(const label newSize) HashTable* newTable = new HashTable(newSize); - for (const_iterator iter = begin(); iter != end(); ++iter) + for (const_iterator iter = cbegin(); iter != cend(); ++iter) { newTable->insert(iter.key(), *iter); } @@ -565,7 +565,7 @@ void Foam::HashTable::operator= clear(); } - for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter) + for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter) { insert(iter.key(), *iter); } @@ -579,22 +579,22 @@ bool Foam::HashTable::operator== ) const { // Are all my elements in rhs? - for (const_iterator iter = begin(); iter != end(); ++iter) + for (const_iterator iter = cbegin(); iter != cend(); ++iter) { const_iterator fnd = rhs.find(iter.key()); - if (fnd == rhs.end() || fnd() != iter()) + if (fnd == rhs.cend() || fnd() != iter()) { return false; } } // Are all rhs elements in me? - for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter) + for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter) { const_iterator fnd = find(iter.key()); - if (fnd == end() || fnd() != iter()) + if (fnd == cend() || fnd() != iter()) { return false; } diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H index aea5f3043a..f117a601b9 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H @@ -112,7 +112,7 @@ inline const T& Foam::HashTable::operator[](const Key& key) const { const_iterator iter = find(key); - if (iter == end()) + if (iter == cend()) { FatalErrorIn("HashTable::operator[](const Key&) const") << key << " not found in table. Valid entries: " @@ -283,8 +283,15 @@ Foam::HashTable::begin() { label i = 0; - while (table_ && !table_[i] && ++i < tableSize_) - {} + if (nElmts_) + { + while (table_ && !table_[i] && ++i < tableSize_) + {} + } + else + { + i = tableSize_; + } if (i == tableSize_) { @@ -456,8 +463,15 @@ Foam::HashTable::cbegin() const { label i = 0; - while (table_ && !table_[i] && ++i < tableSize_) - {} + if (nElmts_) + { + while (table_ && !table_[i] && ++i < tableSize_) + {} + } + else + { + i = tableSize_; + } if (i == tableSize_) { diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C index d0251f5f21..4daab805c0 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C @@ -39,7 +39,7 @@ Foam::HashTable::HashTable(Istream& is, const label size) endIter_(*this, NULL, 0), endConstIter_(*this, NULL, 0) { - for (label i=0; i>(Istream& is, HashTable& L) ) { is.putBack(lastToken); + Key key; is >> key; + T element; is >> element; + L.insert(key, element); is.fatalCheck @@ -174,8 +177,8 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const HashTable& L) // Write contents for ( - typename HashTable::const_iterator iter = L.begin(); - iter != L.end(); + typename HashTable::const_iterator iter = L.cbegin(); + iter != L.cend(); ++iter ) { diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C index 3ba659c83d..7b011e135e 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C @@ -101,14 +101,17 @@ Foam::StaticHashTable::~StaticHashTable() template bool Foam::StaticHashTable::found(const Key& key) const { - label hashIdx = Hash()(key, keys_.size()); - const List& localKeys = keys_[hashIdx]; - - forAll(localKeys, elemIdx) + if (nElmts_) { - if (key == localKeys[elemIdx]) + label hashIdx = Hash()(key, keys_.size()); + const List& localKeys = keys_[hashIdx]; + + forAll(localKeys, elemIdx) { - return true; + if (key == localKeys[elemIdx]) + { + return true; + } } } @@ -131,14 +134,17 @@ Foam::StaticHashTable::find const Key& key ) { - label hashIdx = Hash()(key, keys_.size()); - const List& localKeys = keys_[hashIdx]; - - forAll(localKeys, elemIdx) + if (nElmts_) { - if (key == localKeys[elemIdx]) + label hashIdx = Hash()(key, keys_.size()); + const List& localKeys = keys_[hashIdx]; + + forAll(localKeys, elemIdx) { - return iterator(*this, hashIdx, elemIdx); + if (key == localKeys[elemIdx]) + { + return iterator(*this, hashIdx, elemIdx); + } } } diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H index 5cd380357a..6ea55beae7 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H @@ -102,7 +102,7 @@ inline const T& Foam::StaticHashTable::operator[] { const_iterator iter = find(key); - if (iter == end()) + if (iter == cend()) { FatalErrorIn ( diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C index 064ce3c619..766ccc9d64 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C @@ -33,7 +33,7 @@ License template Foam::StaticHashTable::StaticHashTable ( - Istream& is, + Istream& is, const label size ) : @@ -142,10 +142,13 @@ Foam::Istream& Foam::operator>>(Istream& is, StaticHashTable& L) ) { is.putBack(lastToken); + Key key; is >> key; + T element; is >> element; + L.insert(key, element); is.fatalCheck From 2aeee852e82a611d4f35c7584980b4ff90c64910 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 26 Feb 2009 15:32:47 +0100 Subject: [PATCH 06/25] PackedList bugfix, HashTable tweak - it was possible to create a PackedList::iterator from a PackedList::const_iterator and violate const-ness - added HashTable::printInfo for emitting some information - changed default table sizes from 100 -> 128 in preparation for future 2^n table sizes --- applications/test/FixedList/FixedListTest.C | 28 ++++++++----- .../test/PackedList2/PackedListTest2.C | 29 +++++++++++++- applications/test/string/stringTest.C | 7 +++- .../HashTables/HashPtrTable/HashPtrTable.H | 2 +- .../containers/HashTables/HashSet/HashSet.H | 2 +- .../HashTables/HashTable/HashTable.H | 6 ++- .../HashTables/HashTable/HashTableIO.C | 39 +++++++++++++++++++ src/OpenFOAM/containers/HashTables/Map/Map.H | 2 +- .../containers/HashTables/PtrMap/PtrMap.H | 2 +- .../StaticHashTable/StaticHashTable.H | 7 +++- .../StaticHashTable/StaticHashTableIO.C | 35 +++++++++++++++++ .../containers/Lists/FixedList/FixedListI.H | 7 ++-- .../containers/Lists/PackedList/PackedList.H | 9 ++++- src/OpenFOAM/db/IOobjectList/IOobjectList.H | 2 +- .../db/objectRegistry/objectRegistry.H | 6 +-- src/OpenFOAM/meshes/meshShapes/edge/EdgeMap.H | 2 +- .../primitives/strings/string/stringI.H | 8 ++-- 17 files changed, 159 insertions(+), 34 deletions(-) diff --git a/applications/test/FixedList/FixedListTest.C b/applications/test/FixedList/FixedListTest.C index a5e3341b65..d82f077eae 100644 --- a/applications/test/FixedList/FixedListTest.C +++ b/applications/test/FixedList/FixedListTest.C @@ -52,16 +52,18 @@ int main(int argc, char *argv[]) list[1] = 2; list[2] = 3; list[3] = 4; - Info<< list << endl; + + Info<< "list:" << list + << " hash:" << FixedList::Hash<>()(list) << endl; label a[4] = {0, 1, 2, 3}; FixedList list2(a); - Info<< list2 << endl; - Info<< FixedList::Hash<>()(list2) << endl; + Info<< "list:" << list2 + << " hash:" << FixedList::Hash<>()(list2) << endl; - //FixedList hmm(Sin); - //Info<< hmm << endl; + // FixedList hmm(Sin); + // Info<< hmm << endl; if (Pstream::parRun()) { @@ -69,7 +71,12 @@ int main(int argc, char *argv[]) { Serr<< "slave sending to master " << Pstream::masterNo() << endl; - OPstream toMaster(Pstream::masterNo(), IOstream::ASCII); + + OPstream toMaster + ( + Pstream::blocking, Pstream::masterNo(), IOstream::ASCII + ); + FixedList list3; list3[0] = 0; list3[1] = 1; @@ -79,13 +86,16 @@ int main(int argc, char *argv[]) { for ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); + int slave = Pstream::firstSlave(); + slave <= Pstream::lastSlave(); slave++ ) { Serr << "master receiving from slave " << slave << endl; - IPstream fromSlave(slave, IOstream::ASCII); + IPstream fromSlave + ( + Pstream::blocking, slave, IOstream::ASCII + ); FixedList list3(fromSlave); Serr<< list3 << endl; diff --git a/applications/test/PackedList2/PackedListTest2.C b/applications/test/PackedList2/PackedListTest2.C index 78f0f9f914..ef027fee2e 100644 --- a/applications/test/PackedList2/PackedListTest2.C +++ b/applications/test/PackedList2/PackedListTest2.C @@ -61,8 +61,20 @@ int main(int argc, char *argv[]) fullHash.insert(i); } - // don't use fullStaticHash, it's too slow + // fullStaticHash is really slow + // give it lots of slots to help StaticHashTable > emptyStaticHash; + StaticHashTable > fullStaticHash(100000); + for (label i = 0; i < n; i++) + { + fullStaticHash.insert(i, nil()); + } + + emptyHash.printInfo(Info); + fullHash.printInfo(Info); + emptyStaticHash.printInfo(Info); + fullStaticHash.printInfo(Info); + cpuTime timer; @@ -252,6 +264,21 @@ int main(int argc, char *argv[]) << " s" << endl; Info<< " sum " << sum << endl; +#if 0 + // we can skip this test - it is usually quite slow + // Read full static hash + sum = 0; + for (label iter = 0; iter < nIters; ++iter) + { + forAll(unpacked, i) + { + sum += fullStaticHash.found(i); + } + } + Info<< "Reading full StaticHash:" << timer.cpuTimeIncrement() + << " s" << endl; + Info<< " sum " << sum << endl; +#endif Info<< "Starting write tests" << endl; diff --git a/applications/test/string/stringTest.C b/applications/test/string/stringTest.C index 7981356760..b8442102f3 100644 --- a/applications/test/string/stringTest.C +++ b/applications/test/string/stringTest.C @@ -38,10 +38,11 @@ int main(int argc, char *argv[]) { string test("$HOME kjhkjhkjh \" \\$HOME/tyetyery ${FOAM_RUN} \n ; hkjh ;$"); - Info<< test << endl; + Info<< "string:" << test << nl << "hash:" + << unsigned(string::hash()(test)) << endl; // test sub-strings via iterators - string::const_iterator iter = test.end(); + string::const_iterator iter = test.end(); string::const_iterator iter2 = test.end(); string::size_type fnd = test.find('\\'); @@ -77,6 +78,8 @@ int main(int argc, char *argv[]) cout<< "output string with " << s2.length() << " characters\n"; cout<< "ostream<< >" << s2 << "<\n"; Info<< "Ostream<< >" << s2 << "<\n"; + Info<< "hash:" << unsigned(string::hash()(s2)) << endl; + Info << "End\n" << endl; diff --git a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H index ee1c7ba7cc..8ae3697f1d 100644 --- a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H +++ b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H @@ -83,7 +83,7 @@ public: // Constructors //- Construct given initial table size - HashPtrTable(const label size = 100); + HashPtrTable(const label size = 128); //- Construct from Istream using given Istream constructor class template diff --git a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H index 9a4c5951be..6353818d7e 100644 --- a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H +++ b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H @@ -72,7 +72,7 @@ public: // Constructors //- Construct given initial size - HashSet(const label size = 100) + HashSet(const label size = 128) : HashTable(size) {} diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index 457e2f1b7e..65a5635e16 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -142,10 +142,10 @@ public: // Constructors //- Construct given initial table size - HashTable(const label size = 100); + HashTable(const label size = 128); //- Construct from Istream - HashTable(Istream&, const label size = 100); + HashTable(Istream&, const label size = 128); //- Construct as copy HashTable(const HashTable&); @@ -183,6 +183,8 @@ public: //- Return the table of contents List toc() const; + //- Print information + Ostream& printInfo(Ostream&) const; // Edit diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C index 4daab805c0..1525d1d72e 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C @@ -48,6 +48,45 @@ Foam::HashTable::HashTable(Istream& is, const label size) } +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +template +Foam::Ostream& +Foam::HashTable::printInfo(Ostream& os) const +{ + label used = 0; + label maxChain = 0; + unsigned avgChain = 0; + + for (label hashIdx = 0; hashIdx < tableSize_; ++hashIdx) + { + label count = 0; + for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_) + { + ++count; + } + + if (count) + { + ++used; + avgChain += count; + + if (maxChain < count) + { + maxChain = count; + } + } + } + + os << "HashTable" + << " elements:" << size() << " slots:" << used << "/" << tableSize_ + << " chaining(avg/max):" << (used ? float(avgChain/used) : 0) + << "/" << maxChain << endl; + + return os; +} + + // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // template diff --git a/src/OpenFOAM/containers/HashTables/Map/Map.H b/src/OpenFOAM/containers/HashTables/Map/Map.H index e43283412d..e84e96899a 100644 --- a/src/OpenFOAM/containers/HashTables/Map/Map.H +++ b/src/OpenFOAM/containers/HashTables/Map/Map.H @@ -63,7 +63,7 @@ public: // Constructors //- Construct given initial size - Map(const label size = 100) + Map(const label size = 128) : HashTable >(size) {} diff --git a/src/OpenFOAM/containers/HashTables/PtrMap/PtrMap.H b/src/OpenFOAM/containers/HashTables/PtrMap/PtrMap.H index cab0cf17ff..5d0b92b6de 100644 --- a/src/OpenFOAM/containers/HashTables/PtrMap/PtrMap.H +++ b/src/OpenFOAM/containers/HashTables/PtrMap/PtrMap.H @@ -58,7 +58,7 @@ public: // Constructors //- Construct given initial map size - PtrMap(const label size = 100) + PtrMap(const label size = 128) : HashPtrTable >(size) {} diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H index 4513ea0245..60ed0e6fbb 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H @@ -141,10 +141,10 @@ public: // Constructors //- Construct given initial table size - StaticHashTable(const label size = 100); + StaticHashTable(const label size = 128); //- Construct from Istream - StaticHashTable(Istream&, const label size = 100); + StaticHashTable(Istream&, const label size = 128); //- Construct as copy StaticHashTable(const StaticHashTable&); @@ -181,6 +181,9 @@ public: //- Return the table of contents List toc() const; + //- Print information + Ostream& printInfo(Ostream&) const; + // Edit diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C index 766ccc9d64..3939851fc5 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C @@ -57,6 +57,41 @@ Foam::StaticHashTable::StaticHashTable } +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +template +Foam::Ostream& +Foam::StaticHashTable::printInfo(Ostream& os) const +{ + label used = 0; + label maxChain = 0; + unsigned avgChain = 0; + + // Find first non-empty entry + forAll(keys_, hashIdx) + { + const label count = keys_[hashIdx].size(); + if (count) + { + ++used; + avgChain += count; + + if (maxChain < count) + { + maxChain = count; + } + } + } + + os << "StaticHashTable" + << " elements:" << size() << " slots:" << used << "/" << keys_.size() + << " chaining(avg/max):" << (used ? float(avgChain/used) : 0) + << "/" << maxChain << endl; + + return os; +} + + // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // template diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H index a800b04b1d..4820ecc7f9 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H @@ -408,7 +408,8 @@ template inline Foam::FixedList::Hash::Hash() {} -//- Rotating Hash. From http://burtleburtle.net/bob/hash/doobs.html + +// Rotating Hash template template inline Foam::label Foam::FixedList::Hash::operator() @@ -422,7 +423,7 @@ inline Foam::label Foam::FixedList::Hash::operator() for (register int i=0; i>farbit)^HashT()(lst[i]); + val = (val << 4) ^ (val >> farbit) ^ HashT()(lst[i]); } return val; @@ -436,7 +437,7 @@ inline Foam::label Foam::FixedList::Hash::operator() const label tableSize ) const { - return mag(operator()(lst)) % tableSize; + return ::abs(operator()(lst)) % tableSize; } #endif diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H index 5f71976aa9..182c469b41 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H @@ -148,9 +148,11 @@ public: //- Masking for all bits below the offset inline static unsigned int maskLower(unsigned offset); - // Forward declaration of iteratorBase + // Forward declaration of iterators class iteratorBase; + class iterator; + class const_iterator; // Constructors @@ -355,7 +357,10 @@ public: public iteratorBase { - //- Should never violate const-ness! + //- Disallow copy constructor from const_iterator - violates const-ness! + iterator(const const_iterator&); + + //- Disallow assignment from const_iterator - violates const-ness! void operator=(const const_iterator&); public: diff --git a/src/OpenFOAM/db/IOobjectList/IOobjectList.H b/src/OpenFOAM/db/IOobjectList/IOobjectList.H index 44cb6f1dc1..71c63f9d38 100644 --- a/src/OpenFOAM/db/IOobjectList/IOobjectList.H +++ b/src/OpenFOAM/db/IOobjectList/IOobjectList.H @@ -63,7 +63,7 @@ public: // Constructors //- Construct given an initial estimate for the number of entries - explicit IOobjectList(const label nIoObjects = 100); + explicit IOobjectList(const label nIoObjects = 128); //- Construct from objectRegistry and instance path IOobjectList diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistry.H b/src/OpenFOAM/db/objectRegistry/objectRegistry.H index ce67831457..6c701e1d85 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistry.H +++ b/src/OpenFOAM/db/objectRegistry/objectRegistry.H @@ -82,12 +82,12 @@ public: // Constructors - //- Construct the time objectRegistry given an initial estimate + //- Construct the time objectRegistry given an initial estimate // for the number of entries explicit objectRegistry ( const Time& db, - const label nIoObjects = 100 + const label nIoObjects = 128 ); //- Construct a sub-registry given an IObject to describe the registry @@ -95,7 +95,7 @@ public: explicit objectRegistry ( const IOobject& io, - const label nIoObjects = 100 + const label nIoObjects = 128 ); diff --git a/src/OpenFOAM/meshes/meshShapes/edge/EdgeMap.H b/src/OpenFOAM/meshes/meshShapes/edge/EdgeMap.H index 6db2a7b016..7767fab30e 100644 --- a/src/OpenFOAM/meshes/meshShapes/edge/EdgeMap.H +++ b/src/OpenFOAM/meshes/meshShapes/edge/EdgeMap.H @@ -56,7 +56,7 @@ public: // Constructors //- Construct given initial map size - EdgeMap(label size = 100) + EdgeMap(const label size = 128) : HashTable >(size) {} diff --git a/src/OpenFOAM/primitives/strings/string/stringI.H b/src/OpenFOAM/primitives/strings/string/stringI.H index 38f8c80aa0..0720c27257 100644 --- a/src/OpenFOAM/primitives/strings/string/stringI.H +++ b/src/OpenFOAM/primitives/strings/string/stringI.H @@ -133,7 +133,7 @@ inline bool Foam::string::meta(const string& str, const char quote) template -inline Foam::string +inline Foam::string Foam::string::quotemeta(const string& str, const char quote) { if (!quote) @@ -205,14 +205,14 @@ inline Foam::string::size_type Foam::string::hash::operator() const string& key ) const { - register size_type hashVal = 0; + register size_type val = 0; for (string::const_iterator iter=key.begin(); iter!=key.end(); ++iter) { - hashVal = hashVal<<1 ^ *iter; + val = (val << 1) ^ *iter; } - return hashVal; + return val; } From a46c85f5a46327b15e58f60edaf32788d16aba56 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 26 Feb 2009 17:49:47 +0100 Subject: [PATCH 07/25] HashTable changes - make table power-of-two, but since it seems to give 1-2% performance improvement, maybe forget it too. - remove two-argument form of hashing classes and do the modulus direclty within HashTable instead. This simplifies things a fair bit. - migrate Hash from db/dlLibrary to primitives/hashes/Hash --- .../multiphaseMixture/multiphaseMixture.H | 11 +-- .../HashTables/HashTable/HashTable.C | 52 ++++++++++--- .../HashTables/HashTable/HashTable.H | 13 +++- .../HashTables/HashTable/HashTableI.H | 11 +++ .../HashTables/HashTable/HashTableIO.C | 9 ++- .../StaticHashTable/StaticHashTable.C | 76 +++++++++++++------ .../StaticHashTable/StaticHashTable.H | 11 ++- .../StaticHashTable/StaticHashTableI.H | 13 +++- .../containers/Lists/FixedList/FixedList.H | 11 +-- .../containers/Lists/FixedList/FixedListI.H | 18 +---- .../db/dlLibraryTable/dlLibraryTable.H | 26 +------ src/OpenFOAM/meshes/meshShapes/edge/edge.H | 4 +- .../meshes/meshShapes/triFace/triFace.H | 2 +- src/OpenFOAM/primitives/hashes/Hash/Hash.H | 25 +++++- .../primitives/strings/string/string.H | 5 +- .../primitives/strings/string/stringI.H | 14 ---- 16 files changed, 177 insertions(+), 124 deletions(-) diff --git a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.H b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.H index 74533d0416..fbff84f808 100644 --- a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.H +++ b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.H @@ -57,7 +57,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class multiphaseMixture Declaration + Class multiphaseMixture Declaration \*---------------------------------------------------------------------------*/ class multiphaseMixture @@ -85,15 +85,6 @@ public: { return word::hash()(key.first()) + word::hash()(key.second()); } - - label operator() - ( - const interfacePair& key, - const label tableSize - ) const - { - return mag(operator()(key)) % tableSize; - } }; diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C index e1def941d6..c2034a69ea 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C @@ -30,20 +30,49 @@ License #include "HashTable.H" #include "List.H" +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +template +Foam::label Foam::HashTable::canonicalSize(const label size) +{ + if (size < 1) + { + return 0; + } + + // enforce power of two + unsigned int goodSize = size; + + if (goodSize & (goodSize - 1)) + { + // brute-force is fast enough + goodSize = 1; + while (goodSize < unsigned(size)) + { + goodSize <<= 1; + } + } + + return goodSize; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::HashTable::HashTable(const label size) : - tableSize_(size), - table_(NULL), + HashTableName(), nElmts_(0), + tableSize_(canonicalSize(size)), + table_(NULL), endIter_(*this, NULL, 0), endConstIter_(*this, NULL, 0) { if (tableSize_) { table_ = new hashedEntry*[tableSize_]; + for (label hashIdx = 0; hashIdx < tableSize_; hashIdx++) { table_[hashIdx] = 0; @@ -56,9 +85,9 @@ template Foam::HashTable::HashTable(const HashTable& ht) : HashTableName(), + nElmts_(0), tableSize_(ht.tableSize_), table_(NULL), - nElmts_(0), endIter_(*this, NULL, 0), endConstIter_(*this, NULL, 0) { @@ -85,9 +114,9 @@ Foam::HashTable::HashTable ) : HashTableName(), + nElmts_(0), tableSize_(0), table_(NULL), - nElmts_(0), endIter_(*this, NULL, 0), endConstIter_(*this, NULL, 0) { @@ -115,7 +144,7 @@ bool Foam::HashTable::found(const Key& key) const { if (nElmts_) { - const label hashIdx = Hash()(key, tableSize_); + const label hashIdx = hashKeyIndex(key); for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_) { @@ -147,7 +176,7 @@ Foam::HashTable::find { if (nElmts_) { - const label hashIdx = Hash()(key, tableSize_); + const label hashIdx = hashKeyIndex(key); for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_) { @@ -179,7 +208,7 @@ Foam::HashTable::find { if (nElmts_) { - label hashIdx = Hash()(key, tableSize_); + const label hashIdx = hashKeyIndex(key); for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_) { @@ -231,7 +260,8 @@ bool Foam::HashTable::set resize(2); } - label hashIdx = Hash()(key, tableSize_); + const label hashIdx = hashKeyIndex(key); + hashedEntry* existing = 0; hashedEntry* prev = 0; @@ -449,14 +479,16 @@ Foam::label Foam::HashTable::erase template -void Foam::HashTable::resize(const label newSize) +void Foam::HashTable::resize(const label sz) { + label newSize = canonicalSize(sz); + if (newSize == tableSize_) { # ifdef FULLDEBUG if (debug) { - Info<< "HashTable::resize(const label newSize) : " + Info<< "HashTable::resize(const label) : " << "new table size == old table size\n"; } # endif diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index 65a5635e16..64812044da 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -108,18 +108,25 @@ class HashTable // Private data: size of table, the table and current number of elements + //- The current number of elements in table + label nElmts_; + //- Number of primary entries allocated in table (not necessarily used) label tableSize_; //- The table of primary entries hashedEntry** table_; - //- The current number of elements in table - label nElmts_; - // Private Member Functions + //- Return a canonical (power-of-two) size + static label canonicalSize(const label); + + //- Return the hash index of the Key within the current table size. + // No checks for zero-sized tables. + inline label hashKeyIndex(const Key&) const; + //- Assign a new hashedEntry to a possibly already existing key bool set(const Key&, const T& newElmt, bool protect); diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H index f117a601b9..e50d307968 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H @@ -42,6 +42,17 @@ inline Foam::HashTable::hashedEntry::hashedEntry {} +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +template +inline Foam::label +Foam::HashTable::hashKeyIndex(const Key& key) const +{ + // size is power of two - this is the modulus + return Hash()(key) & (tableSize_ - 1); +} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C index 1525d1d72e..2a407b44a5 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C @@ -33,15 +33,16 @@ License template Foam::HashTable::HashTable(Istream& is, const label size) : - tableSize_(size), - table_(new hashedEntry*[tableSize_]), + HashTableName(), nElmts_(0), + tableSize_(canonicalSize(size)), + table_(new hashedEntry*[tableSize_]), endIter_(*this, NULL, 0), endConstIter_(*this, NULL, 0) { - for (label i=0; i < tableSize_; i++) + for (label hashIdx = 0; hashIdx < tableSize_; hashIdx++) { - table_[i] = 0; + table_[hashIdx] = 0; } operator>>(is, *this); diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C index 7b011e135e..9b08bb3e67 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C @@ -31,6 +31,33 @@ License #include "List.H" #include "IOstreams.H" +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +template +Foam::label Foam::StaticHashTable::canonicalSize(const label size) +{ + if (size < 1) + { + return 0; + } + + // enforce power of two + unsigned int goodSize = size; + + if (goodSize & (goodSize - 1)) + { + // brute-force is fast enough + goodSize = 1; + while (goodSize < unsigned(size)) + { + goodSize <<= 1; + } + } + + return goodSize; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Construct given initial table size @@ -38,8 +65,8 @@ template Foam::StaticHashTable::StaticHashTable(const label size) : StaticHashTableName(), - keys_(size), - objects_(size), + keys_(canonicalSize(size)), + objects_(keys_.size()), nElmts_(0), endIter_(*this, keys_.size(), 0), endConstIter_(*this, keys_.size(), 0) @@ -75,7 +102,7 @@ Foam::StaticHashTable::StaticHashTable template Foam::StaticHashTable::StaticHashTable ( - const Xfer >& ht + const Xfer< StaticHashTable >& ht ) : StaticHashTableName(), @@ -103,7 +130,7 @@ bool Foam::StaticHashTable::found(const Key& key) const { if (nElmts_) { - label hashIdx = Hash()(key, keys_.size()); + const label hashIdx = hashKeyIndex(key); const List& localKeys = keys_[hashIdx]; forAll(localKeys, elemIdx) @@ -136,7 +163,7 @@ Foam::StaticHashTable::find { if (nElmts_) { - label hashIdx = Hash()(key, keys_.size()); + const label hashIdx = hashKeyIndex(key); const List& localKeys = keys_[hashIdx]; forAll(localKeys, elemIdx) @@ -167,14 +194,17 @@ Foam::StaticHashTable::find const Key& key ) const { - label hashIdx = Hash()(key, keys_.size()); - const List& localKeys = keys_[hashIdx]; - - forAll(localKeys, elemIdx) + if (nElmts_) { - if (key == localKeys[elemIdx]) + const label hashIdx = hashKeyIndex(key); + const List& localKeys = keys_[hashIdx]; + + forAll(localKeys, elemIdx) { - return const_iterator(*this, hashIdx, elemIdx); + if (key == localKeys[elemIdx]) + { + return const_iterator(*this, hashIdx, elemIdx); + } } } @@ -186,7 +216,7 @@ Foam::StaticHashTable::find } # endif - return end(); + return cend(); } @@ -197,7 +227,7 @@ Foam::List Foam::StaticHashTable::toc() const List tofc(nElmts_); label i = 0; - for (const_iterator iter = begin(); iter != end(); ++iter) + for (const_iterator iter = cbegin(); iter != cend(); ++iter) { tofc[i++] = iter.key(); } @@ -214,7 +244,7 @@ bool Foam::StaticHashTable::set const bool protect ) { - label hashIdx = Hash()(key, keys_.size()); + const label hashIdx = hashKeyIndex(key); List& localKeys = keys_[hashIdx]; label existing = localKeys.size(); @@ -375,8 +405,10 @@ Foam::label Foam::StaticHashTable::erase template -void Foam::StaticHashTable::resize(const label newSize) +void Foam::StaticHashTable::resize(const label sz) { + label newSize = canonicalSize(sz); + if (newSize == keys_.size()) { # ifdef FULLDEBUG @@ -394,7 +426,7 @@ void Foam::StaticHashTable::resize(const label newSize) { FatalErrorIn ( - "StaticHashTable::StaticHashTable(const label size)" + "StaticHashTable::resize(const label)" ) << "Illegal size " << newSize << " for StaticHashTable." << " Minimum size is 1" << abort(FatalError); } @@ -402,7 +434,7 @@ void Foam::StaticHashTable::resize(const label newSize) StaticHashTable newTable(newSize); - for (iterator iter = begin(); iter != end(); ++iter) + for (const_iterator iter = cbegin(); iter != cend(); ++iter) { newTable.insert(iter.key(), *iter); } @@ -499,7 +531,7 @@ void Foam::StaticHashTable::operator= } - for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter) + for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter) { insert(iter.key(), *iter); } @@ -512,22 +544,22 @@ bool Foam::StaticHashTable::operator== ) const { // Are all my elements in rhs? - for (const_iterator iter = begin(); iter != end(); ++iter) + for (const_iterator iter = cbegin(); iter != cend(); ++iter) { const_iterator fnd = rhs.find(iter.key()); - if (fnd == rhs.end() || fnd() != iter()) + if (fnd == rhs.cend() || fnd() != iter()) { return false; } } // Are all rhs elements in me? - for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter) + for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter) { const_iterator fnd = find(iter.key()); - if (fnd == end() || fnd() != iter()) + if (fnd == cend() || fnd() != iter()) { return false; } diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H index 60ed0e6fbb..e0a01746f9 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H @@ -99,6 +99,13 @@ class StaticHashTable //- The current number of elements in table label nElmts_; + //- Return a canonical (power-of-two) size + static label canonicalSize(const label); + + //- Return the hash index of the Key within the current table size. + // No checks for zero-sized tables. + inline label hashKeyIndex(const Key&) const; + //- Assign a new hashed entry to a possibly already existing key bool set(const Key&, const T& newElmt, bool protect); @@ -150,7 +157,7 @@ public: StaticHashTable(const StaticHashTable&); //- Construct by transferring the parameter contents - StaticHashTable(const Xfer >&); + StaticHashTable(const Xfer< StaticHashTable >&); // Destructor @@ -218,7 +225,7 @@ public: void transfer(StaticHashTable&); //- Transfer contents to the Xfer container - inline Xfer > xfer(); + inline Xfer< StaticHashTable > xfer(); // Member Operators diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H index 6ea55beae7..88f2d9bdb9 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H @@ -29,6 +29,17 @@ License // * * * * * * * * * * * * * Private Member Classes * * * * * * * * * * * * // +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +template +inline Foam::label +Foam::StaticHashTable::hashKeyIndex(const Key& key) const +{ + // size is power of two - this is the modulus + return Hash()(key) & (keys_.size() - 1); +} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template @@ -68,7 +79,7 @@ inline bool Foam::StaticHashTable::set template -inline Foam::Xfer > +inline Foam::Xfer< Foam::StaticHashTable > Foam::StaticHashTable::xfer() { return xferMove(*this); diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H index 0079f13a02..2cb2cfcea3 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H @@ -80,17 +80,12 @@ public: // Rotating hash from http://burtleburtle.net/bob/hash/doobs.html template > class Hash - : - public Foam::Hash > { public: - inline Hash(); + Hash() + {} + label operator()(const FixedList&) const; - label operator() - ( - const FixedList&, - const label tableSize - ) const; }; // Static Member Functions diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H index 4820ecc7f9..66a6257be8 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H @@ -403,11 +403,6 @@ inline bool Foam::FixedList::empty() const #ifndef __CINT__ -template -template -inline Foam::FixedList::Hash::Hash() -{} - // Rotating Hash template @@ -429,17 +424,6 @@ inline Foam::label Foam::FixedList::Hash::operator() return val; } -template -template -inline Foam::label Foam::FixedList::Hash::operator() -( - const FixedList& lst, - const label tableSize -) const -{ - return ::abs(operator()(lst)) % tableSize; -} -#endif - +#endif // __CINT__ // ************************************************************************* // diff --git a/src/OpenFOAM/db/dlLibraryTable/dlLibraryTable.H b/src/OpenFOAM/db/dlLibraryTable/dlLibraryTable.H index 610f54282a..086a2c7655 100644 --- a/src/OpenFOAM/db/dlLibraryTable/dlLibraryTable.H +++ b/src/OpenFOAM/db/dlLibraryTable/dlLibraryTable.H @@ -38,7 +38,7 @@ SourceFiles #include "HashTable.H" #include "label.H" -#include "pTraits.H" +#include "Hash.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -46,31 +46,9 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class dlLibraryTable Declaration + Class dlLibraryTable Declaration \*---------------------------------------------------------------------------*/ -//- A means of hashing pointer addresses -template<> -class Hash -{ - -public: - - Hash() - {} - - long operator()(const void* const& p) const - { - return long(p); - } - - label operator()(const void* const& p, const label tableSize) const - { - return abs(operator()(p)) % tableSize; - } -}; - - class dlLibraryTable : public HashTable > diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edge.H b/src/OpenFOAM/meshes/meshShapes/edge/edge.H index b0bb1f4e64..c726ad941c 100644 --- a/src/OpenFOAM/meshes/meshShapes/edge/edge.H +++ b/src/OpenFOAM/meshes/meshShapes/edge/edge.H @@ -133,12 +133,12 @@ public: }; -//- Hash specialisation +//- Hash specialization for hashing edges // Simple commutative hash. template<> inline label Hash::operator()(const edge& e) const { - return e[0]*e[1] + e[0]+e[1]; + return (e[0]*e[1] + e[0]+e[1]); } template<> diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H index 90512b712b..c962a4fc5d 100644 --- a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H +++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H @@ -164,7 +164,7 @@ public: }; -//- Hash specialisation +//- Hash specialization for hashing triFace // Simple commutative hash. template<> inline label Hash::operator()(const triFace& t) const diff --git a/src/OpenFOAM/primitives/hashes/Hash/Hash.H b/src/OpenFOAM/primitives/hashes/Hash/Hash.H index ab8aa07a3b..7675d44bbb 100644 --- a/src/OpenFOAM/primitives/hashes/Hash/Hash.H +++ b/src/OpenFOAM/primitives/hashes/Hash/Hash.H @@ -27,7 +27,7 @@ Class Description Hash function class for primitives. All non-primitives used to hash - entries on hash tables need a specialised version of this class. + entries on hash tables need a specialized version of this class. \*---------------------------------------------------------------------------*/ @@ -35,6 +35,7 @@ Description #define Hash_H #include "label.H" +#include "pTraits.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -42,7 +43,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class Hash Declaration + Class Hash Declaration \*---------------------------------------------------------------------------*/ template @@ -59,10 +60,26 @@ public: return label(p); } - label operator()(const PrimitiveType& p, const label tableSize) const +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +//- Hash specialization for hashing pointer addresses +template<> +class Hash +{ + +public: + + Hash() + {} + + long operator()(const void* const& p) const { - return mag(operator()(p)) % tableSize; + return long(p); } + }; diff --git a/src/OpenFOAM/primitives/strings/string/string.H b/src/OpenFOAM/primitives/strings/string/string.H index 714c72a335..86bbb2a1f5 100644 --- a/src/OpenFOAM/primitives/strings/string/string.H +++ b/src/OpenFOAM/primitives/strings/string/string.H @@ -89,9 +89,10 @@ public: class hash { public: - inline hash(); + hash() + {} + inline size_type operator()(const string&) const; - inline size_type operator()(const string&, const size_type) const; }; diff --git a/src/OpenFOAM/primitives/strings/string/stringI.H b/src/OpenFOAM/primitives/strings/string/stringI.H index 0720c27257..dc8c0e8fa0 100644 --- a/src/OpenFOAM/primitives/strings/string/stringI.H +++ b/src/OpenFOAM/primitives/strings/string/stringI.H @@ -196,10 +196,6 @@ inline Foam::string Foam::string::operator()(const size_type n) const } -inline Foam::string::hash::hash() -{} - - inline Foam::string::size_type Foam::string::hash::operator() ( const string& key @@ -216,14 +212,4 @@ inline Foam::string::size_type Foam::string::hash::operator() } -inline Foam::string::size_type Foam::string::hash::operator() -( - const string& key, - const size_type tableSize -) const -{ - return ::abs(operator()(key)) % tableSize; -} - - // ************************************************************************* // From 576d9388f02908b7bf7c89d95f899375b65bb988 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 27 Feb 2009 12:40:37 +0100 Subject: [PATCH 08/25] Preliminary work on hashing - Hash returns unsigned - FixedList templated on unsigned int - include uLabel.H in UList, HashTable etc. so the output function is know throughout --- .../HashTables/HashTable/HashTable.H | 3 +- .../StaticHashTable/StaticHashTable.H | 3 +- .../LinkedLists/accessTypes/LList/LList.H | 1 + .../LinkedLists/accessTypes/UILList/UILList.H | 1 + .../linkTypes/DLListBase/DLListBase.H | 1 + .../linkTypes/SLListBase/SLListBase.H | 1 + .../containers/Lists/FixedList/FixedList.C | 18 +-- .../containers/Lists/FixedList/FixedList.H | 14 +- .../containers/Lists/FixedList/FixedListI.H | 122 +++++++++--------- .../containers/Lists/FixedList/FixedListIO.C | 14 +- src/OpenFOAM/containers/Lists/List/List.C | 2 +- src/OpenFOAM/containers/Lists/List/List.H | 4 +- src/OpenFOAM/containers/Lists/UList/UList.H | 3 +- .../db/IOstreams/IOstreams/IOstream.H | 1 + .../db/IOstreams/Sstreams/readHexLabel.H | 2 +- src/OpenFOAM/db/IOstreams/token/token.H | 1 + .../db/dlLibraryTable/dlLibraryTable.H | 2 +- src/OpenFOAM/db/error/messageStream.H | 2 +- src/OpenFOAM/fields/Fields/Field/SubField.H | 5 +- .../fields/Fields/labelField/labelField.H | 2 +- .../pointConstraint/pointConstraint.H | 3 +- src/OpenFOAM/matrices/Matrix/Matrix.H | 5 +- .../meshShapes/cellMatcher/cellMatcher.H | 1 - src/OpenFOAM/meshes/meshShapes/edge/edge.H | 2 +- .../meshes/meshShapes/triFace/triFace.H | 2 +- .../primitiveMesh/primitivePatch/walkPatch.H | 1 - .../primitives/DiagTensor/DiagTensor.H | 8 +- src/OpenFOAM/primitives/Scalar/doubleFloat.H | 2 +- .../primitives/contiguous/contiguous.H | 6 +- .../primitives/diagTensor/diagTensor.H | 2 +- src/OpenFOAM/primitives/hashes/Hash/Hash.H | 7 +- src/OpenFOAM/primitives/label/label.C | 11 +- .../primitives/strings/string/string.H | 4 +- .../primitives/strings/string/stringI.H | 11 +- src/OpenFOAM/primitives/uint/uint.H | 2 +- src/OpenFOAM/primitives/vector/vector.H | 2 +- .../fvMeshDistribute/fvMeshDistribute.H | 11 +- .../general/findRefCell/findRefCell.H | 6 +- src/meshTools/indexedOctree/labelBits.H | 5 +- 39 files changed, 159 insertions(+), 134 deletions(-) diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index 64812044da..696ab41075 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -39,9 +39,10 @@ SourceFiles #define HashTable_H #include "label.H" +#include "uLabel.H" #include "word.H" -#include "className.H" #include "Xfer.H" +#include "className.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H index e0a01746f9..3c3264e42a 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H @@ -45,9 +45,10 @@ SourceFiles #define StaticHashTable_H #include "label.H" +#include "uLabel.H" #include "word.H" -#include "className.H" #include "Xfer.H" +#include "className.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H index 44e9878c72..9c8a22945a 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H @@ -38,6 +38,7 @@ SourceFiles #define LList_H #include "label.H" +#include "uLabel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H index 448add5df3..feefd60c7c 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H @@ -38,6 +38,7 @@ SourceFiles #define UILList_H #include "label.H" +#include "uLabel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H index ba3423c8e2..848b797b2e 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H @@ -38,6 +38,7 @@ SourceFiles #include "bool.H" #include "label.H" +#include "uLabel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H index 0c67d7a56e..b5c957a537 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H @@ -38,6 +38,7 @@ SourceFiles #include "bool.H" #include "label.H" +#include "uLabel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.C b/src/OpenFOAM/containers/Lists/FixedList/FixedList.C index eec73d4143..735d897bb4 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.C +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.C @@ -31,7 +31,7 @@ License // * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * // -template +template void Foam::FixedList::swap(FixedList& a) { List_ACCESS(T, (*this), vp); @@ -47,7 +47,7 @@ void Foam::FixedList::swap(FixedList& a) // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -template +template bool Foam::FixedList::operator==(const FixedList& a) const { bool equal = true; @@ -63,20 +63,20 @@ bool Foam::FixedList::operator==(const FixedList& a) const } -template +template bool Foam::FixedList::operator!=(const FixedList& a) const { return !operator==(a); } -template +template bool Foam::FixedList::operator<(const FixedList& a) const { for ( - const_iterator vi = begin(), ai = a.begin(); - vi < end() && ai < a.end(); + const_iterator vi = cbegin(), ai = a.cbegin(); + vi < cend() && ai < a.cend(); vi++, ai++ ) { @@ -101,21 +101,21 @@ bool Foam::FixedList::operator<(const FixedList& a) const } -template +template bool Foam::FixedList::operator>(const FixedList& a) const { return a.operator<(*this); } -template +template bool Foam::FixedList::operator<=(const FixedList& a) const { return !operator>(a); } -template +template bool Foam::FixedList::operator>=(const FixedList& a) const { return !operator<(a); diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H index 2cb2cfcea3..34bc05749f 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H @@ -38,7 +38,9 @@ SourceFiles #ifndef FixedList_H #define FixedList_H +#include "bool.H" #include "label.H" +#include "uLabel.H" #include "Hash.H" #include "autoPtr.H" @@ -49,12 +51,12 @@ namespace Foam // Forward declaration of friend functions and operators -template class FixedList; +template class FixedList; -template +template Istream& operator>>(Istream&, FixedList&); -template +template Ostream& operator<<(Ostream&, const FixedList&); template class UList; @@ -65,7 +67,7 @@ template class SLList; Class FixedList Declaration \*---------------------------------------------------------------------------*/ -template +template class FixedList { // Private data @@ -78,14 +80,14 @@ public: //- Hashing function class // Rotating hash from http://burtleburtle.net/bob/hash/doobs.html - template > + template< class HashT=Hash > class Hash { public: Hash() {} - label operator()(const FixedList&) const; + inline unsigned operator()(const FixedList&) const; }; // Static Member Functions diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H index 66a6257be8..8523ba7672 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H @@ -29,44 +29,44 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template +template inline Foam::FixedList::FixedList() {} -template +template inline Foam::FixedList::FixedList(const T v[Size]) { - for (register label i=0; i +template inline Foam::FixedList::FixedList(const T& t) { - for (register label i=0; i +template inline Foam::FixedList::FixedList(const UList& lst) { checkSize(lst.size()); - for (register label i=0; i +template inline Foam::FixedList::FixedList(const SLList& lst) { checkSize(lst.size()); @@ -84,41 +84,41 @@ inline Foam::FixedList::FixedList(const SLList& lst) } -template +template inline Foam::FixedList::FixedList(const FixedList& lst) { - for (register label i=0; i -inline Foam::autoPtr > +template +inline Foam::autoPtr< Foam::FixedList > Foam::FixedList::clone() const { - return autoPtr >(new FixedList(*this)); + return autoPtr< FixedList >(new FixedList(*this)); } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template +template inline const Foam::FixedList& Foam::FixedList::null() { return *reinterpret_cast< FixedList* >(0); } -template +template inline Foam::label Foam::FixedList::fcIndex(const label i) const { return (i == Size-1 ? 0 : i+1); } -template +template inline Foam::label Foam::FixedList::rcIndex(const label i) const { return (i ? i-1 : Size-1); @@ -126,51 +126,51 @@ inline Foam::label Foam::FixedList::rcIndex(const label i) const // Check start is within valid range (0 ... size-1). -template +template inline void Foam::FixedList::checkStart(const label start) const { - if (start<0 || (start && start>=Size)) + if (start < 0 || (start && unsigned(start) >= Size)) { FatalErrorIn("FixedList::checkStart(const label)") - << "start " << start << " out of range 0 ... " << max(Size-1, 0) + << "start " << start << " out of range 0 ... " << (Size-1) << abort(FatalError); } } // Check size is within valid range (0 ... size). -template +template inline void Foam::FixedList::checkSize(const label size) const { - if (size<0 || size>Size) + if (size < 0 || unsigned(size) > Size) { FatalErrorIn("FixedList::checkSize(const label)") - << "size " << size << " out of range 0 ... " << Size + << "size " << size << " out of range 0 ... " << (Size) << abort(FatalError); } } // Check index i is within valid range (0 ... size-1). -template +template inline void Foam::FixedList::checkIndex(const label i) const { if (!Size) { FatalErrorIn("FixedList::checkIndex(const label)") - << "attempt to access element from zero sized list" + << "attempt to access element from zero-sized list" << abort(FatalError); } - else if (i<0 || i>=Size) + else if (i < 0 || i >= Size) { FatalErrorIn("FixedList::checkIndex(const label)") - << "index " << i << " out of range 0 ... " << Size-1 + << "index " << i << " out of range 0 ... " << (Size-1) << abort(FatalError); } } -template +template inline void Foam::FixedList::resize(const label s) { # ifdef FULLDEBUG @@ -178,7 +178,7 @@ inline void Foam::FixedList::resize(const label s) # endif } -template +template inline void Foam::FixedList::setSize(const label s) { # ifdef FULLDEBUG @@ -186,17 +186,17 @@ inline void Foam::FixedList::setSize(const label s) # endif } -template +template inline void Foam::FixedList::transfer(const FixedList& lst) { - for (register label i=0; i +template inline const T* Foam::FixedList::cdata() const { @@ -204,7 +204,7 @@ Foam::FixedList::cdata() const } -template +template inline T* Foam::FixedList::data() { @@ -215,7 +215,7 @@ Foam::FixedList::data() // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // element access -template +template inline T& Foam::FixedList::operator[](const label i) { # ifdef FULLDEBUG @@ -226,7 +226,7 @@ inline T& Foam::FixedList::operator[](const label i) // const element access -template +template inline const T& Foam::FixedList::operator[](const label i) const { # ifdef FULLDEBUG @@ -236,27 +236,27 @@ inline const T& Foam::FixedList::operator[](const label i) const } -template +template inline void Foam::FixedList::operator=(const T lst[Size]) { - for (register label i=0; i +template inline void Foam::FixedList::operator=(const UList& lst) { checkSize(lst.size()); - for (register label i=0; i +template inline void Foam::FixedList::operator=(const SLList& lst) { checkSize(lst.size()); @@ -273,10 +273,10 @@ inline void Foam::FixedList::operator=(const SLList& lst) } } -template +template inline void Foam::FixedList::operator=(const T& t) { - for (register label i=0; i::operator=(const T& t) // * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * // -template +template inline typename Foam::FixedList::iterator Foam::FixedList::begin() { @@ -293,7 +293,7 @@ Foam::FixedList::begin() } -template +template inline typename Foam::FixedList::const_iterator Foam::FixedList::begin() const { @@ -301,7 +301,7 @@ Foam::FixedList::begin() const } -template +template inline typename Foam::FixedList::const_iterator Foam::FixedList::cbegin() const { @@ -309,7 +309,7 @@ Foam::FixedList::cbegin() const } -template +template inline typename Foam::FixedList::iterator Foam::FixedList::end() { @@ -317,7 +317,7 @@ Foam::FixedList::end() } -template +template inline typename Foam::FixedList::const_iterator Foam::FixedList::end() const { @@ -325,7 +325,7 @@ Foam::FixedList::end() const } -template +template inline typename Foam::FixedList::const_iterator Foam::FixedList::cend() const { @@ -333,7 +333,7 @@ Foam::FixedList::cend() const } -template +template inline typename Foam::FixedList::iterator Foam::FixedList::rbegin() { @@ -341,7 +341,7 @@ Foam::FixedList::rbegin() } -template +template inline typename Foam::FixedList::const_iterator Foam::FixedList::rbegin() const { @@ -349,7 +349,7 @@ Foam::FixedList::rbegin() const } -template +template inline typename Foam::FixedList::const_iterator Foam::FixedList::crbegin() const { @@ -357,7 +357,7 @@ Foam::FixedList::crbegin() const } -template +template inline typename Foam::FixedList::iterator Foam::FixedList::rend() { @@ -365,7 +365,7 @@ Foam::FixedList::rend() } -template +template inline typename Foam::FixedList::const_iterator Foam::FixedList::rend() const { @@ -373,7 +373,7 @@ Foam::FixedList::rend() const } -template +template inline typename Foam::FixedList::const_iterator Foam::FixedList::crend() const { @@ -381,21 +381,21 @@ Foam::FixedList::crend() const } -template +template inline Foam::label Foam::FixedList::size() const { return Size; } -template +template inline Foam::label Foam::FixedList::max_size() const { return Size; } -template +template inline bool Foam::FixedList::empty() const { return false; @@ -405,18 +405,18 @@ inline bool Foam::FixedList::empty() const #ifndef __CINT__ // Rotating Hash -template +template template -inline Foam::label Foam::FixedList::Hash::operator() +inline unsigned Foam::FixedList::Hash::operator() ( const FixedList& lst ) const { - static const label farbit(8*sizeof(label)-4); + static const unsigned farbit(8*sizeof(label)-4); - label val = Size; + unsigned val = Size; - for (register int i=0; i> farbit) ^ HashT()(lst[i]); } diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C b/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C index 49caad2a0a..aab7376e05 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C @@ -32,14 +32,14 @@ License // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // -template +template Foam::FixedList::FixedList(Istream& is) { operator>>(is, *this); } -template +template Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList& L) { is.fatalCheck("operator>>(Istream&, FixedList&)"); @@ -86,7 +86,7 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList& L) if (listDelimiter == token::BEGIN_LIST) { - for (register label i=0; i> L[i]; @@ -108,7 +108,7 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList& L) "reading the single entry" ); - for (register label i=0; i>(Foam::Istream& is, FixedList& L) // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // -template +template void Foam::FixedList::writeEntry(Ostream& os) const { if @@ -153,7 +153,7 @@ void Foam::FixedList::writeEntry(Ostream& os) const } -template +template void Foam::FixedList::writeEntry ( const word& keyword, @@ -166,7 +166,7 @@ void Foam::FixedList::writeEntry } -template +template Foam::Ostream& Foam::operator<<(Ostream& os, const FixedList& L) { // Write list contents depending on data format diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C index 137f17e8ea..542f945184 100644 --- a/src/OpenFOAM/containers/Lists/List/List.C +++ b/src/OpenFOAM/containers/Lists/List/List.C @@ -205,7 +205,7 @@ Foam::List::List(InputIterator first, InputIterator last) // Construct as copy of FixedList template -template +template Foam::List::List(const FixedList& lst) : UList(NULL, Size) diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index 983b2be008..0c08eed8fe 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -59,7 +59,7 @@ template class List; template Istream& operator>>(Istream&, List&); -template class FixedList; +template class FixedList; template class PtrList; template class SLList; template @@ -117,7 +117,7 @@ public: List(InputIterator first, InputIterator last); //- Construct as copy of FixedList - template