CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   save the last timestep (https://www.cfd-online.com/Forums/openfoam/87732-save-last-timestep.html)

pit April 27, 2011 18:44

save the last timestep
 
Hi, I have only a short question. Is it possible to save the timestep before foam shut down? I have a long calculation with adjustable timestep and long write intervals. The 'purgeWrite' option doesen't work well for me. Thanks and best regards

mturcios777 April 27, 2011 19:06

When does your simulation end? If you know how long you are going to run it, then you just need to match your interval in such a way you get an integer number of steps. Otherwise you need to add

Code:

runTime.writeNow()
to the solver, just before the
Code:

return 0;
statment ending the simulation.

tonyuprm April 28, 2011 23:19

In your system/controlDict you can use:

stopAt writeNow;

This will stop and write your fields. Hope this helps.

mabinty November 28, 2011 09:24

dear all!

i have to stop my simulation and write the current time step after a pre-specified ClockTime -> clockTimeLimit. For this task I used the runTime.writeAndEnd() function in the main while-loop of the solver:

Code:

while (runTime.run())
{
        .
        .
        .

        runTime.write();

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;

    if(runTime.elapsedClockTime() >= clockTimeLimit)
    {
            Info<< "  Time limit reached." << nl
                  << "  Stop simulation and write current time step."
                  << nl << endl;

        runTime.writeAndEnd();
    }
}

The code works in serial but causes problem in parallel: at the moment the runTime.writeAndEnd() is executed the solver hangs and does nothing, no output in the log-file.

Does somebody have an idea what is going wrong here?

Thanks in advance!

Cheers,
Aram

mabinty November 28, 2011 13:18

hi!

i changed the code and now it seems to work in parallel:

Code:

    scalar clockTime = runTime.elapsedClockTime();
    reduce(clockTime, sumOp<scalar>());

    if(clockTime/Pstream::nProcs() >= clockTimeLimit)
    {
            Info<< "  CPU time limit " << clockTimeLimit << " s reached." << nl
                << "  Stop simulation and write current time step."
                << nl << endl;

            runTime.writeAndEnd();
    }

cheers,
aram


All times are GMT -4. The time now is 08:45.