Non-linear Solver
- class flatiron_tk.solver.non_linear_solver.NonLinearSolver(*args: Any, **kwargs: Any)[source]
Bases:
NewtonSolverA wrapper class around dolfinx.nls.petsc.NewtonSolver for solving nonlinear PDE problems within the flatironx framework.
This class handles the setup of the nonlinear solver’s convergence criteria and provides a mechanism to customize the underlying linear (KSP) solver’s settings.
- Parameters:
(MPI.Comm) (comm) – The MPI communicator.
(dolfinx.fem.petsc.NonlinearProblem) (problem) – The nonlinear problem to solve.
**kwargs –
Arbitrary keyword arguments to configure the solver.
Common kwargs include:
atol (float): Absolute tolerance for the nonlinear solver.
rtol (float): Relative tolerance for the nonlinear solver.
report (bool): Whether to report convergence.
relaxation_parameter (float): Relaxation parameter for Newton’s method.
max_it (int): Maximum number of nonlinear iterations.
convergence_criterion (str): Convergence criterion (“incremental” or “residual”).
- outer_ksp_set_function (callable): A function to customize the KSP solver.
It should take one argument: the PETSc KSP object.
post_ksp_setup_hook (callable): A hook function to run after KSP setup.
- default_set_ksp(ksp: petsc4py.PETSc.KSP)[source]
Sets default values for the KSP solver. This method is used if no custom KSP setup function is provided by the user. It uses set_ksp_option and ksp.setFromOptions() for consistency.
- Parameters:
(PETSc.KSP) (ksp) – The KSP object to configure.
- init_ksp()[source]
Initializes the KSP solver, sets matrix structure and applies post-setup hooks like FieldSplit configuration.
- set_ksp_option(ksp: petsc4py.PETSc.KSP, keyword: str, value)[source]
Helper method to set a PETSc KSP option using its option prefix. This ensures options are specific to this KSP instance.
- Parameters:
(PETSc.KSP) (ksp) – The KSP object.
(str) (keyword) – The PETSc option keyword (e.g., “ksp_type”, “pc_type”).
value – The value for the option.