Reference documentation for deal.II version GIT 4e92747666 2022-12-02 08: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_component.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_component_h
17 #define dealii_mg_transfer_component_h
18 
19 #include <deal.II/base/config.h>
20 
22 
24 
26 
31 
33 
34 #include <memory>
35 
36 
37 
39 
40 // Forward declaration
41 #ifndef DOXYGEN
42 template <int dim, int spacedim>
43 class DoFHandler;
44 #endif
45 
46 /*
47  * MGTransferBase is defined in mg_base.h
48  */
49 
63 {
64 public:
68  std::size_t
69  memory_consumption() const;
70 
71 
72 protected:
83  template <int dim, int spacedim>
84  void
85  build(const DoFHandler<dim, spacedim> &dof_handler);
86 
95 
104 
108  std::vector<unsigned int> target_component;
109 
113  std::vector<unsigned int> mg_target_component;
114 
118  mutable std::vector<std::vector<types::global_dof_index>> sizes;
119 
123  std::vector<types::global_dof_index> component_start;
124 
128  std::vector<std::vector<types::global_dof_index>> mg_component_start;
129 
134 
135 private:
136  std::vector<std::shared_ptr<BlockSparsityPattern>> prolongation_sparsities;
137 
138 protected:
144  std::vector<std::shared_ptr<BlockSparseMatrix<double>>> prolongation_matrices;
145 
150  std::vector<std::vector<std::pair<types::global_dof_index, unsigned int>>>
152 
157  std::vector<std::set<types::global_dof_index>> boundary_indices;
158 };
159 
160 // TODO:[GK] Update documentation for copy_* functions
161 
162 // TODO: Use same kind of template argument as MGTransferSelect
163 
173 template <typename number>
174 class MGTransferSelect : public MGTransferBase<Vector<number>>,
176 {
177 public:
183 
188 
192  virtual ~MGTransferSelect() override = default;
193 
194  // TODO: rewrite docs; make sure defaulted args are actually allowed
220  template <int dim, int spacedim>
221  void
222  build(const DoFHandler<dim, spacedim> &dof,
223  unsigned int selected,
224  unsigned int mg_selected,
225  const std::vector<unsigned int> &target_component =
226  std::vector<unsigned int>(),
227  const std::vector<unsigned int> &mg_target_component =
228  std::vector<unsigned int>(),
229  const std::vector<std::set<types::global_dof_index>> &boundary_indices =
230  std::vector<std::set<types::global_dof_index>>());
231 
235  void
236  select(const unsigned int component,
237  const unsigned int mg_component = numbers::invalid_unsigned_int);
238 
239  virtual void
240  prolongate(const unsigned int to_level,
241  Vector<number> & dst,
242  const Vector<number> &src) const override;
243 
244  virtual void
245  restrict_and_add(const unsigned int from_level,
246  Vector<number> & dst,
247  const Vector<number> &src) const override;
248 
255  template <int dim, typename number2, int spacedim>
256  void
259  const Vector<number2> & src) const;
260 
267  template <int dim, typename number2, int spacedim>
268  void
270  Vector<number2> & dst,
271  const MGLevelObject<Vector<number>> &src) const;
272 
278  template <int dim, typename number2, int spacedim>
279  void
281  Vector<number2> & dst,
282  const MGLevelObject<Vector<number>> &src) const;
283 
290  template <int dim, typename number2, int spacedim>
291  void
294  const BlockVector<number2> & src) const;
295 
302  template <int dim, typename number2, int spacedim>
303  void
305  BlockVector<number2> & dst,
306  const MGLevelObject<Vector<number>> &src) const;
307 
313  template <int dim, typename number2, int spacedim>
314  void
316  BlockVector<number2> & dst,
317  const MGLevelObject<Vector<number>> &src) const;
318 
322  std::size_t
324 
325 private:
329  template <int dim, class OutVector, int spacedim>
330  void
332  OutVector & dst,
333  const MGLevelObject<Vector<number>> &src) const;
334 
338  template <int dim, class OutVector, int spacedim>
339  void
341  OutVector & dst,
342  const MGLevelObject<Vector<number>> &src) const;
343 
347  template <int dim, class InVector, int spacedim>
348  void
351  const InVector & src) const;
355  unsigned int selected_component;
359  unsigned int mg_selected_component;
360 
366  std::vector<IndexSet> interface_dofs;
367 
371 public:
373 };
374 
377 //---------------------------------------------------------------------------
378 template <typename number>
379 inline void
380 MGTransferSelect<number>::select(const unsigned int component,
381  const unsigned int mg_component)
382 {
383  selected_component = component;
384  mg_selected_component =
385  (mg_component == numbers::invalid_unsigned_int) ? component : mg_component;
386 }
387 
389 
390 #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:458
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:459
#define DeclException0(Exception0)
Definition: exceptions.h:464
static ::ExceptionBase & ExcMatricesNotBuilt()
static const unsigned int invalid_unsigned_int
Definition: types.h:206