mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
change solvers, utilities, etc. to use while (..) time-looping idiom
- this (now deprecated) idiom:
for (runTime++; !runTime.end(); runTime++) { ... }
has a few problems:
* stop-on-next-write will be off-by-one (ie, doesn't work)
* function objects are not executed on exit with runTime.end()
Fixing these problems is not really possible.
- this idiom
while (runTime.run())
{
runTime++;
...
}
works without the above problems.
This commit is contained in:
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -52,8 +52,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
autoPtr<Foam::motionSolver> motionPtr = motionSolver::New(mesh);
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
#include "readPISOControls.H"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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"
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -64,7 +64,7 @@ int main(int argc, char *argv[])
|
||||
# include "setInitialDeltaT.H"
|
||||
}
|
||||
|
||||
while(runTime.run())
|
||||
while (runTime.run())
|
||||
{
|
||||
# include "readTimeControls.H"
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -46,8 +46,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
autoPtr<Foam::motionSolver> motionPtr = motionSolver::New(mesh);
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
|
||||
mesh.movePoints(motionPtr->newPoints());
|
||||
|
||||
@ -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 "readSIMPLEControls.H"
|
||||
|
||||
@ -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"
|
||||
|
||||
Reference in New Issue
Block a user