Reference documentation for deal.II version GIT b6bf1e606d 2022-08-11 15:25: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\}}\)
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 <map>
27 #include <vector>
28 
30 
31 // Forward declarations
32 #ifndef DOXYGEN
33 template <typename number>
34 class FullMatrix;
35 template <typename number>
36 class SparseMatrix;
37 template <typename number>
38 class Vector;
39 
40 template <typename number>
41 class SparseVanka;
42 template <typename number>
43 class SparseBlockVanka;
44 #endif
45 
137 template <typename number>
139 {
140 public:
145 
153 
166  SparseVanka(const SparseMatrix<number> &M, const std::vector<bool> &selected);
167 
172 
177  {
178  public:
182  explicit AdditionalData(const std::vector<bool> &selected);
183 
187  const std::vector<bool> &selected;
188  };
189 
190 
201  void
203  const AdditionalData & additional_data);
204 
209  template <typename number2>
210  void
211  vmult(Vector<number2> &dst, const Vector<number2> &src) const;
212 
217  template <typename number2>
218  void
219  Tvmult(Vector<number2> &dst, const Vector<number2> &src) const;
220 
228  size_type
229  m() const;
230 
238  size_type
239  n() const;
240 
241 protected:
263  template <typename number2>
264  void
266  const Vector<number2> & src,
267  const std::vector<bool> *const dof_mask = nullptr) const;
268 
273  std::size_t
275 
276 private:
281 
285  const std::vector<bool> *selected;
286 
291  mutable std::vector<SmartPointer<FullMatrix<float>, SparseVanka<number>>>
293 
298 
303 
307  void
309 
316  void
318 
326  void
327  compute_inverse(const size_type row, std::vector<size_type> &local_indices);
328 
329  // Make the derived class a friend. This seems silly, but is actually
330  // necessary, since derived classes can only access non-public members
331  // through their @p this pointer, but not access these members as member
332  // functions of other objects of the type of this base class (i.e. like
333  // <tt>x.f()</tt>, where @p x is an object of the base class, and @p f one
334  // of it's non-public member functions).
335  //
336  // Now, in the case of the @p SparseBlockVanka class, we would like to take
337  // the address of a function of the base class in order to call it through
338  // the multithreading framework, so the derived class has to be a friend.
339  template <typename T>
340  friend class SparseBlockVanka;
341 };
342 
343 
344 
476 template <typename number>
477 class SparseBlockVanka : public SparseVanka<number>
478 {
479 public:
484 
490  {
498  adaptive
499  };
500 
505  const std::vector<bool> & selected,
506  const unsigned int n_blocks,
507  const BlockingStrategy blocking_strategy);
508 
512  template <typename number2>
513  void
514  vmult(Vector<number2> &dst, const Vector<number2> &src) const;
515 
520  std::size_t
522 
523 private:
527  const unsigned int n_blocks;
528 
536  std::vector<std::vector<bool>> dof_masks;
537 
542  void
544  const std::vector<bool> & selected,
545  const BlockingStrategy blocking_strategy);
546 };
547 
549 /* ---------------------------------- Inline functions ------------------- */
550 
551 #ifndef DOXYGEN
552 
553 template <typename number>
554 inline typename SparseVanka<number>::size_type
556 {
557  Assert(_m != 0, ExcNotInitialized());
558  return _m;
559 }
560 
561 template <typename number>
562 inline typename SparseVanka<number>::size_type
564 {
565  Assert(_n != 0, ExcNotInitialized());
566  return _n;
567 }
568 
569 template <typename number>
570 template <typename number2>
571 inline void
573  const Vector<number2> & /*src*/) const
574 {
575  AssertThrow(false, ExcNotImplemented());
576 }
577 
578 #endif // DOXYGEN
579 
581 
582 #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:536
const unsigned int n_blocks
Definition: sparse_vanka.h:527
AdditionalData(const std::vector< bool > &selected)
const std::vector< bool > & selected
Definition: sparse_vanka.h:187
size_type m() const
size_type _n
Definition: sparse_vanka.h:302
SmartPointer< const SparseMatrix< number >, SparseVanka< number > > matrix
Definition: sparse_vanka.h:280
size_type _m
Definition: sparse_vanka.h:297
void compute_inverses()
std::vector< SmartPointer< FullMatrix< float >, SparseVanka< number > > > inverses
Definition: sparse_vanka.h:292
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:285
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:144
Definition: vector.h:110
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
static ::ExceptionBase & ExcNotInitialized()
#define Assert(cond, exc)
Definition: exceptions.h:1473
static ::ExceptionBase & ExcNotImplemented()
#define AssertThrow(cond, exc)
Definition: exceptions.h:1583
VectorType::value_type * begin(VectorType &V)
VectorType::value_type * end(VectorType &V)
unsigned int global_dof_index
Definition: types.h:76