include/deal.II/lac/petsc_parallel_block_sparse_matrix.h

00001 //---------------------------------------------------------------------------
00002 //    @f$Id: petsc_parallel_block_sparse_matrix.h 25345 2012-03-31 08:37:04Z bangerth @f$
00003 //
00004 //    Copyright (C) 2004, 2005, 2006, 2007, 2010, 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_block_sparse_matrix_h
00013 #define __deal2__petsc_parallel_block_sparse_matrix_h
00014 
00015 
00016 #include <deal.II/base/config.h>
00017 
00018 #ifdef DEAL_II_USE_PETSC
00019 
00020 #  include <deal.II/base/table.h>
00021 #  include <deal.II/lac/block_matrix_base.h>
00022 #  include <deal.II/lac/petsc_parallel_sparse_matrix.h>
00023 #  include <deal.II/lac/petsc_parallel_block_vector.h>
00024 #  include <deal.II/lac/exceptions.h>
00025 #  include <cmath>
00026 
00027 DEAL_II_NAMESPACE_OPEN
00028 
00029 
00030 
00031 namespace PETScWrappers
00032 {
00033   namespace MPI
00034   {
00035 
00062     class BlockSparseMatrix : public BlockMatrixBase<SparseMatrix>
00063     {
00064       public:
00069         typedef BlockMatrixBase<SparseMatrix> BaseClass;
00070 
00075         typedef BaseClass::BlockType  BlockType;
00076 
00081         typedef BaseClass::value_type      value_type;
00082         typedef BaseClass::pointer         pointer;
00083         typedef BaseClass::const_pointer   const_pointer;
00084         typedef BaseClass::reference       reference;
00085         typedef BaseClass::const_reference const_reference;
00086         typedef BaseClass::size_type       size_type;
00087         typedef BaseClass::iterator        iterator;
00088         typedef BaseClass::const_iterator  const_iterator;
00089 
00111         BlockSparseMatrix ();
00112 
00116         ~BlockSparseMatrix ();
00117 
00124         BlockSparseMatrix &
00125         operator = (const BlockSparseMatrix &);
00126 
00143         BlockSparseMatrix &
00144         operator = (const double d);
00145 
00172         void reinit (const unsigned int n_block_rows,
00173                      const unsigned int n_block_columns);
00174 
00180         void vmult (BlockVector       &dst,
00181                     const BlockVector &src) const;
00182 
00190         void vmult (BlockVector          &dst,
00191                     const Vector &src) const;
00192 
00200         void vmult (Vector    &dst,
00201                     const BlockVector &src) const;
00202 
00210         void vmult (Vector       &dst,
00211                     const Vector &src) const;
00212 
00221         void Tvmult (BlockVector       &dst,
00222                      const BlockVector &src) const;
00223 
00231         void Tvmult (BlockVector  &dst,
00232                      const Vector &src) const;
00233 
00241         void Tvmult (Vector    &dst,
00242                      const BlockVector &src) const;
00243 
00251         void Tvmult (Vector       &dst,
00252                      const Vector &src) const;
00253 
00266         void collect_sizes ();
00267 
00273         const MPI_Comm & get_mpi_communicator () const;
00274 
00280         using BlockMatrixBase<SparseMatrix>::clear;
00281     };
00282 
00283 
00284 
00287 // ------------- inline and template functions -----------------
00288 
00289     inline
00290     BlockSparseMatrix &
00291     BlockSparseMatrix::operator = (const double d)
00292     {
00293       Assert (d==0, ExcScalarAssignmentOnlyForZeroValue());
00294 
00295       for (unsigned int r=0; r<this->n_block_rows(); ++r)
00296         for (unsigned int c=0; c<this->n_block_cols(); ++c)
00297           this->block(r,c) = d;
00298 
00299       return *this;
00300     }
00301 
00302 
00303 
00304     inline
00305     void
00306     BlockSparseMatrix::vmult (BlockVector       &dst,
00307                               const BlockVector &src) const
00308     {
00309       BaseClass::vmult_block_block (dst, src);
00310     }
00311 
00312 
00313 
00314     inline
00315     void
00316     BlockSparseMatrix::vmult (BlockVector  &dst,
00317                               const Vector &src) const
00318     {
00319       BaseClass::vmult_block_nonblock (dst, src);
00320     }
00321 
00322 
00323 
00324     inline
00325     void
00326     BlockSparseMatrix::vmult (Vector            &dst,
00327                               const BlockVector &src) const
00328     {
00329       BaseClass::vmult_nonblock_block (dst, src);
00330     }
00331 
00332 
00333 
00334     inline
00335     void
00336     BlockSparseMatrix::vmult (Vector       &dst,
00337                               const Vector &src) const
00338     {
00339       BaseClass::vmult_nonblock_nonblock (dst, src);
00340     }
00341 
00342 
00343     inline
00344     void
00345     BlockSparseMatrix::Tvmult (BlockVector       &dst,
00346                                const BlockVector &src) const
00347     {
00348       BaseClass::Tvmult_block_block (dst, src);
00349     }
00350 
00351 
00352 
00353     inline
00354     void
00355     BlockSparseMatrix::Tvmult (BlockVector  &dst,
00356                                const Vector &src) const
00357     {
00358       BaseClass::Tvmult_block_nonblock (dst, src);
00359     }
00360 
00361 
00362 
00363     inline
00364     void
00365     BlockSparseMatrix::Tvmult (Vector            &dst,
00366                                const BlockVector &src) const
00367     {
00368       BaseClass::Tvmult_nonblock_block (dst, src);
00369     }
00370 
00371 
00372 
00373     inline
00374     void
00375     BlockSparseMatrix::Tvmult (Vector       &dst,
00376                                const Vector &src) const
00377     {
00378       BaseClass::Tvmult_nonblock_nonblock (dst, src);
00379     }
00380 
00381   }
00382 
00383 }
00384 
00385 
00386 DEAL_II_NAMESPACE_CLOSE
00387 
00388 
00389 #endif    // DEAL_II_USE_PETSC
00390 
00391 #endif    // __deal2__petsc_parallel_block_sparse_matrix_h
00392 
 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