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_component.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_component_h
17 #define dealii_mg_transfer_component_h
18 
19 #include <deal.II/base/config.h>
20 
22 
24 
26 
32 
34 
35 #include <memory>
36 
37 
38 
40 
41 // Forward declaration
42 #ifndef DOXYGEN
43 template <int dim, int spacedim>
44 class DoFHandler;
45 #endif
46 
47 /*
48  * MGTransferBase is defined in mg_base.h
49  */
50 
53 
64 {
65 public:
69  std::size_t
70  memory_consumption() const;
71 
72 
73 protected:
84  template <int dim, int spacedim>
85  void
86  build(const DoFHandler<dim, spacedim> &dof_handler);
87 
100  template <int dim, int spacedim>
101  DEAL_II_DEPRECATED void
103  const DoFHandler<dim, spacedim> &mg_dof);
104 
113 
122 
126  std::vector<unsigned int> target_component;
127 
131  std::vector<unsigned int> mg_target_component;
132 
136  mutable std::vector<std::vector<types::global_dof_index>> sizes;
137 
141  std::vector<types::global_dof_index> component_start;
142 
146  std::vector<std::vector<types::global_dof_index>> mg_component_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 
168  std::vector<std::vector<std::pair<types::global_dof_index, unsigned int>>>
170 
175  std::vector<std::set<types::global_dof_index>> boundary_indices;
176 };
177 
178 // TODO:[GK] Update documentation for copy_* functions
179 
180 // TODO: Use same kind of template argument as MGTransferSelect
181 
193 template <typename number>
194 class MGTransferSelect : public MGTransferBase<Vector<number>>,
196 {
197 public:
203 
208 
212  virtual ~MGTransferSelect() override = default;
213 
214  // TODO: rewrite docs; make sure defaulted args are actually allowed
242  template <int dim, int spacedim>
243  DEAL_II_DEPRECATED void
245  const DoFHandler<dim, spacedim> &dof,
246  const DoFHandler<dim, spacedim> &mg_dof,
247  unsigned int selected,
248  unsigned int mg_selected,
249  const std::vector<unsigned int> &target_component =
250  std::vector<unsigned int>(),
251  const std::vector<unsigned int> &mg_target_component =
252  std::vector<unsigned int>(),
253  const std::vector<std::set<types::global_dof_index>> &boundary_indices =
254  std::vector<std::set<types::global_dof_index>>());
255 
281  template <int dim, int spacedim>
282  void
283  build(const DoFHandler<dim, spacedim> &dof,
284  unsigned int selected,
285  unsigned int mg_selected,
286  const std::vector<unsigned int> &target_component =
287  std::vector<unsigned int>(),
288  const std::vector<unsigned int> &mg_target_component =
289  std::vector<unsigned int>(),
290  const std::vector<std::set<types::global_dof_index>> &boundary_indices =
291  std::vector<std::set<types::global_dof_index>>());
292 
296  void
297  select(const unsigned int component,
298  const unsigned int mg_component = numbers::invalid_unsigned_int);
299 
300  virtual void
301  prolongate(const unsigned int to_level,
302  Vector<number> & dst,
303  const Vector<number> &src) const override;
304 
305  virtual void
306  restrict_and_add(const unsigned int from_level,
307  Vector<number> & dst,
308  const Vector<number> &src) const override;
309 
316  template <int dim, typename number2, int spacedim>
317  void
320  const Vector<number2> & src) const;
321 
328  template <int dim, typename number2, int spacedim>
329  void
331  Vector<number2> & dst,
332  const MGLevelObject<Vector<number>> &src) const;
333 
339  template <int dim, typename number2, int spacedim>
340  void
342  Vector<number2> & dst,
343  const MGLevelObject<Vector<number>> &src) const;
344 
351  template <int dim, typename number2, int spacedim>
352  void
355  const BlockVector<number2> & src) const;
356 
363  template <int dim, typename number2, int spacedim>
364  void
366  BlockVector<number2> & dst,
367  const MGLevelObject<Vector<number>> &src) const;
368 
374  template <int dim, typename number2, int spacedim>
375  void
377  BlockVector<number2> & dst,
378  const MGLevelObject<Vector<number>> &src) const;
379 
383  std::size_t
384  memory_consumption() const;
385 
386 private:
390  template <int dim, class OutVector, int spacedim>
391  void
393  OutVector & dst,
394  const MGLevelObject<Vector<number>> &src) const;
395 
399  template <int dim, class OutVector, int spacedim>
400  void
402  OutVector & dst,
403  const MGLevelObject<Vector<number>> &src) const;
404 
408  template <int dim, class InVector, int spacedim>
409  void
412  const InVector & src) const;
416  unsigned int selected_component;
420  unsigned int mg_selected_component;
421 
427  std::vector<IndexSet> interface_dofs;
428 
432 public:
434 };
435 
438 //---------------------------------------------------------------------------
439 template <typename number>
440 inline void
441 MGTransferSelect<number>::select(const unsigned int component,
442  const unsigned int mg_component)
443 {
444  selected_component = component;
445  mg_selected_component =
446  (mg_component == numbers::invalid_unsigned_int) ? component : mg_component;
447 }
448 
450 
451 #endif
MGTransferSelect::~MGTransferSelect
virtual ~MGTransferSelect() override=default
MGTransferSelect::selected_component
unsigned int selected_component
Definition: mg_transfer_component.h:416
mg_base.h
MGTransferComponentBase::ExcMatricesNotBuilt
static ::ExceptionBase & ExcMatricesNotBuilt()
MGTransferSelect::memory_consumption
std::size_t memory_consumption() const
MGTransferBase
Definition: mg_base.h:177
MGTransferSelect
Definition: mg_transfer_component.h:194
BlockVector
Definition: block_vector.h:71
MGTransferComponentBase::mg_component_start
std::vector< std::vector< types::global_dof_index > > mg_component_start
Definition: mg_transfer_component.h:146
MGTransferComponentBase::build_matrices
void build_matrices(const DoFHandler< dim, spacedim > &dof, const DoFHandler< dim, spacedim > &mg_dof)
Definition: mg_transfer_component.cc:259
MGTransferComponentBase::prolongation_matrices
std::vector< std::shared_ptr< BlockSparseMatrix< double > > > prolongation_matrices
Definition: mg_transfer_component.h:162
MGTransferSelect::constraints
SmartPointer< const AffineConstraints< double > > constraints
Definition: mg_transfer_component.h:433
ComponentMask
Definition: component_mask.h:83
block_sparsity_pattern.h
MGTransferComponentBase::mg_component_mask
ComponentMask mg_component_mask
Definition: mg_transfer_component.h:121
DoFHandler
Definition: dof_handler.h:205
MGTransferSelect::do_copy_from_mg_add
void do_copy_from_mg_add(const DoFHandler< dim, spacedim > &mg_dof, OutVector &dst, const MGLevelObject< Vector< number >> &src) const
MGTransferSelect::do_copy_to_mg
void do_copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< Vector< number >> &dst, const InVector &src) const
Definition: mg_transfer_component.cc:217
MGTransferComponentBase::target_component
std::vector< unsigned int > target_component
Definition: mg_transfer_component.h:126
MGTransferComponentBase::mg_target_component
std::vector< unsigned int > mg_target_component
Definition: mg_transfer_component.h:131
block_vector.h
MGTransferSelect::MGTransferSelect
MGTransferSelect()
Definition: multigrid.cc:198
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
MGTransferSelect::build_matrices
void build_matrices(const DoFHandler< dim, spacedim > &dof, const DoFHandler< dim, spacedim > &mg_dof, unsigned int selected, unsigned int mg_selected, const std::vector< unsigned int > &target_component=std::vector< unsigned int >(), const std::vector< unsigned int > &mg_target_component=std::vector< unsigned int >(), const std::vector< std::set< types::global_dof_index >> &boundary_indices=std::vector< std::set< types::global_dof_index >>())
Definition: mg_transfer_component.cc:576
MGTransferSelect::select
void select(const unsigned int component, const unsigned int mg_component=numbers::invalid_unsigned_int)
Definition: mg_transfer_component.h:441
MGTransferComponentBase::component_mask
ComponentMask component_mask
Definition: mg_transfer_component.h:112
MGTransferSelect::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:232
MGTransferSelect::copy_to_mg
void copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< Vector< number >> &dst, const Vector< number2 > &src) const
DEAL_II_DEPRECATED
#define DEAL_II_DEPRECATED
Definition: config.h:98
sparsity_pattern.h
mg_level_object.h
component_mask.h
MGTransferSelect::interface_dofs
std::vector< IndexSet > interface_dofs
Definition: mg_transfer_component.h:427
MGTransferComponentBase::memory_consumption
std::size_t memory_consumption() const
Definition: multigrid.cc:149
SmartPointer
Definition: smartpointer.h:68
AffineConstraints< double >
MGTransferComponentBase::copy_to_and_from_indices
std::vector< std::vector< std::pair< types::global_dof_index, unsigned int > > > copy_to_and_from_indices
Definition: mg_transfer_component.h:169
MGTransferSelect::copy_from_mg
void copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, Vector< number2 > &dst, const MGLevelObject< Vector< number >> &src) const
MGLevelObject
Definition: mg_level_object.h:50
MGTransferComponentBase::component_start
std::vector< types::global_dof_index > component_start
Definition: mg_transfer_component.h:141
dof_handler.h
DeclException0
#define DeclException0(Exception0)
Definition: exceptions.h:473
MGTransferComponentBase::build
void build(const DoFHandler< dim, spacedim > &dof_handler)
Definition: mg_transfer_component.cc:269
affine_constraints.h
numbers::invalid_unsigned_int
static const unsigned int invalid_unsigned_int
Definition: types.h:191
MGTransferComponentBase
Definition: mg_transfer_component.h:63
MGTransferSelect::copy_from_mg_add
void copy_from_mg_add(const DoFHandler< dim, spacedim > &mg_dof, Vector< number2 > &dst, const MGLevelObject< Vector< number >> &src) const
MGTransferSelect::prolongate
virtual void prolongate(const unsigned int to_level, Vector< number > &dst, const Vector< number > &src) const override
Definition: multigrid.cc:215
vector_memory.h
MGTransferSelect::mg_selected_component
unsigned int mg_selected_component
Definition: mg_transfer_component.h:420
config.h
MGTransferComponentBase::sizes
std::vector< std::vector< types::global_dof_index > > sizes
Definition: mg_transfer_component.h:136
MGTransferComponentBase::prolongation_sparsities
std::vector< std::shared_ptr< BlockSparsityPattern > > prolongation_sparsities
Definition: mg_transfer_component.h:154
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
Vector< number >
MGTransferSelect::do_copy_from_mg
void do_copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, OutVector &dst, const MGLevelObject< Vector< number >> &src) const
MGTransferComponentBase::boundary_indices
std::vector< std::set< types::global_dof_index > > boundary_indices
Definition: mg_transfer_component.h:175
MGTransferSelect::build
void build(const DoFHandler< dim, spacedim > &dof, unsigned int selected, unsigned int mg_selected, const std::vector< unsigned int > &target_component=std::vector< unsigned int >(), const std::vector< unsigned int > &mg_target_component=std::vector< unsigned int >(), const std::vector< std::set< types::global_dof_index >> &boundary_indices=std::vector< std::set< types::global_dof_index >>())
Definition: mg_transfer_component.cc:593