# ngsPETSc.pc

This module contains all the function and class needed to wrap a PETSc Preconditioner in NGSolve

## Classes

`PETScPreconditioner` | This class creates a Netgen/NGSolve BaseMatrix corresponding to a PETSc PC
`ASMPreconditioner` | This class creates a Netgen/NGSolve BaseMatrix corresponding to a PETSc ASM PC

## Functions

`createPETScPreconditioner`(mat, freeDofs, solverParameters) | Create PETSc PC that can be accessed by NGSolve.

## Module Contents

class ngsPETSc.pc.PETScPreconditioner(mat, freeDofs, solverParameters=None, optionsPrefix='', nullspace=None, matType='aij')

  Bases: `ngsolve.BaseMatrix`

  This class creates a Netgen/NGSolve BaseMatrix corresponding to a PETSc PC

  Parameters:

    - mat – NGSolve Matrix one would like to build the PETSc preconditioner for.

    - freeDofs – not constrained degrees of freedom of the finite element space over

  which the BilinearForm corresponding to the matrix is defined.

  Parameters:

    - solverParameters – parameters to be passed to the KSP solver

    - optionsPrefix – special solver options prefix for this specific Krylov solver

    - matType – type of sparse matrix, i.e. PETSc sparse: aij,

  MKL sparse: mklaij or CUDA: aijcusparse

  ngsMat
  vecMap
  lgmap
  petscPreconditioner
  Shape()

    Shape of the BaseMatrix

  CreateVector(col)

    Create vector corresponding to the matrix

    Parameters:

      col – True if one want a column vector

  Mult(x, y)

    BaseMatrix multiplication Ax = y :arg x: vector we are multiplying :arg y: vector we are storeing the result in

  MultTrans(x, y)

    BaseMatrix multiplication A^T x = y :arg x: vector we are multiplying :arg y: vector we are storeing the result in

  setActingDofs(dofs)

    Set the acting dofs of the preconditioner :arg dofs: dofs that the preconditioner is acting on

ngsPETSc.pc.createPETScPreconditioner(mat, freeDofs, solverParameters)

  Create PETSc PC that can be accessed by NGSolve. :arg mat: NGSolve Matrix one would like to build the PETSc preconditioner for.

  Parameters:

    freeDofs – not constrained degrees of freedom of the finite element space over

  which the BilinearForm corresponding to the matrix is defined.

  Parameters:

    solverParameters – parameters to be passed to the KSP solver

class ngsPETSc.pc.ASMPreconditioner(mat, freeDofs, solverParameters=None, optionsPrefix='', nullspace=None, matType='aij', blocks=None)

  Bases: `PETScPreconditioner`

  This class creates a Netgen/NGSolve BaseMatrix corresponding to a PETSc ASM PC

  asmpc = None
  Mult(x, y)

    BaseMatrix multiplication Ax = y :arg x: vector we are multiplying :arg y: vector we are storeing the result in

  MultTrans(x, y)

    BaseMatrix multiplication A^T x = y :arg x: vector we are multiplying :arg y: vector we are storeing the result in