
[Sponsors] 
January 24, 2013, 12:19 
how to program two independent time loops

#1 
Senior Member
Mieszko Młody
Join Date: Mar 2009
Location: POLAND, USA
Posts: 136
Rep Power: 9 
Dear OpenFOAM users,
I am trying to implement two independent time loops in one solver. More precisely one "main time loop" and "one nested loop" where some other iteration dependent equation is solved. Something like that: while(runTime.loop()) { FIRST EQUATION while (some_stop_condition) { SECOND EQUATION } } If it is programmed like above, the second equation in the innerloop is not solved/updated... Is it any way to have eg. two independent integration times in one solver ? Thanks ZMM 

January 24, 2013, 15:53 

#2 
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 245
Rep Power: 10 
hi!
you can look at interFoam and its subCycle.H used to perform sub timestep for the interface equation. Regards, Cyp 

January 25, 2013, 05:36 

#3 
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Deltares, Delft, The Netherlands
Posts: 1,693
Rep Power: 27 
Yes, Cyp points to the right part of the code.
One subtlety, which you might need at some point: The timeIndex, i.e. the integer index telling, which time step you have reached, is always incremented, so if the inner loop has say 9 subtime steps, then the outer loop will only happen on timeIndices 0, 10, 20, 30, etc. Kind regards, Niels 

January 25, 2013, 05:56 

#4 
Member
Jim Knopf
Join Date: Dec 2010
Posts: 60
Rep Power: 7 
You can do somethings like:
Code:
while(runTime.loop()) FIRST_EQUATION // runs eqn 1 every time step if (runTime.timeName() % N == 0) { SECOND_EQUATION } // 2nd eqn only solved every Nth time step Jim 

January 25, 2013, 07:59 

#5 
Senior Member
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 1,121
Rep Power: 20 
I've implemented something of the likes for interFoamSSF. Maybe it helps you to have a look at my code:
http://code.google.com/p/interfoamss...se/interFoam.C  Anton
__________________
*On twitter @akidTwit *Spend as much time formulating your questions as you expect people to spend on their answer. *Join the OpenFOAM stackexchange Q&A site: http://area51.stackexchange.com/prop...oHPxcPqde7HtA2 

January 25, 2013, 18:47 

#6 
Senior Member
Mieszko Młody
Join Date: Mar 2009
Location: POLAND, USA
Posts: 136
Rep Power: 9 
Thanks all of you for your answers, they are really helpful.
Maybe you will have some hints how to deal with problem I encountered recently. Which is part of this algorithm. I am trying to solve equation for in rectangular domain: I decided to solve it as follows: fvScalarMatrix yEqn ( fvm::ddt(y)  U.component(1)  fvm::laplacian(nu + (A/C)*nu2, y) + D/C ); where: nu and nu2 are defined to act in z and u directions respectively and and where A, C and D are solved explicitly. But solver had a problem with it, because C were getting too large. So I decided to multiply above equation by C and get: fvScalarMatrix yEqn ( C*fvm::ddt(y)  C*U.component(1)  fvm::laplacian(C*nu + A*nu2, y) + D ); Here I got solution, somehow similar to the one it should converge, but not exactly. Problem seems to be in "C*fvm::ddt(y)" term, because it gives me the same answer if I have just "fvm::ddt(y)" ... Any idea, what can be here wrong, or how to make it better ? Thanks ZMM 

January 26, 2013, 08:05 

#7 
Senior Member
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 249
Blog Entries: 10
Rep Power: 9 
Quote:
I think you don't need two time loops. You should keep one time loop for the yEqn and update the other relations inside the time loop without any local convergence iterations (they are still time dependent). This should, hopefully, enhance the results of your solver. Also, if you have very large numbers try to work with different units for your constants ... e.g. for mass instead of gm use kgm Hope this helps! Hisham 

January 26, 2013, 10:39 

#8 
Senior Member
Mieszko Młody
Join Date: Mar 2009
Location: POLAND, USA
Posts: 136
Rep Power: 9 
Thanks Hisham for your thoughts.
But this is just one of three equations I need to solve. In fact this one will run inside inner loop, and after convergence, it will be used for two others equations which run in outer loop. In short, this equation need to be solved in every time step of outer/main loop. Changing units here is not a solution, because I work with nondimensional equations. Best ZMM 

Tags 
nested equations, nested integration, nested time loops, time levels, two time loops 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Multiple floating objects  CKH  OpenFOAM Running, Solving & CFD  12  March 21, 2016 14:05 
TimeVaryingMappedFixedValue  irishdave  OpenFOAM Running, Solving & CFD  28  May 28, 2015 13:37 
pisoFoam with kepsilon turb blows up  Some questions  Heroic  OpenFOAM Running, Solving & CFD  26  December 17, 2012 04:34 
Convergence moving mesh  lr103476  OpenFOAM Running, Solving & CFD  30  November 19, 2007 15:09 
unsteady calcs in FLUENT  Sanjay Padhiar  Main CFD Forum  1  March 31, 1999 12:32 