reuse constructor parameter of AMG backend is *very* dangerous
I just had a case where I was using the ISTLBackend_AMG_NOVLP
and accidentally (without recognizing it) did set reuse to true. This lead to setting up the AMG hierarchy only once for the very first newton step performed and reusing this obviously wrong preconditioner throughout the time stepping.
I only recognized this misuse on a small example where AMG translated to a direct solver that is used as a preconditioner. For later timesteps I was surprised that the linear solver took more than 1 step. My first guess was that the discretization was wrong. After a good night's sleep I woke up with the insight that this might be a to high ReassembleThreshold
, but that turned out to be set to zero. Finally I realized that we did set reuse to 1 (probably copy and paste from somewhere).
This took quite some time to realize and might take others a lot more.
Please note, that if this parameter is true, AMG will always use the linear system of the very first newton step of the first time step. I cannot think of a case where one would actually wants this. Should we not honor the ReassembleThreshold
when setting up AMG, instead?
I herewith propose to drop this parameter from the constructors and change the Newton to use the setReuse
to indicate whether or not the linear system got reassembled. I will be happy to provide such a patch if appreciated.