Reference documentation for deal.II version 9.3.2
\(\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 
136 template <typename number>
138 {
139 public:
144 
152 
161  const std::vector<bool> & selected,
162  const bool conserve_memory,
163  const unsigned int n_threads = MultithreadInfo::n_threads());
164 
177  SparseVanka(const SparseMatrix<number> &M, const std::vector<bool> &selected);
178 
183 
188  {
189  public:
193  explicit AdditionalData(const std::vector<bool> &selected);
194 
202  AdditionalData(const std::vector<bool> &selected,
203  const bool conserve_memory,
204  const unsigned int n_threads = MultithreadInfo::n_threads());
205 
209  const std::vector<bool> &selected;
210  };
211 
212 
223  void
225  const AdditionalData & additional_data);
226 
231  template <typename number2>
232  void
233  vmult(Vector<number2> &dst, const Vector<number2> &src) const;
234 
239  template <typename number2>
240  void
241  Tvmult(Vector<number2> &dst, const Vector<number2> &src) const;
242 
250  size_type
251  m() const;
252 
260  size_type
261  n() const;
262 
263 protected:
285  template <typename number2>
286  void
288  const Vector<number2> & src,
289  const std::vector<bool> *const dof_mask = nullptr) const;
290 
295  std::size_t
297 
298 private:
303 
307  const std::vector<bool> *selected;
308 
313  mutable std::vector<SmartPointer<FullMatrix<float>, SparseVanka<number>>>
315 
320 
325 
329  void
331 
338  void
340 
348  void
349  compute_inverse(const size_type row, std::vector<size_type> &local_indices);
350 
351  // Make the derived class a friend. This seems silly, but is actually
352  // necessary, since derived classes can only access non-public members
353  // through their @p this pointer, but not access these members as member
354  // functions of other objects of the type of this base class (i.e. like
355  // <tt>x.f()</tt>, where @p x is an object of the base class, and @p f one
356  // of it's non-public member functions).
357  //
358  // Now, in the case of the @p SparseBlockVanka class, we would like to take
359  // the address of a function of the base class in order to call it through
360  // the multithreading framework, so the derived class has to be a friend.
361  template <typename T>
362  friend class SparseBlockVanka;
363 };
364 
365 
366 
498 template <typename number>
499 class SparseBlockVanka : public SparseVanka<number>
500 {
501 public:
506 
512  {
520  adaptive
521  };
522 
531  const std::vector<bool> & selected,
532  const unsigned int n_blocks,
533  const BlockingStrategy blocking_strategy,
534  const bool conserve_memory,
535  const unsigned int n_threads = MultithreadInfo::n_threads());
536 
541  const std::vector<bool> & selected,
542  const unsigned int n_blocks,
543  const BlockingStrategy blocking_strategy);
544 
548  template <typename number2>
549  void
550  vmult(Vector<number2> &dst, const Vector<number2> &src) const;
551 
556  std::size_t
558 
559 private:
563  const unsigned int n_blocks;
564 
572  std::vector<std::vector<bool>> dof_masks;
573 
578  void
580  const std::vector<bool> & selected,
581  const BlockingStrategy blocking_strategy);
582 };
583 
585 /* ---------------------------------- Inline functions ------------------- */
586 
587 #ifndef DOXYGEN
588 
589 template <typename number>
590 inline typename SparseVanka<number>::size_type
592 {
593  Assert(_m != 0, ExcNotInitialized());
594  return _m;
595 }
596 
597 template <typename number>
598 inline typename SparseVanka<number>::size_type
600 {
601  Assert(_n != 0, ExcNotInitialized());
602  return _n;
603 }
604 
605 template <typename number>
606 template <typename number2>
607 inline void
609  const Vector<number2> & /*src*/) const
610 {
611  AssertThrow(false, ExcNotImplemented());
612 }
613 
614 #endif // DOXYGEN
615 
617 
618 #endif
static unsigned int n_threads()
Definition: vector.h:110
#define DEAL_II_DEPRECATED
Definition: config.h:159
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:396
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:397
static ::ExceptionBase & ExcNotInitialized()
#define Assert(cond, exc)
Definition: exceptions.h:1465
static ::ExceptionBase & ExcNotImplemented()
#define AssertThrow(cond, exc)
Definition: exceptions.h:1575
SparseVanka(const SparseMatrix< number > &M, const std::vector< bool > &selected, const bool conserve_memory, const unsigned int n_threads=MultithreadInfo::n_threads())
size_type m() const
size_type _n
Definition: sparse_vanka.h:324
SmartPointer< const SparseMatrix< number >, SparseVanka< number > > matrix
Definition: sparse_vanka.h:302
size_type _m
Definition: sparse_vanka.h:319
void compute_inverses()
std::vector< SmartPointer< FullMatrix< float >, SparseVanka< number > > > inverses
Definition: sparse_vanka.h:314
std::size_t memory_consumption() const
void compute_inverse(const size_type row, std::vector< size_type > &local_indices)
AdditionalData(const std::vector< bool > &selected)
size_type n() const
void compute_inverses(const size_type begin, const size_type end)
AdditionalData(const std::vector< bool > &selected, const bool conserve_memory, const unsigned int n_threads=MultithreadInfo::n_threads())
void initialize(const SparseMatrix< number > &M, const AdditionalData &additional_data)
void compute_dof_masks(const SparseMatrix< number > &M, const std::vector< bool > &selected, const BlockingStrategy blocking_strategy)
void Tvmult(Vector< number2 > &dst, const Vector< number2 > &src) const
void vmult(Vector< number2 > &dst, const Vector< number2 > &src) const
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)
const std::vector< bool > * selected
Definition: sparse_vanka.h:307
SparseBlockVanka(const SparseMatrix< number > &M, const std::vector< bool > &selected, const unsigned int n_blocks, const BlockingStrategy blocking_strategy, const bool conserve_memory, const unsigned int n_threads=MultithreadInfo::n_threads())
void vmult(Vector< number2 > &dst, const Vector< number2 > &src) const
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
std::vector< std::vector< bool > > dof_masks
Definition: sparse_vanka.h:572
types::global_dof_index size_type
Definition: sparse_vanka.h:143
const std::vector< bool > & selected
Definition: sparse_vanka.h:209
const unsigned int n_blocks
Definition: sparse_vanka.h:563
VectorType::value_type * begin(VectorType &V)
VectorType::value_type * end(VectorType &V)
unsigned int global_dof_index
Definition: types.h:76