ngsPETSc.ksp

This module contains all the functions related to the PETSc linear system solver (KSP) interface for NGSolve

Attributes

parse

Classes

KrylovSolver

This class creates a PETSc Krylov Solver (KSP) for NGSolve.

KSPOpeator

This class wraps a PETSc KSP solver as an NGSolve matrix

Functions

createFromBilinearForm(a, freeDofs, solverParameters)

This function creates a PETSc matrix from an NGSolve bilinear form

createFromMatrix(a, freeDofs, solverParameters)

This function creates a PETSc matrix from an NGSolve bilinear form

createFromPC(a, freeDofs, solverParameters)

This function creates a PETSc matrix from an ngsPETSc PETSc Preconditioner

createFromAction(a, freeDofs, solverParameters)

This function creates a matrix free PETSc matrix from an NGSolve matrix

Module Contents

ngsPETSc.ksp.createFromBilinearForm(a, freeDofs, solverParameters)

This function creates a PETSc matrix from an NGSolve bilinear form

ngsPETSc.ksp.createFromMatrix(a, freeDofs, solverParameters)

This function creates a PETSc matrix from an NGSolve bilinear form

ngsPETSc.ksp.createFromPC(a, freeDofs, solverParameters)

This function creates a PETSc matrix from an ngsPETSc PETSc Preconditioner

ngsPETSc.ksp.createFromAction(a, freeDofs, solverParameters)

This function creates a matrix free PETSc matrix from an NGSolve matrix

ngsPETSc.ksp.parse
class ngsPETSc.ksp.KrylovSolver(a, dofsDescr, p=None, nullspace=None, optionsPrefix='', solverParameters={})

This class creates a PETSc Krylov Solver (KSP) for NGSolve. Inspired by Firedrake linear solver class.

Parameters:
  • a – either the bilinear form, ngs Matrix or a petsc4py matrix

  • dofsDescr – either finite element space

  • p – either the bilinear form, ngs Matrix or petsc4py matrix actin as a preconditioner

  • nullspace – either a PETSc NullSpace or ngsPETSc PETSc Preconditioner

or touple of ngsPETSc PETSc Preconditioner.

Parameters:
  • solverParameters – parameters to be passed to the KS P solver

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

mapping
ksp
ngsA
solve(b, x, mapping=None)

This function solves the linear system

Parameters:
  • b – right hand side of the linear system

  • x – solution of the linear system

operator()

This function returns the operator of the KSP solver

class ngsPETSc.ksp.KSPOpeator(ksp)

Bases: ngsolve.la.BaseMatrix

This class wraps a PETSc KSP solver as an NGSolve matrix

ksp
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)

Matrix-vector product