diff --git a/applications/solvers/incompressible/shallowWaterFoam/shallowWaterFoam.C b/applications/solvers/incompressible/shallowWaterFoam/shallowWaterFoam.C index 5a031c6352393ce88b9fd47a3d0f46d343dab331..4b9c23118070f37851e2c0b3f489ef9957ed6290 100644 --- a/applications/solvers/incompressible/shallowWaterFoam/shallowWaterFoam.C +++ b/applications/solvers/incompressible/shallowWaterFoam/shallowWaterFoam.C @@ -48,10 +48,8 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (runTime.loop()) { - runTime++; - Info<< "\n Time = " << runTime.timeName() << nl << endl; #include "readPISOControls.H" diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index f52303220f27347e315f1acffa61c5f7676925a0..0a3cbedc187b59c2dd02dacb156638662ea190d2 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -507,6 +507,19 @@ bool Foam::Time::run() const } +bool Foam::Time::loop() +{ + bool running = run(); + + if (running) + { + operator++(); + } + + return running; +} + + bool Foam::Time::end() const { return value() > (endTime_ + 0.5*deltaT_); diff --git a/src/OpenFOAM/db/Time/Time.H b/src/OpenFOAM/db/Time/Time.H index 70f6985b4142b349cca2ca2a9971fafe6e93268e..261d9eb0a2387497147a7c4ea364465a8dd79b4e 100644 --- a/src/OpenFOAM/db/Time/Time.H +++ b/src/OpenFOAM/db/Time/Time.H @@ -352,7 +352,7 @@ public: // also invokes the functionObjectList::end() method // when the time goes out of range // @note - // For correct baheviour, the following style of time-loop + // For correct behaviour, the following style of time-loop // is recommended: // @code // while (runTime.run()) @@ -364,6 +364,21 @@ public: // @endcode virtual bool run() const; + //- 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