include/deal.II/lac/petsc_block_sparse_matrix.h

00001 //---------------------------------------------------------------------------
00002 //    @f$Id: petsc_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_block_sparse_matrix_h
00013 #define __deal2__petsc_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_sparse_matrix.h>
00023 #  include <deal.II/lac/petsc_block_vector.h>
00024 #  include <deal.II/lac/exceptions.h>
00025 
00026 #  include <cmath>
00027 
00028 DEAL_II_NAMESPACE_OPEN
00029 
00030 
00031 
00032 namespace PETScWrappers
00033 {
00034 
00061   class BlockSparseMatrix : public BlockMatrixBase<PETScWrappers::SparseMatrix>
00062   {
00063     public:
00068       typedef BlockMatrixBase<SparseMatrix> BaseClass;
00069 
00074       typedef BaseClass::BlockType  BlockType;
00075 
00080       typedef BaseClass::value_type      value_type;
00081       typedef BaseClass::pointer         pointer;
00082       typedef BaseClass::const_pointer   const_pointer;
00083       typedef BaseClass::reference       reference;
00084       typedef BaseClass::const_reference const_reference;
00085       typedef BaseClass::size_type       size_type;
00086       typedef BaseClass::iterator        iterator;
00087       typedef BaseClass::const_iterator  const_iterator;
00088 
00110       BlockSparseMatrix ();
00111 
00115       ~BlockSparseMatrix ();
00116 
00122       BlockSparseMatrix &
00123       operator = (const BlockSparseMatrix &);
00124 
00140       BlockSparseMatrix &
00141       operator = (const double d);
00142 
00169       void reinit (const unsigned int n_block_rows,
00170                    const unsigned int n_block_columns);
00171 
00184       void collect_sizes ();
00185 
00191       void vmult (BlockVector       &dst,
00192                   const BlockVector &src) const;
00193 
00201       void vmult (BlockVector          &dst,
00202                   const Vector &src) const;
00203 
00211       void vmult (Vector    &dst,
00212                   const BlockVector &src) const;
00213 
00221       void vmult (Vector       &dst,
00222                   const Vector &src) const;
00223 
00232       void Tvmult (BlockVector       &dst,
00233                    const BlockVector &src) const;
00234 
00242       void Tvmult (BlockVector  &dst,
00243                    const Vector &src) const;
00244 
00252       void Tvmult (Vector    &dst,
00253                    const BlockVector &src) const;
00254 
00262       void Tvmult (Vector       &dst,
00263                    const Vector &src) const;
00264 
00270       using BlockMatrixBase<SparseMatrix>::clear;
00271 
00279       DeclException4 (ExcIncompatibleRowNumbers,
00280                       int, int, int, int,
00281                       << "The blocks [" << arg1 << ',' << arg2 << "] and ["
00282                       << arg3 << ',' << arg4 << "] have differing row numbers.");
00286       DeclException4 (ExcIncompatibleColNumbers,
00287                       int, int, int, int,
00288                       << "The blocks [" << arg1 << ',' << arg2 << "] and ["
00289                       << arg3 << ',' << arg4 << "] have differing column numbers.");
00291   };
00292 
00293 
00294 
00297 // ------------- inline and template functions -----------------
00298 
00299   inline
00300   BlockSparseMatrix &
00301   BlockSparseMatrix::operator = (const double d)
00302   {
00303     Assert (d==0, ExcScalarAssignmentOnlyForZeroValue());
00304 
00305     for (unsigned int r=0; r<this->n_block_rows(); ++r)
00306       for (unsigned int c=0; c<this->n_block_cols(); ++c)
00307         this->block(r,c) = d;
00308 
00309     return *this;
00310   }
00311 
00312 
00313 
00314   inline
00315   void
00316   BlockSparseMatrix::vmult (BlockVector       &dst,
00317                             const BlockVector &src) const
00318   {
00319     BaseClass::vmult_block_block (dst, src);
00320   }
00321 
00322 
00323 
00324   inline
00325   void
00326   BlockSparseMatrix::vmult (BlockVector  &dst,
00327                             const Vector &src) const
00328   {
00329     BaseClass::vmult_block_nonblock (dst, src);
00330   }
00331 
00332 
00333 
00334   inline
00335   void
00336   BlockSparseMatrix::vmult (Vector            &dst,
00337                             const BlockVector &src) const
00338   {
00339     BaseClass::vmult_nonblock_block (dst, src);
00340   }
00341 
00342 
00343 
00344   inline
00345   void
00346   BlockSparseMatrix::vmult (Vector       &dst,
00347                             const Vector &src) const
00348   {
00349     BaseClass::vmult_nonblock_nonblock (dst, src);
00350   }
00351 
00352 
00353   inline
00354   void
00355   BlockSparseMatrix::Tvmult (BlockVector       &dst,
00356                             const BlockVector &src) const
00357   {
00358     BaseClass::Tvmult_block_block (dst, src);
00359   }
00360 
00361 
00362 
00363   inline
00364   void
00365   BlockSparseMatrix::Tvmult (BlockVector  &dst,
00366                             const Vector &src) const
00367   {
00368     BaseClass::Tvmult_block_nonblock (dst, src);
00369   }
00370 
00371 
00372 
00373   inline
00374   void
00375   BlockSparseMatrix::Tvmult (Vector            &dst,
00376                             const BlockVector &src) const
00377   {
00378     BaseClass::Tvmult_nonblock_block (dst, src);
00379   }
00380 
00381 
00382 
00383   inline
00384   void
00385   BlockSparseMatrix::Tvmult (Vector       &dst,
00386                             const Vector &src) const
00387   {
00388     BaseClass::Tvmult_nonblock_nonblock (dst, src);
00389   }
00390 
00391 }
00392 
00393 DEAL_II_NAMESPACE_CLOSE
00394 
00395 #endif    // DEAL_II_USE_PETSC
00396 
00397 #endif    // __deal2__petsc_block_sparse_matrix_h
00398 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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