Reference documentation for deal.II version Git 3f1f337db3 2021-10-23 13:19:02 -0600
\(\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 
61 {
62 public:
68 
73 
77  std::size_t
78  memory_consumption() const;
79 
80 protected:
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 
137 private:
138  std::vector<std::shared_ptr<BlockSparsityPattern>> prolongation_sparsities;
139 
140 protected:
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 
182 template <typename number>
183 class MGTransferBlock : public MGTransferBase<BlockVector<number>>,
184  private MGTransferBlockBase
185 {
186 public:
190  MGTransferBlock();
191 
195  virtual ~MGTransferBlock() override;
196 
201  void
202  initialize(const std::vector<number> & factors,
203  VectorMemory<Vector<number>> &memory);
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,
218  BlockVector<number> & dst,
219  const BlockVector<number> &src) const override;
220 
221  virtual void
222  restrict_and_add(const unsigned int from_level,
223  BlockVector<number> & dst,
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
251  copy_from_mg(const DoFHandler<dim, spacedim> & dof_handler,
252  BlockVector<number2> & dst,
253  const MGLevelObject<BlockVector<number>> &src) const;
254 
260  template <int dim, typename number2, int spacedim>
261  void
262  copy_from_mg_add(const DoFHandler<dim, spacedim> & dof_handler,
263  BlockVector<number2> & dst,
264  const MGLevelObject<BlockVector<number>> &src) const;
265 
267 
268 private:
273  std::vector<number> factors;
274 
280 };
281 
282 
283 // TODO:[GK] Update documentation for copy_* functions
284 
295 template <typename number>
296 class MGTransferBlockSelect : public MGTransferBase<Vector<number>>,
297  private MGTransferBlockBase
298 {
299 public:
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
366  copy_from_mg(const DoFHandler<dim, spacedim> & dof_handler,
367  Vector<number2> & dst,
368  const MGLevelObject<Vector<number>> &src) const;
369 
375  template <int dim, typename number2, int spacedim>
376  void
377  copy_from_mg_add(const DoFHandler<dim, spacedim> & dof_handler,
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
402  copy_from_mg(const DoFHandler<dim, spacedim> & dof_handler,
403  BlockVector<number2> & dst,
404  const MGLevelObject<Vector<number>> &src) const;
405 
411  template <int dim, typename number2, int spacedim>
412  void
413  copy_from_mg_add(const DoFHandler<dim, spacedim> & dof_handler,
414  BlockVector<number2> & dst,
415  const MGLevelObject<Vector<number>> &src) const;
416 
420  std::size_t
421  memory_consumption() const;
422 
423 private:
427  template <int dim, class OutVector, int spacedim>
428  void
429  do_copy_from_mg(const DoFHandler<dim, spacedim> & dof_handler,
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
439  do_copy_from_mg_add(const DoFHandler<dim, spacedim> & dof_handler,
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
449  do_copy_to_mg(const DoFHandler<dim, spacedim> &dof_handler,
451  const InVector & src,
452  const unsigned int offset) const;
456  unsigned int selected_block;
457 };
458 
461 //------------------------- inline function definition ------------------------
462 template <typename number>
463 inline void
464 MGTransferBlockSelect<number>::select(const unsigned int block)
465 {
466  selected_block = block;
467 }
468 
470 
471 #endif
std::size_t memory_consumption() const
Definition: multigrid.cc:174
std::vector< types::global_dof_index > block_start
SmartPointer< const MGConstrainedDoFs, MGTransferBlockBase > mg_constrained_dofs
std::vector< std::vector< types::global_dof_index > > sizes
std::vector< std::shared_ptr< BlockSparseMatrix< double > > > prolongation_matrices
#define DeclException0(Exception0)
Definition: exceptions.h:464
void build(const DoFHandler< dim, spacedim > &dof_handler)
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:401
std::vector< std::shared_ptr< BlockSparsityPattern > > prolongation_sparsities
void select(const unsigned int block)
std::vector< std::vector< std::vector< std::pair< unsigned int, unsigned int > > > > copy_indices
std::vector< unsigned int > mg_block
static ::ExceptionBase & ExcMatricesNotBuilt()
std::vector< std::vector< types::global_dof_index > > mg_block_start
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:400
SmartPointer< VectorMemory< Vector< number > >, MGTransferBlock< number > > memory
std::vector< number > factors
std::vector< bool > selected