Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
mg_transfer_component.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2001 - 2018 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 
21 #include <deal.II/base/mg_level_object.h>
22 
23 #include <deal.II/dofs/dof_handler.h>
24 
25 #include <deal.II/fe/component_mask.h>
26 
27 #include <deal.II/lac/affine_constraints.h>
28 #include <deal.II/lac/block_sparsity_pattern.h>
29 #include <deal.II/lac/block_vector.h>
30 #include <deal.II/lac/sparsity_pattern.h>
31 #include <deal.II/lac/vector_memory.h>
32 
33 #include <deal.II/multigrid/mg_base.h>
34 
35 #include <memory>
36 
37 
38 
39 DEAL_II_NAMESPACE_OPEN
40 
41 
42 template <int dim, int spacedim>
43 class DoFHandler;
44 
45 /*
46  * MGTransferBase is defined in mg_base.h
47  */
48 
51 
62 {
63 public:
67  std::size_t
68  memory_consumption() const;
69 
70 
71 protected:
82  template <int dim, int spacedim>
83  void
85  const DoFHandler<dim, spacedim> &mg_dof);
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 
175 template <typename number>
176 class MGTransferSelect : public MGTransferBase<Vector<number>>,
178 {
179 public:
185 
190 
194  virtual ~MGTransferSelect() override = default;
195 
196  // TODO: rewrite docs; make sure defaulted args are actually allowed
222  template <int dim, int spacedim>
223  void
225  const DoFHandler<dim, spacedim> &dof,
226  const DoFHandler<dim, spacedim> &mg_dof,
227  unsigned int selected,
228  unsigned int mg_selected,
229  const std::vector<unsigned int> &target_component =
230  std::vector<unsigned int>(),
231  const std::vector<unsigned int> &mg_target_component =
232  std::vector<unsigned int>(),
233  const std::vector<std::set<types::global_dof_index>> &boundary_indices =
234  std::vector<std::set<types::global_dof_index>>());
235 
239  void
240  select(const unsigned int component,
241  const unsigned int mg_component = numbers::invalid_unsigned_int);
242 
243  virtual void
244  prolongate(const unsigned int to_level,
245  Vector<number> & dst,
246  const Vector<number> &src) const override;
247 
248  virtual void
249  restrict_and_add(const unsigned int from_level,
250  Vector<number> & dst,
251  const Vector<number> &src) const override;
252 
259  template <int dim, typename number2, int spacedim>
260  void
263  const Vector<number2> & src) const;
264 
271  template <int dim, typename number2, int spacedim>
272  void
274  Vector<number2> & dst,
275  const MGLevelObject<Vector<number>> &src) const;
276 
282  template <int dim, typename number2, int spacedim>
283  void
285  Vector<number2> & dst,
286  const MGLevelObject<Vector<number>> &src) const;
287 
294  template <int dim, typename number2, int spacedim>
295  void
298  const BlockVector<number2> & src) const;
299 
306  template <int dim, typename number2, int spacedim>
307  void
309  BlockVector<number2> & dst,
310  const MGLevelObject<Vector<number>> &src) const;
311 
317  template <int dim, typename number2, int spacedim>
318  void
320  BlockVector<number2> & dst,
321  const MGLevelObject<Vector<number>> &src) const;
322 
326  std::size_t
327  memory_consumption() const;
328 
329 private:
333  template <int dim, class OutVector, int spacedim>
334  void
336  OutVector & dst,
337  const MGLevelObject<Vector<number>> &src) const;
338 
342  template <int dim, class OutVector, int spacedim>
343  void
345  OutVector & dst,
346  const MGLevelObject<Vector<number>> &src) const;
347 
351  template <int dim, class InVector, int spacedim>
352  void
355  const InVector & src) const;
359  unsigned int selected_component;
363  unsigned int mg_selected_component;
364 
370  std::vector<IndexSet> interface_dofs;
371 
375 public:
377 };
378 
381 //---------------------------------------------------------------------------
382 template <typename number>
383 inline void
384 MGTransferSelect<number>::select(const unsigned int component,
385  const unsigned int mg_component)
386 {
387  selected_component = component;
388  mg_selected_component =
389  (mg_component == numbers::invalid_unsigned_int) ? component : mg_component;
390 }
391 
392 DEAL_II_NAMESPACE_CLOSE
393 
394 #endif
std::vector< std::shared_ptr< BlockSparseMatrix< double > > > prolongation_matrices
static const unsigned int invalid_unsigned_int
Definition: types.h:173
std::vector< std::set< types::global_dof_index > > boundary_indices
static ::ExceptionBase & ExcMatricesNotBuilt()
std::vector< unsigned int > target_component
virtual ~MGTransferSelect() override=default
void do_copy_from_mg_add(const DoFHandler< dim, spacedim > &mg_dof, OutVector &dst, const MGLevelObject< Vector< number >> &src) const
std::size_t memory_consumption() const
void select(const unsigned int component, const unsigned int mg_component=numbers::invalid_unsigned_int)
void do_copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, OutVector &dst, const MGLevelObject< Vector< number >> &src) const
void copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< Vector< number >> &dst, const Vector< number2 > &src) const
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 >>())
std::size_t memory_consumption() const
Definition: multigrid.cc:149
std::vector< types::global_dof_index > component_start
void copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, Vector< number2 > &dst, const MGLevelObject< Vector< number >> &src) const
virtual void restrict_and_add(const unsigned int from_level, Vector< number > &dst, const Vector< number > &src) const override
Definition: multigrid.cc:232
#define DeclException0(Exception0)
Definition: exceptions.h:473
std::vector< std::vector< std::pair< types::global_dof_index, unsigned int > > > copy_to_and_from_indices
virtual void prolongate(const unsigned int to_level, Vector< number > &dst, const Vector< number > &src) const override
Definition: multigrid.cc:215
unsigned int mg_selected_component
void do_copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< Vector< number >> &dst, const InVector &src) const
std::vector< unsigned int > mg_target_component
std::vector< IndexSet > interface_dofs
SmartPointer< const AffineConstraints< double > > constraints
void copy_from_mg_add(const DoFHandler< dim, spacedim > &mg_dof, Vector< number2 > &dst, const MGLevelObject< Vector< number >> &src) const
std::vector< std::vector< types::global_dof_index > > mg_component_start
void build_matrices(const DoFHandler< dim, spacedim > &dof, const DoFHandler< dim, spacedim > &mg_dof)
std::vector< std::vector< types::global_dof_index > > sizes
unsigned int selected_component