Reference documentation for deal.II version 9.4.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\}}\)
mg_transfer_block.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2001 - 2021 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_mg_transfer_block_h
17#define dealii_mg_transfer_block_h
18
19#include <deal.II/base/config.h>
20
22
24
29
32
33#include <memory>
34
35
37
38
39// Forward declaration
40#ifndef DOXYGEN
41template <int dim, int spacedim>
42class DoFHandler;
43#endif
44
45/*
46 * MGTransferBase is defined in mg_base.h
47 */
48
51
61{
62public:
68
73
77 std::size_t
78 memory_consumption() const;
79
80protected:
88 template <int dim, int spacedim>
89 void
90 build(const DoFHandler<dim, spacedim> &dof_handler);
91
98 // TODO: rename this to block_mask, in the same way as has already been done
99 // in MGTransferComponent, and give it type BlockMask
100 std::vector<bool> selected;
101
105 unsigned int n_mg_blocks;
106
113 // TODO: rename this to mg_block_mask, in the same way as has already been
114 // done in MGTransferComponent, and give it type BlockMask
115 std::vector<unsigned int> mg_block;
116
120 mutable std::vector<std::vector<types::global_dof_index>> sizes;
121
125 std::vector<types::global_dof_index> block_start;
126
130 std::vector<std::vector<types::global_dof_index>> mg_block_start;
131
136
137private:
138 std::vector<std::shared_ptr<BlockSparsityPattern>> prolongation_sparsities;
139
140protected:
146 std::vector<std::shared_ptr<BlockSparseMatrix<double>>> prolongation_matrices;
147
154 std::vector<std::vector<std::vector<std::pair<unsigned int, unsigned int>>>>
156
163};
164
182template <typename number>
183class MGTransferBlock : public MGTransferBase<BlockVector<number>>,
184 private MGTransferBlockBase
185{
186public:
191
195 virtual ~MGTransferBlock() override;
196
201 void
202 initialize(const std::vector<number> & factors,
204
211 template <int dim, int spacedim>
212 void
213 build(const DoFHandler<dim, spacedim> &dof_handler,
214 const std::vector<bool> & selected);
215
216 virtual void
217 prolongate(const unsigned int to_level,
219 const BlockVector<number> &src) const override;
220
221 virtual void
222 restrict_and_add(const unsigned int from_level,
224 const BlockVector<number> &src) const override;
225
237 template <int dim, typename number2, int spacedim>
238 void
239 copy_to_mg(const DoFHandler<dim, spacedim> & dof_handler,
241 const BlockVector<number2> & src) const;
242
249 template <int dim, typename number2, int spacedim>
250 void
253 const MGLevelObject<BlockVector<number>> &src) const;
254
260 template <int dim, typename number2, int spacedim>
261 void
264 const MGLevelObject<BlockVector<number>> &src) const;
265
267
268private:
273 std::vector<number> factors;
274
280};
281
282
283// TODO:[GK] Update documentation for copy_* functions
284
295template <typename number>
296class MGTransferBlockSelect : public MGTransferBase<Vector<number>>,
297 private MGTransferBlockBase
298{
299public:
305
310
314 virtual ~MGTransferBlockSelect() override = default;
315
326 template <int dim, int spacedim>
327 void
328 build(const DoFHandler<dim, spacedim> &dof_handler, unsigned int selected);
329
333 void
334 select(const unsigned int block);
335
336 virtual void
337 prolongate(const unsigned int to_level,
338 Vector<number> & dst,
339 const Vector<number> &src) const override;
340
341 virtual void
342 restrict_and_add(const unsigned int from_level,
343 Vector<number> & dst,
344 const Vector<number> &src) const override;
345
352 template <int dim, typename number2, int spacedim>
353 void
354 copy_to_mg(const DoFHandler<dim, spacedim> &dof_handler,
356 const Vector<number2> & src) const;
357
364 template <int dim, typename number2, int spacedim>
365 void
367 Vector<number2> & dst,
368 const MGLevelObject<Vector<number>> &src) const;
369
375 template <int dim, typename number2, int spacedim>
376 void
378 Vector<number2> & dst,
379 const MGLevelObject<Vector<number>> &src) const;
380
388 template <int dim, typename number2, int spacedim>
389 void
390 copy_to_mg(const DoFHandler<dim, spacedim> &dof_handler,
392 const BlockVector<number2> & src) const;
393
400 template <int dim, typename number2, int spacedim>
401 void
404 const MGLevelObject<Vector<number>> &src) const;
405
411 template <int dim, typename number2, int spacedim>
412 void
415 const MGLevelObject<Vector<number>> &src) const;
416
420 std::size_t
422
423private:
427 template <int dim, class OutVector, int spacedim>
428 void
430 OutVector & dst,
431 const MGLevelObject<Vector<number>> &src,
432 const unsigned int offset) const;
433
437 template <int dim, class OutVector, int spacedim>
438 void
440 OutVector & dst,
441 const MGLevelObject<Vector<number>> &src,
442 const unsigned int offset) const;
443
447 template <int dim, class InVector, int spacedim>
448 void
451 const InVector & src,
452 const unsigned int offset) const;
456 unsigned int selected_block;
457};
458
461//------------------------- inline function definition ------------------------
462template <typename number>
463inline void
465{
466 selected_block = block;
467}
468
470
471#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
SmartPointer< 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:174
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:266
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:289
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:78
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:111
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:59
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:68
SmartPointer< VectorMemory< Vector< number > >, MGTransferBlock< number > > memory
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
#define DeclException0(Exception0)
Definition: exceptions.h:464
static ::ExceptionBase & ExcMatricesNotBuilt()