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

oldTime() outputting current time value:

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By gtg258f

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 9, 2012, 10:33
Default oldTime() outputting current time value:
  #1
New Member
 
Join Date: Jun 2011
Posts: 13
Rep Power: 14
gtg258f is on a distinguished road
Dear all,

I have a solver with an outer time loop, and inner loop with sub-iterations. In order to check the convergence of the outer and inner iterations, I wanted to access my field values at the
- previous time step: p.oldTime()
- previous inner iteration: p.prevIter()

While prev.Iter() seems to work fine, I am encountering issues with oldTime() and was wondering if I was doing something wrong.

I am storing values with storePrevIter(), should I use something else for oldTime()?

Another option is that there may be a memory issue with oldTime:
when one adds print statements before modifying a field value, then oldTime() is stored properly whereas it is not without the print statement (which seems fishy)


Playing around with the problem, I wrote a very simple code (attached) with the following algorithm, and a set-up ready to run (though the example code really can run on any case)
Code:
DP=1
for( time )
    p.storePrevIter()
    //comment 1: print DP.oldTime()
    for( innerIteration<2 )
    {
        DP.storePrevIter()
        DP+=DP
    }
    //comment 2: print p.oldTime()
    p = DP
without any print statement, the values at the end of the first time steps are:
p[0] oldTime, prevIter, current = 4 1 4
DP[0] oldTime, prevIter, current = 4 2 4

with the print statements in comment 1 and 2, the values are properly stored and read as:
p[0] oldTime, prevIter, current = 1 1 4
DP[0] oldTime, prevIter, current = 1 2 4


Any help on that problem would be great,
Diane
Attached Files
File Type: zip OldTimeProblem.zip (32.6 KB, 21 views)
Jun_93 likes this.
gtg258f is offline   Reply With Quote

Old   November 11, 2016, 10:20
Default
  #2
New Member
 
Khomenko Maxim
Join Date: Aug 2015
Posts: 16
Rep Power: 10
mbookin is on a distinguished road
I do not know why this happen, but of you call p.oldTime() before you update your p then p.oldTime() will have the right value. You dont even need to print, just call p.oldTime(); I think pseudocode can illustrate this:
Code:
P=1;
for( time )
    {
    P+=P
    Info<<P<<"_"<<P.oldTime()<<endl;
    }
Will give
Code:
2_2   
3_3
..
And
Code:
P=1;
for( time )
    {
    P.oldTime();
    P+=P
    Info<<P<<"_"<<P.oldTime()<<endl;
    }
Will return
Code:
2_1
3_2
..

Last edited by mbookin; November 11, 2016 at 10:21. Reason: typo
mbookin 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
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 05:36
Set current time step tsram90 FLUENT 0 November 11, 2011 10:19
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 18:07
How to read out time used for current solution Angelo Sozzi FLUENT 1 July 7, 2004 13:16
unsteady calcs in FLUENT Sanjay Padhiar Main CFD Forum 1 March 31, 1999 12:32


All times are GMT -4. The time now is 04:06.