Petsc wrapper

The following objects are only available if PetscDefined is set which is the case if Petsc is included.

The Petsc MATSHELL is created by the Operator class by calling create_PetscShellMatrix(). It contains a pointer to an instance of the the ShellMatrix class which works with the vector structure, Vec, of Petsc.

The matrix-free multiplcation is a wrapper of the low-level function MATMUL_basic(…):

template<class T>
PetscErrorCode danceq::internal::MATMUL_PETSC(Mat shell, Vec input, Vec output)

C-function used by Petsc to perform matrix-vector multiplication.

shell is a MATSHELL object from Petsc that is used for matrix-free multiplication. It has a context pointer that points to a ShellMatrix which provides a full memory layout for the communication pattern and avoids reallocating memory. It simply calls the low-level function MATMUL_basic(…).

Parameters:
  • shell – MATSHELL object

  • input – Input Vec

  • output – Output Vec

Returns:

PetscErrorCode

The function MATDESTROY_PETSC() destroys the shell by deleting the pointer to the ShellMatrix class:

template<class T>
PetscErrorCode danceq::internal::MATDESTROY_PETSC(Mat shell)

C-function used by Petsc to destroy the matrix shell.

shell is a MATSHELL object from Petsc that is used for matrix-free multiplication. It has a context pointer that points to a ShellMatrix which is deleted after calling this functions.

Parameters:

shell – MATSHELL object

Returns:

PetscErrorCode