Closed grmnptr closed 1 year ago
Some solvers in derived classes don't use absolute/relative tolerance (like LaspackLinearSolver
). So maybe adding a new function is the way to go.
Hmm, it appears you are correct. And for PetscNonlinearSolver
, I think things are a bit more involved because the tolerances used for the linear solver can depend on the current nonlinear residual norm, but we have the same pattern repeated there:
ierr = KSPSetTolerances (ksp, this->initial_linear_tolerance, PETSC_DEFAULT,
PETSC_DEFAULT, this->max_linear_iterations);
So I would be in favor adding support for a user-defined absolute tolerance, but it would probably be a pain to do this while keeping backwards compatibility for all the different overridden LinearSolver::solve()
APIs. Maybe we should deprecate the tol
that is currently passed in to solve() in favor of a more general approach that allows multiple tolerances to be set on the base class and then used by derived classes as appropriate.
Also, I'm sure you are already aware, but if you just want to quickly control the absolute tolerance used by the PETSc linear solvers without making a big libmesh change, I think you should be able to do this with the -ksp_atol
command line argument.
Maybe we should deprecate the
tol
that is currently passed in to solve() in favor of a more general approach that allows multiple tolerances to be set on the base class and then used by derived classes as appropriate.
This seems like a good suggestion to me
I encountered a problem where I would like to set an absolute tolerance for
PetscLinearSolver
in MOOSE. Right now, the solve function takes a relative tolerance only:and assigns the default petsc option for the absolute tolerance:
I am thinking about either of these two:
solve
function with a default value of 0 or a small number supported by all derived classes.What do you think @lindsayad , @roystgnr , @jwpeterson ?