00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __deal2__petsc_sparse_matrix_h
00013 #define __deal2__petsc_sparse_matrix_h
00014
00015
00016 #include <deal.II/base/config.h>
00017
00018 #ifdef DEAL_II_USE_PETSC
00019
00020 # include <deal.II/lac/exceptions.h>
00021 # include <deal.II/lac/petsc_matrix_base.h>
00022 # include <vector>
00023
00024 DEAL_II_NAMESPACE_OPEN
00025
00026 template <typename MatrixType> class BlockMatrixBase;
00027
00028
00029 namespace PETScWrappers
00030 {
00044 class SparseMatrix : public MatrixBase
00045 {
00046 public:
00058 struct Traits
00059 {
00065 static const bool zero_addition_can_be_elided = true;
00066 };
00067
00072 SparseMatrix ();
00073
00099 SparseMatrix (const unsigned int m,
00100 const unsigned int n,
00101 const unsigned int n_nonzero_per_row,
00102 const bool is_symmetric = false);
00103
00132 SparseMatrix (const unsigned int m,
00133 const unsigned int n,
00134 const std::vector<unsigned int> &row_lengths,
00135 const bool is_symmetric = false);
00136
00169 template <typename SparsityType>
00170 SparseMatrix (const SparsityType &sparsity_pattern,
00171 const bool preset_nonzero_locations = true);
00172
00189 SparseMatrix & operator = (const double d);
00190
00199 void reinit (const unsigned int m,
00200 const unsigned int n,
00201 const unsigned int n_nonzero_per_row,
00202 const bool is_symmetric = false);
00203
00212 void reinit (const unsigned int m,
00213 const unsigned int n,
00214 const std::vector<unsigned int> &row_lengths,
00215 const bool is_symmetric = false);
00216
00265 template <typename SparsityType>
00266 void reinit (const SparsityType &sparsity_pattern,
00267 const bool preset_nonzero_locations = true);
00268
00276 virtual const MPI_Comm & get_mpi_communicator () const;
00277
00278 private:
00279
00287 void do_reinit (const unsigned int m,
00288 const unsigned int n,
00289 const unsigned int n_nonzero_per_row,
00290 const bool is_symmetric = false);
00291
00295 void do_reinit (const unsigned int m,
00296 const unsigned int n,
00297 const std::vector<unsigned int> &row_lengths,
00298 const bool is_symmetric = false);
00299
00303 template <typename SparsityType>
00304 void do_reinit (const SparsityType &sparsity_pattern,
00305 const bool preset_nonzero_locations);
00306
00312 friend class BlockMatrixBase<SparseMatrix>;
00313 };
00314 }
00315
00316 DEAL_II_NAMESPACE_CLOSE
00317
00318 #endif // DEAL_II_USE_PETSC
00319
00320
00321
00322 #endif
00323
00324