CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Can we restart the simulation from a different time in OpenFoam (http://www.cfd-online.com/Forums/openfoam/80119-can-we-restart-simulation-different-time-openfoam.html)

nandiganavishal September 15, 2010 22:57

Can we restart the simulation from a different time in OpenFoam
 
Dear Foamers,

I was running a simulation till a particular time period, but found that the steady state was not reached. I would like to know, whether I have to rerun my simulations again from the beginning or is it possible to start the simulations from the point where I stopped as the starting value. I was trying to implement this by changing the starting value in controlDict file, but couldnt be of any use. I would appreciate if you guys can throw your suggestions.

Thanks

Vishal

santiagomarquezd September 15, 2010 23:39

Yes, it is possible use latestTime in stead of startTime in system/controDict. This info is available in User's Guide.

Regards.

nandiganavishal September 16, 2010 00:44

Dear Santiago,

Thanks for the reply. I did change it in my control dict, but still get the same error.

My controlDict initial few lines

application eofFoam;

startFrom latestTime;

latestTime 3e6;

stopAt endTime;

endTime 6e6;

deltaT 200;

writeControl timeStep;

writeInterval 10000;

purgeWrite 0;

writeFormat ascii;

writePrecision 6;

writeCompression uncompressed;

timeFormat general;

timePrecision 6;

runTimeModifiable yes;


Error message:

Create time

Create mesh for time = 3e+06

Reading field C1 (A)



compound has already been transfered from token
on line 39689 the empty compound of type List<scalar>#0 Foam::error::printStack(Foam::Ostream&) in "/home/vishal/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#1 Foam::error::abort() in "/home/vishal/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#2 Foam::token::transferCompoundToken() in "/home/vishal/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#3 Foam::Istream& Foam::operator>><double>(Foam::Istream&, Foam::List<double>&) in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#4 Foam::Field<double>::Field(Foam::word const&, Foam::dictionary const&, int) in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#5 Foam::zeroIonFluxFvPatchScalarField::zeroIonFluxFv PatchScalarField(Foam::fvPatch const&, Foam::DimensionedField<double, Foam::volMesh> const&, Foam::dictionary const&) in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#6 Foam::fvPatchField<double>::adddictionaryConstruct orToTable<Foam::zeroIonFluxFvPatchScalarField>::Ne w(Foam::fvPatch const&, Foam::DimensionedField<double, Foam::volMesh> const&, Foam::dictionary const&) in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#7 Foam::fvPatchField<double>::New(Foam::fvPatch const&, Foam::DimensionedField<double, Foam::volMesh> const&, Foam::dictionary const&) in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#8 Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField::GeometricB oundaryField(Foam::fvBoundaryMesh const&, Foam::DimensionedField<double, Foam::volMesh> const&, Foam::dictionary const&) in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#9 Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::readField(Foam::Istream&) in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#10 Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::fvMesh const&) in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#11 main in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#12 __libc_start_main in "/lib/tls/i686/cmov/libc.so.6"
#13 Foam::regIOobject::readIfModified() in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"


From function token::transferCompoundToken()
in file lnInclude/token.C at line 96.

FOAM aborting

Aborted

Kindly let me know where I am making an error.

Regards

Vishal

olesen September 16, 2010 02:31

Quote:

Originally Posted by nandiganavishal (Post 275375)
Dear Santiago,

Thanks for the reply. I did change it in my control dict, but still get the same error.

My controlDict initial few lines

startFrom latestTime;
latestTime 3e6;
stopAt endTime;
endTime 6e6;

...
Kindly let me know where I am making an error.

With the entry
Code:


startFrom latestTime;

the latest time step available on the disk will be used.
Note that this is also the default if the keyword "startFrom" is missing.
With this option, you'd simply remove any later results, this will do what you want.

The entry
Code:


latestTime 3e6;

has no meaning and will be ignored.

Note, you could also use another alterative combination. For example,
Code:


startFrom startTime;
startTime 1000;

to specify that the calculation should start (or restart) from iteration 1000. However, I generally find it easier to remove the old results via the command-line and use the default startFrom latestTime.

Beyond that I'm not sure what other problem you are encountering.

nandiganavishal September 18, 2010 17:07

Dear Santiago

I did try your suggestion again but still get the same error. I would check with the tutorial codes and see if the cavity foam wrks or not. Further, I would like to know if I use probes function to calculate variation a variable with time, is it possible to start dumping the values from a particular start and stop time rather than from time t =0.

Kindly throw some light on this. I was searchin this in openFOAM tutorials and other forums but couldn't get any concrete answer.

Regards

Vishal

Linse September 20, 2010 09:30

I do not know if it is connected to your error message, but:
I did some restarts of different cases. If I restarted from the alst timestep, sometimes some data was missing. Usually everything went fine as soon as I used the last BUT ONE timestep as restarting step.

Perhaps it works if you try to restart from 2.99e6 or another value you still have stored inside the simulation folder?

nandiganavishal September 20, 2010 11:31

Thanks for the reply Linse, I would try that and would let you know!!

nandiganavishal October 10, 2010 15:11

Dear Foamers,

I did try again to start the simulation from the latest time but still end up with the same error. I was able to run the cavity foam example and it was working fine for that case.

Here is a part of my controldict file

application eofFoam;

startFrom latestTime;

latestTime 100;

stopAt endTime;

endTime 200;

deltaT 100;

writeControl runTime;

writeInterval 100;

purgeWrite 0;

writeFormat ascii;

writePrecision 6;

writeCompression uncompressed;

timeFormat general;

timePrecision 6;

runTimeModifiable yes;

I notice that simulation is starting from 100 (initial time) and not from 200 (as deltaT is 100 and latest time is 100).

Here is the error message

Create time

Create mesh for time = 100

Reading field C1 (A)



compound has already been transfered from token
on line 39689 the empty compound of type List<scalar>#0 Foam::error::printStack(Foam::Ostream&) in "/home/vishal/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#1 Foam::error::abort() in "/home/vishal/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#2 Foam::token::transferCompoundToken() in "/home/vishal/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so"
#3 Foam::Istream& Foam::operator>><double>(Foam::Istream&, Foam::List<double>&) in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#4 Foam::Field<double>::Field(Foam::word const&, Foam::dictionary const&, int) in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#5 Foam::zeroIonFluxFvPatchScalarField::zeroIonFluxFv PatchScalarField(Foam::fvPatch const&, Foam::DimensionedField<double, Foam::volMesh> const&, Foam::dictionary const&) in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#6 Foam::fvPatchField<double>::adddictionaryConstruct orToTable<Foam::zeroIonFluxFvPatchScalarField>::Ne w(Foam::fvPatch const&, Foam::DimensionedField<double, Foam::volMesh> const&, Foam::dictionary const&) in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#7 Foam::fvPatchField<double>::New(Foam::fvPatch const&, Foam::DimensionedField<double, Foam::volMesh> const&, Foam::dictionary const&) in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#8 Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField::GeometricB oundaryField(Foam::fvBoundaryMesh const&, Foam::DimensionedField<double, Foam::volMesh> const&, Foam::dictionary const&) in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#9 Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::readField(Foam::Istream&) in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#10 Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject const&, Foam::fvMesh const&) in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#11 main in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"
#12 __libc_start_main in "/lib/tls/i686/cmov/libc.so.6"
#13 Foam::regIOobject::readIfModified() in "/home/vishal/OpenFOAM/vishal-1.5/applications/bin/linuxGccDPOpt/eofFoam"


From function token::transferCompoundToken()
in file lnInclude/token.C at line 96.

FOAM aborting

Kindly can anyone provide some help.

Thanks

Regards

Vishal Nandigana

anfho March 7, 2011 16:34

Hi,
notheless this thread is almost six months old, I wanted to add and clarify that if you are using OF1.7.x, it is not necessary to specify the latestTime per sae. If OF1.7.x is restarted and

startFrom latestTime;

is specified it will always start from the last solution written in the case folder (either at time 0 or at time latestTime).

My controlDict looks like this and is able to restart at any time:

Code:


application    fireFoam;
startFrom      latestTime;
startTime      0.0;
stopAt          endTime;
endTime        10.0;
deltaT          0.001;

Regards, Andreas

nandiganavishal March 7, 2011 16:57

Thanks Andreas. I was able to solve that issue..

Regards
Vishal

akidess March 9, 2011 12:37

Quote:

Originally Posted by nandiganavishal (Post 298315)
Thanks Andreas. I was able to solve that issue..

It might help other people if you add a post providing details how you solved your problem.

benk March 9, 2011 13:49

Is there an easy way to revert back to an old time during runtime (ie. while the solver is running)?

This way if my solver is becoming unstable due to a time step that is too large, I can go back to the last successful time and pick a smaller time step.

anfho March 9, 2011 15:43

Quote:

It might help other people if you add a post providing details how you solved your problem.
@Anton: I think I did that above.

Quote:

Is there an easy way to revert back to an old time during runtime (ie. while the solver is running)?
@Ben: You would have to stop the solver iteration loop and then delete the unstable solutions in your directory and start with a different time step/ different settings from the time where you have a stable solution. This is definetely not possible while the solver is running.

Regards, Andreas

akidess March 9, 2011 16:31

Quote:

Originally Posted by anfho (Post 298713)
@Anton: I think I did that above.

@Ben: You would have to stop the solver iteration loop and then delete the unstable solutions in your directory and start with a different time step/ different settings from the time step where you have a stable solution. This is definetely not possible while the solver is running.

Regards, Andreas

The way I read Vishal's answer was that he solved the entire problem (he already had 'latestTime' included in his post from October 10). If that was not what he meant, you are right there was nothing to add.

Ben, I do believe that should be possible with some programming work. You have to access the Time object, then you can use either runTime.setTime() to set a specific time or runTime-- to go back one time step. Now, you'll have to make sure that old data is available, by calling setTime for a time you know you wrote data or storing the old time data like done in a SIMPLE style solver. Let me know if it works! :)

Doxygen for Time: http://foam.sourceforge.net/docs/cpp...14f547f414.php

nandiganavishal March 9, 2011 17:18

Dear Foamers,

I did change the controlDict file from the latesttime step i had in my simulation for example

application coupleFoam;

startFrom startTime;

startTime 18e6;

stopAt endTime;

endTime 25e6;

deltaT 100;

writeControl runTime;

writeInterval 1e6;

purgeWrite 0;

writeFormat ascii;

writePrecision 6;

writeCompression uncompressed;

timeFormat general;

timePrecision 6;

runTimeModifiable yes;


The problem I was facing was that in the 18e6 folder some variables had non uniform values in the boundary condition that was not deducted by openfoam so I changed those non uniform values to uniform 0 (as once the iteration starts these values will be computed again)

Hope this helps

Regards

Vishal

benk March 10, 2011 11:22

Quote:

Originally Posted by akidess (Post 298723)
Ben, I do believe that should be possible with some programming work. You have to access the Time object, then you can use either runTime.setTime() to set a specific time or runTime-- to go back one time step. Now, you'll have to make sure that old data is available, by calling setTime for a time you know you wrote data or storing the old time data like done in a SIMPLE style solver. Let me know if it works! :)

Doxygen for Time: http://foam.sourceforge.net/docs/cpp...14f547f414.php

I have something that kindof works:

Code:

if (trouble_flag == 1) {

// this will go back to the last good timestep
runTime.setTime( runTime.times()[runTime.times().size()-1].value(), runTime.times()[runTime.times().size()-1].value() );

// Now I have to read the values of the last good timestep...what's the best way to do this?
fieldName(IOobject("fieldName",runTime.timeName(),mesh,IOobject::MUST_READ,IOobject::AUTO_WRITE),mesh);
...
...
//read in all fields
...
...
//set a new dt
runTime.setDeltaT(someDeltaT);
//continue simulation
}

I think this works, but I have to manually read in the time directory fields, maybe I shouldn't be complaining about this but it just seems like a lot of unnecessary work.

I think having a feature like this could be very useful to OpenFOAM, I believe most commercial solvers can do this.

akidess March 14, 2011 09:31

Can you check if this works?

Code:

if (troubleflag == 1)
    {
        // this will go back to the last good timestep
        instant oldtime = runTime.times()[runTime.times().size()];
        runTime.setTime( oldtime.value(), runTime.findClosestTimeIndex(runTime.times(), oldtime.value() ) );

        //set a new dt
        runTime.setDeltaT(runTime.deltaT().value() / 2.0);

        //runTime++ after include of setDeltaT should call objectRegistry::readModifiedObjects(), which in turn should update fields
    };

PS. Didn't you already solve this problem in a different way last year? -> http://www.cfd-online.com/Forums/ope...tml#post262131


All times are GMT -4. The time now is 02:16.