Added Time::loop() to allow the

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

idiom.

Demonstrated in the shallowWaterFoam solver.
This commit is contained in:
henry
2009-02-17 22:00:59 +00:00
parent fcd4e88e0e
commit aa6710901e
3 changed files with 30 additions and 4 deletions

View File

@ -48,10 +48,8 @@ int main(int argc, char *argv[])
Info<< "\nStarting time loop\n" << endl; Info<< "\nStarting time loop\n" << endl;
while (runTime.run()) while (runTime.loop())
{ {
runTime++;
Info<< "\n Time = " << runTime.timeName() << nl << endl; Info<< "\n Time = " << runTime.timeName() << nl << endl;
#include "readPISOControls.H" #include "readPISOControls.H"

View File

@ -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 bool Foam::Time::end() const
{ {
return value() > (endTime_ + 0.5*deltaT_); return value() > (endTime_ + 0.5*deltaT_);

View File

@ -352,7 +352,7 @@ public:
// also invokes the functionObjectList::end() method // also invokes the functionObjectList::end() method
// when the time goes out of range // when the time goes out of range
// @note // @note
// For correct baheviour, the following style of time-loop // For correct behaviour, the following style of time-loop
// is recommended: // is recommended:
// @code // @code
// while (runTime.run()) // while (runTime.run())
@ -364,6 +364,21 @@ public:
// @endcode // @endcode
virtual bool run() const; 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, //- Return true if end of run,
// does not invoke any functionObject methods // does not invoke any functionObject methods
// @note // @note