Advanced Multi-Physics (AMP)
On-Line Documentation
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
AMP::LinearAlgebra::PetscMatrix Class Referencefinal

PetscMatrix is a bridge between AMP::LinearAlgebra::Matrix and the PETSc Vec data structure. More...

#include <PetscMatrix.h>

Public Member Functions

std::shared_ptr< MatrixgetManagedMat ()
 
std::shared_ptr< const MatrixgetManagedMat () const
 
MatgetMat ()
 Obtain PETSc Mat for use in PETSc routines.
 
const MatgetMat () const
 Obtain PETSc Mat for use in PETSc routines.
 
MatgetNativeMat ()
 
const MatgetNativeMat () const
 
virtual ~PetscMatrix ()
 Destructor.
 

Static Public Member Functions

static std::shared_ptr< const PetscMatrixconstView (std::shared_ptr< const Matrix > AmpMatrix)
 If needed, create a PETSc wrapper for AmpMatrix. Otherwise, return AmpMatrix.
 
static std::shared_ptr< PetscMatrixview (std::shared_ptr< Matrix > AmpMatrix)
 If needed, create a PETSc wrapper for AmpMatrix. Otherwise, return AmpMatrix.
 

Protected Member Functions

 PetscMatrix ()
 Empty constructor.
 
 PetscMatrix (std::shared_ptr< Matrix > mat)
 Default constructor.
 

Protected Attributes

Mat d_Mat
 
std::shared_ptr< Matrixd_matrix
 

Detailed Description

PetscMatrix is a bridge between AMP::LinearAlgebra::Matrix and the PETSc Vec data structure.

A PetscMatrix has a Mat data structure. Given an AMP::LinearAlgebra::Matrix, this class can create a PETSc view without copying the data. As such, this class serves three purposes:

  1. Provides a PETSc Mat for derived classes to use, fill, manage, etc.
  2. Provides an interface for accessing this PETSc Mat independent of derived classes
  3. Provides a static method for creating a PETSc view of an AMP Matrix.

Definition at line 26 of file PetscMatrix.h.

Constructor & Destructor Documentation

◆ ~PetscMatrix()

virtual AMP::LinearAlgebra::PetscMatrix::~PetscMatrix ( )
virtual

Destructor.

◆ PetscMatrix() [1/2]

AMP::LinearAlgebra::PetscMatrix::PetscMatrix ( )
protected

Empty constructor.

◆ PetscMatrix() [2/2]

AMP::LinearAlgebra::PetscMatrix::PetscMatrix ( std::shared_ptr< Matrix mat)
explicitprotected

Default constructor.

Member Function Documentation

◆ constView()

static std::shared_ptr< const PetscMatrix > AMP::LinearAlgebra::PetscMatrix::constView ( std::shared_ptr< const Matrix AmpMatrix)
static

If needed, create a PETSc wrapper for AmpMatrix. Otherwise, return AmpMatrix.

The function attempts to return a view with the least amount of work. It will never copy data. If the matrix cannot be wrapped it wll return an error.

Parameters
AmpMatrixa shared pointer to a Matrix

◆ getManagedMat() [1/2]

std::shared_ptr< Matrix > AMP::LinearAlgebra::PetscMatrix::getManagedMat ( )
inline

Definition at line 72 of file PetscMatrix.h.

References d_matrix.

◆ getManagedMat() [2/2]

std::shared_ptr< const Matrix > AMP::LinearAlgebra::PetscMatrix::getManagedMat ( ) const
inline

Definition at line 73 of file PetscMatrix.h.

References d_matrix.

◆ getMat() [1/2]

Mat & AMP::LinearAlgebra::PetscMatrix::getMat ( )
inline

Obtain PETSc Mat for use in PETSc routines.

This function is used to get a PETSc matrix. The following idiom should be used since it fails gracefully. In this function, a view may be created before the Mat is extracted

Definition at line 41 of file PetscMatrix.h.

References d_Mat.

◆ getMat() [2/2]

const Mat & AMP::LinearAlgebra::PetscMatrix::getMat ( ) const
inline

Obtain PETSc Mat for use in PETSc routines.

This function is used to get a PETSc matrix. The following idiom should be used since it fails gracefully. In this function, a view may be created before the Mat is extracted

Definition at line 50 of file PetscMatrix.h.

References d_Mat.

◆ getNativeMat() [1/2]

Mat & AMP::LinearAlgebra::PetscMatrix::getNativeMat ( )
inline

Definition at line 70 of file PetscMatrix.h.

References d_Mat.

◆ getNativeMat() [2/2]

const Mat & AMP::LinearAlgebra::PetscMatrix::getNativeMat ( ) const
inline

Definition at line 71 of file PetscMatrix.h.

References d_Mat.

◆ view()

static std::shared_ptr< PetscMatrix > AMP::LinearAlgebra::PetscMatrix::view ( std::shared_ptr< Matrix AmpMatrix)
static

If needed, create a PETSc wrapper for AmpMatrix. Otherwise, return AmpMatrix.

The function attempts to return a view with the least amount of work. It will never copy data. If the matrix cannot be wrapped it wll return an error.

Parameters
AmpMatrixa shared pointer to a Matrix

Referenced by AMP::LinearAlgebra::PETScInterfaceLeftVectorFactory::getVector(), and AMP::LinearAlgebra::PETScInterfaceRightVectorFactory::getVector().

Member Data Documentation

◆ d_Mat

Mat AMP::LinearAlgebra::PetscMatrix::d_Mat
protected

Definition at line 84 of file PetscMatrix.h.

Referenced by getMat(), getMat(), getNativeMat(), and getNativeMat().

◆ d_matrix

std::shared_ptr<Matrix> AMP::LinearAlgebra::PetscMatrix::d_matrix
protected

Definition at line 85 of file PetscMatrix.h.

Referenced by getManagedMat(), and getManagedMat().


The documentation for this class was generated from the following file:



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:43.
Comments on this page