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/buoyantBoussinesqFoam/Make/files b/applications/solvers/heatTransfer/buoyantBoussinesqFoam/Make/files deleted file mode 100644 index d6a7819c0e..0000000000 --- a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -buoyantBoussinesqFoam.C - -EXE = $(FOAM_APPBIN)/buoyantBoussinesqFoam diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/Make/files b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/Make/files new file mode 100644 index 0000000000..d7b85221d8 --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/Make/files @@ -0,0 +1,3 @@ +buoyantBoussinesqPisoFoam.C + +EXE = $(FOAM_APPBIN)/buoyantBoussinesqPisoFoam diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/Make/options b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/Make/options similarity index 100% rename from applications/solvers/heatTransfer/buoyantBoussinesqFoam/Make/options rename to applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/Make/options diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/TEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/TEqn.H similarity index 100% rename from applications/solvers/heatTransfer/buoyantBoussinesqFoam/TEqn.H rename to applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/TEqn.H diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/UEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/UEqn.H similarity index 100% rename from applications/solvers/heatTransfer/buoyantBoussinesqFoam/UEqn.H rename to applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/UEqn.H diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/buoyantBoussinesqFoam.C b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C similarity index 95% rename from applications/solvers/heatTransfer/buoyantBoussinesqFoam/buoyantBoussinesqFoam.C rename to applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C index 72aab39ac0..1a9f023253 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/buoyantBoussinesqFoam.C +++ b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C @@ -23,10 +23,10 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - buoyantBoussinesqSimpleFoam + buoyantBoussinesqPisoFoam Description - Steady-state solver for buoyant, turbulent flow of incompressible fluids + Transient solver for buoyant, turbulent flow of incompressible fluids Uses the Boussinesq approximation: \f[ @@ -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/buoyantBoussinesqFoam/createFields.H b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/createFields.H similarity index 100% rename from applications/solvers/heatTransfer/buoyantBoussinesqFoam/createFields.H rename to applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/createFields.H diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/pdEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/pdEqn.H similarity index 100% rename from applications/solvers/heatTransfer/buoyantBoussinesqFoam/pdEqn.H rename to applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/pdEqn.H diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/readTransportProperties.H b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/readTransportProperties.H similarity index 100% rename from applications/solvers/heatTransfer/buoyantBoussinesqFoam/readTransportProperties.H rename to applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/readTransportProperties.H diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqFoam/writeAdditionalFields.H b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/writeAdditionalFields.H similarity index 100% rename from applications/solvers/heatTransfer/buoyantBoussinesqFoam/writeAdditionalFields.H rename to applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/writeAdditionalFields.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/buoyantFoam/Make/files b/applications/solvers/heatTransfer/buoyantFoam/Make/files deleted file mode 100644 index fccde862b2..0000000000 --- a/applications/solvers/heatTransfer/buoyantFoam/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -buoyantFoam.C - -EXE = $(FOAM_APPBIN)/buoyantFoam diff --git a/applications/solvers/heatTransfer/buoyantPisoFoam/Make/files b/applications/solvers/heatTransfer/buoyantPisoFoam/Make/files new file mode 100644 index 0000000000..65e5d52305 --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantPisoFoam/Make/files @@ -0,0 +1,3 @@ +buoyantPisoFoam.C + +EXE = $(FOAM_APPBIN)/buoyantPisoFoam diff --git a/applications/solvers/heatTransfer/buoyantFoam/Make/options b/applications/solvers/heatTransfer/buoyantPisoFoam/Make/options similarity index 100% rename from applications/solvers/heatTransfer/buoyantFoam/Make/options rename to applications/solvers/heatTransfer/buoyantPisoFoam/Make/options diff --git a/applications/solvers/heatTransfer/buoyantFoam/UEqn.H b/applications/solvers/heatTransfer/buoyantPisoFoam/UEqn.H similarity index 100% rename from applications/solvers/heatTransfer/buoyantFoam/UEqn.H rename to applications/solvers/heatTransfer/buoyantPisoFoam/UEqn.H diff --git a/applications/solvers/heatTransfer/buoyantFoam/buoyantFoam.C b/applications/solvers/heatTransfer/buoyantPisoFoam/buoyantPisoFoam.C similarity index 99% rename from applications/solvers/heatTransfer/buoyantFoam/buoyantFoam.C rename to applications/solvers/heatTransfer/buoyantPisoFoam/buoyantPisoFoam.C index 75eb401d3d..18dadabf8b 100644 --- a/applications/solvers/heatTransfer/buoyantFoam/buoyantFoam.C +++ b/applications/solvers/heatTransfer/buoyantPisoFoam/buoyantPisoFoam.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - buoyantFoam + buoyantPisoFoam Description Transient Solver for buoyant, turbulent flow of compressible fluids for diff --git a/applications/solvers/heatTransfer/buoyantFoam/createFields.H b/applications/solvers/heatTransfer/buoyantPisoFoam/createFields.H similarity index 100% rename from applications/solvers/heatTransfer/buoyantFoam/createFields.H rename to applications/solvers/heatTransfer/buoyantPisoFoam/createFields.H diff --git a/applications/solvers/heatTransfer/buoyantFoam/hEqn.H b/applications/solvers/heatTransfer/buoyantPisoFoam/hEqn.H similarity index 100% rename from applications/solvers/heatTransfer/buoyantFoam/hEqn.H rename to applications/solvers/heatTransfer/buoyantPisoFoam/hEqn.H diff --git a/applications/solvers/heatTransfer/buoyantFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantPisoFoam/pEqn.H similarity index 100% rename from applications/solvers/heatTransfer/buoyantFoam/pEqn.H rename to applications/solvers/heatTransfer/buoyantPisoFoam/pEqn.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/simpleFoam/simpleFoam.C b/applications/solvers/incompressible/simpleFoam/simpleFoam.C index d5b99e33ea..ec0515aa19 100644 --- a/applications/solvers/incompressible/simpleFoam/simpleFoam.C +++ b/applications/solvers/incompressible/simpleFoam/simpleFoam.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/multiphase/bubbleFoam/bubbleFoam.C b/applications/solvers/multiphase/bubbleFoam/bubbleFoam.C index 4344f5d471..4a6f845fd8 100644 --- a/applications/solvers/multiphase/bubbleFoam/bubbleFoam.C +++ b/applications/solvers/multiphase/bubbleFoam/bubbleFoam.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.timeName() << nl << endl; # include "readBubbleFoamControls.H" diff --git a/applications/solvers/multiphase/settlingFoam/settlingFoam.C b/applications/solvers/multiphase/settlingFoam/settlingFoam.C index 70fe56a37c..a43dd5408b 100644 --- a/applications/solvers/multiphase/settlingFoam/settlingFoam.C +++ b/applications/solvers/multiphase/settlingFoam/settlingFoam.C @@ -57,8 +57,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/multiphase/twoLiquidMixingFoam/twoLiquidMixingFoam.C b/applications/solvers/multiphase/twoLiquidMixingFoam/twoLiquidMixingFoam.C index 6501f24a50..dbc8b2774f 100644 --- a/applications/solvers/multiphase/twoLiquidMixingFoam/twoLiquidMixingFoam.C +++ b/applications/solvers/multiphase/twoLiquidMixingFoam/twoLiquidMixingFoam.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/stressAnalysis/solidDisplacementFoam/solidDisplacementFoam.C b/applications/solvers/stressAnalysis/solidDisplacementFoam/solidDisplacementFoam.C index 4405652cd4..afa3c66001 100644 --- a/applications/solvers/stressAnalysis/solidDisplacementFoam/solidDisplacementFoam.C +++ b/applications/solvers/stressAnalysis/solidDisplacementFoam/solidDisplacementFoam.C @@ -57,8 +57,9 @@ int main(int argc, char *argv[]) Info<< "\nCalculating displacement field\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; Info<< "Iteration: " << runTime.value() << nl << endl; # include "readSolidDisplacementFoamControls.H" diff --git a/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/solidEquilibriumDisplacementFoam.C b/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/solidEquilibriumDisplacementFoam.C index f0f93112b9..00a98b2531 100644 --- a/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/solidEquilibriumDisplacementFoam.C +++ b/applications/solvers/stressAnalysis/solidEquilibriumDisplacementFoam/solidEquilibriumDisplacementFoam.C @@ -55,8 +55,9 @@ int main(int argc, char *argv[]) Info<< "\nCalculating displacement field\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + runTime++; Info<< "Iteration: " << runTime.value() << nl << endl; # include "readSteadyStressFoamControls.H" diff --git a/applications/test/LduMatrix/LduMatrixTest3.C b/applications/test/LduMatrix/LduMatrixTest3.C index 18f3a7391f..729bc59329 100644 --- a/applications/test/LduMatrix/LduMatrixTest3.C +++ b/applications/test/LduMatrix/LduMatrixTest3.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.timeName() << nl << endl; # include "readPISOControls.H" diff --git a/applications/test/nearWallDist-wave/testWallDist2.C b/applications/test/nearWallDist-wave/testWallDist2.C index c84b7fb118..304cdba3d6 100644 --- a/applications/test/nearWallDist-wave/testWallDist2.C +++ b/applications/test/nearWallDist-wave/testWallDist2.C @@ -120,8 +120,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() << endl; diff --git a/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C b/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C index 1e2ec46744..64d65e3aff 100644 --- a/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C +++ b/applications/utilities/mesh/manipulation/moveDynamicMesh/moveDynamicMesh.C @@ -46,8 +46,9 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createDynamicFvMesh.H" - for (runTime++; !runTime.end(); runTime++) + while (runTime.run()) { + 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 75cd8ef583..a10782b553 100644 --- a/applications/utilities/mesh/manipulation/moveEngineMesh/moveEngineMesh.C +++ b/applications/utilities/mesh/manipulation/moveEngineMesh/moveEngineMesh.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.theta() << " CA-deg\n" << endl; mesh.move(); diff --git a/applications/utilities/mesh/manipulation/moveMesh/moveMesh.C b/applications/utilities/mesh/manipulation/moveMesh/moveMesh.C index da82839b1b..82e6e45a75 100644 --- a/applications/utilities/mesh/manipulation/moveMesh/moveMesh.C +++ b/applications/utilities/mesh/manipulation/moveMesh/moveMesh.C @@ -46,8 +46,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() << 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..f52303220f 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,15 @@ 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; @@ -501,7 +509,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 +619,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 +649,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 +675,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 +690,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 +702,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..70f6985b41 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,28 @@ 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 baheviour, 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 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 +418,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