Reference documentation for deal.II version 8.4.1
petsc_sparse_matrix.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2004 - 2016 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_sparse_matrix_h
17 #define dealii__petsc_sparse_matrix_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #ifdef DEAL_II_WITH_PETSC
23 
24 # include <deal.II/lac/exceptions.h>
25 # include <deal.II/lac/petsc_matrix_base.h>
26 # include <vector>
27 
28 DEAL_II_NAMESPACE_OPEN
29 // forward declaration
30 template <typename MatrixType> class BlockMatrixBase;
31 
32 
33 namespace PETScWrappers
34 {
48  class SparseMatrix : public MatrixBase
49  {
50  public:
51 
59  struct Traits
60  {
65  static const bool zero_addition_can_be_elided = true;
66  };
67 
71  SparseMatrix ();
72 
87  SparseMatrix (const size_type m,
88  const size_type n,
89  const size_type n_nonzero_per_row,
90  const bool is_symmetric = false);
91 
108  SparseMatrix (const size_type m,
109  const size_type n,
110  const std::vector<size_type> &row_lengths,
111  const bool is_symmetric = false);
112 
130  template <typename SparsityPatternType>
131  explicit SparseMatrix (const SparsityPatternType &sparsity_pattern,
132  const bool preset_nonzero_locations = true);
133 
143  SparseMatrix &operator = (const double d);
144 
150  void reinit (const size_type m,
151  const size_type n,
152  const size_type n_nonzero_per_row,
153  const bool is_symmetric = false);
154 
160  void reinit (const size_type m,
161  const size_type n,
162  const std::vector<size_type> &row_lengths,
163  const bool is_symmetric = false);
164 
190  template <typename SparsityPatternType>
191  void reinit (const SparsityPatternType &sparsity_pattern,
192  const bool preset_nonzero_locations = true);
193 
199  virtual const MPI_Comm &get_mpi_communicator () const;
200 
215  PetscScalar matrix_norm_square (const VectorBase &v) const;
216 
225  PetscScalar matrix_scalar_product (const VectorBase &u,
226  const VectorBase &v) const;
227 
228  private:
229 
233  SparseMatrix(const SparseMatrix &);
238 
244  void do_reinit (const size_type m,
245  const size_type n,
246  const size_type n_nonzero_per_row,
247  const bool is_symmetric = false);
248 
252  void do_reinit (const size_type m,
253  const size_type n,
254  const std::vector<size_type> &row_lengths,
255  const bool is_symmetric = false);
256 
260  template <typename SparsityPatternType>
261  void do_reinit (const SparsityPatternType &sparsity_pattern,
262  const bool preset_nonzero_locations);
263 
268  };
269 }
270 
271 DEAL_II_NAMESPACE_CLOSE
272 
273 #endif // DEAL_II_WITH_PETSC
274 
275 /*---------------------------- petsc_sparse_matrix.h ---------------------------*/
276 
277 #endif
278 /*---------------------------- petsc_sparse_matrix.h ---------------------------*/
PetscScalar matrix_scalar_product(const VectorBase &u, const VectorBase &v) const
PetscBool is_symmetric(const double tolerance=1.e-12)
SparseMatrix & operator=(const double d)
void reinit(const size_type m, const size_type n, const size_type n_nonzero_per_row, const bool is_symmetric=false)
types::global_dof_index size_type
virtual const MPI_Comm & get_mpi_communicator() const
void do_reinit(const size_type m, const size_type n, const size_type n_nonzero_per_row, const bool is_symmetric=false)
PetscScalar matrix_norm_square(const VectorBase &v) const