Page 2 of 2
Re: Maximim number of linear solver iterations in Code Satur
Posted: Mon Oct 02, 2017 1:20 pm
by Antech
Under "all solvers" I mean linear solvers that may be selected via GUI. Assume I run calculations selecting different solvers, I'd like to make this user function universal, for it to handle arbitrary solver selection. And let it be for velocity only (or for velocity and pressure), not for all variables. Otherwise, if I'll change the linear solver in GUI, the user function will not limit the number of iterations.
Sorry for my stupid questions

Re: Maximim number of linear solver iterations in Code Satur
Posted: Mon Oct 02, 2017 2:14 pm
by Yvan Fournier
Hello,
If I understand correctly, what you want to do is similar to what is done in src/alge/cs_sles_default.c, but it will involve a bit of programming even if you start from that example.
And again, using a number of iterations rather than precision to manage solver convergence is quite tricky, as number of iterations may depend on the mesh (at least for some solver types), so your "tuning" will not be so generic.
Regards,
Yvan
Re: Maximim number of linear solver iterations in Code Satur
Posted: Tue Oct 03, 2017 11:30 am
by Antech
Hello.
Thanks for your answers, I reviewed what you said and took a closer look at sources, trying to understand the solver options setup mechanism in extent I can...
As I can see, for every variable the solver is selected automatically if not set by the user (Automatic option) so, in any case, I must determine the solver selected for velocity if I set the number of iterations in
cs_user_linear_solvers(). Then the function must select the solver type (multigrid or "simple") and set options accordingly.
I see that solver options for particular variable are set with
cs_sles_it_define(). Even if the multigrid solver is used for variable, the
cs_sles_it_define() function is called for it and maximum number of iteration is set (don't know how it affects the MG solver). Can I query the solver for velocity currently set in
cs_user_linear_solvers function? If not, or it's too complex, I think it's better to just limit precision at first stage and live with these rare "iteration spikes" at main stage of calculation. My knowledge is not enough to do some complex things with Saturne programming. But if I can determine parameters that are set with
cs_sles_it_define, than I can just query and then set similar options changing only number of iterations. Is there some kine of "cs_sles_it_query"? I didn't find resembling function in Doxygen. Also, if MG solver is used for velocity, I will likely have to tweak maximum cycles and/or coarse iterations leaving other options unchanged. Is there a function to query MG solver options like "cs_multigrid_
get_solver_options"?
That's why I' interested in this question. Here is my "Saturne monitoring" script output, table version. You see that at outer loop iteration 199 there was 785 "linear iterations" for velocity (solver and preconditioner are Automatic) while average "linear" iterations for velocity was around 40. So this one 199'th outer loop iteration consumed about 20x time for velocity field calculation compared with many of the same linear solvings for an average iteration.
Code: Select all
============================================================================================
| Itr (abs) | Faces Visc | Itr Vel | Itr Prs | VelMag Max | Prs Min | Prs Max |
| [---] | [%] | [---] | [---] | [m/s] | [Pa] | [Pa] |
============================================================================================
| 199 | 0 | 785 | 15 | 52.891 | -623.41 | 305.12 |
| 200 | 0 | 26 | 12 | 53.009 | -628.32 | 303.17 |
| 201 | 0 | 65 | 15 | 53.373 | -630.52 | 369.26 |
| 202 | 0 | 35 | 14 | 68.225 | -1010 | 516.88 |
| 203 | 0 | 47 | 15 | 85.909 | -1587.9 | 470.3 |
| 204 | 0 | 45 | 14 | 95.526 | -1945.1 | 350.34 |
| 205 | 0 | 42 | 15 | 69.466 | -1427.4 | 308.28 |
| 206 | 0 | 47 | 14 | 53.589 | -640.26 | 383.26 |
| 207 | 0 | 43 | 16 | 269.91 | -643.9 | 4276.4 |
| 208 | 0 | 55 | 16 | 428.81 | -648.75 | 9871.5 |
[/size]
Thanks for your attention.
Re: Maximim number of linear solver iterations in Code Satur
Posted: Tue Oct 03, 2017 6:18 pm
by Yvan Fournier
Hello,
A solver is set either to a non-multigrid solver (cs_sles_it_define), or to a multigrid solver (though a non-multigrid can use multigrid as a preconditioner).
In any case, you can be sure you are not using multigrid for velocity. Multigrid is used mainly for pressure correction or pure diffusion cases. There is an experimental multigrid for convection/diffusion but only for scalars.
Regards,
Yvan
Re: Maximim number of linear solver iterations in Code Satur
Posted: Wed Oct 04, 2017 7:04 am
by Antech
Hello.
In this case I can just use cs_sles_it_define(). But, besides the field id/name and maximum number of iterations, it also takes solver_type (the solver to select) and poly_degree (preconditioning polynomial degree). How can I set the new max number of iterations preserving existing values for two other parameters?
Re: Maximim number of linear solver iterations in Code Satur
Posted: Wed Oct 04, 2017 1:17 pm
by Yvan Fournier
Hello,
Currently, cs_sles_it_...* does not provide all the query functions for this, though you could use cs_sles_it_get_type and cs_sles_it_get_pc and then the cs_sles_pc query functions to determine the type and preconditioner associated with a solver.
Regards,
Yvan
Re: Maximim number of linear solver iterations in Code Satur
Posted: Mon Oct 09, 2017 9:48 am
by Antech
(Sorry, cannot answer now, busy with work. Will try these functions later)