deal.II version GIT relicensing-2167-g9622207b8f 2024-11-21 12:40:00+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\}}\)
Loading...
Searching...
No Matches
sparse_vanka.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 1999 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_sparse_vanka_h
16#define dealii_sparse_vanka_h
17
18#include <deal.II/base/config.h>
19
22
23#include <vector>
24
26
27// Forward declarations
28#ifndef DOXYGEN
29template <typename number>
30class FullMatrix;
31template <typename number>
32class SparseMatrix;
33template <typename number>
34class Vector;
35
36template <typename number>
37class SparseVanka;
38template <typename number>
40#endif
41
133template <typename number>
135{
136public:
141
149
162 SparseVanka(const SparseMatrix<number> &M, const std::vector<bool> &selected);
163
168
173 {
174 public:
178 explicit AdditionalData(const std::vector<bool> &selected);
179
183 const std::vector<bool> &selected;
184 };
185
186
197 void
199 const AdditionalData &additional_data);
200
205 template <typename number2>
206 void
207 vmult(Vector<number2> &dst, const Vector<number2> &src) const;
208
213 template <typename number2>
214 void
215 Tvmult(Vector<number2> &dst, const Vector<number2> &src) const;
216
220 void
222
231 m() const;
232
241 n() const;
242
243protected:
268 template <typename number2>
269 void
271 const Vector<number2> &src,
272 const bool transpose = false,
273 const std::vector<bool> *const dof_mask = nullptr) const;
274
279 std::size_t
281
282private:
287
291 const std::vector<bool> *selected;
292
297 mutable std::vector<ObserverPointer<FullMatrix<float>, SparseVanka<number>>>
299
304
309
313 void
315
322 void
323 compute_inverses(const size_type begin, const size_type end);
324
332 void
333 compute_inverse(const size_type row, std::vector<size_type> &local_indices);
334
335 // Make the derived class a friend. This seems silly, but is actually
336 // necessary, since derived classes can only access non-public members
337 // through their @p this pointer, but not access these members as member
338 // functions of other objects of the type of this base class (i.e. like
339 // <tt>x.f()</tt>, where @p x is an object of the base class, and @p f one
340 // of it's non-public member functions).
341 //
342 // Now, in the case of the @p SparseBlockVanka class, we would like to take
343 // the address of a function of the base class in order to call it through
344 // the multithreading framework, so the derived class has to be a friend.
345 template <typename T>
346 friend class SparseBlockVanka;
347};
348
349
350
482template <typename number>
483class SparseBlockVanka : public SparseVanka<number>
484{
485public:
490
506
511 const std::vector<bool> &selected,
512 const unsigned int n_blocks,
513 const BlockingStrategy blocking_strategy);
514
518 template <typename number2>
519 void
520 vmult(Vector<number2> &dst, const Vector<number2> &src) const;
521
522
526 template <typename number2>
527 void
528 Tvmult(Vector<number2> &dst, const Vector<number2> &src) const;
529
534 std::size_t
536
537private:
541 const unsigned int n_blocks;
542
550 std::vector<std::vector<bool>> dof_masks;
551
556 void
558 const std::vector<bool> &selected,
559 const BlockingStrategy blocking_strategy);
560};
561
563/* ---------------------------------- Inline functions ------------------- */
564
565#ifndef DOXYGEN
566
567template <typename number>
568inline typename SparseVanka<number>::size_type
570{
571 Assert(_m != 0, ExcNotInitialized());
572 return _m;
573}
574
575template <typename number>
576inline typename SparseVanka<number>::size_type
578{
579 Assert(_n != 0, ExcNotInitialized());
580 return _n;
581}
582
583#endif // DOXYGEN
584
586
587#endif
void Tvmult(Vector< number2 > &dst, const Vector< number2 > &src) const
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
const unsigned int n_blocks
AdditionalData(const std::vector< bool > &selected)
const std::vector< bool > & selected
size_type m() const
void apply_preconditioner(Vector< number2 > &dst, const Vector< number2 > &src, const bool transpose=false, const std::vector< bool > *const dof_mask=nullptr) const
size_type _n
size_type _m
void compute_inverses()
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)
ObserverPointer< const SparseMatrix< number >, SparseVanka< number > > matrix
void vmult(Vector< number2 > &dst, const Vector< number2 > &src) const
void Tvmult(Vector< number2 > &dst, const Vector< number2 > &src) const
const std::vector< bool > * selected
std::vector< ObserverPointer< FullMatrix< float >, SparseVanka< number > > > inverses
SparseVanka(const SparseMatrix< number > &M, const std::vector< bool > &selected)
void clear()
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
DerivativeForm< 1, spacedim, dim, Number > transpose(const DerivativeForm< 1, dim, spacedim, Number > &DF)
#define Assert(cond, exc)
static ::ExceptionBase & ExcNotInitialized()
unsigned int global_dof_index
Definition types.h:81