petsc_ksp.py¶
OpenMDAO LinearSolver that uses PetSC KSP to solve for a system’s derivatives. This solver can be used under MPI.
-
class
openmdao.solvers.petsc_ksp.
Monitor
(ksp)[source]¶ Bases:
object
Prints output from PETSc’s KSP solvers
-
class
openmdao.solvers.petsc_ksp.
PetscKSP
[source]¶ Bases:
openmdao.solvers.solver_base.LinearSolver
OpenMDAO LinearSolver that uses PetSC KSP to solve for a system’s derivatives. This solver can be used under MPI.
Options: options[‘atol’] : float(1e-12)
Absolute convergence tolerance.
options[‘err_on_maxiter’] : bool(False)
If True, raise an AnalysisError if not converged at maxiter.
options[‘iprint’] : int(0)
Set to 0 to print only failures, set to 1 to print iteration totals to stdout, set to 2 to print the residual each iteration to stdout, or -1 to suppress all printing.
options[‘ksp_type’] : str(‘fgmres’)
KSP algorithm to use. Default is ‘fgmres’.
options[‘maxiter’] : int(100)
Maximum number of iterations.
options[‘mode’] : str(‘auto’)
Derivative calculation mode, set to ‘fwd’ for forward mode, ‘rev’ for reverse mode, or ‘auto’ to let OpenMDAO determine the best mode.
options[‘rtol’] : float(1e-12)
Relative convergence tolerance.
-
apply
(mat, arg, result)[source]¶ Applies preconditioner.
Args: arg : PetSC Vector
Incoming vector
result : PetSC Vector
Empty vector into which we return the preconditioned arg
-
mult
(mat, arg, result)[source]¶ KSP Callback: applies Jacobian matrix. Mode is determined by the system.
Args: arg : PetSC Vector
Incoming vector
result : PetSC Vector
Empty array into which we place the matrix-vector product.
-
print_all_convergence
(level=2)[source]¶ Turns on iprint for this solver and all subsolvers. Override if your solver has subsolvers.
Args: level : int(2)
iprint level. Set to 2 to print residuals each iteration; set to 1 to print just the iteration totals.
-
solve
(rhs_mat, system, mode)[source]¶ Solves the linear system for the problem in self.system. The full solution vector is returned.
Args: rhs_mat : dict of ndarray
Dictionary containing one ndarry per top level quantity of interest. Each array contains the right-hand side for the linear solve.
system : System
Parent System object.
mode : string
Derivative mode, can be ‘fwd’ or ‘rev’.
Returns: dict of ndarray : Solution vectors
-