solvers#

class NonlinearMaterialProblem(qmap: QuadratureMap | Sequence[QuadratureMap], F: Form | Sequence[Form], u: Function | Sequence[Function], *, petsc_options_prefix: str, bcs: Sequence[DirichletBC] | None = None, J: Form | Sequence[Sequence[Form]] | None = None, P: Form | Sequence[Sequence[Form]] | None = None, kind: str | Sequence[Sequence[str]] | None = None, petsc_options: dict | None = None, form_compiler_options: dict | None = None, jit_options: dict | None = None, entity_maps: Sequence[EntityMap] | None = None)[source]#

Bases: NonlinearProblem

This class handles the definition of a nonlinear problem containing an abstract QuadratureMap object compatible with a dolfinx NewtonSolver.

Parameters:
  • qmap (dolfinx_materials.quadrature_map.QuadratureMap, list) – The abstract QuadratureMap object, can also be a list.

  • F (Form) – Nonlinear residual form

  • u (fem.Function) – Unknown function representing the solution

  • J (Form) – Associated Jacobian form

  • J – Associated Jacobian form

  • bcs (list) – list of fem.dirichletbc

  • entity_maps – If any trial functions, test functions, or coefficients in the form are not defined over the same mesh as the integration domain, a corresponding :class: EntityMap<dolfinx.mesh.EntityMap> must be provided.

solve()[source]#

Solve the problem.

This method updates the solution u function(s) stored in the problem instance.

Note

The user is responsible for asserting convergence of the SNES solver e.g. assert problem.solver.getConvergedReason() > 0. Alternatively, pass "snes_error_if_not_converged": True and "ksp_error_if_not_converged" : True in petsc_options to raise a PETScError on failure.

Returns:

The solution function(s).