Reference documentation for deal.II version GIT 3d869ba6cd 2022-05-16 18:15:01+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_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 
62 {
63 public:
67  std::size_t
68  memory_consumption() const;
69 
70 
71 protected:
82  template <int dim, int spacedim>
83  void
84  build(const DoFHandler<dim, spacedim> &dof_handler);
85 
94 
103 
107  std::vector<unsigned int> target_component;
108 
112  std::vector<unsigned int> mg_target_component;
113 
117  mutable std::vector<std::vector<types::global_dof_index>> sizes;
118 
122  std::vector<types::global_dof_index> component_start;
123 
127  std::vector<std::vector<types::global_dof_index>> mg_component_start;
128 
133 
134 private:
135  std::vector<std::shared_ptr<BlockSparsityPattern>> prolongation_sparsities;
136 
137 protected:
143  std::vector<std::shared_ptr<BlockSparseMatrix<double>>> prolongation_matrices;
144 
149  std::vector<std::vector<std::pair<types::global_dof_index, unsigned int>>>
151 
156  std::vector<std::set<types::global_dof_index>> boundary_indices;
157 };
158 
159 // TODO:[GK] Update documentation for copy_* functions
160 
161 // TODO: Use same kind of template argument as MGTransferSelect
162 
172 template <typename number>
173 class MGTransferSelect : public MGTransferBase<Vector<number>>,
175 {
176 public:
182 
187 
191  virtual ~MGTransferSelect() override = default;
192 
193  // TODO: rewrite docs; make sure defaulted args are actually allowed
219  template <int dim, int spacedim>
220  void
221  build(const DoFHandler<dim, spacedim> &dof,
222  unsigned int selected,
223  unsigned int mg_selected,
224  const std::vector<unsigned int> &target_component =
225  std::vector<unsigned int>(),
226  const std::vector<unsigned int> &mg_target_component =
227  std::vector<unsigned int>(),
228  const std::vector<std::set<types::global_dof_index>> &boundary_indices =
229  std::vector<std::set<types::global_dof_index>>());
230 
234  void
235  select(const unsigned int component,
236  const unsigned int mg_component = numbers::invalid_unsigned_int);
237 
238  virtual void
239  prolongate(const unsigned int to_level,
240  Vector<number> & dst,
241  const Vector<number> &src) const override;
242 
243  virtual void
244  restrict_and_add(const unsigned int from_level,
245  Vector<number> & dst,
246  const Vector<number> &src) const override;
247 
254  template <int dim, typename number2, int spacedim>
255  void
258  const Vector<number2> & src) const;
259 
266  template <int dim, typename number2, int spacedim>
267  void
269  Vector<number2> & dst,
270  const MGLevelObject<Vector<number>> &src) const;
271 
277  template <int dim, typename number2, int spacedim>
278  void
280  Vector<number2> & dst,
281  const MGLevelObject<Vector<number>> &src) const;
282 
289  template <int dim, typename number2, int spacedim>
290  void
293  const BlockVector<number2> & src) const;
294 
301  template <int dim, typename number2, int spacedim>
302  void
304  BlockVector<number2> & dst,
305  const MGLevelObject<Vector<number>> &src) const;
306 
312  template <int dim, typename number2, int spacedim>
313  void
315  BlockVector<number2> & dst,
316  const MGLevelObject<Vector<number>> &src) const;
317 
321  std::size_t
323 
324 private:
328  template <int dim, class OutVector, int spacedim>
329  void
331  OutVector & dst,
332  const MGLevelObject<Vector<number>> &src) const;
333 
337  template <int dim, class OutVector, int spacedim>
338  void
340  OutVector & dst,
341  const MGLevelObject<Vector<number>> &src) const;
342 
346  template <int dim, class InVector, int spacedim>
347  void
350  const InVector & src) const;
354  unsigned int selected_component;
358  unsigned int mg_selected_component;
359 
365  std::vector<IndexSet> interface_dofs;
366 
370 public:
372 };
373 
376 //---------------------------------------------------------------------------
377 template <typename number>
378 inline void
379 MGTransferSelect<number>::select(const unsigned int component,
380  const unsigned int mg_component)
381 {
382  selected_component = component;
383  mg_selected_component =
384  (mg_component == numbers::invalid_unsigned_int) ? component : mg_component;
385 }
386 
388 
389 #endif
std::vector< unsigned int > mg_target_component
std::vector< unsigned int > target_component
std::vector< types::global_dof_index > component_start
std::vector< std::shared_ptr< BlockSparseMatrix< double > > > prolongation_matrices
std::vector< std::vector< std::pair< types::global_dof_index, unsigned int > > > copy_to_and_from_indices
std::vector< std::vector< types::global_dof_index > > mg_component_start
std::vector< std::shared_ptr< BlockSparsityPattern > > prolongation_sparsities
void build(const DoFHandler< dim, spacedim > &dof_handler)
std::vector< std::vector< types::global_dof_index > > sizes
std::size_t memory_consumption() const
Definition: multigrid.cc:149
std::vector< std::set< types::global_dof_index > > boundary_indices
void copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< Vector< number >> &dst, const Vector< number2 > &src) const
void copy_from_mg_add(const DoFHandler< dim, spacedim > &mg_dof, Vector< number2 > &dst, const MGLevelObject< Vector< number >> &src) const
std::size_t memory_consumption() const
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 >>())
virtual void prolongate(const unsigned int to_level, Vector< number > &dst, const Vector< number > &src) const override
Definition: multigrid.cc:215
void copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, BlockVector< number2 > &dst, const MGLevelObject< Vector< number >> &src) const
SmartPointer< const AffineConstraints< double > > constraints
unsigned int mg_selected_component
void do_copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< Vector< number >> &dst, const InVector &src) const
unsigned int selected_component
void do_copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, OutVector &dst, const MGLevelObject< Vector< number >> &src) const
void copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, Vector< number2 > &dst, const MGLevelObject< Vector< number >> &src) const
virtual ~MGTransferSelect() override=default
void select(const unsigned int component, const unsigned int mg_component=numbers::invalid_unsigned_int)
virtual void restrict_and_add(const unsigned int from_level, Vector< number > &dst, const Vector< number > &src) const override
Definition: multigrid.cc:232
void copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< Vector< number >> &dst, const BlockVector< number2 > &src) const
std::vector< IndexSet > interface_dofs
void copy_from_mg_add(const DoFHandler< dim, spacedim > &mg_dof, BlockVector< number2 > &dst, const MGLevelObject< Vector< number >> &src) const
void do_copy_from_mg_add(const DoFHandler< dim, spacedim > &mg_dof, OutVector &dst, const MGLevelObject< Vector< number >> &src) const
Definition: vector.h:109
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:416
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:417
#define DeclException0(Exception0)
Definition: exceptions.h:464
static ::ExceptionBase & ExcMatricesNotBuilt()
static const unsigned int invalid_unsigned_int
Definition: types.h:201