Reference documentation for deal.II version 8.4.2
petsc_block_sparse_matrix.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2004 - 2015 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii__petsc_block_sparse_matrix_h
17 #define dealii__petsc_block_sparse_matrix_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #ifdef DEAL_II_WITH_PETSC
23 
24 # include <deal.II/base/table.h>
25 # include <deal.II/lac/block_matrix_base.h>
26 # include <deal.II/lac/petsc_sparse_matrix.h>
27 # include <deal.II/lac/petsc_block_vector.h>
28 # include <deal.II/lac/exceptions.h>
29 
30 # include <cmath>
31 
32 DEAL_II_NAMESPACE_OPEN
33 
34 
35 
36 namespace PETScWrappers
37 {
38 
66  class BlockSparseMatrix : public BlockMatrixBase<PETScWrappers::SparseMatrix>
67  {
68  public:
73 
78 
83  typedef BaseClass::pointer pointer;
84  typedef BaseClass::const_pointer const_pointer;
85  typedef BaseClass::reference reference;
86  typedef BaseClass::const_reference const_reference;
87  typedef BaseClass::size_type size_type;
90 
103 
108 
115 
126  operator = (const double d);
127 
141  void reinit (const size_type n_block_rows,
142  const size_type n_block_columns);
143 
150  void collect_sizes ();
151 
156  void vmult (BlockVector &dst,
157  const BlockVector &src) const;
158 
163  void vmult (BlockVector &dst,
164  const Vector &src) const;
165 
170  void vmult (Vector &dst,
171  const BlockVector &src) const;
172 
177  void vmult (Vector &dst,
178  const Vector &src) const;
179 
185  void Tvmult (BlockVector &dst,
186  const BlockVector &src) const;
187 
192  void Tvmult (BlockVector &dst,
193  const Vector &src) const;
194 
199  void Tvmult (Vector &dst,
200  const BlockVector &src) const;
201 
206  void Tvmult (Vector &dst,
207  const Vector &src) const;
208 
214 
223  DeclException4 (ExcIncompatibleRowNumbers,
224  int, int, int, int,
225  << "The blocks [" << arg1 << ',' << arg2 << "] and ["
226  << arg3 << ',' << arg4 << "] have differing row numbers.");
230  DeclException4 (ExcIncompatibleColNumbers,
231  int, int, int, int,
232  << "The blocks [" << arg1 << ',' << arg2 << "] and ["
233  << arg3 << ',' << arg4 << "] have differing column numbers.");
235  };
236 
237 
238 
241 // ------------- inline and template functions -----------------
242 
243  inline
246  {
247  Assert (d==0, ExcScalarAssignmentOnlyForZeroValue());
248 
249  for (size_type r=0; r<this->n_block_rows(); ++r)
250  for (size_type c=0; c<this->n_block_cols(); ++c)
251  this->block(r,c) = d;
252 
253  return *this;
254  }
255 
256 
257 
258  inline
259  void
261  const BlockVector &src) const
262  {
263  BaseClass::vmult_block_block (dst, src);
264  }
265 
266 
267 
268  inline
269  void
271  const Vector &src) const
272  {
274  }
275 
276 
277 
278  inline
279  void
281  const BlockVector &src) const
282  {
284  }
285 
286 
287 
288  inline
289  void
291  const Vector &src) const
292  {
294  }
295 
296 
297  inline
298  void
300  const BlockVector &src) const
301  {
303  }
304 
305 
306 
307  inline
308  void
310  const Vector &src) const
311  {
313  }
314 
315 
316 
317  inline
318  void
320  const BlockVector &src) const
321  {
323  }
324 
325 
326 
327  inline
328  void
330  const Vector &src) const
331  {
333  }
334 
335 }
336 
337 DEAL_II_NAMESPACE_CLOSE
338 
339 #endif // DEAL_II_WITH_PETSC
340 
341 #endif // dealii__petsc_block_sparse_matrix_h
void vmult_block_nonblock(BlockVectorType &dst, const VectorType &src) const
BlockSparseMatrix & operator=(const BlockSparseMatrix &)
void vmult(BlockVector &dst, const BlockVector &src) const
void vmult_nonblock_block(VectorType &dst, const BlockVectorType &src) const
void Tvmult_block_nonblock(BlockVectorType &dst, const VectorType &src) const
void Tvmult_block_block(BlockVectorType &dst, const BlockVectorType &src) const
void Tvmult_nonblock_block(VectorType &dst, const BlockVectorType &src) const
void vmult_block_block(BlockVectorType &dst, const BlockVectorType &src) const
void Tvmult_nonblock_nonblock(VectorType &dst, const VectorType &src) const
void Tvmult(BlockVector &dst, const BlockVector &src) const
void reinit(const size_type n_block_rows, const size_type n_block_columns)
#define Assert(cond, exc)
Definition: exceptions.h:294
DeclException4(ExcIncompatibleRowNumbers, int, int, int, int,<< "The blocks ["<< arg1<< ','<< arg2<< "] and ["<< arg3<< ','<< arg4<< "] have differing row numbers.")
BlockType::value_type value_type
void vmult_nonblock_nonblock(VectorType &dst, const VectorType &src) const
BlockType & block(const unsigned int row, const unsigned int column)
BlockMatrixBase< SparseMatrix > BaseClass