Reference documentation for deal.II version 9.2.0
\(\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 - 2019 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 
139 template <typename number>
141 {
142 public:
147 
154  SparseVanka();
155 
182  const std::vector<bool> & selected,
183  const bool conserve_memory = false,
184  const unsigned int n_threads = MultithreadInfo::n_threads());
185 
189  ~SparseVanka();
190 
195  {
196  public:
200  AdditionalData(const std::vector<bool> &selected,
201  const bool conserve_memory = false,
202  const unsigned int n_threads = MultithreadInfo::n_threads());
203 
207  const std::vector<bool> &selected;
208 
212  const bool conserve_mem;
213 
218  const unsigned int n_threads;
219  };
220 
221 
232  void
234  const AdditionalData & additional_data);
235 
240  template <typename number2>
241  void
242  vmult(Vector<number2> &dst, const Vector<number2> &src) const;
243 
248  template <typename number2>
249  void
250  Tvmult(Vector<number2> &dst, const Vector<number2> &src) const;
251 
259  size_type
260  m() const;
261 
269  size_type
270  n() const;
271 
272 protected:
294  template <typename number2>
295  void
297  const Vector<number2> & src,
298  const std::vector<bool> *const dof_mask = nullptr) const;
299 
304  std::size_t
305  memory_consumption() const;
306 
307 private:
312 
317 
321  const std::vector<bool> *selected;
322 
327  unsigned int n_threads;
328 
333  mutable std::vector<SmartPointer<FullMatrix<float>, SparseVanka<number>>>
335 
340 
345 
349  void
351 
358  void
360 
368  void
369  compute_inverse(const size_type row, std::vector<size_type> &local_indices);
370 
371  // Make the derived class a friend. This seems silly, but is actually
372  // necessary, since derived classes can only access non-public members
373  // through their @p this pointer, but not access these members as member
374  // functions of other objects of the type of this base class (i.e. like
375  // <tt>x.f()</tt>, where @p x is an object of the base class, and @p f one
376  // of it's non-public member functions).
377  //
378  // Now, in the case of the @p SparseBlockVanka class, we would like to take
379  // the address of a function of the base class in order to call it through
380  // the multithreading framework, so the derived class has to be a friend.
381  template <typename T>
382  friend class SparseBlockVanka;
383 };
384 
385 
386 
520 template <typename number>
521 class SparseBlockVanka : public SparseVanka<number>
522 {
523 public:
528 
534  {
543  };
544 
549  const std::vector<bool> & selected,
550  const unsigned int n_blocks,
551  const BlockingStrategy blocking_strategy,
552  const bool conserve_memory = false,
553  const unsigned int n_threads = MultithreadInfo::n_threads());
554 
558  template <typename number2>
559  void
560  vmult(Vector<number2> &dst, const Vector<number2> &src) const;
561 
566  std::size_t
567  memory_consumption() const;
568 
569 private:
573  const unsigned int n_blocks;
574 
582  std::vector<std::vector<bool>> dof_masks;
583 
588  void
590  const std::vector<bool> & selected,
591  const BlockingStrategy blocking_strategy);
592 };
593 
595 /* ---------------------------------- Inline functions ------------------- */
596 
597 #ifndef DOXYGEN
598 
599 template <typename number>
600 inline typename SparseVanka<number>::size_type
602 {
603  Assert(_m != 0, ExcNotInitialized());
604  return _m;
605 }
606 
607 template <typename number>
608 inline typename SparseVanka<number>::size_type
610 {
611  Assert(_n != 0, ExcNotInitialized());
612  return _n;
613 }
614 
615 template <typename number>
616 template <typename number2>
617 inline void
618 SparseVanka<number>::Tvmult(Vector<number2> & /*dst*/,
619  const Vector<number2> & /*src*/) const
620 {
621  AssertThrow(false, ExcNotImplemented());
622 }
623 
624 #endif // DOXYGEN
625 
627 
628 #endif
SparseVanka::Tvmult
void Tvmult(Vector< number2 > &dst, const Vector< number2 > &src) const
SparseBlockVanka::BlockingStrategy
BlockingStrategy
Definition: sparse_vanka.h:533
LinearAlgebraDealII::Vector
Vector< double > Vector
Definition: generic_linear_algebra.h:43
SparseBlockVanka::adaptive
@ adaptive
Definition: sparse_vanka.h:542
SparseBlockVanka::n_blocks
const unsigned int n_blocks
Definition: sparse_vanka.h:573
MultithreadInfo::n_threads
static unsigned int n_threads()
Definition: multithread_info.cc:169
SparseVanka::_n
size_type _n
Definition: sparse_vanka.h:344
SparseVanka::compute_inverses
void compute_inverses()
StandardExceptions::ExcNotImplemented
static ::ExceptionBase & ExcNotImplemented()
SparseVanka
Definition: sparse_vanka.h:140
SparseVanka::AdditionalData::AdditionalData
AdditionalData(const std::vector< bool > &selected, const bool conserve_memory=false, const unsigned int n_threads=MultithreadInfo::n_threads())
SparseVanka::initialize
void initialize(const SparseMatrix< number > &M, const AdditionalData &additional_data)
SparseMatrix
Definition: sparse_matrix.h:497
SparseBlockVanka::compute_dof_masks
void compute_dof_masks(const SparseMatrix< number > &M, const std::vector< bool > &selected, const BlockingStrategy blocking_strategy)
multithread_info.h
SparseVanka::compute_inverse
void compute_inverse(const size_type row, std::vector< size_type > &local_indices)
SparseVanka::n
size_type n() const
SparseVanka::AdditionalData::conserve_mem
const bool conserve_mem
Definition: sparse_vanka.h:212
SparseVanka::inverses
std::vector< SmartPointer< FullMatrix< float >, SparseVanka< number > > > inverses
Definition: sparse_vanka.h:334
SparseVanka::AdditionalData::selected
const std::vector< bool > & selected
Definition: sparse_vanka.h:207
SparseVanka::AdditionalData
Definition: sparse_vanka.h:194
SparseBlockVanka
Definition: sparse_vanka.h:521
SparseVanka::SparseVanka
SparseVanka()
SparseVanka::selected
const std::vector< bool > * selected
Definition: sparse_vanka.h:321
SparseVanka::n_threads
unsigned int n_threads
Definition: sparse_vanka.h:327
SparseBlockVanka::dof_masks
std::vector< std::vector< bool > > dof_masks
Definition: sparse_vanka.h:582
SparseBlockVanka::vmult
void vmult(Vector< number2 > &dst, const Vector< number2 > &src) const
types::global_dof_index
unsigned int global_dof_index
Definition: types.h:76
TrilinosWrappers::internal::begin
VectorType::value_type * begin(VectorType &V)
Definition: trilinos_sparse_matrix.cc:51
SparseVanka::~SparseVanka
~SparseVanka()
SparseVanka::vmult
void vmult(Vector< number2 > &dst, const Vector< number2 > &src) const
SparseVanka::memory_consumption
std::size_t memory_consumption() const
SparseVanka::matrix
SmartPointer< const SparseMatrix< number >, SparseVanka< number > > matrix
Definition: sparse_vanka.h:311
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
TrilinosWrappers::internal::end
VectorType::value_type * end(VectorType &V)
Definition: trilinos_sparse_matrix.cc:65
smartpointer.h
StandardExceptions::ExcNotInitialized
static ::ExceptionBase & ExcNotInitialized()
SparseVanka::conserve_mem
bool conserve_mem
Definition: sparse_vanka.h:316
SparseVanka::SparseBlockVanka
friend class SparseBlockVanka
Definition: sparse_vanka.h:382
SmartPointer
Definition: smartpointer.h:68
unsigned int
Assert
#define Assert(cond, exc)
Definition: exceptions.h:1419
SparseVanka::m
size_type m() const
config.h
FullMatrix
Definition: full_matrix.h:71
SparseVanka::_m
size_type _m
Definition: sparse_vanka.h:339
SparseVanka::AdditionalData::n_threads
const unsigned int n_threads
Definition: sparse_vanka.h:218
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
Vector
Definition: mapping_q1_eulerian.h:32
SparseVanka::apply_preconditioner
void apply_preconditioner(Vector< number2 > &dst, const Vector< number2 > &src, const std::vector< bool > *const dof_mask=nullptr) const
SparseBlockVanka::index_intervals
@ index_intervals
Definition: sparse_vanka.h:538
AssertThrow
#define AssertThrow(cond, exc)
Definition: exceptions.h:1531
SparseBlockVanka::memory_consumption
std::size_t memory_consumption() const