Reference documentation for deal.II version GIT 9c182271f7 2023-03-28 14:30:01+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\}}\)
sparse_vanka.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2020 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_sparse_vanka_h
17 #define dealii_sparse_vanka_h
18 
19 
20 
21 #include <deal.II/base/config.h>
22 
25 
26 #include <vector>
27 
29 
30 // Forward declarations
31 #ifndef DOXYGEN
32 template <typename number>
33 class FullMatrix;
34 template <typename number>
35 class SparseMatrix;
36 template <typename number>
37 class Vector;
38 
39 template <typename number>
40 class SparseVanka;
41 template <typename number>
42 class SparseBlockVanka;
43 #endif
44 
136 template <typename number>
138 {
139 public:
144 
152 
165  SparseVanka(const SparseMatrix<number> &M, const std::vector<bool> &selected);
166 
171 
176  {
177  public:
181  explicit AdditionalData(const std::vector<bool> &selected);
182 
186  const std::vector<bool> &selected;
187  };
188 
189 
200  void
202  const AdditionalData & additional_data);
203 
208  template <typename number2>
209  void
210  vmult(Vector<number2> &dst, const Vector<number2> &src) const;
211 
216  template <typename number2>
217  void
218  Tvmult(Vector<number2> &dst, const Vector<number2> &src) const;
219 
227  size_type
228  m() const;
229 
237  size_type
238  n() const;
239 
240 protected:
262  template <typename number2>
263  void
265  const Vector<number2> & src,
266  const std::vector<bool> *const dof_mask = nullptr) const;
267 
272  std::size_t
274 
275 private:
280 
284  const std::vector<bool> *selected;
285 
290  mutable std::vector<SmartPointer<FullMatrix<float>, SparseVanka<number>>>
292 
297 
302 
306  void
308 
315  void
317 
325  void
326  compute_inverse(const size_type row, std::vector<size_type> &local_indices);
327 
328  // Make the derived class a friend. This seems silly, but is actually
329  // necessary, since derived classes can only access non-public members
330  // through their @p this pointer, but not access these members as member
331  // functions of other objects of the type of this base class (i.e. like
332  // <tt>x.f()</tt>, where @p x is an object of the base class, and @p f one
333  // of it's non-public member functions).
334  //
335  // Now, in the case of the @p SparseBlockVanka class, we would like to take
336  // the address of a function of the base class in order to call it through
337  // the multithreading framework, so the derived class has to be a friend.
338  template <typename T>
339  friend class SparseBlockVanka;
340 };
341 
342 
343 
475 template <typename number>
476 class SparseBlockVanka : public SparseVanka<number>
477 {
478 public:
483 
489  {
497  adaptive
498  };
499 
504  const std::vector<bool> & selected,
505  const unsigned int n_blocks,
506  const BlockingStrategy blocking_strategy);
507 
511  template <typename number2>
512  void
513  vmult(Vector<number2> &dst, const Vector<number2> &src) const;
514 
519  std::size_t
521 
522 private:
526  const unsigned int n_blocks;
527 
535  std::vector<std::vector<bool>> dof_masks;
536 
541  void
543  const std::vector<bool> & selected,
544  const BlockingStrategy blocking_strategy);
545 };
546 
548 /* ---------------------------------- Inline functions ------------------- */
549 
550 #ifndef DOXYGEN
551 
552 template <typename number>
553 inline typename SparseVanka<number>::size_type
555 {
556  Assert(_m != 0, ExcNotInitialized());
557  return _m;
558 }
559 
560 template <typename number>
561 inline typename SparseVanka<number>::size_type
563 {
564  Assert(_n != 0, ExcNotInitialized());
565  return _n;
566 }
567 
568 template <typename number>
569 template <typename number2>
570 inline void
572  const Vector<number2> & /*src*/) const
573 {
574  AssertThrow(false, ExcNotImplemented());
575 }
576 
577 #endif // DOXYGEN
578 
580 
581 #endif
void compute_dof_masks(const SparseMatrix< number > &M, const std::vector< bool > &selected, const BlockingStrategy blocking_strategy)
std::size_t memory_consumption() const
SparseBlockVanka(const SparseMatrix< number > &M, const std::vector< bool > &selected, const unsigned int n_blocks, const BlockingStrategy blocking_strategy)
void vmult(Vector< number2 > &dst, const Vector< number2 > &src) const
std::vector< std::vector< bool > > dof_masks
Definition: sparse_vanka.h:535
const unsigned int n_blocks
Definition: sparse_vanka.h:526
AdditionalData(const std::vector< bool > &selected)
const std::vector< bool > & selected
Definition: sparse_vanka.h:186
size_type m() const
size_type _n
Definition: sparse_vanka.h:301
SmartPointer< const SparseMatrix< number >, SparseVanka< number > > matrix
Definition: sparse_vanka.h:279
size_type _m
Definition: sparse_vanka.h:296
void compute_inverses()
std::vector< SmartPointer< FullMatrix< float >, SparseVanka< number > > > inverses
Definition: sparse_vanka.h:291
std::size_t memory_consumption() const
void compute_inverse(const size_type row, std::vector< size_type > &local_indices)
size_type n() const
void compute_inverses(const size_type begin, const size_type end)
void initialize(const SparseMatrix< number > &M, const AdditionalData &additional_data)
void Tvmult(Vector< number2 > &dst, const Vector< number2 > &src) const
void vmult(Vector< number2 > &dst, const Vector< number2 > &src) const
const std::vector< bool > * selected
Definition: sparse_vanka.h:284
SparseVanka(const SparseMatrix< number > &M, const std::vector< bool > &selected)
void apply_preconditioner(Vector< number2 > &dst, const Vector< number2 > &src, const std::vector< bool > *const dof_mask=nullptr) const
types::global_dof_index size_type
Definition: sparse_vanka.h:143
Definition: vector.h:109
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:474
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:475
static ::ExceptionBase & ExcNotInitialized()
#define Assert(cond, exc)
Definition: exceptions.h:1586
static ::ExceptionBase & ExcNotImplemented()
#define AssertThrow(cond, exc)
Definition: exceptions.h:1675
VectorType::value_type * begin(VectorType &V)
VectorType::value_type * end(VectorType &V)
unsigned int global_dof_index
Definition: types.h:82