ngsPETSc.ksp
============

.. py:module:: ngsPETSc.ksp

.. autoapi-nested-parse::

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



Attributes
----------

.. autoapisummary::

   ngsPETSc.ksp.parse


Classes
-------

.. autoapisummary::

   ngsPETSc.ksp.KrylovSolver
   ngsPETSc.ksp.KSPOpeator


Functions
---------

.. autoapisummary::

   ngsPETSc.ksp.createFromBilinearForm
   ngsPETSc.ksp.createFromMatrix
   ngsPETSc.ksp.createFromPC
   ngsPETSc.ksp.createFromAction


Module Contents
---------------

.. py:function:: createFromBilinearForm(a, freeDofs, solverParameters)

   This function creates a PETSc matrix from an NGSolve bilinear form


.. py:function:: createFromMatrix(a, freeDofs, solverParameters)

   This function creates a PETSc matrix from an NGSolve bilinear form


.. py:function:: createFromPC(a, freeDofs, solverParameters)

   This function creates a PETSc matrix from an ngsPETSc PETSc Preconditioner


.. py:function:: createFromAction(a, freeDofs, solverParameters)

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


.. py:data:: parse

.. py:class:: 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.

   :arg a: either the bilinear form, ngs Matrix or a petsc4py matrix

   :arg dofsDescr: either finite element space

   :arg p: either the bilinear form, ngs Matrix or petsc4py matrix actin as a preconditioner

   :arg nullspace: either a PETSc NullSpace or ngsPETSc PETSc Preconditioner
   or touple of ngsPETSc PETSc Preconditioner.

   :arg solverParameters: parameters to be passed to the KS P solver

   :arg optionsPrefix: special solver options prefix for this specific Krylov solver



   .. py:attribute:: mapping


   .. py:attribute:: ksp


   .. py:attribute:: ngsA


   .. py:method:: solve(b, x, mapping=None)

      This function solves the linear system

      :arg b: right hand side of the linear system
      :arg x: solution of the linear system



   .. py:method:: operator()

      This function returns the operator of the KSP solver



.. py:class:: KSPOpeator(ksp)

   Bases: :py:obj:`ngsolve.la.BaseMatrix`


   This class wraps a PETSc KSP solver as an NGSolve matrix


   .. py:attribute:: ksp


   .. py:method:: Shape()

      Shape of the BaseMatrix




   .. py:method:: CreateVector(col)

      Create vector corresponding to the matrix

      :arg col: True if one want a column vector




   .. py:method:: Mult(x, y)

      Matrix-vector product



