Reference documentation for deal.II version 9.2.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 - 2020 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
41 template <int dim, int spacedim>
42 class DoFHandler;
43 #endif
44 
45 /*
46  * MGTransferBase is defined in mg_base.h
47  */
48 
51 
63 {
64 public:
70 
75 
79  std::size_t
80  memory_consumption() const;
81 
82 protected:
90  template <int dim, int spacedim>
91  void
92  build(const DoFHandler<dim, spacedim> &dof_handler);
93 
103  template <int dim, int spacedim>
104  DEAL_II_DEPRECATED void
106  const DoFHandler<dim, spacedim> &mg_dof);
107 
114  // TODO: rename this to block_mask, in the same way as has already been done
115  // in MGTransferComponent, and give it type BlockMask
116  std::vector<bool> selected;
117 
121  unsigned int n_mg_blocks;
122 
129  // TODO: rename this to mg_block_mask, in the same way as has already been
130  // done in MGTransferComponent, and give it type BlockMask
131  std::vector<unsigned int> mg_block;
132 
136  mutable std::vector<std::vector<types::global_dof_index>> sizes;
137 
141  std::vector<types::global_dof_index> block_start;
142 
146  std::vector<std::vector<types::global_dof_index>> mg_block_start;
147 
152 
153 private:
154  std::vector<std::shared_ptr<BlockSparsityPattern>> prolongation_sparsities;
155 
156 protected:
162  std::vector<std::shared_ptr<BlockSparseMatrix<double>>> prolongation_matrices;
163 
170  std::vector<std::vector<std::vector<std::pair<unsigned int, unsigned int>>>>
172 
179 };
180 
200 template <typename number>
201 class MGTransferBlock : public MGTransferBase<BlockVector<number>>,
202  private MGTransferBlockBase
203 {
204 public:
208  MGTransferBlock();
209 
213  virtual ~MGTransferBlock() override;
214 
219  void
220  initialize(const std::vector<number> & factors,
222 
229  template <int dim, int spacedim>
230  void
231  build(const DoFHandler<dim, spacedim> &dof_handler,
232  const std::vector<bool> & selected);
233 
242  template <int dim, int spacedim>
243  DEAL_II_DEPRECATED void
245  const DoFHandler<dim, spacedim> &mg_dof,
246  const std::vector<bool> & selected);
247 
248  virtual void
249  prolongate(const unsigned int to_level,
250  BlockVector<number> & dst,
251  const BlockVector<number> &src) const override;
252 
253  virtual void
254  restrict_and_add(const unsigned int from_level,
255  BlockVector<number> & dst,
256  const BlockVector<number> &src) const override;
257 
269  template <int dim, typename number2, int spacedim>
270  void
271  copy_to_mg(const DoFHandler<dim, spacedim> & dof_handler,
273  const BlockVector<number2> & src) const;
274 
281  template <int dim, typename number2, int spacedim>
282  void
283  copy_from_mg(const DoFHandler<dim, spacedim> & dof_handler,
284  BlockVector<number2> & dst,
285  const MGLevelObject<BlockVector<number>> &src) const;
286 
292  template <int dim, typename number2, int spacedim>
293  void
294  copy_from_mg_add(const DoFHandler<dim, spacedim> & dof_handler,
295  BlockVector<number2> & dst,
296  const MGLevelObject<BlockVector<number>> &src) const;
297 
299 
300 private:
305  std::vector<number> factors;
306 
312 };
313 
314 
315 // TODO:[GK] Update documentation for copy_* functions
316 
329 template <typename number>
330 class MGTransferBlockSelect : public MGTransferBase<Vector<number>>,
331  private MGTransferBlockBase
332 {
333 public:
339 
344 
348  virtual ~MGTransferBlockSelect() override = default;
349 
360  template <int dim, int spacedim>
361  void
362  build(const DoFHandler<dim, spacedim> &dof_handler, unsigned int selected);
363 
377  template <int dim, int spacedim>
378  DEAL_II_DEPRECATED void
380  const DoFHandler<dim, spacedim> &mg_dof,
381  unsigned int selected);
382 
386  void
387  select(const unsigned int block);
388 
389  virtual void
390  prolongate(const unsigned int to_level,
391  Vector<number> & dst,
392  const Vector<number> &src) const override;
393 
394  virtual void
395  restrict_and_add(const unsigned int from_level,
396  Vector<number> & dst,
397  const Vector<number> &src) const override;
398 
405  template <int dim, typename number2, int spacedim>
406  void
407  copy_to_mg(const DoFHandler<dim, spacedim> &dof_handler,
409  const Vector<number2> & src) const;
410 
417  template <int dim, typename number2, int spacedim>
418  void
419  copy_from_mg(const DoFHandler<dim, spacedim> & dof_handler,
420  Vector<number2> & dst,
421  const MGLevelObject<Vector<number>> &src) const;
422 
428  template <int dim, typename number2, int spacedim>
429  void
430  copy_from_mg_add(const DoFHandler<dim, spacedim> & dof_handler,
431  Vector<number2> & dst,
432  const MGLevelObject<Vector<number>> &src) const;
433 
441  template <int dim, typename number2, int spacedim>
442  void
443  copy_to_mg(const DoFHandler<dim, spacedim> &dof_handler,
445  const BlockVector<number2> & src) const;
446 
453  template <int dim, typename number2, int spacedim>
454  void
455  copy_from_mg(const DoFHandler<dim, spacedim> & dof_handler,
456  BlockVector<number2> & dst,
457  const MGLevelObject<Vector<number>> &src) const;
458 
464  template <int dim, typename number2, int spacedim>
465  void
466  copy_from_mg_add(const DoFHandler<dim, spacedim> & dof_handler,
467  BlockVector<number2> & dst,
468  const MGLevelObject<Vector<number>> &src) const;
469 
473  std::size_t
474  memory_consumption() const;
475 
476 private:
480  template <int dim, class OutVector, int spacedim>
481  void
482  do_copy_from_mg(const DoFHandler<dim, spacedim> & dof_handler,
483  OutVector & dst,
484  const MGLevelObject<Vector<number>> &src,
485  const unsigned int offset) const;
486 
490  template <int dim, class OutVector, int spacedim>
491  void
493  OutVector & dst,
494  const MGLevelObject<Vector<number>> &src,
495  const unsigned int offset) const;
496 
500  template <int dim, class InVector, int spacedim>
501  void
502  do_copy_to_mg(const DoFHandler<dim, spacedim> &dof_handler,
504  const InVector & src,
505  const unsigned int offset) const;
509  unsigned int selected_block;
510 };
511 
514 //------------------------- inline function definition ------------------------
515 template <typename number>
516 inline void
517 MGTransferBlockSelect<number>::select(const unsigned int block)
518 {
519  selected_block = block;
520 }
521 
523 
524 #endif
MGTransferBlock::prolongate
virtual void prolongate(const unsigned int to_level, BlockVector< number > &dst, const BlockVector< number > &src) const override
Definition: multigrid.cc:78
MGTransferBlockBase::build_matrices
void build_matrices(const DoFHandler< dim, spacedim > &dof, const DoFHandler< dim, spacedim > &mg_dof)
Definition: mg_transfer_block.cc:207
mg_base.h
MGTransferBlock::copy_to_mg
void copy_to_mg(const DoFHandler< dim, spacedim > &dof_handler, MGLevelObject< BlockVector< number >> &dst, const BlockVector< number2 > &src) const
Definition: mg_transfer_block.cc:183
MGTransferBlockBase::selected
std::vector< bool > selected
Definition: mg_transfer_block.h:116
MGTransferBlockBase::block_start
std::vector< types::global_dof_index > block_start
Definition: mg_transfer_block.h:141
MGTransferBase
Definition: mg_base.h:177
MGTransferBlock::MGTransferBlock
MGTransferBlock()
Definition: multigrid.cc:53
BlockVector< number >
MGTransferBlockBase::build
void build(const DoFHandler< dim, spacedim > &dof_handler)
Definition: mg_transfer_block.cc:218
MGConstrainedDoFs
Definition: mg_constrained_dofs.h:45
MGTransferBlock
Definition: mg_transfer_block.h:201
MGTransferBlock::build
void build(const DoFHandler< dim, spacedim > &dof_handler, const std::vector< bool > &selected)
Definition: mg_transfer_block.cc:593
MGTransferBlock::~MGTransferBlock
virtual ~MGTransferBlock() override
Definition: multigrid.cc:59
MGTransferBlockBase::sizes
std::vector< std::vector< types::global_dof_index > > sizes
Definition: mg_transfer_block.h:136
block_sparsity_pattern.h
MGTransferBlockSelect::do_copy_to_mg
void do_copy_to_mg(const DoFHandler< dim, spacedim > &dof_handler, MGLevelObject< Vector< number >> &dst, const InVector &src, const unsigned int offset) const
DoFHandler
Definition: dof_handler.h:205
MGTransferBlockSelect::prolongate
virtual void prolongate(const unsigned int to_level, Vector< number > &dst, const Vector< number > &src) const override
Definition: multigrid.cc:266
MGTransferBlockSelect::MGTransferBlockSelect
MGTransferBlockSelect()
Definition: multigrid.cc:249
MGTransferBlock::build_matrices
void build_matrices(const DoFHandler< dim, spacedim > &dof, const DoFHandler< dim, spacedim > &mg_dof, const std::vector< bool > &selected)
Definition: mg_transfer_block.cc:582
MGTransferBlock::copy_from_mg_add
void copy_from_mg_add(const DoFHandler< dim, spacedim > &dof_handler, BlockVector< number2 > &dst, const MGLevelObject< BlockVector< number >> &src) const
MGTransferBlockSelect::selected_block
unsigned int selected_block
Definition: mg_transfer_block.h:509
MGTransferBlockSelect::restrict_and_add
virtual void restrict_and_add(const unsigned int from_level, Vector< number > &dst, const Vector< number > &src) const override
Definition: multigrid.cc:289
block_vector.h
MGTransferBlockBase::mg_block_start
std::vector< std::vector< types::global_dof_index > > mg_block_start
Definition: mg_transfer_block.h:146
MGTransferBlock::memory
SmartPointer< VectorMemory< Vector< number > >, MGTransferBlock< number > > memory
Definition: mg_transfer_block.h:311
MGTransferBlockSelect::build
void build(const DoFHandler< dim, spacedim > &dof_handler, unsigned int selected)
Definition: mg_transfer_block.cc:494
MGTransferBlockBase::copy_indices
std::vector< std::vector< std::vector< std::pair< unsigned int, unsigned int > > > > copy_indices
Definition: mg_transfer_block.h:171
MGTransferBlockBase
Definition: mg_transfer_block.h:62
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
MGTransferBlockSelect::copy_from_mg_add
void copy_from_mg_add(const DoFHandler< dim, spacedim > &dof_handler, Vector< number2 > &dst, const MGLevelObject< Vector< number >> &src) const
MGTransferBlockBase::n_mg_blocks
unsigned int n_mg_blocks
Definition: mg_transfer_block.h:121
MGTransferBlockBase::prolongation_sparsities
std::vector< std::shared_ptr< BlockSparsityPattern > > prolongation_sparsities
Definition: mg_transfer_block.h:154
MGTransferBlockSelect
Definition: mg_transfer_block.h:330
DEAL_II_DEPRECATED
#define DEAL_II_DEPRECATED
Definition: config.h:98
sparsity_pattern.h
mg_level_object.h
MGTransferBlockSelect::build_matrices
void build_matrices(const DoFHandler< dim, spacedim > &dof, const DoFHandler< dim, spacedim > &mg_dof, unsigned int selected)
Definition: mg_transfer_block.cc:483
MGTransferBlock::restrict_and_add
virtual void restrict_and_add(const unsigned int from_level, BlockVector< number > &dst, const BlockVector< number > &src) const override
Definition: multigrid.cc:111
MGTransferBlockBase::memory_consumption
std::size_t memory_consumption() const
Definition: multigrid.cc:174
mg_constrained_dofs.h
SmartPointer< const MGConstrainedDoFs, MGTransferBlockBase >
MGTransferBlockSelect::memory_consumption
std::size_t memory_consumption() const
MGTransferBlock::copy_from_mg
void copy_from_mg(const DoFHandler< dim, spacedim > &dof_handler, BlockVector< number2 > &dst, const MGLevelObject< BlockVector< number >> &src) const
MGLevelObject
Definition: mg_level_object.h:50
MGTransferBlockSelect::select
void select(const unsigned int block)
Definition: mg_transfer_block.h:517
dof_handler.h
MGTransferBlockBase::ExcMatricesNotBuilt
static ::ExceptionBase & ExcMatricesNotBuilt()
MGTransferBlockBase::MGTransferBlockBase
MGTransferBlockBase()
Definition: multigrid.cc:39
DeclException0
#define DeclException0(Exception0)
Definition: exceptions.h:473
MGTransferBlock::factors
std::vector< number > factors
Definition: mg_transfer_block.h:305
vector_memory.h
config.h
MGTransferBlockSelect::~MGTransferBlockSelect
virtual ~MGTransferBlockSelect() override=default
MGTransferBlockBase::prolongation_matrices
std::vector< std::shared_ptr< BlockSparseMatrix< double > > > prolongation_matrices
Definition: mg_transfer_block.h:162
MGTransferBlockSelect::do_copy_from_mg_add
void do_copy_from_mg_add(const DoFHandler< dim, spacedim > &dof_handler, OutVector &dst, const MGLevelObject< Vector< number >> &src, const unsigned int offset) const
MGTransferBlockBase::mg_block
std::vector< unsigned int > mg_block
Definition: mg_transfer_block.h:131
MGTransferBlockSelect::copy_from_mg
void copy_from_mg(const DoFHandler< dim, spacedim > &dof_handler, Vector< number2 > &dst, const MGLevelObject< Vector< number >> &src) const
MGTransferBlock::initialize
void initialize(const std::vector< number > &factors, VectorMemory< Vector< number >> &memory)
Definition: multigrid.cc:68
MGTransferBlockSelect::copy_to_mg
void copy_to_mg(const DoFHandler< dim, spacedim > &dof_handler, MGLevelObject< Vector< number >> &dst, const Vector< number2 > &src) const
Definition: mg_transfer_block.cc:158
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
Vector< number >
MGTransferBlockBase::mg_constrained_dofs
SmartPointer< const MGConstrainedDoFs, MGTransferBlockBase > mg_constrained_dofs
Definition: mg_transfer_block.h:178
MGTransferBlockSelect::do_copy_from_mg
void do_copy_from_mg(const DoFHandler< dim, spacedim > &dof_handler, OutVector &dst, const MGLevelObject< Vector< number >> &src, const unsigned int offset) const
VectorMemory
Definition: vector_memory.h:107