20 #include "libmesh/libmesh_config.h" 22 #ifdef LIBMESH_HAVE_PETSC 25 #include "libmesh/petsc_matrix_base.h" 26 #include "libmesh/petsc_matrix_shell_matrix.h" 27 #include "libmesh/petsc_matrix.h" 42 _destroy_mat_on_exit(true)
52 const bool destroy_on_exit) :
54 _destroy_mat_on_exit(destroy_on_exit)
76 if ((this->
initialized()) && (this->_destroy_mat_on_exit))
78 exceptionless_semiparallel_only();
82 PetscErrorCode ierr = MatDestroy (&_mat);
84 libmesh_warning(
"Warning: MatDestroy returned a non-zero error code which we ignored.");
93 this->_destroy_mat_on_exit =
destroy;
100 std::swap(_mat, m_in.
_mat);
104 template <
typename T>
108 PetscContainer container;
109 LibmeshPetscCall(PetscContainerCreate(this->comm().
get(), &container));
110 LibmeshPetscCall(PetscContainerSetPointer(container,
this));
111 LibmeshPetscCall(PetscObjectCompose((PetscObject)(Mat)this->_mat,
"PetscMatrixCtx", (PetscObject)container));
112 LibmeshPetscCall(PetscContainerDestroy(&container));
115 template <
typename T>
119 PetscContainer container;
120 LibmeshPetscCall2(comm, PetscObjectQuery((PetscObject)mat,
"PetscMatrixCtx", (PetscObject *)&container));
124 LibmeshPetscCall2(comm, PetscContainerGetPointer(container, &
ctx));
129 template <
typename T>
134 PetscInt petsc_m=0, petsc_n=0;
136 LibmeshPetscCall(MatGetSize (this->_mat, &petsc_m, &petsc_n));
141 template <
typename T>
148 LibmeshPetscCall(MatGetLocalSize (this->_mat, &m, NULL));
153 template <
typename T>
158 PetscInt petsc_m=0, petsc_n=0;
160 LibmeshPetscCall(MatGetSize (this->_mat, &petsc_m, &petsc_n));
165 template <
typename T>
172 LibmeshPetscCall(MatGetLocalSize (this->_mat, NULL, &n));
177 template <
typename T>
182 PetscInt start=0,
stop=0;
184 LibmeshPetscCall(MatGetOwnershipRange(this->_mat, &start, &
stop));
189 template <
typename T>
194 PetscInt start=0,
stop=0;
196 LibmeshPetscCall(MatGetOwnershipRange(this->_mat, &start, &
stop));
201 template <
typename T>
206 PetscInt start=0,
stop=0;
208 LibmeshPetscCall(MatGetOwnershipRangeColumn(this->_mat, &start, &
stop));
213 template <
typename T>
218 PetscInt start=0,
stop=0;
220 LibmeshPetscCall(MatGetOwnershipRangeColumn(this->_mat, &start, &
stop));
225 template <
typename T>
237 MatAssemblyBeginEnd(this->comm(), this->_mat, MAT_FINAL_ASSEMBLY);
240 template <
typename T>
247 LibmeshPetscCall(MatAssembled(this->_mat, &assembled));
249 return (assembled == PETSC_TRUE);
259 #endif // #ifdef LIBMESH_HAVE_PETSC bool closed()
Checks that the library has been closed.
bool _destroy_mat_on_exit
This boolean value should only be set to false for the constructor which takes a PETSc Mat object...
This class provides a nice interface to the PETSc C-based data structures for parallel, sparse matrices.
The libMesh namespace provides an interface to certain functionality in the library.
dof_id_type numeric_index_type
bool _is_initialized
Flag that tells if init() has been called.
void stop(const char *file, int line, const char *date, const char *time)
Mat _mat
PETSc matrix datatype to store values.
PetscMatrixBase(const Parallel::Communicator &comm_in)
bool initialized()
Checks that library initialization has been done.
void destroy(triangulateio &t, IO_Type)
Frees any memory which has been dynamically allocated by Triangle.