Reference documentation for deal.II version 8.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
petsc_sparse_matrix.h
1 // ---------------------------------------------------------------------
2 // @f$Id: petsc_sparse_matrix.h 30040 2013-07-18 17:06:48Z maier @f$
3 //
4 // Copyright (C) 2004 - 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_sparse_matrix_h
18 #define __deal2__petsc_sparse_matrix_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 <vector>
28 
30 // forward declaration
31 template <typename MatrixType> class BlockMatrixBase;
32 
33 
34 namespace PETScWrappers
35 {
49  class SparseMatrix : public MatrixBase
50  {
51  public:
52 
64  struct Traits
65  {
71  static const bool zero_addition_can_be_elided = true;
72  };
73 
78  SparseMatrix ();
79 
105  SparseMatrix (const size_type m,
106  const size_type n,
107  const size_type n_nonzero_per_row,
108  const bool is_symmetric = false);
109 
138  SparseMatrix (const size_type m,
139  const size_type n,
140  const std::vector<size_type> &row_lengths,
141  const bool is_symmetric = false);
142 
175  template <typename SparsityType>
176  explicit SparseMatrix (const SparsityType &sparsity_pattern,
177  const bool preset_nonzero_locations = true);
178 
195  SparseMatrix &operator = (const double d);
196 
205  void reinit (const size_type m,
206  const size_type n,
207  const size_type n_nonzero_per_row,
208  const bool is_symmetric = false);
209 
218  void reinit (const size_type m,
219  const size_type n,
220  const std::vector<size_type> &row_lengths,
221  const bool is_symmetric = false);
222 
271  template <typename SparsityType>
272  void reinit (const SparsityType &sparsity_pattern,
273  const bool preset_nonzero_locations = true);
274 
282  virtual const MPI_Comm &get_mpi_communicator () const;
283 
310  PetscScalar matrix_norm_square (const VectorBase &v) const;
311 
324  PetscScalar matrix_scalar_product (const VectorBase &u,
325  const VectorBase &v) const;
326 
327  private:
328 
332  SparseMatrix(const SparseMatrix &);
337 
345  void do_reinit (const size_type m,
346  const size_type n,
347  const size_type n_nonzero_per_row,
348  const bool is_symmetric = false);
349 
353  void do_reinit (const size_type m,
354  const size_type n,
355  const std::vector<size_type> &row_lengths,
356  const bool is_symmetric = false);
357 
361  template <typename SparsityType>
362  void do_reinit (const SparsityType &sparsity_pattern,
363  const bool preset_nonzero_locations);
364 
371  };
372 }
373 
374 DEAL_II_NAMESPACE_CLOSE
375 
376 #endif // DEAL_II_WITH_PETSC
377 
378 /*---------------------------- petsc_sparse_matrix.h ---------------------------*/
379 
380 #endif
381 /*---------------------------- petsc_sparse_matrix.h ---------------------------*/
PetscScalar matrix_scalar_product(const VectorBase &u, const VectorBase &v) const
virtual const MPI_Comm & get_mpi_communicator() const
size_type n() const
size_type m() const
PetscBool is_symmetric(const double tolerance=1.e-12)
PetscScalar matrix_norm_square(const VectorBase &v) const
void do_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
void reinit(const size_type m, const size_type n, const size_type n_nonzero_per_row, const bool is_symmetric=false)
SparseMatrix & operator=(const double d)