On Tue, 8 Dec 2020, Laura Scarabosio wrote:
>> LinearSolver::set_solver_type(foo) and set_preconditioner_type(bar), But shouldn't I get the linear solver from the equation system or the system? If I declare a linear solver as you said, how does libmesh know that it has to be used to solve a particular system of equations?
I'm afraid the answer is "it depends". If you have a LinearImplicitSystem or a DifferentiableSystem with a NewtonSolver then get_linear_solver() will return a pointer to the solver used in the linear solve or the quasi-Newton step of the nonlinear solve, which in those cases is a persistent solver that you can change the attributes of for subsequent uses. But if you have a plain System or ExplicitSystem, then it doesn't even have a linear solver associated with it; they're more simple than that, intended for visualization or non-stiff problems or such. And many of our other system types aren't simple *enough* - e.g. there's a nonlinear solver attached, and we can't easily extract (or even guarantee the existance of) a linear solver at the core of it, so get_linear_solver() just generates a temporary for use in linearizations (adjoint solves and sensitivity solves) of the system, not a reference to a fixed solver you can modify. This is where my second suggestion comes in:
but most of our users instead rely on the PETSc command line flags, which we pass through to them and which can be a lot more flexible.
Likewise,
>> I like using a PETSc configured with MUMPs support; I think more of our users prefer SuperLU_Dist.
This means that to use the direct solver I should use set_solver_type(SuperLU_Dist)?
Nope. We don't even bother trying to keep up with the N-factorial different combinations of solvers that each linear algebra package might support. Something as generic as GMRES we have an enum for, but something as specific as SuperLU_Dist you have to get at through the PETSc interface, either by extracting the internal PETSc object from one of our solver shims and using their APIs, or by using the PETSc command line flags, e.g.: ./yourapp -ksp_type preonly -pc_type lu -pc_factor_mat_solver_package superlu_dist --- Roy _______________________________________________ Libmesh-users mailing list Libmesh-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libmesh-users