petsc_ksp.py¶
LinearSolver that uses PetSC KSP to solve for a system’s derivatives.

class
openmdao.solvers.linear.petsc_ksp.
Monitor
(solver)[source]¶ Bases:
object
Prints output from PETSc’s KSP solvers.
Callable object given to KSP as a callback for printing the residual.

class
openmdao.solvers.linear.petsc_ksp.
PETScKrylov
(**kwargs)[source]¶ Bases:
openmdao.solvers.solver.LinearSolver
LinearSolver that uses PetSC KSP to solve for a system’s derivatives.
Attributes
precon
(Solver) Preconditioner for linear solve. Default is None for no preconditioner.

SOLVER
= 'LN: PETScKrylov'¶

__init__
(self, **kwargs)[source]¶ Declare the solver options.
 Parameters
 **kwargsdict
dictionary of options set by the instantiating class/script.

add_recorder
(self, recorder)¶ Add a recorder to the solver’s RecordingManager.
 Parameters
 recorder<CaseRecorder>
A recorder instance to be added to RecManager.

apply
(self, mat, in_vec, result)[source]¶ Apply preconditioner.
 Parameters
 matPETSc.Mat
PETSc matrix object.
 in_vecPETSc.Vector
Incoming vector
 resultPETSc.Vector
Empty vector in which the preconditioned in_vec is stored.

cleanup
(self)¶ Clean up resources prior to exit.

property
msginfo
¶ Return info to prepend to messages.
 Returns
 str
Info to prepend to messages.

mult
(self, mat, in_vec, result)[source]¶ Apply Jacobian matrix (KSP Callback).
The following attributes must be defined when solve is called to provide information used in this callback:
 _systemSystem
pointer to the owning system.
 _vec_namestr
the righthandside (RHS) vector name.
 _modestr
‘fwd’ or ‘rev’.
 Parameters
 matPETSc.Mat
PETSc matrix object.
 in_vecPetSC Vector
Incoming vector.
 resultPetSC Vector
Empty array into which we place the matrixvector product.

property
preconditioner
¶ Provide ‘preconditioner’ property for backwards compatibility.
 Returns
 <LinearSolver>
reference to the ‘precon’ property.

record_iteration
(self, **kwargs)¶ Record an iteration of the current Solver.
 Parameters
 **kwargsdict
Keyword arguments (used for abs and rel error).

solve
(self, vec_names, mode, rel_systems=None)[source]¶ Solve the linear system for the problem in self._system().
The full solution vector is returned.
 Parameters
 vec_nameslist
list of vector names.
 modestring
Derivative mode, can be ‘fwd’ or ‘rev’.
 rel_systemsset of str
Names of systems relevant to the current solve.


class
openmdao.solvers.linear.petsc_ksp.
PetscKSP
(**kwargs)[source]¶ Bases:
openmdao.solvers.linear.petsc_ksp.PETScKrylov
Deprecated. Use PETScKrylov.

SOLVER
= 'LN: PETScKrylov'¶

add_recorder
(self, recorder)¶ Add a recorder to the solver’s RecordingManager.
 Parameters
 recorder<CaseRecorder>
A recorder instance to be added to RecManager.

apply
(self, mat, in_vec, result)¶ Apply preconditioner.
 Parameters
 matPETSc.Mat
PETSc matrix object.
 in_vecPETSc.Vector
Incoming vector
 resultPETSc.Vector
Empty vector in which the preconditioned in_vec is stored.

cleanup
(self)¶ Clean up resources prior to exit.

property
msginfo
¶ Return info to prepend to messages.
 Returns
 str
Info to prepend to messages.

mult
(self, mat, in_vec, result)¶ Apply Jacobian matrix (KSP Callback).
The following attributes must be defined when solve is called to provide information used in this callback:
 _systemSystem
pointer to the owning system.
 _vec_namestr
the righthandside (RHS) vector name.
 _modestr
‘fwd’ or ‘rev’.
 Parameters
 matPETSc.Mat
PETSc matrix object.
 in_vecPetSC Vector
Incoming vector.
 resultPetSC Vector
Empty array into which we place the matrixvector product.

property
preconditioner
¶ Provide ‘preconditioner’ property for backwards compatibility.
 Returns
 <LinearSolver>
reference to the ‘precon’ property.

record_iteration
(self, **kwargs)¶ Record an iteration of the current Solver.
 Parameters
 **kwargsdict
Keyword arguments (used for abs and rel error).

solve
(self, vec_names, mode, rel_systems=None)¶ Solve the linear system for the problem in self._system().
The full solution vector is returned.
 Parameters
 vec_nameslist
list of vector names.
 modestring
Derivative mode, can be ‘fwd’ or ‘rev’.
 rel_systemsset of str
Names of systems relevant to the current solve.
