diff --git a/applications/solvers/DNS/dnsFoam/dnsFoam.C b/applications/solvers/DNS/dnsFoam/dnsFoam.C index 277a78002d..cc41c03969 100644 --- a/applications/solvers/DNS/dnsFoam/dnsFoam.C +++ b/applications/solvers/DNS/dnsFoam/dnsFoam.C @@ -55,8 +55,9 @@ int main(int argc, char *argv[]) Info<< nl << "Starting time loop" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPISOControls.H" diff --git a/applications/solvers/basic/laplacianFoam/laplacianFoam.C b/applications/solvers/basic/laplacianFoam/laplacianFoam.C index 4a804d01bb..5b56c72a8c 100644 --- a/applications/solvers/basic/laplacianFoam/laplacianFoam.C +++ b/applications/solvers/basic/laplacianFoam/laplacianFoam.C @@ -48,8 +48,9 @@ int main(int argc, char *argv[]) Info<< "\nCalculating temperature distribution\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readSIMPLEControls.H" diff --git a/applications/solvers/basic/scalarTransportFoam/scalarTransportFoam.C b/applications/solvers/basic/scalarTransportFoam/scalarTransportFoam.C index d2d2eb4e6d..ad0107319f 100644 --- a/applications/solvers/basic/scalarTransportFoam/scalarTransportFoam.C +++ b/applications/solvers/basic/scalarTransportFoam/scalarTransportFoam.C @@ -50,8 +50,9 @@ int main(int argc, char *argv[]) # include "CourantNo.H" - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readSIMPLEControls.H" diff --git a/applications/solvers/combustion/dieselFoam/dieselFoam.C b/applications/solvers/combustion/dieselFoam/dieselFoam.C index 64df8bcc8f..4c41a0db2d 100644 --- a/applications/solvers/combustion/dieselFoam/dieselFoam.C +++ b/applications/solvers/combustion/dieselFoam/dieselFoam.C @@ -63,7 +63,7 @@ int main(int argc, char *argv[]) Info << "\nStarting time loop\n" << endl; - while(runTime.run()) + while (runTime.run()) { # include "readPISOControls.H" # include "compressibleCourantNo.H" diff --git a/applications/solvers/compressible/rhoPorousSimpleFoam/rhoPorousSimpleFoam.C b/applications/solvers/compressible/rhoPorousSimpleFoam/rhoPorousSimpleFoam.C index b0bd54d3b3..b1b11a7cec 100644 --- a/applications/solvers/compressible/rhoPorousSimpleFoam/rhoPorousSimpleFoam.C +++ b/applications/solvers/compressible/rhoPorousSimpleFoam/rhoPorousSimpleFoam.C @@ -51,8 +51,9 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + 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 ba2b0afd60..d985abe25d 100644 --- a/applications/solvers/compressible/rhoSimpleFoam/rhoSimpleFoam.C +++ b/applications/solvers/compressible/rhoSimpleFoam/rhoSimpleFoam.C @@ -49,8 +49,9 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + 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 662a4f0ad3..b4bdc9e493 100644 --- a/applications/solvers/compressible/rhoSonicFoam/rhoSonicFoam.C +++ b/applications/solvers/compressible/rhoSonicFoam/rhoSonicFoam.C @@ -47,8 +47,9 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; surfaceScalarField phiv diff --git a/applications/solvers/compressible/rhopSonicFoam/rhopSonicFoam.C b/applications/solvers/compressible/rhopSonicFoam/rhopSonicFoam.C index b1be4d711e..b3f1c8e06d 100644 --- a/applications/solvers/compressible/rhopSonicFoam/rhopSonicFoam.C +++ b/applications/solvers/compressible/rhopSonicFoam/rhopSonicFoam.C @@ -53,8 +53,9 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; Info<< "Time = " << runTime.value() << nl << endl; # include "readPISOControls.H" diff --git a/applications/solvers/compressible/sonicDyMFoam/sonicDyMFoam.C b/applications/solvers/compressible/sonicDyMFoam/sonicDyMFoam.C index 34faaf78fa..593bc742cf 100644 --- a/applications/solvers/compressible/sonicDyMFoam/sonicDyMFoam.C +++ b/applications/solvers/compressible/sonicDyMFoam/sonicDyMFoam.C @@ -52,8 +52,9 @@ int main(int argc, char *argv[]) autoPtr motionPtr = motionSolver::New(mesh); - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; #include "readPISOControls.H" diff --git a/applications/solvers/compressible/sonicFoam/sonicFoam.C b/applications/solvers/compressible/sonicFoam/sonicFoam.C index 08d1f85fec..741141c1c4 100644 --- a/applications/solvers/compressible/sonicFoam/sonicFoam.C +++ b/applications/solvers/compressible/sonicFoam/sonicFoam.C @@ -49,8 +49,9 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; #include "readPISOControls.H" diff --git a/applications/solvers/compressible/sonicLiquidFoam/sonicLiquidFoam.C b/applications/solvers/compressible/sonicLiquidFoam/sonicLiquidFoam.C index 90243b2322..87dcf947b0 100644 --- a/applications/solvers/compressible/sonicLiquidFoam/sonicLiquidFoam.C +++ b/applications/solvers/compressible/sonicLiquidFoam/sonicLiquidFoam.C @@ -50,8 +50,9 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPISOControls.H" diff --git a/applications/solvers/electromagnetics/electrostaticFoam/electrostaticFoam.C b/applications/solvers/electromagnetics/electrostaticFoam/electrostaticFoam.C index 13438974ac..11daf2e0b4 100644 --- a/applications/solvers/electromagnetics/electrostaticFoam/electrostaticFoam.C +++ b/applications/solvers/electromagnetics/electrostaticFoam/electrostaticFoam.C @@ -47,8 +47,9 @@ int main(int argc, char *argv[]) Info<< "\nStarting iteration loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; Info<< "Iteration = " << runTime.timeName() << nl << endl; solve diff --git a/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C b/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C index 9da017da3a..e121150c7a 100644 --- a/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C +++ b/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C @@ -71,8 +71,9 @@ int main(int argc, char *argv[]) Info<< nl << "Starting time loop" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; # include "readPISOControls.H" # include "readBPISOControls.H" diff --git a/applications/solvers/financial/financialFoam/financialFoam.C b/applications/solvers/financial/financialFoam/financialFoam.C index eabbafaf73..9edd07a8d0 100644 --- a/applications/solvers/financial/financialFoam/financialFoam.C +++ b/applications/solvers/financial/financialFoam/financialFoam.C @@ -55,8 +55,9 @@ int main(int argc, char *argv[]) Info<< "Starting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; delta == fvc::grad(V)().component(Foam::vector::X); solve diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C index 6a4381efbf..1a9f023253 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C +++ b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C @@ -69,8 +69,9 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + 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 5e9deff764..c8e62813e8 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C +++ b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C @@ -66,8 +66,9 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + 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 ebe0f4579a..e9c48b937f 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C @@ -51,8 +51,9 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + 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 21059f5064..21e4912ae7 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C +++ b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C @@ -54,8 +54,9 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + 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 84c7c11806..8a19fd0264 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) # include "setInitialDeltaT.H" } - while(runTime.run()) + while (runTime.run()) { # include "readTimeControls.H" diff --git a/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C b/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C index a8e063c2db..2360fb6677 100644 --- a/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C +++ b/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C @@ -58,8 +58,9 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; fvVectorMatrix divR = turbulence->divDevReff(U); diff --git a/applications/solvers/incompressible/channelFoam/channelFoam.C b/applications/solvers/incompressible/channelFoam/channelFoam.C index fe245ed82d..94d8f4acd4 100644 --- a/applications/solvers/incompressible/channelFoam/channelFoam.C +++ b/applications/solvers/incompressible/channelFoam/channelFoam.C @@ -51,8 +51,9 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for(runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; #include "readPISOControls.H" diff --git a/applications/solvers/incompressible/icoFoam/icoFoam.C b/applications/solvers/incompressible/icoFoam/icoFoam.C index 993f328905..d8c549668f 100644 --- a/applications/solvers/incompressible/icoFoam/icoFoam.C +++ b/applications/solvers/incompressible/icoFoam/icoFoam.C @@ -48,8 +48,9 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPISOControls.H" diff --git a/applications/solvers/incompressible/nonNewtonianIcoFoam/nonNewtonianIcoFoam.C b/applications/solvers/incompressible/nonNewtonianIcoFoam/nonNewtonianIcoFoam.C index b1ce245017..f949b39cfc 100644 --- a/applications/solvers/incompressible/nonNewtonianIcoFoam/nonNewtonianIcoFoam.C +++ b/applications/solvers/incompressible/nonNewtonianIcoFoam/nonNewtonianIcoFoam.C @@ -49,8 +49,9 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPISOControls.H" diff --git a/applications/solvers/incompressible/pisoFoam/pisoFoam.C b/applications/solvers/incompressible/pisoFoam/pisoFoam.C index 01b349e9fa..95b4bc0843 100644 --- a/applications/solvers/incompressible/pisoFoam/pisoFoam.C +++ b/applications/solvers/incompressible/pisoFoam/pisoFoam.C @@ -52,8 +52,9 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPISOControls.H" diff --git a/applications/solvers/incompressible/shallowWaterFoam/CourantNo.H b/applications/solvers/incompressible/shallowWaterFoam/CourantNo.H new file mode 100644 index 0000000000..125f1b23b5 --- /dev/null +++ b/applications/solvers/incompressible/shallowWaterFoam/CourantNo.H @@ -0,0 +1,66 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Global + CourantNo + +Description + Calculates and outputs the maximum Courant Number. + +\*---------------------------------------------------------------------------*/ + + +scalar CoNum = 0.0; +scalar meanCoNum = 0.0; +scalar waveCoNum = 0.0; + +if (mesh.nInternalFaces()) +{ + surfaceScalarField SfUfbyDelta = + mesh.surfaceInterpolation::deltaCoeffs() + *mag(phi)/fvc::interpolate(h); + + CoNum = max(SfUfbyDelta/mesh.magSf()) + .value()*runTime.deltaT().value(); + + meanCoNum = (sum(SfUfbyDelta)/sum(mesh.magSf())) + .value()*runTime.deltaT().value(); + + // Gravity wave Courant number + waveCoNum = + 0.5*max + ( + mesh.surfaceInterpolation::deltaCoeffs() + *sqrt(fvc::interpolate(h)) + ).value()*sqrt(magg).value()*runTime.deltaT().value(); +} + +Info<< "Courant number mean: " << meanCoNum + << " max: " << CoNum << endl; + +Info<< "Gravity wave Courant number max: " << waveCoNum + << endl; + + +// ************************************************************************* // diff --git a/applications/solvers/incompressible/shallowWaterFoam/Make/files b/applications/solvers/incompressible/shallowWaterFoam/Make/files new file mode 100644 index 0000000000..448878dfc7 --- /dev/null +++ b/applications/solvers/incompressible/shallowWaterFoam/Make/files @@ -0,0 +1,3 @@ +shallowWaterFoam.C + +EXE = $(FOAM_APPBIN)/shallowWaterFoam diff --git a/applications/solvers/incompressible/shallowWaterFoam/Make/options b/applications/solvers/incompressible/shallowWaterFoam/Make/options new file mode 100644 index 0000000000..fa15f12452 --- /dev/null +++ b/applications/solvers/incompressible/shallowWaterFoam/Make/options @@ -0,0 +1,5 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -lfiniteVolume diff --git a/applications/solvers/incompressible/shallowWaterFoam/createFields.H b/applications/solvers/incompressible/shallowWaterFoam/createFields.H new file mode 100644 index 0000000000..cfc14216f7 --- /dev/null +++ b/applications/solvers/incompressible/shallowWaterFoam/createFields.H @@ -0,0 +1,74 @@ +Info<< "Reading field h\n" << endl; +volScalarField h +( + IOobject + ( + "h", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh +); + +Info<< "Reading field h0 if present\n" << endl; +volScalarField h0 +( + IOobject + ( + "h0", + runTime.findInstance("polyMesh", "points"), + mesh, + IOobject::READ_IF_PRESENT + ), + mesh, + dimensionedScalar("h0", dimLength, 0.0) +); + +Info<< "Reading field U\n" << endl; +volVectorField U +( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh +); + +Info<< "Creating field hU\n" << endl; +volVectorField hU +( + IOobject + ( + "hU", + runTime.timeName(), + mesh + ), + h*U, + U.boundaryField().types() +); + +Info<< "Creating field hTotal for post processing\n" << endl; +volScalarField hTotal +( + IOobject + ( + "hTotal", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + h+h0 +); +hTotal.write(); + +# include "createPhi.H" + +Info<< "Creating Coriolis Force" << endl; +const dimensionedVector F("F", ((2.0*Omega) & gHat)*gHat); diff --git a/applications/solvers/incompressible/shallowWaterFoam/createPhi.H b/applications/solvers/incompressible/shallowWaterFoam/createPhi.H new file mode 100644 index 0000000000..0c79ffdc34 --- /dev/null +++ b/applications/solvers/incompressible/shallowWaterFoam/createPhi.H @@ -0,0 +1,57 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Global + createPhi + +Description + Creates and initialises the face-flux field phi. + +\*---------------------------------------------------------------------------*/ + +#ifndef createPhi_H +#define createPhi_H + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Info<< "Reading/calculating face flux field phi\n" << endl; + +surfaceScalarField phi +( + IOobject + ( + "phi", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + linearInterpolate(hU) & mesh.Sf() +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/incompressible/shallowWaterFoam/readEnvironmentalProperties.H b/applications/solvers/incompressible/shallowWaterFoam/readEnvironmentalProperties.H new file mode 100644 index 0000000000..866335eef1 --- /dev/null +++ b/applications/solvers/incompressible/shallowWaterFoam/readEnvironmentalProperties.H @@ -0,0 +1,21 @@ +Info<< "\nReading environmentalProperties" << endl; + +IOdictionary environmentalProperties +( + IOobject + ( + "environmentalProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) +); + +const dimensionedVector g(environmentalProperties.lookup("g")); +const Switch rotating(environmentalProperties.lookup("rotating")); +const dimensionedVector Omega = + rotating ? environmentalProperties.lookup("Omega") + : dimensionedVector("Omega", -dimTime, vector(0,0,0)); +const dimensionedScalar magg = mag(g); +const dimensionedVector gHat = g/magg; diff --git a/applications/solvers/incompressible/shallowWaterFoam/shallowWaterFoam.C b/applications/solvers/incompressible/shallowWaterFoam/shallowWaterFoam.C new file mode 100644 index 0000000000..4b9c231180 --- /dev/null +++ b/applications/solvers/incompressible/shallowWaterFoam/shallowWaterFoam.C @@ -0,0 +1,163 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + shallowWaterFoam + +Description + Transient solver for inviscid shallow-water equations with rotation. + If the geometry is 3D then it is assumed to be one layers of cells and the + component of the velocity normal to gravity is removed. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "readEnvironmentalProperties.H" + #include "createFields.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.loop()) + { + Info<< "\n Time = " << runTime.timeName() << nl << endl; + + #include "readPISOControls.H" + #include "CourantNo.H" + + for (int ucorr=0; ucorr motionPtr = motionSolver::New(mesh); - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; Info<< "Time = " << runTime.timeName() << endl; mesh.movePoints(motionPtr->newPoints()); diff --git a/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C b/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C index 3132872c03..45faede694 100644 --- a/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C +++ b/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C @@ -74,7 +74,7 @@ namespace Foam } else { - functionObjectList fol(runTime, runTime.controlDict()); + functionObjectList fol(runTime); fol.start(); fol.execute(); } diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 92c81085ab..833be5ccd5 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -144,11 +144,14 @@ $(regIOobject)/regIOobjectWrite.C db/IOobjectList/IOobjectList.C db/objectRegistry/objectRegistry.C -db/functionObject/functionObject.C -db/functionObjectList/functionObjectList.C db/CallbackRegistry/CallbackRegistryName.C db/dlLibraryTable/dlLibraryTable.C +db/functionObjects/functionObject/functionObject.C +db/functionObjects/functionObjectList/functionObjectList.C +db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C + + Time = db/Time $(Time)/TimePaths.C $(Time)/TimeState.C diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index 26d2182e95..0a3cbedc18 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -352,25 +352,27 @@ Foam::Time::Time // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::Time::~Time() -{} +{ + // destroy function objects first + functionObjects_.clear(); +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::word Foam::Time::timeName(const scalar t) { - std::ostringstream osBuffer; - osBuffer.setf(ios_base::fmtflags(format_), ios_base::floatfield); - osBuffer.precision(precision_); - osBuffer << t; - return osBuffer.str(); + std::ostringstream buf; + buf.setf(ios_base::fmtflags(format_), ios_base::floatfield); + buf.precision(precision_); + buf << t; + return buf.str(); } Foam::word Foam::Time::timeName() const { return dimensionedScalar::name(); - //return timeName(timeOutputValue()); } @@ -432,7 +434,7 @@ Foam::instant Foam::Time::findClosestTime(const scalar t) const return times[nearestIndex]; } -// + // This should work too, // if we don't worry about checking "constant" explicitly // @@ -490,9 +492,28 @@ bool Foam::Time::run() const { bool running = value() < (endTime_ - 0.5*deltaT_); - if (!subCycling_ && !running && timeIndex_ != startTimeIndex_) + if (!subCycling_) { - const_cast(functionObjects_).execute(); + // only execute when the condition is no longer true + // ie, when exiting the control loop + if (!running && timeIndex_ != startTimeIndex_) + { + // Note, end() also calls an indirect start() as required + functionObjects_.end(); + } + } + + return running; +} + + +bool Foam::Time::loop() +{ + bool running = run(); + + if (running) + { + operator++(); } return running; @@ -501,7 +522,7 @@ bool Foam::Time::run() const bool Foam::Time::end() const { - return (value() > (endTime_ + 0.5*deltaT_)); + return value() > (endTime_ + 0.5*deltaT_); } @@ -611,9 +632,7 @@ Foam::Time& Foam::Time::operator+=(const dimensionedScalar& deltaT) Foam::Time& Foam::Time::operator+=(const scalar deltaT) { setDeltaT(deltaT); - operator++(); - - return *this; + return operator++(); } @@ -643,22 +662,22 @@ Foam::Time& Foam::Time::operator++() setTime(0.0, timeIndex_); } - switch(writeControl_) + switch (writeControl_) { case wcTimeStep: - outputTime_ = !(timeIndex_%label(writeInterval_)); + outputTime_ = !(timeIndex_ % label(writeInterval_)); break; case wcRunTime: case wcAdjustableRunTime: { - label outputTimeIndex = + label outputIndex = label(((value() - startTime_) + 0.5*deltaT_)/writeInterval_); - if (outputTimeIndex > outputTimeIndex_) + if (outputIndex > outputTimeIndex_) { outputTime_ = true; - outputTimeIndex_ = outputTimeIndex; + outputTimeIndex_ = outputIndex; } else { @@ -669,13 +688,11 @@ Foam::Time& Foam::Time::operator++() case wcCpuTime: { - label outputTimeIndex = - label(elapsedCpuTime()/writeInterval_); - - if (outputTimeIndex > outputTimeIndex_) + label outputIndex = label(elapsedCpuTime()/writeInterval_); + if (outputIndex > outputTimeIndex_) { outputTime_ = true; - outputTimeIndex_ = outputTimeIndex; + outputTimeIndex_ = outputIndex; } else { @@ -686,11 +703,11 @@ Foam::Time& Foam::Time::operator++() case wcClockTime: { - label outputTimeIndex = label(elapsedClockTime()/writeInterval_); - if (outputTimeIndex > outputTimeIndex_) + label outputIndex = label(elapsedClockTime()/writeInterval_); + if (outputIndex > outputTimeIndex_) { outputTime_ = true; - outputTimeIndex_ = outputTimeIndex; + outputTimeIndex_ = outputIndex; } else { @@ -698,8 +715,9 @@ Foam::Time& Foam::Time::operator++() } } break; - }; + } + // see if endTime needs adjustment to stop at the next run()/end() check if (!end()) { if (stopAt_ == saNoWriteNow) diff --git a/src/OpenFOAM/db/Time/Time.H b/src/OpenFOAM/db/Time/Time.H index f69f11b581..261d9eb0a2 100644 --- a/src/OpenFOAM/db/Time/Time.H +++ b/src/OpenFOAM/db/Time/Time.H @@ -26,7 +26,7 @@ Class Foam::Time Description - Class to control time during FOAM simulations which is also the + Class to control time during OpenFOAM simulations that is also the top-level objectRegistry. SourceFiles @@ -109,7 +109,7 @@ protected: // Protected data - label startTimeIndex_; + label startTimeIndex_; scalar startTime_; scalar endTime_; @@ -121,10 +121,10 @@ protected: scalar writeInterval_; - label purgeWrite_; + label purgeWrite_; mutable FIFOStack previousOutputTimes_; - //- Is the time currently being sub-cycled + //- Is the time currently being sub-cycled? bool subCycling_; //- Time directory name format @@ -157,21 +157,21 @@ private: //- Default graph format word graphFormat_; - //- Is runtim modification of dictionaries allowed + //- Is runtime modification of dictionaries allowed? Switch runTimeModifiable_; //- Instantiate a dummy class to cause the reading of dynamic libraries dlLibraryTable::readDlLibrary readLibs_; //- Function objects executed at start and on ++, += - functionObjectList functionObjects_; + mutable functionObjectList functionObjects_; public: TypeName("time"); - //- The default control dictionary name + //- The default control dictionary name (normally "controlDict") static word controlDictName; @@ -282,8 +282,8 @@ public: void readModifiedObjects(); //- Return the location of "dir" containing the file "name". - // (Used in reading mesh data) - // If name is null search for the directory "dir" only + // (eg, used in reading mesh data) + // If name is null, search for the directory "dir" only word findInstance ( const fileName& dir, @@ -291,7 +291,7 @@ public: const IOobject::readOption rOpt = IOobject::MUST_READ ) const; - //- Search tha case for valid time directories + //- Search the case for valid time directories instantList times() const; //- Search the case for the time directory path @@ -307,9 +307,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 the objects now and continue the run @@ -348,10 +348,43 @@ public: // Check - //- Return true if run should continue + //- Return true if run should continue, + // also invokes the functionObjectList::end() method + // when the time goes out of range + // @note + // For correct behaviour, the following style of time-loop + // is recommended: + // @code + // while (runTime.run()) + // { + // runTime++; + // solve; + // runTime.write(); + // } + // @endcode virtual bool run() const; - //- Return true if end of run + //- Return true if run should continue and if so increment time + // also invokes the functionObjectList::end() method + // when the time goes out of range + // @note + // For correct behaviour, the following style of time-loop + // is recommended: + // @code + // while (runTime.loop()) + // { + // solve; + // runTime.write(); + // } + // @endcode + virtual bool loop(); + + //- Return true if end of run, + // does not invoke any functionObject methods + // @note + // The rounding heuristics near endTime mean that + // @code run() @endcode and @code !end() @endcode may + // not yield the same result virtual bool end() const; @@ -400,16 +433,18 @@ public: // Member operators - //- Set deltaT to that specified and increment time + //- Set deltaT to that specified and increment time via operator++() virtual Time& operator+=(const dimensionedScalar&); - //- Set deltaT to that specified and increment time + //- Set deltaT to that specified and increment time via operator++() virtual Time& operator+=(const scalar); - //- Prefix increment + //- Prefix increment, + // also invokes the functionObjectList::start() or + // functionObjectList::execute() method, depending on the time-index virtual Time& operator++(); - //- Postfix increment + //- Postfix increment, this is identical to the prefix increment virtual Time& operator++(int); }; diff --git a/src/OpenFOAM/db/Time/TimeIO.C b/src/OpenFOAM/db/Time/TimeIO.C index 1f1df0507e..58197b520e 100644 --- a/src/OpenFOAM/db/Time/TimeIO.C +++ b/src/OpenFOAM/db/Time/TimeIO.C @@ -61,7 +61,7 @@ void Foam::Time::readDict() if (oldWriteInterval != writeInterval_) { - switch(writeControl_) + switch (writeControl_) { case wcRunTime: case wcAdjustableRunTime: @@ -180,11 +180,7 @@ void Foam::Time::readDict() } controlDict_.readIfPresent("graphFormat", graphFormat_); - - if (controlDict_.found("runTimeModifiable")) - { - runTimeModifiable_ = Switch(controlDict_.lookup("runTimeModifiable")); - } + controlDict_.readIfPresent("runTimeModifiable", runTimeModifiable_); } @@ -268,25 +264,14 @@ bool Foam::Time::writeObject timeDict.add("deltaT", deltaT_); timeDict.add("deltaT0", deltaT0_); - timeDict.regIOobject::writeObject - ( - fmt, - ver, - cmp - ); - - bool writeOK = objectRegistry::writeObject - ( - fmt, - ver, - cmp - ); + timeDict.regIOobject::writeObject(fmt, ver, cmp); + bool writeOK = objectRegistry::writeObject(fmt, ver, cmp); if (writeOK && purgeWrite_) { previousOutputTimes_.push(timeName()); - while(previousOutputTimes_.size() > purgeWrite_) + while (previousOutputTimes_.size() > purgeWrite_) { rmDir(objectRegistry::path(previousOutputTimes_.pop())); } @@ -310,7 +295,7 @@ bool Foam::Time::writeNow() bool Foam::Time::writeAndEnd() { - stopAt_ = saWriteNow; + stopAt_ = saWriteNow; endTime_ = value(); return writeNow(); diff --git a/src/OpenFOAM/db/Time/subCycleTime.H b/src/OpenFOAM/db/Time/subCycleTime.H index 8081edbb17..01082625fb 100644 --- a/src/OpenFOAM/db/Time/subCycleTime.H +++ b/src/OpenFOAM/db/Time/subCycleTime.H @@ -44,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class subCycleTimeTime Declaration + Class subCycleTime Declaration \*---------------------------------------------------------------------------*/ class subCycleTime @@ -62,7 +62,7 @@ public: // Constructors //- Construct from original time and number of sub-cycles - subCycleTime(Time& t, const label nSubCycles); + subCycleTime(Time&, const label nSubCycles); // Destructor @@ -72,6 +72,7 @@ public: // Member functions + //- Return true if the number of sub-cycles has been reached bool end() const; //- End the sub-cycling and reset the time-state diff --git a/src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.C b/src/OpenFOAM/db/functionObjects/IOOutputFilter/IOOutputFilter.C similarity index 100% rename from src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.C rename to src/OpenFOAM/db/functionObjects/IOOutputFilter/IOOutputFilter.C diff --git a/src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.H b/src/OpenFOAM/db/functionObjects/IOOutputFilter/IOOutputFilter.H similarity index 100% rename from src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.H rename to src/OpenFOAM/db/functionObjects/IOOutputFilter/IOOutputFilter.H diff --git a/src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.C b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C similarity index 93% rename from src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.C rename to src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C index 45305257e9..15a32c1e8e 100644 --- a/src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.C +++ b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C @@ -65,6 +65,20 @@ Foam::OutputFilterFunctionObject::OutputFilterFunctionObject // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template +void Foam::OutputFilterFunctionObject::on() +{ + enabled_ = true; +} + + +template +void Foam::OutputFilterFunctionObject::off() +{ + enabled_ = false; +} + + template bool Foam::OutputFilterFunctionObject::start() { @@ -120,16 +134,19 @@ bool Foam::OutputFilterFunctionObject::execute() template -void Foam::OutputFilterFunctionObject::on() +bool Foam::OutputFilterFunctionObject::end() { - enabled_ = true; -} + if (enabled_) + { + ptr_->end(); + if (enabled_ && outputControl_.output()) + { + ptr_->write(); + } + } -template -void Foam::OutputFilterFunctionObject::off() -{ - enabled_ = false; + return true; } diff --git a/src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.H b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H similarity index 89% rename from src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.H rename to src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H index 7800d764a6..5ab4ebbece 100644 --- a/src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.H +++ b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H @@ -53,7 +53,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class OutputFilterFunctionObject Declaration + Class OutputFilterFunctionObject Declaration \*---------------------------------------------------------------------------*/ template @@ -69,7 +69,7 @@ class OutputFilterFunctionObject word regionName_; word dictName_; - //- Switch for the execution of the functionObjects + //- Switch for the execution of the functionObject bool enabled_; outputFilterOutputControl outputControl_; @@ -114,20 +114,25 @@ public: return name_; } - //- start is called at the start of the time-loop - virtual bool start(); - - //- execute is called at each ++ or += of the time-loop - virtual bool execute(); - //- Switch the function object on virtual void on(); //- Switch the function object off virtual void off(); - //- Read and set the function object if its data has changed - virtual bool read(const dictionary& dict); + + //- Called at the start of the time-loop + virtual bool start(); + + //- Called at each ++ or += of the time-loop + virtual bool execute(); + + //- Called when Time::run() determines that the time-loop exits + virtual bool end(); + + + //- Read and set the function object if its data have changed + virtual bool read(const dictionary&); }; diff --git a/src/OpenFOAM/db/functionObject/functionObject.C b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C similarity index 84% rename from src/OpenFOAM/db/functionObject/functionObject.C rename to src/OpenFOAM/db/functionObjects/functionObject/functionObject.C index c7eb279303..a731621ff6 100644 --- a/src/OpenFOAM/db/functionObject/functionObject.C +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C @@ -30,11 +30,8 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -namespace Foam -{ - defineRunTimeSelectionTable(functionObject, dictionary); - int functionObject::debug(::Foam::debug::debugSwitch("functionObject", 0)); -} +defineRunTimeSelectionTable(Foam::functionObject, dictionary); +int Foam::functionObject::debug(Foam::debug::debugSwitch("functionObject", 0)); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -71,10 +68,10 @@ Foam::autoPtr Foam::functionObject::New FatalErrorIn ( "functionObject::New" - "(const word& functionType, const Time&, const dictionary&)" + "(const word& name, const Time&, const dictionary&)" ) << "Unknown function type " - << functionType << endl << endl - << "Table of functionObjects is empty" + << functionType << nl << nl + << "Table of functionObjects is empty" << endl << exit(FatalError); } @@ -86,11 +83,11 @@ Foam::autoPtr Foam::functionObject::New FatalErrorIn ( "functionObject::New" - "(const word& functionType, const Time&, const dictionary&)" + "(const word& name, const Time&, const dictionary&)" ) << "Unknown function type " - << functionType << endl << endl - << "Valid functions are : " << endl - << dictionaryConstructorTablePtr_->toc() + << functionType << nl << nl + << "Valid functions are : " << nl + << dictionaryConstructorTablePtr_->toc() << endl << exit(FatalError); } @@ -106,6 +103,12 @@ Foam::functionObject::~functionObject() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +bool Foam::functionObject::end() +{ + return execute(); +} + + Foam::autoPtr Foam::functionObject::iNew::operator() ( const word& name, diff --git a/src/OpenFOAM/db/functionObject/functionObject.H b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H similarity index 89% rename from src/OpenFOAM/db/functionObject/functionObject.H rename to src/OpenFOAM/db/functionObjects/functionObject/functionObject.H index 72bf1b166c..94a2f7aea4 100644 --- a/src/OpenFOAM/db/functionObject/functionObject.H +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H @@ -121,7 +121,7 @@ public: // Selectors - //- Select from Time and Istream + //- Select from dictionary, based on its "type" entry static autoPtr New ( const word& name, @@ -137,14 +137,18 @@ public: // Member Functions - //- start is called at the start of the time-loop + //- Called at the start of the time-loop virtual bool start() = 0; - //- execute is called at each ++ or += of the time-loop + //- Called at each ++ or += of the time-loop virtual bool execute() = 0; - //- Read and set the function object if its data has changed - virtual bool read(const dictionary& dict) = 0; + //- Called when Time::run() determines that the time-loop exits. + // By default it simply calls execute(). + virtual bool end(); + + //- Read and set the function object if its data have changed + virtual bool read(const dictionary&) = 0; }; diff --git a/src/OpenFOAM/db/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C similarity index 68% rename from src/OpenFOAM/db/functionObjectList/functionObjectList.C rename to src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index 00f6131547..0e52db7fc7 100644 --- a/src/OpenFOAM/db/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -29,7 +29,8 @@ License // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // -Foam::functionObject* Foam::functionObjectList::remove(const word& key) +Foam::functionObject* +Foam::functionObjectList::remove(const word& key, label& oldIndex) { functionObject* ptr = 0; @@ -38,10 +39,16 @@ Foam::functionObject* Foam::functionObjectList::remove(const word& key) if (fnd != indices_.end()) { - // remove the pointer from the old list - ptr = functions_.set(fnd(), 0).ptr(); + oldIndex = fnd(); + + // retrieve the pointer and remove it from the old list + ptr = this->set(oldIndex, 0).ptr(); indices_.erase(fnd); } + else + { + oldIndex = -1; + } return ptr; } @@ -55,7 +62,8 @@ Foam::functionObjectList::functionObjectList const bool execution ) : - functions_(), + PtrList(), + digests_(), indices_(), time_(t), parentDict_(t.controlDict()), @@ -71,7 +79,8 @@ Foam::functionObjectList::functionObjectList const bool execution ) : - functions_(), + PtrList(), + digests_(), indices_(), time_(t), parentDict_(parentDict), @@ -88,6 +97,34 @@ Foam::functionObjectList::~functionObjectList() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void Foam::functionObjectList::clear() +{ + PtrList::clear(); + digests_.clear(); + indices_.clear(); + updated_ = false; +} + + +void Foam::functionObjectList::on() +{ + execution_ = true; +} + + +void Foam::functionObjectList::off() +{ + // for safety, also force a read() when execution is turned back on + updated_ = execution_ = false; +} + + +bool Foam::functionObjectList::status() const +{ + return execution_; +} + + bool Foam::functionObjectList::start() { return read(); @@ -105,7 +142,12 @@ bool Foam::functionObjectList::execute() read(); } - forAllIter(PtrList, functions_, iter) + forAllIter + ( + PtrList, + static_cast&>(*this), + iter + ) { ok = iter().execute() && ok; } @@ -115,15 +157,29 @@ bool Foam::functionObjectList::execute() } -void Foam::functionObjectList::on() +bool Foam::functionObjectList::end() { - execution_ = true; -} + bool ok = true; + if (execution_) + { + if (!updated_) + { + read(); + } -void Foam::functionObjectList::off() -{ - execution_ = false; + forAllIter + ( + PtrList, + static_cast&>(*this), + iter + ) + { + ok = iter().end() && ok; + } + } + + return ok; } @@ -143,6 +199,7 @@ bool Foam::functionObjectList::read() if (entryPtr) { PtrList newPtrs; + List newDigs; HashTable