cashocs.snes_solve#
- cashocs.snes_solve(nonlinear_form: ufl.Form, u: fenics.Function, bcs: fenics.DirichletBC | list[fenics.DirichletBC], derivative: ufl.Form | None = None, petsc_options: _typing.KspOption | None = None, shift: ufl.Form | None = None, rtol: float | None = None, atol: float | None = None, max_iter: int | None = None, A_tensor: fenics.PETScMatrix | None = None, b_tensor: fenics.PETScVector | None = None, preconditioner_form: ufl.Form | None = None) fenics.Function [source]#
Solve a nonlinear PDE problem with PETSc SNES.
An overview over possible PETSc command line options for the SNES can be found at https://petsc.org/release/manualpages/SNES/.
- Parameters:
nonlinear_form (ufl.Form) – The variational form of the nonlinear problem to be solved by Newton’s method.
u (fenics.Function) – The sought solution / initial guess. It is not assumed that the initial guess satisfies the Dirichlet boundary conditions, they are applied automatically. The method overwrites / updates this Function.
bcs (fenics.DirichletBC | list[fenics.DirichletBC]) – A list of DirichletBCs for the nonlinear variational problem.
derivative (ufl.Form | None) – The Jacobian of nonlinear_form, used for the Newton method. Default is None, and in this case the Jacobian is computed automatically with AD.
petsc_options (_typing.KspOption | None) – The options for PETSc SNES object.
shift (ufl.Form | None) – A shift term, if the right-hand side of the nonlinear problem is not zero, but shift.
rtol (float | None) – Relative tolerance of the solver (default is
rtol = 1e-10
).atol (float | None) – Absolute tolerance of the solver (default is
atol = 1e-10
).max_iter (int | None) – Maximum number of iterations carried out by the method (default is
max_iter = 50
).A_tensor (fenics.PETScMatrix | None) – A fenics.PETScMatrix for storing the left-hand side of the linear sub-problem.
b_tensor (fenics.PETScVector | None) – A fenics.PETScVector for storing the right-hand side of the linear sub-problem.
preconditioner_form (ufl.Form | None) – A UFL form which defines the preconditioner matrix.
- Returns:
The solution in form of a FEniCS Function.
- Return type:
fenics.Function