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 
207  MGTransferSelect(const AffineConstraints<double> &constraints);
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
318  copy_to_mg(const DoFHandler<dim, spacedim> &mg_dof,
320  const Vector<number2> & src) const;
321 
328  template <int dim, typename number2, int spacedim>
329  void
330  copy_from_mg(const DoFHandler<dim, spacedim> & mg_dof,
331  Vector<number2> & dst,
332  const MGLevelObject<Vector<number>> &src) const;
333 
339  template <int dim, typename number2, int spacedim>
340  void
341  copy_from_mg_add(const DoFHandler<dim, spacedim> & mg_dof,
342  Vector<number2> & dst,
343  const MGLevelObject<Vector<number>> &src) const;
344 
351  template <int dim, typename number2, int spacedim>
352  void
353  copy_to_mg(const DoFHandler<dim, spacedim> &mg_dof,
355  const BlockVector<number2> & src) const;
356 
363  template <int dim, typename number2, int spacedim>
364  void
365  copy_from_mg(const DoFHandler<dim, spacedim> & mg_dof,
366  BlockVector<number2> & dst,
367  const MGLevelObject<Vector<number>> &src) const;
368 
374  template <int dim, typename number2, int spacedim>
375  void
376  copy_from_mg_add(const DoFHandler<dim, spacedim> & mg_dof,
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
392  do_copy_from_mg(const DoFHandler<dim, spacedim> & mg_dof,
393  OutVector & dst,
394  const MGLevelObject<Vector<number>> &src) const;
395 
399  template <int dim, class OutVector, int spacedim>
400  void
401  do_copy_from_mg_add(const DoFHandler<dim, spacedim> & mg_dof,
402  OutVector & dst,
403  const MGLevelObject<Vector<number>> &src) const;
404 
408  template <int dim, class InVector, int spacedim>
409  void
410  do_copy_to_mg(const DoFHandler<dim, spacedim> &mg_dof,
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
void build(const DoFHandler< dim, spacedim > &dof_handler)
std::vector< std::shared_ptr< BlockSparseMatrix< double > > > prolongation_matrices
static const unsigned int invalid_unsigned_int
Definition: types.h:191
std::vector< std::set< types::global_dof_index > > boundary_indices
static ::ExceptionBase & ExcMatricesNotBuilt()
std::vector< unsigned int > target_component
void select(const unsigned int component, const unsigned int mg_component=numbers::invalid_unsigned_int)
std::size_t memory_consumption() const
Definition: multigrid.cc:149
std::vector< types::global_dof_index > component_start
#define DeclException0(Exception0)
Definition: exceptions.h:473
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
std::vector< std::vector< std::pair< types::global_dof_index, unsigned int > > > copy_to_and_from_indices
std::vector< std::shared_ptr< BlockSparsityPattern > > prolongation_sparsities
unsigned int mg_selected_component
std::vector< unsigned int > mg_target_component
std::vector< IndexSet > interface_dofs
SmartPointer< const AffineConstraints< double > > constraints
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
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)
#define DEAL_II_DEPRECATED
Definition: config.h:98
std::vector< std::vector< types::global_dof_index > > sizes
unsigned int selected_component