Reference documentation for deal.II version GIT f24ba87524 2022-11-27 03:40:02+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\}}\)
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 
28 
31 
32 #include <memory>
33 
34 
36 
37 
38 // Forward declaration
39 #ifndef DOXYGEN
40 template <int dim, int spacedim>
41 class DoFHandler;
42 #endif
43 
44 /*
45  * MGTransferBase is defined in mg_base.h
46  */
47 
62 {
63 public:
69 
74 
78  std::size_t
79  memory_consumption() const;
80 
81 protected:
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 
138 private:
139  std::vector<std::shared_ptr<BlockSparsityPattern>> prolongation_sparsities;
140 
141 protected:
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 
183 template <typename number>
184 class MGTransferBlock : public MGTransferBase<BlockVector<number>>,
185  private MGTransferBlockBase
186 {
187 public:
191  MGTransferBlock();
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,
219  BlockVector<number> & dst,
220  const BlockVector<number> &src) const override;
221 
222  virtual void
223  restrict_and_add(const unsigned int from_level,
224  BlockVector<number> & dst,
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
253  BlockVector<number2> & dst,
254  const MGLevelObject<BlockVector<number>> &src) const;
255 
261  template <int dim, typename number2, int spacedim>
262  void
264  BlockVector<number2> & dst,
265  const MGLevelObject<BlockVector<number>> &src) const;
266 
268 
269 private:
274  std::vector<number> factors;
275 
281 };
282 
283 
284 // TODO:[GK] Update documentation for copy_* functions
285 
296 template <typename number>
297 class MGTransferBlockSelect : public MGTransferBase<Vector<number>>,
298  private MGTransferBlockBase
299 {
300 public:
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
404  BlockVector<number2> & dst,
405  const MGLevelObject<Vector<number>> &src) const;
406 
412  template <int dim, typename number2, int spacedim>
413  void
415  BlockVector<number2> & dst,
416  const MGLevelObject<Vector<number>> &src) const;
417 
421  std::size_t
423 
424 private:
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 ------------------------
463 template <typename number>
464 inline void
465 MGTransferBlockSelect<number>::select(const unsigned int block)
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
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 do_copy_to_mg(const DoFHandler< dim, spacedim > &dof_handler, MGLevelObject< Vector< number >> &dst, const InVector &src, const unsigned int offset) 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 copy_from_mg(const DoFHandler< dim, spacedim > &dof_handler, BlockVector< number2 > &dst, const MGLevelObject< Vector< number >> &src) const
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(const DoFHandler< dim, spacedim > &dof_handler, Vector< 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
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 copy_from_mg_add(const DoFHandler< dim, spacedim > &dof_handler, BlockVector< number2 > &dst, const MGLevelObject< Vector< number >> &src) const
std::size_t memory_consumption() const
void copy_to_mg(const DoFHandler< dim, spacedim > &dof_handler, MGLevelObject< Vector< number >> &dst, const Vector< number2 > &src) 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 select(const unsigned int block)
std::vector< number > factors
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)
void copy_from_mg_add(const DoFHandler< dim, spacedim > &dof_handler, BlockVector< number2 > &dst, const MGLevelObject< BlockVector< number >> &src) const
void copy_from_mg(const DoFHandler< dim, spacedim > &dof_handler, BlockVector< number2 > &dst, const MGLevelObject< BlockVector< number >> &src) const
virtual void restrict_and_add(const unsigned int from_level, BlockVector< number > &dst, const BlockVector< number > &src) const override
Definition: multigrid.cc:111
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
Definition: vector.h:109
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:458
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:459
#define DeclException0(Exception0)
Definition: exceptions.h:464
static ::ExceptionBase & ExcMatricesNotBuilt()