Reference documentation for deal.II version 9.6.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\}}\)
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
19
20#include <deal.II/base/config.h>
21
24
25#include <vector>
26
28
29// Forward declarations
30#ifndef DOXYGEN
31template <typename number>
32class FullMatrix;
33template <typename number>
34class SparseMatrix;
35template <typename number>
36class Vector;
37
38template <typename number>
39class SparseVanka;
40template <typename number>
42#endif
43
135template <typename number>
137{
138public:
143
151
164 SparseVanka(const SparseMatrix<number> &M, const std::vector<bool> &selected);
165
170
175 {
176 public:
180 explicit AdditionalData(const std::vector<bool> &selected);
181
185 const std::vector<bool> &selected;
186 };
187
188
199 void
201 const AdditionalData &additional_data);
202
207 template <typename number2>
208 void
209 vmult(Vector<number2> &dst, const Vector<number2> &src) const;
210
215 template <typename number2>
216 void
217 Tvmult(Vector<number2> &dst, const Vector<number2> &src) const;
218
227 m() const;
228
237 n() const;
238
239protected:
261 template <typename number2>
262 void
264 const Vector<number2> &src,
265 const std::vector<bool> *const dof_mask = nullptr) const;
266
271 std::size_t
273
274private:
279
283 const std::vector<bool> *selected;
284
289 mutable std::vector<SmartPointer<FullMatrix<float>, SparseVanka<number>>>
291
296
301
305 void
307
314 void
315 compute_inverses(const size_type begin, const size_type end);
316
324 void
325 compute_inverse(const size_type row, std::vector<size_type> &local_indices);
326
327 // Make the derived class a friend. This seems silly, but is actually
328 // necessary, since derived classes can only access non-public members
329 // through their @p this pointer, but not access these members as member
330 // functions of other objects of the type of this base class (i.e. like
331 // <tt>x.f()</tt>, where @p x is an object of the base class, and @p f one
332 // of it's non-public member functions).
333 //
334 // Now, in the case of the @p SparseBlockVanka class, we would like to take
335 // the address of a function of the base class in order to call it through
336 // the multithreading framework, so the derived class has to be a friend.
337 template <typename T>
338 friend class SparseBlockVanka;
339};
340
341
342
474template <typename number>
475class SparseBlockVanka : public SparseVanka<number>
476{
477public:
482
498
503 const std::vector<bool> &selected,
504 const unsigned int n_blocks,
505 const BlockingStrategy blocking_strategy);
506
510 template <typename number2>
511 void
512 vmult(Vector<number2> &dst, const Vector<number2> &src) const;
513
518 std::size_t
520
521private:
525 const unsigned int n_blocks;
526
534 std::vector<std::vector<bool>> dof_masks;
535
540 void
542 const std::vector<bool> &selected,
543 const BlockingStrategy blocking_strategy);
544};
545
547/* ---------------------------------- Inline functions ------------------- */
548
549#ifndef DOXYGEN
550
551template <typename number>
552inline typename SparseVanka<number>::size_type
554{
555 Assert(_m != 0, ExcNotInitialized());
556 return _m;
557}
558
559template <typename number>
560inline typename SparseVanka<number>::size_type
562{
563 Assert(_n != 0, ExcNotInitialized());
564 return _n;
565}
566
567template <typename number>
568template <typename number2>
569inline void
571 const Vector<number2> & /*src*/) const
572{
574}
575
576#endif // DOXYGEN
577
579
580#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
const unsigned int n_blocks
AdditionalData(const std::vector< bool > &selected)
const std::vector< bool > & selected
size_type m() const
size_type _n
SmartPointer< const SparseMatrix< number >, SparseVanka< number > > matrix
size_type _m
void compute_inverses()
std::vector< SmartPointer< FullMatrix< float >, SparseVanka< number > > > 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)
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
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
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:503
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:504
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcNotInitialized()
#define AssertThrow(cond, exc)
unsigned int global_dof_index
Definition types.h:81