|
[Sponsors] |
May 3, 2010, 06:09 |
saved data recomputation ....
|
#1 |
New Member
Join Date: Apr 2010
Posts: 5
Rep Power: 16 |
hello
Is it possible to recompute a OpenFoam calculation to continue it? If so, somebody knows how we can do that? thank you |
|
May 6, 2010, 02:14 |
|
#2 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
Quote:
Code:
startFrom latestTime; |
||
June 3, 2010, 15:55 |
|
#3 |
Senior Member
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19 |
Is there any way to call this while my solver is running?
For example, I'm trying to implement variable deltaT (time step) and if I pick a deltaT that is too high and the solution starts to diverge, I want to restart my simulation based on the latestTime. Any ideas on how to do this? I've tried using: runTime.setTime(latestTime, latestTime) where latestTime = the last stored solution. When I do this, it does reset the time but it doesn't read the stored solution at latestTime, instead it restarts based on the solution that was previously diverging. |
|
June 7, 2010, 05:43 |
|
#4 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
Ben, you could try using storeOldTime() and oldTime(). Or maybe you can find some other ideas in the following thread:
http://www.cfd-online.com/Forums/ope...-openfoam.html |
|
June 7, 2010, 12:14 |
|
#5 |
Senior Member
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19 |
Hmm, I thought that I could just reset the time, as I did above and then read in the stored data using:
Code:
volScalarField scalarName ( IOobject ( "scalar", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); |
|
June 7, 2010, 16:51 |
|
#6 |
Senior Member
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19 |
Ok, so I know what my problem is but I don't know how to fix it.
I detect whether my solution is diverging using a flag and if it's diverging i have: Code:
if (diverging == 1) { //reset time to last good time runTime.setTime(lastStoredTime, lastStoredTime); //read the solution from the last good time volScalarField scalar(IOobject("scalar",runTime.timeName(),mesh,IOobject::MUST_READ,IOobject::AUTO_WRITE),mesh); } So one idea that I have is to read in the old solution into a temporary volScalarField and then copy the temporary field to the proper volScalarField. How do I copy the temporary volScalarField into my actual volScalarField? akidess: I'm not sure how to use storeOldTime() and oldTime(). I tried something like: scalar.storeOldTime() but how do I then revert back to this old value? I tried this: scalar = scalar.oldTime() but this doesn't seem to do anything. |
|
June 8, 2010, 04:48 |
|
#7 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
I'm not too sure about the usage of oldTime either, I just stumbled across it in the code. I would have used it the same way you did (maybe an additional nOldTimes() to see if something was stored).
So if that doesn't work, your own approach seems promising. Can you maybe use Code:
tmp<scalar> old(IOobject("scalar",runTime.timeName(),mesh,IOobject::MUST_READ,IOobject::AUTO_WRITE),mesh); //scalar is the variable you want to restore, defined "globally" scalar == old; - Anton |
|
June 8, 2010, 10:33 |
|
#8 |
Senior Member
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19 |
Thanks for the suggestion. When I try the tmp<scalar> part I get the compiler error:
Code:
error: no matching function for call to Foam::tmp<double>::tmp(Foam::IOobject, Foam::fvMesh&) note: candidates are: Foam::tmp<T>::tmp(const Foam::tmp<T>&) [with T = double] note: Foam::tmp<T>::tmp(const T&) [with T = double] note: Foam::tmp<T>::tmp(T*) [with T = double] Code:
error: no match for operator== in scalar == old note: candidates are: void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==(const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh] I'm surprised that this sort of time control isn't more popular amongst foamers since it could dramatically reduce computation time by allowing large/dynamic time steps. |
|
June 8, 2010, 11:03 |
|
#9 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
About the first error: We'll have to use a normal scalarField then instead of the tmp<scalar> field. I guess the performance impact won't be noticable anyways.
So did you try Code:
volScalarField old(IOobject("scalar",runTime.timeName(),mesh,IOobject::MUST_READ,IOobject::AUTO_WRITE),mesh); restoreScalar == old; Most Foamers seem happy with the built in time control based on the Courant number. It's good enough for most of my own simulations. |
|
June 8, 2010, 13:57 |
|
#10 |
Senior Member
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19 |
Aha, that seems to have worked! (reading old solution into a new volScalarField and then using scalar == scalar_old). Thanks!
I don't have a Courant number because I don't have a momentum balance in my model (which is why I need to use my own method to control the time step). |
|
June 9, 2010, 05:14 |
|
#11 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
Great! I was starting to run out of ideas
I had an unstable case where the time adjustment based on the Courant number would lead to an oscillating time step and bad results, and I think a time step control similar to yours could help there as well. For more stable cases it can be a let-down that this method has no means to increase the timestep. - Anton |
|
Tags |
reject time step, time step |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[OpenFOAM] Saved DATA doesnt have Patch Names | velan | ParaView | 0 | January 9, 2009 08:32 |
Getting Time Series data from saved unsteady data | Atul | FLUENT | 4 | November 26, 2008 06:12 |
information from saved data files:Unsteady flow | Atul | FLUENT | 5 | July 27, 2008 21:05 |
reading saved case and data | maxime henno | FLUENT | 1 | June 12, 2007 07:40 |
How to update polyPatchbs localPoints | liu | OpenFOAM Running, Solving & CFD | 6 | December 30, 2005 18:27 |