Reference documentation for deal.II version 8.1.0
petsc_matrix_free.h
1 // ---------------------------------------------------------------------
2 // @f$Id: petsc_matrix_free.h 30036 2013-07-18 16:55:32Z maier @f$
3 //
4 // Copyright (C) 2012 - 2013 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // The deal.II library is free software; you can use it, redistribute
9 // it, and/or modify it under the terms of the GNU Lesser General
10 // Public License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // The full text of the license can be found in the file LICENSE at
13 // the top level of the deal.II distribution.
14 //
15 // ---------------------------------------------------------------------
16 
17 #ifndef __deal2__petsc_matrix_free_h
18 #define __deal2__petsc_matrix_free_h
19 
20 
21 #include <deal.II/base/config.h>
22 
23 #ifdef DEAL_II_WITH_PETSC
24 
25 # include <deal.II/lac/exceptions.h>
26 # include <deal.II/lac/petsc_matrix_base.h>
27 # include <deal.II/lac/petsc_vector.h>
28 
30 
31 
32 
33 namespace PETScWrappers
34 {
64  class MatrixFree : public MatrixBase
65  {
66  public:
67 
72  MatrixFree ();
73 
96  MatrixFree (const MPI_Comm &communicator,
97  const unsigned int m,
98  const unsigned int n,
99  const unsigned int local_rows,
100  const unsigned int local_columns);
101 
119  MatrixFree (const MPI_Comm &communicator,
120  const unsigned int m,
121  const unsigned int n,
122  const std::vector<unsigned int> &local_rows_per_process,
123  const std::vector<unsigned int> &local_columns_per_process,
124  const unsigned int this_process);
125 
132  MatrixFree (const unsigned int m,
133  const unsigned int n,
134  const unsigned int local_rows,
135  const unsigned int local_columns);
136 
143  MatrixFree (const unsigned int m,
144  const unsigned int n,
145  const std::vector<unsigned int> &local_rows_per_process,
146  const std::vector<unsigned int> &local_columns_per_process,
147  const unsigned int this_process);
148 
157  void reinit (const MPI_Comm &communicator,
158  const unsigned int m,
159  const unsigned int n,
160  const unsigned int local_rows,
161  const unsigned int local_columns);
162 
171  void reinit (const MPI_Comm &communicator,
172  const unsigned int m,
173  const unsigned int n,
174  const std::vector<unsigned int> &local_rows_per_process,
175  const std::vector<unsigned int> &local_columns_per_process,
176  const unsigned int this_process);
177 
182  void reinit (const unsigned int m,
183  const unsigned int n,
184  const unsigned int local_rows,
185  const unsigned int local_columns);
186 
191  void reinit (const unsigned int m,
192  const unsigned int n,
193  const std::vector<unsigned int> &local_rows_per_process,
194  const std::vector<unsigned int> &local_columns_per_process,
195  const unsigned int this_process);
196 
203  void clear ();
204 
210  const MPI_Comm &get_mpi_communicator () const;
211 
230  virtual
231  void vmult (VectorBase &dst,
232  const VectorBase &src) const = 0;
233 
252  virtual
253  void Tvmult (VectorBase &dst,
254  const VectorBase &src) const = 0;
255 
274  virtual
275  void vmult_add (VectorBase &dst,
276  const VectorBase &src) const = 0;
277 
299  virtual
300  void Tvmult_add (VectorBase &dst,
301  const VectorBase &src) const = 0;
302 
314  virtual
315  void vmult (Vec &dst, const Vec &src) const;
316 
317  private:
318 
323  MPI_Comm communicator;
324 
343  static int matrix_free_mult (Mat A, Vec src, Vec dst);
344 
353  void do_reinit (const unsigned int m,
354  const unsigned int n,
355  const unsigned int local_rows,
356  const unsigned int local_columns);
357  };
358 
359 
360 
361 // -------- template and inline functions ----------
362 
363  inline
364  const MPI_Comm &
366  {
367  return communicator;
368  }
369 }
370 
371 DEAL_II_NAMESPACE_CLOSE
372 
373 #endif // DEAL_II_WITH_PETSC
374 
375 
376 /*---------------------------- petsc_matrix_free.h ---------------------------*/
377 
378 #endif
379 /*---------------------------- 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
size_type n() const
size_type m() const
virtual void Tvmult(VectorBase &dst, const VectorBase &src) const =0
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)
void reinit(const MPI_Comm &communicator, const unsigned int m, const unsigned int n, const unsigned int local_rows, const unsigned int local_columns)