17 #include <deal.II/lac/petsc_matrix_free.h> 19 #ifdef DEAL_II_WITH_PETSC 21 #include <deal.II/lac/exceptions.h> 22 #include <deal.II/lac/petsc_compatibility.h> 24 DEAL_II_NAMESPACE_OPEN
29 : communicator (PETSC_COMM_SELF)
40 const unsigned int local_rows,
41 const unsigned int local_columns)
42 : communicator (communicator)
52 const std::vector<unsigned int> &local_rows_per_process,
53 const std::vector<unsigned int> &local_columns_per_process,
54 const unsigned int this_process)
55 : communicator (communicator)
57 Assert (local_rows_per_process.size() == local_columns_per_process.size(),
59 local_columns_per_process.size()));
60 Assert (this_process < local_rows_per_process.size(),
64 local_rows_per_process[this_process],
65 local_columns_per_process[this_process]);
72 const unsigned int local_rows,
73 const unsigned int local_columns)
74 : communicator (MPI_COMM_WORLD)
83 const std::vector<unsigned int> &local_rows_per_process,
84 const std::vector<unsigned int> &local_columns_per_process,
85 const unsigned int this_process)
86 : communicator (MPI_COMM_WORLD)
88 Assert (local_rows_per_process.size() == local_columns_per_process.size(),
90 local_columns_per_process.size()));
91 Assert (this_process < local_rows_per_process.size(),
95 local_rows_per_process[this_process],
96 local_columns_per_process[this_process]);
102 const unsigned int m,
103 const unsigned int n,
104 const unsigned int local_rows,
105 const unsigned int local_columns)
119 const unsigned int m,
120 const unsigned int n,
121 const std::vector<unsigned int> &local_rows_per_process,
122 const std::vector<unsigned int> &local_columns_per_process,
123 const unsigned int this_process)
125 Assert (local_rows_per_process.size() == local_columns_per_process.size(),
127 local_columns_per_process.size()));
128 Assert (this_process < local_rows_per_process.size(),
136 local_rows_per_process[this_process],
137 local_columns_per_process[this_process]);
143 const unsigned int n,
144 const unsigned int local_rows,
145 const unsigned int local_columns)
147 reinit (MPI_COMM_WORLD,
m,
n, local_rows, local_columns);
153 const unsigned int n,
154 const std::vector<unsigned int> &local_rows_per_process,
155 const std::vector<unsigned int> &local_columns_per_process,
156 const unsigned int this_process)
158 reinit (MPI_COMM_WORLD,
m,
n, local_rows_per_process, local_columns_per_process, this_process);
193 const char *vec_type;
194 PetscErrorCode ierr = VecGetType (src, &vec_type);
201 if (strcmp(vec_type,
"mpi") == 0)
204 ierr = VecGetSize (src, &size);
210 else if (strcmp(vec_type,
"seq") == 0)
217 "This only works for Petsc Vec Type = VECMPI | VECSEQ"));
226 ierr = VecCopy (static_cast<const Vec &>(*y), dst);
242 const PetscErrorCode ierr = MatShellGetContext (A, &this_object);
254 const unsigned int n,
255 const unsigned int local_rows,
256 const unsigned int local_columns)
264 PetscErrorCode ierr = MatCreateShell(
communicator, local_rows, local_columns,
269 ierr = MatShellSetOperation (
matrix, MATOP_MULT,
273 ierr = MatSetFromOptions (
matrix);
279 DEAL_II_NAMESPACE_CLOSE
281 #endif // DEAL_II_WITH_PETSC PetscErrorCode destroy_matrix(Mat &matrix)
virtual void vmult(VectorBase &dst, const VectorBase &src) const =0
#define AssertThrow(cond, exc)
static ::ExceptionBase & ExcMessage(std::string arg1)
size_type local_size() const
#define Assert(cond, exc)
void reinit(const MPI_Comm &communicator, const unsigned int m, const unsigned int n, const unsigned int local_rows, const unsigned int local_columns)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
const MPI_Comm & get_mpi_communicator() const
void equ(const PetscScalar a, const VectorBase &V)
static int matrix_free_mult(Mat A, Vec src, Vec dst)
void do_reinit(const unsigned int m, const unsigned int n, const unsigned int local_rows, const unsigned int local_columns)
static ::ExceptionBase & ExcInternalError()