Reference documentation for deal.II version 9.3.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 
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 
101  template <int dim, int spacedim>
102  DEAL_II_DEPRECATED void
104  const DoFHandler<dim, spacedim> &mg_dof);
105 
112  // TODO: rename this to block_mask, in the same way as has already been done
113  // in MGTransferComponent, and give it type BlockMask
114  std::vector<bool> selected;
115 
119  unsigned int n_mg_blocks;
120 
127  // TODO: rename this to mg_block_mask, in the same way as has already been
128  // done in MGTransferComponent, and give it type BlockMask
129  std::vector<unsigned int> mg_block;
130 
134  mutable std::vector<std::vector<types::global_dof_index>> sizes;
135 
139  std::vector<types::global_dof_index> block_start;
140 
144  std::vector<std::vector<types::global_dof_index>> mg_block_start;
145 
150 
151 private:
152  std::vector<std::shared_ptr<BlockSparsityPattern>> prolongation_sparsities;
153 
154 protected:
160  std::vector<std::shared_ptr<BlockSparseMatrix<double>>> prolongation_matrices;
161 
168  std::vector<std::vector<std::vector<std::pair<unsigned int, unsigned int>>>>
170 
177 };
178 
196 template <typename number>
197 class MGTransferBlock : public MGTransferBase<BlockVector<number>>,
198  private MGTransferBlockBase
199 {
200 public:
204  MGTransferBlock();
205 
209  virtual ~MGTransferBlock() override;
210 
215  void
216  initialize(const std::vector<number> & factors,
217  VectorMemory<Vector<number>> &memory);
218 
225  template <int dim, int spacedim>
226  void
227  build(const DoFHandler<dim, spacedim> &dof_handler,
228  const std::vector<bool> & selected);
229 
238  template <int dim, int spacedim>
239  DEAL_II_DEPRECATED void
241  const DoFHandler<dim, spacedim> &mg_dof,
242  const std::vector<bool> & selected);
243 
244  virtual void
245  prolongate(const unsigned int to_level,
246  BlockVector<number> & dst,
247  const BlockVector<number> &src) const override;
248 
249  virtual void
250  restrict_and_add(const unsigned int from_level,
251  BlockVector<number> & dst,
252  const BlockVector<number> &src) const override;
253 
265  template <int dim, typename number2, int spacedim>
266  void
267  copy_to_mg(const DoFHandler<dim, spacedim> & dof_handler,
269  const BlockVector<number2> & src) const;
270 
277  template <int dim, typename number2, int spacedim>
278  void
279  copy_from_mg(const DoFHandler<dim, spacedim> & dof_handler,
280  BlockVector<number2> & dst,
281  const MGLevelObject<BlockVector<number>> &src) const;
282 
288  template <int dim, typename number2, int spacedim>
289  void
290  copy_from_mg_add(const DoFHandler<dim, spacedim> & dof_handler,
291  BlockVector<number2> & dst,
292  const MGLevelObject<BlockVector<number>> &src) const;
293 
295 
296 private:
301  std::vector<number> factors;
302 
308 };
309 
310 
311 // TODO:[GK] Update documentation for copy_* functions
312 
323 template <typename number>
324 class MGTransferBlockSelect : public MGTransferBase<Vector<number>>,
325  private MGTransferBlockBase
326 {
327 public:
333 
338 
342  virtual ~MGTransferBlockSelect() override = default;
343 
354  template <int dim, int spacedim>
355  void
356  build(const DoFHandler<dim, spacedim> &dof_handler, unsigned int selected);
357 
371  template <int dim, int spacedim>
372  DEAL_II_DEPRECATED void
374  const DoFHandler<dim, spacedim> &mg_dof,
375  unsigned int selected);
376 
380  void
381  select(const unsigned int block);
382 
383  virtual void
384  prolongate(const unsigned int to_level,
385  Vector<number> & dst,
386  const Vector<number> &src) const override;
387 
388  virtual void
389  restrict_and_add(const unsigned int from_level,
390  Vector<number> & dst,
391  const Vector<number> &src) const override;
392 
399  template <int dim, typename number2, int spacedim>
400  void
401  copy_to_mg(const DoFHandler<dim, spacedim> &dof_handler,
403  const Vector<number2> & src) const;
404 
411  template <int dim, typename number2, int spacedim>
412  void
413  copy_from_mg(const DoFHandler<dim, spacedim> & dof_handler,
414  Vector<number2> & dst,
415  const MGLevelObject<Vector<number>> &src) const;
416 
422  template <int dim, typename number2, int spacedim>
423  void
424  copy_from_mg_add(const DoFHandler<dim, spacedim> & dof_handler,
425  Vector<number2> & dst,
426  const MGLevelObject<Vector<number>> &src) const;
427 
435  template <int dim, typename number2, int spacedim>
436  void
437  copy_to_mg(const DoFHandler<dim, spacedim> &dof_handler,
439  const BlockVector<number2> & src) const;
440 
447  template <int dim, typename number2, int spacedim>
448  void
449  copy_from_mg(const DoFHandler<dim, spacedim> & dof_handler,
450  BlockVector<number2> & dst,
451  const MGLevelObject<Vector<number>> &src) const;
452 
458  template <int dim, typename number2, int spacedim>
459  void
460  copy_from_mg_add(const DoFHandler<dim, spacedim> & dof_handler,
461  BlockVector<number2> & dst,
462  const MGLevelObject<Vector<number>> &src) const;
463 
467  std::size_t
468  memory_consumption() const;
469 
470 private:
474  template <int dim, class OutVector, int spacedim>
475  void
476  do_copy_from_mg(const DoFHandler<dim, spacedim> & dof_handler,
477  OutVector & dst,
478  const MGLevelObject<Vector<number>> &src,
479  const unsigned int offset) const;
480 
484  template <int dim, class OutVector, int spacedim>
485  void
486  do_copy_from_mg_add(const DoFHandler<dim, spacedim> & dof_handler,
487  OutVector & dst,
488  const MGLevelObject<Vector<number>> &src,
489  const unsigned int offset) const;
490 
494  template <int dim, class InVector, int spacedim>
495  void
496  do_copy_to_mg(const DoFHandler<dim, spacedim> &dof_handler,
498  const InVector & src,
499  const unsigned int offset) const;
503  unsigned int selected_block;
504 };
505 
508 //------------------------- inline function definition ------------------------
509 template <typename number>
510 inline void
511 MGTransferBlockSelect<number>::select(const unsigned int block)
512 {
513  selected_block = block;
514 }
515 
517 
518 #endif
void build_matrices(const DoFHandler< dim, spacedim > &dof, const DoFHandler< dim, spacedim > &mg_dof)
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:470
void build(const DoFHandler< dim, spacedim > &dof_handler)
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:395
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:394
SmartPointer< VectorMemory< Vector< number > >, MGTransferBlock< number > > memory
std::vector< number > factors
#define DEAL_II_DEPRECATED
Definition: config.h:157
std::vector< bool > selected