Reference documentation for deal.II version 9.0.0
petsc_matrix_free.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2012 - 2017 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_petsc_matrix_free_h
17 #define dealii_petsc_matrix_free_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #ifdef DEAL_II_WITH_PETSC
23 # include <deal.II/lac/exceptions.h>
24 # include <deal.II/lac/petsc_matrix_base.h>
25 # include <deal.II/lac/petsc_parallel_vector.h>
26 DEAL_II_NAMESPACE_OPEN
27 
28 
29 
30 namespace PETScWrappers
31 {
60  class MatrixFree : public MatrixBase
61  {
62  public:
63 
67  MatrixFree ();
68 
83  MatrixFree (const MPI_Comm &communicator,
84  const unsigned int m,
85  const unsigned int n,
86  const unsigned int local_rows,
87  const unsigned int local_columns);
88 
100  MatrixFree (const MPI_Comm &communicator,
101  const unsigned int m,
102  const unsigned int n,
103  const std::vector<unsigned int> &local_rows_per_process,
104  const std::vector<unsigned int> &local_columns_per_process,
105  const unsigned int this_process);
106 
112  MatrixFree (const unsigned int m,
113  const unsigned int n,
114  const unsigned int local_rows,
115  const unsigned int local_columns);
116 
122  MatrixFree (const unsigned int m,
123  const unsigned int n,
124  const std::vector<unsigned int> &local_rows_per_process,
125  const std::vector<unsigned int> &local_columns_per_process,
126  const unsigned int this_process);
127 
133  void reinit (const MPI_Comm &communicator,
134  const unsigned int m,
135  const unsigned int n,
136  const unsigned int local_rows,
137  const unsigned int local_columns);
138 
144  void reinit (const MPI_Comm &communicator,
145  const unsigned int m,
146  const unsigned int n,
147  const std::vector<unsigned int> &local_rows_per_process,
148  const std::vector<unsigned int> &local_columns_per_process,
149  const unsigned int this_process);
150 
155  void reinit (const unsigned int m,
156  const unsigned int n,
157  const unsigned int local_rows,
158  const unsigned int local_columns);
159 
164  void reinit (const unsigned int m,
165  const unsigned int n,
166  const std::vector<unsigned int> &local_rows_per_process,
167  const std::vector<unsigned int> &local_columns_per_process,
168  const unsigned int this_process);
169 
174  void clear ();
175 
180  const MPI_Comm &get_mpi_communicator () const;
181 
193  virtual
194  void vmult (VectorBase &dst,
195  const VectorBase &src) const = 0;
196 
209  virtual
210  void Tvmult (VectorBase &dst,
211  const VectorBase &src) const = 0;
212 
224  virtual
225  void vmult_add (VectorBase &dst,
226  const VectorBase &src) const = 0;
227 
240  virtual
241  void Tvmult_add (VectorBase &dst,
242  const VectorBase &src) const = 0;
243 
252  virtual
253  void vmult (Vec &dst, const Vec &src) const;
254 
255  private:
256 
261  MPI_Comm communicator;
262 
274  static int matrix_free_mult (Mat A, Vec src, Vec dst);
275 
281  void do_reinit (const unsigned int m,
282  const unsigned int n,
283  const unsigned int local_rows,
284  const unsigned int local_columns);
285  };
286 
287 
288 
289 // -------- template and inline functions ----------
290 
291  inline
292  const MPI_Comm &
294  {
295  return communicator;
296  }
297 }
298 
299 DEAL_II_NAMESPACE_CLOSE
300 
301 #endif // DEAL_II_WITH_PETSC
302 
303 
304 /*---------------------------- petsc_matrix_free.h ---------------------------*/
305 
306 #endif
307 /*---------------------------- petsc_matrix_free.h ---------------------------*/
virtual void vmult_add(VectorBase &dst, const VectorBase &src) const =0
virtual void Tvmult_add(VectorBase &dst, const VectorBase &src) const =0
virtual void vmult(VectorBase &dst, const VectorBase &src) const =0
virtual void Tvmult(VectorBase &dst, const VectorBase &src) const =0
void reinit(const MPI_Comm &communicator, const unsigned int m, const unsigned int n, const unsigned int local_rows, const unsigned int local_columns)
const MPI_Comm & get_mpi_communicator() const
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)