include/deal.II/lac/petsc_parallel_sparse_matrix.h

00001 //---------------------------------------------------------------------------
00002 //    @f$Id: petsc_parallel_sparse_matrix.h 25345 2012-03-31 08:37:04Z bangerth @f$
00003 //
00004 //    Copyright (C) 2004, 2005, 2006, 2007, 2009, 2012 by the deal.II authors
00005 //
00006 //    This file is subject to QPL and may not be  distributed
00007 //    without copyright and license information. Please refer
00008 //    to the file deal.II/doc/license.html for the  text  and
00009 //    further information on this license.
00010 //
00011 //---------------------------------------------------------------------------
00012 #ifndef __deal2__petsc_parallel_sparse_matrix_h
00013 #define __deal2__petsc_parallel_sparse_matrix_h
00014 
00015 #include <deal.II/base/config.h>
00016 
00017 #ifdef DEAL_II_USE_PETSC
00018 
00019 #  include <deal.II/lac/exceptions.h>
00020 #  include <deal.II/lac/petsc_matrix_base.h>
00021 #  include <vector>
00022 
00023 DEAL_II_NAMESPACE_OPEN
00024 
00025 
00026                                  // forward declaration
00027 template <typename Matrix> class BlockMatrixBase;
00028 
00029 
00030 namespace PETScWrappers
00031 {
00032   namespace MPI
00033   {
00034 
00109     class SparseMatrix : public MatrixBase
00110     {
00111       public:
00123         struct Traits
00124         {
00139             static const bool zero_addition_can_be_elided = false;
00140         };
00141 
00146         SparseMatrix ();
00147 
00178         SparseMatrix (const MPI_Comm     &communicator,
00179                       const unsigned int  m,
00180                       const unsigned int  n,
00181                       const unsigned int  local_rows,
00182                       const unsigned int  local_columns,
00183                       const unsigned int  n_nonzero_per_row,
00184                       const bool          is_symmetric = false);
00185 
00219         SparseMatrix (const MPI_Comm                  &communicator,
00220                       const unsigned int               m,
00221                       const unsigned int               n,
00222                       const unsigned int               local_rows,
00223                       const unsigned int               local_columns,
00224                       const std::vector<unsigned int> &row_lengths,
00225                       const bool                       is_symmetric = false);
00226 
00267         template <typename SparsityType>
00268         SparseMatrix (const MPI_Comm                  &communicator,
00269                       const SparsityType              &sparsity_pattern,
00270                       const std::vector<unsigned int> &local_rows_per_process,
00271                       const std::vector<unsigned int> &local_columns_per_process,
00272                       const unsigned int               this_process,
00273                       const bool                       preset_nonzero_locations = true);
00274 
00291         SparseMatrix & operator = (const value_type d);
00292 
00301         void reinit (const MPI_Comm     &communicator,
00302                      const unsigned int  m,
00303                      const unsigned int  n,
00304                      const unsigned int  local_rows,
00305                      const unsigned int  local_columns,
00306                      const unsigned int  n_nonzero_per_row,
00307                      const bool          is_symmetric = false);
00308 
00317         void reinit (const MPI_Comm                  &communicator,
00318                      const unsigned int               m,
00319                      const unsigned int               n,
00320                      const unsigned int               local_rows,
00321                      const unsigned int               local_columns,
00322                      const std::vector<unsigned int> &row_lengths,
00323                      const bool                       is_symmetric = false);
00324 
00359         template <typename SparsityType>
00360         void reinit (const MPI_Comm                  &communicator,
00361                      const SparsityType              &sparsity_pattern,
00362                      const std::vector<unsigned int> &local_rows_per_process,
00363                      const std::vector<unsigned int> &local_columns_per_process,
00364                      const unsigned int               this_process,
00365                      const bool                       preset_nonzero_locations = true);
00366 
00372         virtual const MPI_Comm & get_mpi_communicator () const;
00373 
00379         DeclException2 (ExcLocalRowsTooLarge,
00380                         int, int,
00381                         << "The number of local rows " << arg1
00382                         << " must be larger than the total number of rows " << arg2);
00384       private:
00385 
00390         MPI_Comm communicator;
00391 
00400         void do_reinit (const unsigned int m,
00401                         const unsigned int n,
00402                         const unsigned int local_rows,
00403                         const unsigned int local_columns,
00404                         const unsigned int n_nonzero_per_row,
00405                         const bool         is_symmetric = false);
00406 
00410         void do_reinit (const unsigned int               m,
00411                         const unsigned int               n,
00412                         const unsigned int               local_rows,
00413                         const unsigned int               local_columns,
00414                         const std::vector<unsigned int> &row_lengths,
00415                         const bool                       is_symmetric = false);
00416 
00420         template <typename SparsityType>
00421         void do_reinit (const SparsityType              &sparsity_pattern,
00422                         const std::vector<unsigned int> &local_rows_per_process,
00423                         const std::vector<unsigned int> &local_columns_per_process,
00424                         const unsigned int               this_process,
00425                         const bool                       preset_nonzero_locations);
00426 
00432         friend class BlockMatrixBase<SparseMatrix>;
00433     };
00434 
00435 
00436 
00437 // -------- template and inline functions ----------
00438 
00439     inline
00440     const MPI_Comm &
00441     SparseMatrix::get_mpi_communicator () const
00442     {
00443       return communicator;
00444     }
00445   }
00446 }
00447 
00448 DEAL_II_NAMESPACE_CLOSE
00449 
00450 #endif // DEAL_II_USE_PETSC
00451 
00452 /*----------------------------   petsc_parallel_sparse_matrix.h     ---------------------------*/
00453 
00454 #endif
00455 /*----------------------------   petsc_parallel_sparse_matrix.h     ---------------------------*/
00456 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

deal.II documentation generated on Wed May 23 2012 06:07:38 by doxygen 1.7.3