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.

apply(mat, sol_vec, rhs_vec)[source]

Applies preconditioner

Args:

sol_vec : PetSC Vector

Incoming vector

rhs_vec : PetSC Vector

Empty vector into which we return the preconditioned sol_vec

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.

setup(system)[source]

Setup petsc problem just once.

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