how to program two independent time loops
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:
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 ?
you can look at interFoam and its subCycle.H used to perform sub timestep for the interface equation.
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.
You can do somethings like:
I've implemented something of the likes for interFoamSSF. Maybe it helps you to have a look at my code:
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:
- fvm::laplacian(nu + (A/C)*nu2, y)
nu and nu2 are defined to act in z and u directions respectively
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:
- fvm::laplacian(C*nu + A*nu2, y)
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 ?
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!
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.
|All times are GMT -4. The time now is 11:39.|