Go to the documentation of this file.
18 #ifndef LIBMESH_PETSC_SHELL_MATRIX_H
19 #define LIBMESH_PETSC_SHELL_MATRIX_H
22 #include "libmesh/libmesh_config.h"
23 #ifdef LIBMESH_HAVE_PETSC
27 #include "libmesh/libmesh_common.h"
28 #include "libmesh/reference_counted_object.h"
29 #include "libmesh/libmesh.h"
30 #include "libmesh/shell_matrix.h"
31 #include "libmesh/petsc_macro.h"
32 #include "libmesh/petsc_solver_exception.h"
33 #include "libmesh/petsc_vector.h"
34 #include "libmesh/libmesh_common.h"
38 # define LIBMESH_SAW_I
42 # undef I // Avoid complex.h contamination
84 virtual void clear ()
override;
86 virtual void init ()
override;
94 Mat
mat() {
if (
_mat)
return _mat;
else libmesh_error_msg(
"A petsc shell matrix is not created yet. Please init() "); }
110 template <
typename T>
120 template <
typename T>
129 template <
typename T>
136 ierr = MatGetSize(_mat,&m,
nullptr);
137 LIBMESH_CHKERR(
ierr);
144 template <
typename T>
151 ierr = MatGetSize(_mat,
nullptr,&n);
152 LIBMESH_CHKERR(
ierr);
158 template <
typename T>
165 ierr = MatGetLocalSize(_mat,&m,
nullptr);
166 LIBMESH_CHKERR(
ierr);
173 template <
typename T>
180 ierr = MatGetLocalSize(_mat,
nullptr,&n);
181 LIBMESH_CHKERR(
ierr);
187 template <
typename T>
194 PetscErrorCode
ierr =
195 MatGetDiagonal(_mat,petsc_dest.
vec()); LIBMESH_CHKERR(
ierr);
202 #endif // LIBMESH_HAVE_PETSC
203 #endif // LIBMESH_SPARSE_SHELL_MATRIX_H
virtual void vector_mult(NumericVector< T > &dest, const NumericVector< T > &arg) const override
Multiplies the matrix with arg and stores the result in dest.
Generic shell matrix, i.e.
virtual ~PetscShellMatrix()
Destructor.
The libMesh namespace provides an interface to certain functionality in the library.
virtual void clear() override
virtual numeric_index_type local_m() const
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
This class allows to use a PETSc shell matrix.
PetscShellMatrix(const Parallel::Communicator &comm_in)
This class provides a nice interface to PETSc's Vec object.
virtual numeric_index_type local_n() const
dof_id_type numeric_index_type
virtual numeric_index_type m() const override
Mat _mat
Petsc Shell Matrix.
bool _is_initialized
Flag that tells if init() has been called.
virtual void init() override
virtual void vector_mult_add(NumericVector< T > &dest, const NumericVector< T > &arg) const override
Multiplies the matrix with arg and adds the result to dest.
virtual bool initialized() const
virtual numeric_index_type n() const override
virtual void get_diagonal(NumericVector< T > &dest) const override
Copies the diagonal part of the matrix into dest.