MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / __init__

Method __init__

python/dolfinx/fem/petsc.py:1148–1325  ·  view source on GitHub ↗

Initialize solver for a nonlinear variational problem. By default, the underlying SNES solver uses PETSc's default options. To use the robust combination of LU via MUMPS with a backtracking linesearch, pass: Example:: petsc_options = {"ksp_type": "preon

(
        self,
        F: ufl.form.Form | Sequence[ufl.form.Form],
        u: _Function | Sequence[_Function],
        *,
        petsc_options_prefix: str,
        bcs: Sequence[DirichletBC] | None = None,
        J: ufl.form.Form | Sequence[Sequence[ufl.form.Form]] | None = None,
        P: ufl.form.Form | Sequence[Sequence[ufl.form.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 from the content-addressed store, hash-verified

1146 """ # noqa: D301
1147
1148 def __init__(
1149 self,
1150 F: ufl.form.Form | Sequence[ufl.form.Form],
1151 u: _Function | Sequence[_Function],
1152 *,
1153 petsc_options_prefix: str,
1154 bcs: Sequence[DirichletBC] | None = None,
1155 J: ufl.form.Form | Sequence[Sequence[ufl.form.Form]] | None = None,
1156 P: ufl.form.Form | Sequence[Sequence[ufl.form.Form]] | None = None,
1157 kind: str | Sequence[Sequence[str]] | None = None,
1158 petsc_options: dict | None = None,
1159 form_compiler_options: dict | None = None,
1160 jit_options: dict | None = None,
1161 entity_maps: Sequence[_EntityMap] | None = None,
1162 ):
1163 """Initialize solver for a nonlinear variational problem.
1164
1165 By default, the underlying SNES solver uses PETSc's default
1166 options. To use the robust combination of LU via MUMPS with
1167 a backtracking linesearch, pass:
1168
1169 Example::
1170
1171 petsc_options = {"ksp_type": "preonly",
1172 "pc_type": "lu",
1173 "pc_factor_mat_solver_type": "mumps",
1174 "snes_linesearch_type": "bt",
1175 }
1176
1177 Every PETSc object will have a unique options prefix set. We
1178 recommend discovering these prefixes dynamically via the
1179 petsc4py API rather than hard-coding each prefix value into
1180 the programme.
1181
1182 Example::
1183
1184 snes_options_prefix = problem.solver.getOptionsPrefix()
1185 jacobian_options_prefix = problem.A.getOptionsPrefix()
1186
1187 Args:
1188 F: UFL form(s) representing the residual :math:`F_i`.
1189 u: Function(s) used to define the residual and Jacobian.
1190 bcs: Dirichlet boundary conditions.
1191 J: UFL form(s) representing the Jacobian
1192 :math:`J_{ij} = dF_i/du_j`. If not passed, derived
1193 automatically.
1194 P: UFL form(s) representing the preconditioner.
1195 kind: The PETSc matrix and vector kind. Common choices
1196 are ``mpi`` and ``nest``. See
1197 :func:`dolfinx.fem.petsc.create_matrix` and
1198 :func:`dolfinx.fem.petsc.create_vector` for more
1199 information.
1200 petsc_options_prefix: Mandatory named argument.
1201 Options prefix used as root prefix on all
1202 internally created PETSc objects. Typically ends with `_`.
1203 Must be the same on all ranks, and is usually unique within
1204 the programme.
1205 petsc_options: Options set on the underlying PETSc SNES only.

Callers

nothing calls this directly

Calls 4

_create_formFunction · 0.90
derivative_blockFunction · 0.90
create_matrixFunction · 0.70
create_vectorFunction · 0.70

Tested by

no test coverage detected