deal.II version GIT relicensing-2652-g41e7496fd4 2025-02-17 19:10: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#include <deal.II/base/types.h>
23
24#include <vector>
25
27
28// Forward declarations
29#ifndef DOXYGEN
30template <typename number>
31class FullMatrix;
32template <typename number>
33class SparseMatrix;
34template <typename number>
35class Vector;
36
37template <typename number>
38class SparseVanka;
39template <typename number>
41#endif
42
134template <typename number>
136{
137public:
142
150
163 SparseVanka(const SparseMatrix<number> &M, const std::vector<bool> &selected);
164
169
174 {
175 public:
179 explicit AdditionalData(const std::vector<bool> &selected);
180
184 const std::vector<bool> &selected;
185 };
186
187
198 void
200 const AdditionalData &additional_data);
201
206 template <typename number2>
207 void
208 vmult(Vector<number2> &dst, const Vector<number2> &src) const;
209
214 template <typename number2>
215 void
216 Tvmult(Vector<number2> &dst, const Vector<number2> &src) const;
217
221 void
223
232 m() const;
233
242 n() const;
243
244protected:
269 template <typename number2>
270 void
272 const Vector<number2> &src,
273 const bool transpose = false,
274 const std::vector<bool> *const dof_mask = nullptr) const;
275
280 std::size_t
282
283private:
288
292 const std::vector<bool> *selected;
293
298 mutable std::vector<ObserverPointer<FullMatrix<float>, SparseVanka<number>>>
300
305
310
314 void
316
323 void
324 compute_inverses(const size_type begin, const size_type end);
325
333 void
334 compute_inverse(const size_type row, std::vector<size_type> &local_indices);
335
336 // Make the derived class a friend. This seems silly, but is actually
337 // necessary, since derived classes can only access non-public members
338 // through their @p this pointer, but not access these members as member
339 // functions of other objects of the type of this base class (i.e. like
340 // <tt>x.f()</tt>, where @p x is an object of the base class, and @p f one
341 // of it's non-public member functions).
342 //
343 // Now, in the case of the @p SparseBlockVanka class, we would like to take
344 // the address of a function of the base class in order to call it through
345 // the multithreading framework, so the derived class has to be a friend.
346 template <typename T>
347 friend class SparseBlockVanka;
348};
349
350
351
483template <typename number>
484class SparseBlockVanka : public SparseVanka<number>
485{
486public:
491
507
512 const std::vector<bool> &selected,
513 const unsigned int n_blocks,
515
519 template <typename number2>
520 void
521 vmult(Vector<number2> &dst, const Vector<number2> &src) const;
522
523
527 template <typename number2>
528 void
529 Tvmult(Vector<number2> &dst, const Vector<number2> &src) const;
530
535 std::size_t
537
538private:
542 const unsigned int n_blocks;
543
551 std::vector<std::vector<bool>> dof_masks;
552
557 void
559 const std::vector<bool> &selected,
561};
562
564/* ---------------------------------- Inline functions ------------------- */
565
566#ifndef DOXYGEN
567
568template <typename number>
569inline typename SparseVanka<number>::size_type
571{
572 Assert(_m != 0, ExcNotInitialized());
573 return _m;
574}
575
576template <typename number>
577inline typename SparseVanka<number>::size_type
579{
580 Assert(_n != 0, ExcNotInitialized());
581 return _n;
582}
583
584#endif // DOXYGEN
585
587
588#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:518
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:519
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:90