Reference documentation for deal.II version GIT 91e6c87029 2023-02-08 03:05:02+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
petsc_block_sparse_matrix.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2004 - 2022 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.md at
12 // the top level directory of deal.II.
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 
26 # include <deal.II/lac/exceptions.h>
29 
30 # include <cmath>
31 
33 
34 
35 
36 namespace PETScWrappers
37 {
38  namespace MPI
39  {
67  class BlockSparseMatrix : public BlockMatrixBase<SparseMatrix>
68  {
69  public:
74 
79 
91 
103  BlockSparseMatrix() = default;
104 
112  explicit BlockSparseMatrix(const Mat &);
113 
117  ~BlockSparseMatrix() override;
118 
124  operator=(const BlockSparseMatrix &);
125 
136  operator=(const double d);
137 
151  void
152  reinit(const size_type n_block_rows, const size_type n_block_columns);
153 
154 
164  void
165  reinit(const std::vector<IndexSet> & rows,
166  const std::vector<IndexSet> & cols,
167  const BlockDynamicSparsityPattern &bdsp,
168  const MPI_Comm & com);
169 
170 
174  void
175  reinit(const std::vector<IndexSet> & sizes,
176  const BlockDynamicSparsityPattern &bdsp,
177  const MPI_Comm & com);
178 
179 
185  void
186  reinit(Mat A);
187 
188 
193  void
194  vmult(BlockVector &dst, const BlockVector &src) const;
195 
200  void
201  vmult(BlockVector &dst, const Vector &src) const;
202 
207  void
208  vmult(Vector &dst, const BlockVector &src) const;
209 
214  void
215  vmult(Vector &dst, const Vector &src) const;
216 
222  void
223  Tvmult(BlockVector &dst, const BlockVector &src) const;
224 
229  void
230  Tvmult(BlockVector &dst, const Vector &src) const;
231 
236  void
237  Tvmult(Vector &dst, const BlockVector &src) const;
238 
243  void
244  Tvmult(Vector &dst, const Vector &src) const;
245 
253  void
254  collect_sizes();
255 
260  std::vector<IndexSet>
262 
268  std::vector<IndexSet>
270 
276  std::uint64_t
277  n_nonzero_elements() const;
278 
283  const MPI_Comm &
284  get_mpi_communicator() const;
285 
291 
299  operator const Mat &() const;
300 
311  Mat &
312  petsc_matrix();
313 
314  private:
321  Mat petsc_nest_matrix = nullptr;
322  };
323 
324 
325 
328  // ------------- inline and template functions -----------------
329 
332  {
333  this->reinit(A);
334  }
335 
336  inline BlockSparseMatrix &
338  {
340 
341  for (size_type r = 0; r < this->n_block_rows(); ++r)
342  for (size_type c = 0; c < this->n_block_cols(); ++c)
343  this->block(r, c) = d;
344 
345  return *this;
346  }
347 
348 
349 
350  inline void
352  {
354  }
355 
356 
357 
358  inline void
360  {
362  }
363 
364 
365 
366  inline void
368  {
370  }
371 
372 
373 
374  inline void
375  BlockSparseMatrix::vmult(Vector &dst, const Vector &src) const
376  {
378  }
379 
380 
381  inline void
383  {
385  }
386 
387 
388 
389  inline void
391  {
393  }
394 
395 
396 
397  inline void
399  {
401  }
402 
403 
404 
405  inline void
406  BlockSparseMatrix::Tvmult(Vector &dst, const Vector &src) const
407  {
409  }
410 
411  } // namespace MPI
412 
413 } // namespace PETScWrappers
414 
415 
417 
418 
419 #endif // DEAL_II_WITH_PETSC
420 
421 #endif // dealii_petsc_block_sparse_matrix_h
void Tvmult_nonblock_nonblock(VectorType &dst, const VectorType &src) const
void vmult_nonblock_nonblock(VectorType &dst, const VectorType &src) const
void Tvmult_block_block(BlockVectorType &dst, const BlockVectorType &src) const
BlockType & block(const unsigned int row, const unsigned int column)
void Tvmult_nonblock_block(VectorType &dst, const BlockVectorType &src) const
unsigned int n_block_rows() const
MatrixIterator< BlockMatrixIterators::Accessor< BlockMatrixBase, true > > const_iterator
void vmult_block_block(BlockVectorType &dst, const BlockVectorType &src) const
types::global_dof_index size_type
typename BlockType::value_type value_type
void vmult_nonblock_block(VectorType &dst, const BlockVectorType &src) const
unsigned int n_block_cols() const
MatrixIterator< BlockMatrixIterators::Accessor< BlockMatrixBase, false > > iterator
void vmult_block_nonblock(BlockVectorType &dst, const VectorType &src) const
void Tvmult_block_nonblock(BlockVectorType &dst, const VectorType &src) const
void Tvmult(BlockVector &dst, const BlockVector &src) const
void vmult(BlockVector &dst, const BlockVector &src) const
void reinit(const size_type n_block_rows, const size_type n_block_columns)
BlockSparseMatrix & operator=(const BlockSparseMatrix &)
std::vector< IndexSet > locally_owned_domain_indices() const
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:461
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:462
static ::ExceptionBase & ExcScalarAssignmentOnlyForZeroValue()
#define Assert(cond, exc)
Definition: exceptions.h:1583
static const char A
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)