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

if (timestep X == true) OR if (current_timestep == timestep X)

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 14, 2014, 08:43
Default if (timestep X == true) OR if (current_timestep == timestep X)
  #1
Senior Member
 
Join Date: Jan 2012
Posts: 166
Rep Power: 14
maybee is on a distinguished road
hi,

I need to implement specific code for specific timesteps. Therefore I though about doing something like

Code:
if (timestep X == true) {...}
OR if

Code:
(current_timestep == timestep X) {...}
Does someone know how I can do so?

greetings
maybee
maybee is offline   Reply With Quote

Old   March 14, 2014, 09:32
Default
  #2
Senior Member
 
Join Date: Jan 2012
Posts: 166
Rep Power: 14
maybee is on a distinguished road
Hi again,

I found

Code:
scalar deltaTValue	() const inline
//Return time step value.
and

Code:
Foam::label timeIndex	() const
//Return current time index.
and

Code:
Foam::dimensionedScalar deltaT	() const
//Return time step.
I guess the first one will give me the whole value of the time step, e.g. 5 Seconds, right?
But what about the second and the third one? Which one will just give me the number of timesteps including the actual running time step?
maybee is offline   Reply With Quote

Old   March 14, 2014, 11:45
Default
  #3
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
Since this sounds like you are doing it in a solver, runTime.value() is your friend.
mturcios777 is offline   Reply With Quote

Old   March 14, 2014, 13:26
Default
  #4
Senior Member
 
Join Date: Jan 2012
Posts: 166
Rep Power: 14
maybee is on a distinguished road
Quote:
Since this sounds like you are doing it in a solver, runTime.value() is your friend.
Thx, for the help. Just to be sure: runTime.value() will return the following values:

first time loop pass: 0
second time loop pass: 1
third time loop pass : 2
and so on

?
maybee is offline   Reply With Quote

Old   March 14, 2014, 13:28
Default
  #5
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
So you want the condition to run when t = a certain value, or dt = a certain value? I may have misunderstood your initial question.
mturcios777 is offline   Reply With Quote

Old   March 14, 2014, 15:07
Default
  #6
Senior Member
 
Join Date: Jan 2012
Posts: 166
Rep Power: 14
maybee is on a distinguished road
Quote:
So you want the condition to run when t = a certain value, or dt = a certain value? I may have misunderstood your initial question.
I want to do something like:

Code:
if (time loop pass == 1)
{

}

if (time loop pass == 2)
{

}
.
.
.
Sure, I can do this without using any members of class Time, but I thought if Time provides such a member it would be better to use it.

Last edited by maybee; March 14, 2014 at 16:51.
maybee is offline   Reply With Quote

Old   March 17, 2014, 02:30
Default
  #7
Member
 
Christian Butcher
Join Date: Jul 2013
Location: Japan
Posts: 85
Rep Power: 12
chrisb2244 is on a distinguished road
I think the confusion is about what sort of 'time' you want to measure.

Within a solver, runTime.value() will return the 'real', physical time, in seconds.
If you want to count the number of iterations of your code, a counter might be a better bet?

runTime.value() will return these values if your deltaT is 1 second per iteration.
Quote:
Originally Posted by maybee View Post
first time loop pass: 0
second time loop pass: 1
third time loop pass : 2
and so on
?
Although actually, the solvers that I've looked at mostly start with a runTime++; , so they'd return 1 as the first time value if dt = 1 and you took it after that line
chrisb2244 is offline   Reply With Quote

Old   March 17, 2014, 03:52
Default
  #8
Senior Member
 
Join Date: Jan 2012
Posts: 166
Rep Power: 14
maybee is on a distinguished road
hi,

thx for the reply. I ve taken an own counter now. This should work fine for me . As I already told - just wanted to check if class Time or any other class already proivdes such a counter.

greetings
maybee
maybee 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
Modifying sonicFoam to run with variable timestep - strange results dalaron OpenFOAM Programming & Development 1 September 2, 2013 07:21
Restart 2-way FSI with different timestep? Lance CFX 10 April 17, 2013 00:37
Timestep and Pressure Correction Relationship in SIMPLE rks171 Main CFD Forum 23 May 4, 2012 01:04
Adequate timestep selection for multidomain problem gerardosrez CFX 6 November 28, 2010 17:50
Timestep study ijk CFX 6 April 9, 2010 07:38


All times are GMT -4. The time now is 09:31.