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" 35 # define LIBMESH_SAW_I 39 # undef I // Avoid complex.h contamination 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;
191 #endif // #ifdef LIBMESH_HAVE_PETSC 192 #endif // LIBMESH_PETSC_MATRIX_BASE_H virtual numeric_index_type n() const override
virtual numeric_index_type local_n() const final
Get the number of columns 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...
virtual void clear() noexcept override
clear() is called from the destructor, so it should not throw.
virtual numeric_index_type row_stop() const override
virtual numeric_index_type col_stop() const override
virtual numeric_index_type local_m() const final
Get the number of rows owned by this process.
This class provides a nice interface to the PETSc C-based data structures for parallel, sparse matrices.
void swap(PetscMatrixBase< T > &)
Swaps the internal data pointers of two PetscMatrices, no actual values are swapped.
virtual numeric_index_type m() const override
const Parallel::Communicator & comm() const
static PetscMatrixBase< T > * get_context(Mat mat, const TIMPI::Communicator &comm)
virtual ~PetscMatrixBase()
The libMesh namespace provides an interface to certain functionality in the library.
void set_context()
Set the context (ourself) for _mat.
dof_id_type numeric_index_type
PetscMatrixBase & operator=(PetscMatrixBase &&)=delete
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...
virtual void close() override
Calls the SparseMatrix's internal assembly routines, ensuring that the values are consistent across p...
virtual numeric_index_type col_start() const override
Mat _mat
PETSc matrix datatype to store values.
PetscMatrixBase(const Parallel::Communicator &comm_in)
virtual bool closed() const override
virtual SolverPackage solver_package() override
virtual numeric_index_type row_start() const override
SolverPackage
Defines an enum for various linear solver packages.
void destroy(triangulateio &t, IO_Type)
Frees any memory which has been dynamically allocated by Triangle.