Reference documentation for deal.II version 9.5.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// Copyright (C) 1999 - 2022 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 <vector>
27
29
30// Forward declarations
31#ifndef DOXYGEN
32template <typename number>
33class FullMatrix;
34template <typename number>
35class SparseMatrix;
36template <typename number>
37class Vector;
38
39template <typename number>
40class SparseVanka;
41template <typename number>
43#endif
44
136template <typename number>
138{
139public:
144
152
165 SparseVanka(const SparseMatrix<number> &M, const std::vector<bool> &selected);
166
171
176 {
177 public:
181 explicit AdditionalData(const std::vector<bool> &selected);
182
186 const std::vector<bool> &selected;
187 };
188
189
200 void
202 const AdditionalData & additional_data);
203
208 template <typename number2>
209 void
210 vmult(Vector<number2> &dst, const Vector<number2> &src) const;
211
216 template <typename number2>
217 void
218 Tvmult(Vector<number2> &dst, const Vector<number2> &src) const;
219
228 m() const;
229
238 n() const;
239
240protected:
262 template <typename number2>
263 void
265 const Vector<number2> & src,
266 const std::vector<bool> *const dof_mask = nullptr) const;
267
272 std::size_t
274
275private:
280
284 const std::vector<bool> *selected;
285
290 mutable std::vector<SmartPointer<FullMatrix<float>, SparseVanka<number>>>
292
297
302
306 void
308
315 void
316 compute_inverses(const size_type begin, const size_type end);
317
325 void
326 compute_inverse(const size_type row, std::vector<size_type> &local_indices);
327
328 // Make the derived class a friend. This seems silly, but is actually
329 // necessary, since derived classes can only access non-public members
330 // through their @p this pointer, but not access these members as member
331 // functions of other objects of the type of this base class (i.e. like
332 // <tt>x.f()</tt>, where @p x is an object of the base class, and @p f one
333 // of it's non-public member functions).
334 //
335 // Now, in the case of the @p SparseBlockVanka class, we would like to take
336 // the address of a function of the base class in order to call it through
337 // the multithreading framework, so the derived class has to be a friend.
338 template <typename T>
339 friend class SparseBlockVanka;
340};
341
342
343
475template <typename number>
476class SparseBlockVanka : public SparseVanka<number>
477{
478public:
483
489 {
498 };
499
504 const std::vector<bool> & selected,
505 const unsigned int n_blocks,
506 const BlockingStrategy blocking_strategy);
507
511 template <typename number2>
512 void
513 vmult(Vector<number2> &dst, const Vector<number2> &src) const;
514
519 std::size_t
521
522private:
526 const unsigned int n_blocks;
527
535 std::vector<std::vector<bool>> dof_masks;
536
541 void
543 const std::vector<bool> & selected,
544 const BlockingStrategy blocking_strategy);
545};
546
548/* ---------------------------------- Inline functions ------------------- */
549
550#ifndef DOXYGEN
551
552template <typename number>
553inline typename SparseVanka<number>::size_type
555{
556 Assert(_m != 0, ExcNotInitialized());
557 return _m;
558}
559
560template <typename number>
561inline typename SparseVanka<number>::size_type
563{
564 Assert(_n != 0, ExcNotInitialized());
565 return _n;
566}
567
568template <typename number>
569template <typename number2>
570inline void
572 const Vector<number2> & /*src*/) const
573{
575}
576
577#endif // DOXYGEN
578
580
581#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:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcNotInitialized()
#define AssertThrow(cond, exc)
unsigned int global_dof_index
Definition types.h:82