CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   value of previous time step (https://www.cfd-online.com/Forums/openfoam-programming-development/92961-value-previous-time-step.html)

akidess November 8, 2013 09:47

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

ooo February 10, 2014 17:16

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 ?

ahmmedshakil February 10, 2014 20:10

U.oldTime() will give the values of U at previous time step.

openfoammaofnepo March 7, 2015 15:35

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 (Post 326786)
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.


GrpOne123 October 7, 2023 21:51

hello
 
Quote:

Originally Posted by ahmmedshakil (Post 474363)
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.


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