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

time step ramp

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Knigge46

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 13, 2015, 06:50
Default time step ramp
  #1
New Member
 
Jan N. Wieczorek
Join Date: Jul 2014
Posts: 14
Rep Power: 11
Knigge46 is on a distinguished road
Hey guys,

I'm trying to implement a ramped time step for a pimpleDYMfoam simulation, because I have a feeling that my solution is very time step sensitive.

I successfully built some if-statements in the controlDict file via runtime code-compilation (marking a coded part with #{ #} brackets), but that results in huge jumps in the force output even if the time step is only reduced by its half.

My desired way of doing this would be to keep using the runtime code compilation and not building some wild libraries...

My code part in the controlDict file looks like this:

Code:
       #{
           const Time& runTime = mesh().time();
          // scalar deltaT_start = 0.005;
           scalar deltaT_end = 0.001;
           scalar t_end = 1.0;
          // const_cast<Time&>(runTime).setDeltaT(deltaT_start+(deltaT_end-deltaT_start)*(pow(sin(min(runTime*pi/(2*t_end),pi/2))),2));
           const_cast<Time&>(runTime).setDeltaT(deltaT_end*(min(1, 0.1*runTime)));


         /*  if (runTime.value()>=2)
           {
               const_cast<Time&>(runTime).setDeltaT(deltaT_end);
           }
           if (runTime.value()>=3)
           {
               const_cast<Time&>(runTime).setDeltaT(deltaT_end/2);
           } */
       #};
I would like to use the commented squared sine function but also fail with the simple minimum function, because my variables seam to have different types.

Error output for a pisoFOAM trial case lokk like this:
Code:
/home.local/janwi/OpenFOAM/janwi-2.3.x/run/incompressible/pisoFoam/ras/cavity/system/controlDict.functions.changeTimeStep:59:79: note: candidates are:
/home.local/janwi/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/label.H:295:1: note: char Foam::min(char, char)
/home.local/janwi/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/label.H:295:1: note:   no known conversion for argument 2 from ‘Foam::dimensioned<double>’ to ‘char’
/home.local/janwi/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/label.H:296:1: note: short int Foam::min(short int, short int)
...and so on for various types...

I think the multiplication of 0.1*runTime is causing this. How can I best solve this issue?
Knigge46 is offline   Reply With Quote

Old   April 13, 2015, 08:53
Smile solution:
  #2
New Member
 
Jan N. Wieczorek
Join Date: Jul 2014
Posts: 14
Rep Power: 11
Knigge46 is on a distinguished road
okay, I found the solution myself:

I didn't set the variable for the time step in a proper way. It's working now, even if the results for the time step look a bit weird. Maybe someone has another (better) function to work as a kind of smoothed ramp.

I use a squared sine function:

Code:
delta_t_start + (delta_t_end - delta_t_start) * (sin^2(min(t*PI/(2* t_end) , PI/2) )
(Is there a way to use LaTeX formatting here on the forum? Then the formula would be presented a much better readable way! )

My working code is:

Code:
#{           
           const Time& runTime = mesh().time();
           double  t = runTime.value();
           scalar deltaT_start = 0.005;
           scalar deltaT_end = 0.001;
           scalar t_end = 1.0;
           double pi = M_PI;
           const_cast<Time&>(runTime).setDeltaT(deltaT_start+(deltaT_end-deltaT_start)*(pow(sin(min(t*pi/(2*t_end),pi/2)),2)));
#};
Feel free to test and feedback!
bikooo3878 likes this.
Knigge46 is offline   Reply With Quote

Reply

Tags
ramp, time step


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
High Courant Number @ icoFoam Artex85 OpenFOAM Running, Solving & CFD 11 February 16, 2017 13:40
Star cd es-ice solver error ernarasimman STAR-CD 2 September 12, 2014 00:01
Rapidly decreasing deltaT for interDyMFoam chrisb2244 OpenFOAM Running, Solving & CFD 3 July 1, 2014 16:40
Full pipe 3D using icoFoam cyberbrain OpenFOAM 4 March 16, 2011 09:20
calculation diverge after continue to run zhajingjing OpenFOAM 0 April 28, 2010 04:35


All times are GMT -4. The time now is 13:37.