CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

value of previous time step

Register Blogs Community New Posts Updated Threads Search

Like Tree17Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 8, 2013, 09:47
Default
  #21
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
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.
akidess is offline   Reply With Quote

Old   February 10, 2014, 17:16
Default
  #22
ooo
Member
 
Join Date: Feb 2012
Posts: 49
Rep Power: 14
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, 20:10
Default
  #23
Senior Member
 
Mohammad Shakil Ahmmed
Join Date: Oct 2012
Location: AUS
Posts: 137
Rep Power: 14
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, 15:35
Default
  #24
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
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


Quote:
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

Old   October 7, 2023, 21:51
Default hello
  #25
New Member
 
Grp
Join Date: Feb 2023
Posts: 14
Rep Power: 3
GrpOne123 is on a distinguished road
Quote:
Originally Posted by ahmmedshakil View Post
U.oldTime() will give the values of U at previous time step.
I want to get the mesh.Cf() of a patch in oldTime , how can i do that?
I try mseh.Cf().oldTime().boundaryField()[patch], it is no works.
GrpOne123 is offline   Reply With Quote

Reply

Tags
field, store, time step


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading forces from previous time step within solver SD@TUB OpenFOAM Programming & Development 5 April 24, 2023 11:51
Time step size and max iterations per time step pUl| FLUENT 33 October 23, 2020 22:50
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 05:36
UDF: Previous time step macros NOT working jpapg FLUENT 0 April 30, 2011 21:35
Convergence moving mesh lr103476 OpenFOAM Running, Solving & CFD 30 November 19, 2007 14:09


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