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

How to get the current time within the controlDict?

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 1 Post By alexeym
  • 1 Post By duan
  • 3 Post By Tobi

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   November 4, 2014, 13:53
Question How to get the current time within the controlDict?
  #1
New Member
 
duan
Join Date: Apr 2014
Posts: 6
Rep Power: 12
duan is on a distinguished road
Hi,

I am trying to set different writeTimeInterval rather than a constant one during the runTime.

for example:
if (currentRunTime<t0)
writeTimeInterval=value0;
else
writeTimeInterval=value1;

Now I have problems on how to get current time within the controlDict.

Here is my code:

Code:
writeInterval   #codeStream
{
    
    code
    #{
        /*// the sample works    
          scalar start = readScalar(dict.lookup("startTime"));
          scalar end = readScalar(dict.lookup("endTime"));
          label nDumps = 5;
          os << ((end - start)/nDumps);*/
        //==================================================
        //how to get the current time within controlDic???
          
          //Tried but Not work
          //scalar t=this->db().time().value(); 
          //error: invalid use of ‘this’ in non-member function
         
          //scalar t = runTime().value() ; 
          //error: ‘runTime’ was not declared in this scope
          //scalar t = timeDirs.last().value(); 
          //error: ‘timeDirs’ was not declared in this scope
          //scalar t = time().value(); 
          //error: too few arguments to function ‘time_t time(time_t*)
          label t0 = 0.4;
          if (t <= t0) {
                os << 0.05;
          }
          else {
                os << 0.02;
          } 
    #};
};
I also have found some post related:
http://www.cfd-online.com/Forums/ope...ntroldict.html
http://www.openfoam.org/version2.0.0...me-control.php
http://www.cfd-online.com/Forums/ope...me-scalar.html



Thanks in advance.
duan is offline   Reply With Quote

 

Tags
controldict, current run time, write control


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
Current density visualisation (PEM fuel cell add-on module) pchoopanya FLUENT 10 August 21, 2023 14:33
Multiple floating objects CKH OpenFOAM Running, Solving & CFD 14 February 20, 2019 09:08
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 05:36
pisoFoam with k-epsilon turb blows up - Some questions Heroic OpenFOAM Running, Solving & CFD 26 December 17, 2012 03:34
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 18:07


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