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
mg_transfer_block.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2001 - 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_mg_transfer_block_h
16#define dealii_mg_transfer_block_h
17
18#include <deal.II/base/config.h>
19
21
23
27
30
31#include <memory>
32
33
35
36
37// Forward declaration
38#ifndef DOXYGEN
39template <int dim, int spacedim>
41class DoFHandler;
42#endif
43
44/*
45 * MGTransferBase is defined in mg_base.h
46 */
47
62{
63public:
69
74
78 std::size_t
79 memory_consumption() const;
80
81protected:
89 template <int dim, int spacedim>
90 void
91 build(const DoFHandler<dim, spacedim> &dof_handler);
92
99 // TODO: rename this to block_mask, in the same way as has already been done
100 // in MGTransferComponent, and give it type BlockMask
101 std::vector<bool> selected;
102
106 unsigned int n_mg_blocks;
107
114 // TODO: rename this to mg_block_mask, in the same way as has already been
115 // done in MGTransferComponent, and give it type BlockMask
116 std::vector<unsigned int> mg_block;
117
121 mutable std::vector<std::vector<types::global_dof_index>> sizes;
122
126 std::vector<types::global_dof_index> block_start;
127
131 std::vector<std::vector<types::global_dof_index>> mg_block_start;
132
137
138private:
139 std::vector<std::shared_ptr<BlockSparsityPattern>> prolongation_sparsities;
140
141protected:
147 std::vector<std::shared_ptr<BlockSparseMatrix<double>>> prolongation_matrices;
148
155 std::vector<std::vector<std::vector<std::pair<unsigned int, unsigned int>>>>
157
164};
165
183template <typename number>
184class MGTransferBlock : public MGTransferBase<BlockVector<number>>,
185 private MGTransferBlockBase
186{
187public:
192
196 virtual ~MGTransferBlock() override;
197
202 void
203 initialize(const std::vector<number> &factors,
205
212 template <int dim, int spacedim>
213 void
214 build(const DoFHandler<dim, spacedim> &dof_handler,
215 const std::vector<bool> &selected);
216
217 virtual void
218 prolongate(const unsigned int to_level,
220 const BlockVector<number> &src) const override;
221
222 virtual void
223 restrict_and_add(const unsigned int from_level,
225 const BlockVector<number> &src) const override;
226
238 template <int dim, typename number2, int spacedim>
239 void
240 copy_to_mg(const DoFHandler<dim, spacedim> &dof_handler,
242 const BlockVector<number2> &src) const;
243
250 template <int dim, typename number2, int spacedim>
251 void
254 const MGLevelObject<BlockVector<number>> &src) const;
255
261 template <int dim, typename number2, int spacedim>
262 void
265 const MGLevelObject<BlockVector<number>> &src) const;
266
268
269private:
274 std::vector<number> factors;
275
281};
282
283
284// TODO:[GK] Update documentation for copy_* functions
285
296template <typename number>
297class MGTransferBlockSelect : public MGTransferBase<Vector<number>>,
298 private MGTransferBlockBase
299{
300public:
306
311
315 virtual ~MGTransferBlockSelect() override = default;
316
327 template <int dim, int spacedim>
328 void
329 build(const DoFHandler<dim, spacedim> &dof_handler, unsigned int selected);
330
334 void
335 select(const unsigned int block);
336
337 virtual void
338 prolongate(const unsigned int to_level,
339 Vector<number> &dst,
340 const Vector<number> &src) const override;
341
342 virtual void
343 restrict_and_add(const unsigned int from_level,
344 Vector<number> &dst,
345 const Vector<number> &src) const override;
346
353 template <int dim, typename number2, int spacedim>
354 void
355 copy_to_mg(const DoFHandler<dim, spacedim> &dof_handler,
357 const Vector<number2> &src) const;
358
365 template <int dim, typename number2, int spacedim>
366 void
368 Vector<number2> &dst,
369 const MGLevelObject<Vector<number>> &src) const;
370
376 template <int dim, typename number2, int spacedim>
377 void
379 Vector<number2> &dst,
380 const MGLevelObject<Vector<number>> &src) const;
381
389 template <int dim, typename number2, int spacedim>
390 void
391 copy_to_mg(const DoFHandler<dim, spacedim> &dof_handler,
393 const BlockVector<number2> &src) const;
394
401 template <int dim, typename number2, int spacedim>
402 void
405 const MGLevelObject<Vector<number>> &src) const;
406
412 template <int dim, typename number2, int spacedim>
413 void
416 const MGLevelObject<Vector<number>> &src) const;
417
421 std::size_t
423
424private:
428 template <int dim, class OutVector, int spacedim>
429 void
431 OutVector &dst,
432 const MGLevelObject<Vector<number>> &src,
433 const unsigned int offset) const;
434
438 template <int dim, class OutVector, int spacedim>
439 void
441 OutVector &dst,
442 const MGLevelObject<Vector<number>> &src,
443 const unsigned int offset) const;
444
448 template <int dim, class InVector, int spacedim>
449 void
452 const InVector &src,
453 const unsigned int offset) const;
457 unsigned int selected_block;
458};
459
462//------------------------- inline function definition ------------------------
463template <typename number>
464inline void
466{
467 selected_block = block;
468}
469
471
472#endif
std::vector< unsigned int > mg_block
std::vector< std::vector< types::global_dof_index > > sizes
void build(const DoFHandler< dim, spacedim > &dof_handler)
std::vector< bool > selected
std::vector< types::global_dof_index > block_start
std::vector< std::shared_ptr< BlockSparseMatrix< double > > > prolongation_matrices
std::vector< std::shared_ptr< BlockSparsityPattern > > prolongation_sparsities
ObserverPointer< const MGConstrainedDoFs, MGTransferBlockBase > mg_constrained_dofs
std::vector< std::vector< types::global_dof_index > > mg_block_start
std::size_t memory_consumption() const
Definition multigrid.cc:172
std::vector< std::vector< std::vector< std::pair< unsigned int, unsigned int > > > > copy_indices
void copy_to_mg(const DoFHandler< dim, spacedim > &dof_handler, MGLevelObject< Vector< number > > &dst, const Vector< number2 > &src) const
void do_copy_to_mg(const DoFHandler< dim, spacedim > &dof_handler, MGLevelObject< Vector< number > > &dst, const InVector &src, const unsigned int offset) const
void copy_from_mg(const DoFHandler< dim, spacedim > &dof_handler, BlockVector< number2 > &dst, const MGLevelObject< Vector< number > > &src) const
virtual ~MGTransferBlockSelect() override=default
virtual void prolongate(const unsigned int to_level, Vector< number > &dst, const Vector< number > &src) const override
Definition multigrid.cc:264
void build(const DoFHandler< dim, spacedim > &dof_handler, unsigned int selected)
virtual void restrict_and_add(const unsigned int from_level, Vector< number > &dst, const Vector< number > &src) const override
Definition multigrid.cc:287
void copy_from_mg_add(const DoFHandler< dim, spacedim > &dof_handler, BlockVector< number2 > &dst, const MGLevelObject< Vector< number > > &src) const
void copy_from_mg_add(const DoFHandler< dim, spacedim > &dof_handler, Vector< number2 > &dst, const MGLevelObject< Vector< number > > &src) const
std::size_t memory_consumption() const
void do_copy_from_mg(const DoFHandler< dim, spacedim > &dof_handler, OutVector &dst, const MGLevelObject< Vector< number > > &src, const unsigned int offset) const
void do_copy_from_mg_add(const DoFHandler< dim, spacedim > &dof_handler, OutVector &dst, const MGLevelObject< Vector< number > > &src, const unsigned int offset) const
void select(const unsigned int block)
void copy_from_mg(const DoFHandler< dim, spacedim > &dof_handler, Vector< number2 > &dst, const MGLevelObject< Vector< number > > &src) const
std::vector< number > factors
void copy_from_mg(const DoFHandler< dim, spacedim > &dof_handler, BlockVector< number2 > &dst, const MGLevelObject< BlockVector< number > > &src) const
virtual void prolongate(const unsigned int to_level, BlockVector< number > &dst, const BlockVector< number > &src) const override
Definition multigrid.cc:76
void build(const DoFHandler< dim, spacedim > &dof_handler, const std::vector< bool > &selected)
virtual void restrict_and_add(const unsigned int from_level, BlockVector< number > &dst, const BlockVector< number > &src) const override
Definition multigrid.cc:109
void copy_from_mg_add(const DoFHandler< dim, spacedim > &dof_handler, BlockVector< number2 > &dst, const MGLevelObject< BlockVector< number > > &src) const
virtual ~MGTransferBlock() override
Definition multigrid.cc:57
ObserverPointer< VectorMemory< Vector< number > >, MGTransferBlock< number > > memory
void copy_to_mg(const DoFHandler< dim, spacedim > &dof_handler, MGLevelObject< BlockVector< number > > &dst, const BlockVector< number2 > &src) const
void initialize(const std::vector< number > &factors, VectorMemory< Vector< number > > &memory)
Definition multigrid.cc:66
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:175
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
#define DeclException0(Exception0)
Definition exceptions.h:466
static ::ExceptionBase & ExcMatricesNotBuilt()