Commit aa671090 authored by henry's avatar henry
Browse files

Added Time::loop() to allow the

while(runTime.loop())
{
...
}

idiom.

Demonstrated in the shallowWaterFoam solver.
parent fcd4e88e
......@@ -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"
......
......@@ -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_);
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment