CFD Online Logo CFD Online URL
Home > Forums > OpenFOAM Programming & Development

value of previous time step

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree9Likes

LinkBack Thread Tools Display Modes
Old   November 8, 2013, 10:47
Senior Member
akidess's Avatar
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 984
Rep Power: 17
akidess will become famous soon enough
oldTime and prevIter both are useful, nothing is deprecated. As stated by David, you can use oldTime to go back multiple time steps (not just one as prevIter), and it manages the storing automatically. That of course only works if you actually need values from a previous timestep, not from subcycle iterations. The latter case is where you would typically use prevIter/storePrevIter, but of course you can also use it to store data from a previous time step.

- Anton
dkxls likes this.
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
*Help define the OpenFOAM stackexchange Q&A site:
akidess is offline   Reply With Quote

Old   February 10, 2014, 18:16
Join Date: Feb 2012
Posts: 49
Rep Power: 5
ooo is on a distinguished road
Does U.oldTime() gives us the value of previous time step, or last value of the field?
assume that we have this situation :

while (runTime.loop())
U = somevalue1 ;
U = somevalue2 ;

x = U.oldTime();

So x is somevalue1 or is the value of U at the previous time step ?
ooo is offline   Reply With Quote

Old   February 10, 2014, 21:10
Senior Member
Mohammad Shakil Ahmmed
Join Date: Oct 2012
Location: AU
Posts: 124
Rep Power: 6
ahmmedshakil is on a distinguished road
U.oldTime() will give the values of U at previous time step.
ahmmedshakil is offline   Reply With Quote

Old   March 7, 2015, 16:35
Senior Member
Join Date: Jan 2013
Posts: 235
Rep Power: 5
openfoammaofnepo is on a distinguished road
Dear Marupio,

Your reply below is very helpful, but I have still the problems about

when "erased and reconstructed at every timestep" happens? At the beginning of each time step or at the end of the time step?

Thank you very much. OFFO

Originally Posted by marupio View Post
Yes, oldTime works much simpler than you think. It is all totally automatic in the background. You never need to call storeOldTime()... and the xn.oldTime() immediately gives you the value from the previous timestep. runTime is clever enough to count how many .oldTime()'s you use, and automatically stores that many in its database.

I think you are probably using a local object. I was always confused as to why xn wouldn't *already* have the previous timestep's value at the start of the next timestep. If you are using a local object, it is erased and reconstructed at every timestep. In this case, oldTime() won't work, and neither would a simpler vectorField copy we talked about either. Where are you constructing your xn object? Will the program encounter the constructor once and only once throughout multiple timestep iterations? If not, move the constructor above your while(runTime.loop())... possibly even into createFields.H. If this is the problem, that's probably why it didn't work when you were using a standard vectorField. I'd recommend returning to the vectorField framework if possible.
openfoammaofnepo is offline   Reply With Quote


field, store, time step

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Time step size and max iterations per time step pUl| FLUENT 31 August 21, 2015 04:46
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 06:36
UDF: Previous time step macros NOT working jpapg FLUENT 0 April 30, 2011 21:35
Reading forces from previous time step within solver SD@TUB OpenFOAM Programming & Development 0 March 14, 2010 07:58
Convergence moving mesh lr103476 OpenFOAM Running, Solving & CFD 30 November 19, 2007 15:09

All times are GMT -4. The time now is 21:34.