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

When does OpenFOAM execute "storeOldTime" ?

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 3 Post By deepsterblue

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 4, 2015, 19:24
Default When does OpenFOAM execute "storeOldTime" ?
  #1
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
Hi All,

I met a problem when I read the EulerDdtScheme.C

Code:
https://github.com/OpenFOAM/OpenFOAM-2.2.x/blob/master/src/finiteVolume/finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.C
I found that when we do the time discretization, we need the rho and vf for both the current time step and the previous time step (lines 253 in the above wenpage):
Code:
rDeltaT*(rho*vf - rho.oldTime()*vf.oldTime())
So my question is: when OpenFOAm is running, when are rho.oldTime() and vf.oldTime() stored into these two fields as the old values? If we take the rhoPimpleFOAM as an example.

I checked the source files for GeometricField.C, and found that there are indeed the functions for storeOldTimes:
Code:
// Store old-time field
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::storeOldTimes() const
{
    if
    (
        field0Ptr_
     && timeIndex_ != this->time().timeIndex()
     && !(
            this->name().size() > 2
         && this->name()(this->name().size()-2, 2) == "_0"
         )
    )
    {
        storeOldTime();
    }

    // Correct time index
    timeIndex_ = this->time().timeIndex();
}
But due to my propably limited knowlwdge of C++, I failed to find the places where the above function is called and where the "storeOldTime()" is defined. Could anybody know about this issue? Thank you in advance!

OFFO
openfoammaofnepo is offline   Reply With Quote

Old   March 5, 2015, 10:50
Default
  #2
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25
deepsterblue will become famous soon enough
It happens on-demand, whenever you invoke 'field.oldTime()'

If you look at the 'GeometricField:ldTime()' member function, it checks for the existence of field0Ptr_, and creates one if it doesn't exist. From that point on, it is updated on access only if the time-step has changed (by checking the value of timeIndex_, which is incremented every time-step)
fedvasu, rajibroy and joshwilliams like this.
__________________
Sandeep Menon
University of Massachusetts Amherst
https://github.com/smenon
deepsterblue is offline   Reply With Quote

Old   March 5, 2015, 10:58
Default
  #3
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
Thank you, deepsterblue. I have not found a place where field.oldTime() is invoked. Could you please give me an example in it? Thank you very much. This is also my question so that I cannot understand when the old fields are stored in running OpenFOAM solvers.

OFFO

Quote:
Originally Posted by deepsterblue View Post
It happens on-demand, whenever you invoke 'field.oldTime()'

If you look at the 'GeometricField:ldTime()' member function, it checks for the existence of field0Ptr_, and creates one if it doesn't exist. From that point on, it is updated on access only if the time-step has changed (by checking the value of timeIndex_, which is incremented every time-step)
openfoammaofnepo is offline   Reply With Quote

Old   March 5, 2015, 11:03
Default
  #4
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25
deepsterblue will become famous soon enough
You gave the example yourself - in your original post. When you have:

Code:
rho.oldTime() * vf.oldTime()
the storage of old-times is invoked at that point.
__________________
Sandeep Menon
University of Massachusetts Amherst
https://github.com/smenon
deepsterblue is offline   Reply With Quote

Old   March 5, 2015, 11:31
Default
  #5
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
Thank you. Since the following is from the Euler time scheme:

Code:
rDeltaT*(rho*vf - rho.oldTime()*vf.oldTime())
So does it mean that when the time discretization is perdormed, the old fields will be stored? I originally thought that rho.oldTime() only extract the old rho fields fore previously stored fields.


Quote:
Originally Posted by deepsterblue View Post
You gave the example yourself - in your original post. When you have:

Code:
rho.oldTime() * vf.oldTime()
the storage of old-times is invoked at that point.
openfoammaofnepo is offline   Reply With Quote

Old   March 5, 2015, 18:42
Default
  #6
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25
deepsterblue will become famous soon enough
Quote:
Originally Posted by openfoammaofnepo View Post
So does it mean that when the time discretization is perdormed, the old fields will be stored?
Yes - makes sense, doesn't it? If you don't discretize in time, then you don't need an old time, and that never needs to be stored. Simple and elegant.
__________________
Sandeep Menon
University of Massachusetts Amherst
https://github.com/smenon
deepsterblue is offline   Reply With Quote

Old   March 5, 2015, 18:47
Default
  #7
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
It seems make sense. In one Solver, we will have several time discretizations, like in UEqn, rhoEqn, pEqn, for rho and the relavant quantities. If I follow your line of reasoning, the oldTime() will be store many times?


Quote:
Originally Posted by deepsterblue View Post
Yes - makes sense, doesn't it? If you don't discretize in time, then you don't need an old time, and that never needs to be stored. Simple and elegant.
openfoammaofnepo is offline   Reply With Quote

Reply


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
OpenFOAM - Validation of Results Ahmed OpenFOAM Running, Solving & CFD 10 May 13, 2018 19:28
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 06:36
OpenFOAM Foundation releases OpenFOAM 2.2.2 opencfd OpenFOAM Announcements from ESI-OpenCFD 0 October 14, 2013 08:18
ESI-OpenCFD Releases OpenFOAM v2.2.0 opencfd OpenFOAM Announcements from ESI-OpenCFD 13 March 30, 2013 17:52
Summer School on Numerical Modelling and OpenFOAM hjasak OpenFOAM 5 October 12, 2008 14:14


All times are GMT -4. The time now is 20:48.