- **OpenFOAM Programming & Development**
(*http://www.cfd-online.com/Forums/openfoam-programming-development/*)

- - **how to program two independent time loops**
(*http://www.cfd-online.com/Forums/openfoam-programming-development/112249-how-program-two-independent-time-loops.html*)

how to program two independent time loopsDear 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 |

hi!
you can look at interFoam and its subCycle.H used to perform sub timestep for the interface equation. Regards, Cyp |

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 sub-time steps, then the outer loop will only happen on timeIndices 0, 10, 20, 30, etc. Kind regards, Niels |

You can do somethings like:
Code:
`while(runTime.loop())` Jim |

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 |

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 |

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 |

All times are GMT -4. The time now is 19:47. |