20#ifndef LIBMESH_PETSC_MATRIX_BASE_H
21#define LIBMESH_PETSC_MATRIX_BASE_H
23#include "libmesh/libmesh_common.h"
25#ifdef LIBMESH_HAVE_PETSC
28#include "libmesh/sparse_matrix.h"
29#include "libmesh/petsc_macro.h"
30#include "libmesh/petsc_solver_exception.h"
31#include "libmesh/wrapped_petsc.h"
46#undef semiparallel_only
47#undef exceptionless_semiparallel_only
51#define semiparallel_only() do { if (this->initialized()) { const char * mytype; \
52 LibmeshPetscCall(MatGetType(this->_mat,&mytype)); \
53 if (!strcmp(mytype, MATSEQAIJ)) \
54 parallel_object_only(); } } while (0)
55#define exceptionless_semiparallel_only() do { if (this->initialized()) { const char * mytype; \
56 auto semiparallel_only_ierr = MatGetType(this->_mat,&mytype); \
57 libmesh_ignore(semiparallel_only_ierr); \
58 if (!strcmp(mytype, MATSEQAIJ)) \
59 exceptionless_parallel_object_only(); } } while (0)
61#define semiparallel_only()
62#define exceptionless_semiparallel_only()
95 bool destroy_on_exit =
false);
126 virtual void clear() noexcept override;
171 virtual
void close () override;
173 virtual
bool closed() const override;
const Parallel::Communicator & comm() const
This class provides a nice interface to the PETSc C-based data structures for parallel,...
PetscMatrixBase(PetscMatrixBase &&)=delete
This class manages a C-style struct (Mat) manually, so we don't want to allow any automatic copy/move...
void swap(PetscMatrixBase< T > &)
Swaps the internal data pointers of two PetscMatrices, no actual values are swapped.
virtual numeric_index_type n() const override
static PetscMatrixBase< T > * get_context(Mat mat, const TIMPI::Communicator &comm)
virtual numeric_index_type local_m() const final
Get the number of rows owned by this process.
bool _destroy_mat_on_exit
This boolean value should only be set to false for the constructor which takes a PETSc Mat object.
PetscMatrixBase & operator=(PetscMatrixBase &&)=delete
virtual numeric_index_type col_start() const override
void set_context()
Set the context (ourself) for _mat.
virtual void close() override
Calls the SparseMatrix's internal assembly routines, ensuring that the values are consistent across p...
virtual ~PetscMatrixBase()
PetscMatrixBase(const PetscMatrixBase &)=delete
virtual numeric_index_type m() const override
virtual bool closed() const override
virtual numeric_index_type local_n() const final
Get the number of columns owned by this process.
virtual numeric_index_type col_stop() const override
virtual numeric_index_type row_start() const override
Mat _mat
PETSc matrix datatype to store values.
virtual SolverPackage solver_package() override
virtual void clear() noexcept override
clear() is called from the destructor, so it should not throw.
virtual numeric_index_type row_stop() const override
void set_destroy_mat_on_exit(bool destroy=true)
If set to false, we don't delete the Mat on destruction and allow instead for PETSc to manage it.
The libMesh namespace provides an interface to certain functionality in the library.
dof_id_type numeric_index_type
SolverPackage
Defines an enum for various linear solver packages.