Reference documentation for deal.II version Git 193422c69f 2020-07-08 17:07:46 +0200
\(\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 
98  template <int dim, int spacedim>
101  const DoFHandler<dim, spacedim> &mg_dof);
102 
111 
120 
124  std::vector<unsigned int> target_component;
125 
129  std::vector<unsigned int> mg_target_component;
130 
134  mutable std::vector<std::vector<types::global_dof_index>> sizes;
135 
139  std::vector<types::global_dof_index> component_start;
140 
144  std::vector<std::vector<types::global_dof_index>> mg_component_start;
145 
150 
151 private:
152  std::vector<std::shared_ptr<BlockSparsityPattern>> prolongation_sparsities;
153 
154 protected:
160  std::vector<std::shared_ptr<BlockSparseMatrix<double>>> prolongation_matrices;
161 
166  std::vector<std::vector<std::pair<types::global_dof_index, unsigned int>>>
168 
173  std::vector<std::set<types::global_dof_index>> boundary_indices;
174 };
175 
176 // TODO:[GK] Update documentation for copy_* functions
177 
178 // TODO: Use same kind of template argument as MGTransferSelect
179 
189 template <typename number>
190 class MGTransferSelect : public MGTransferBase<Vector<number>>,
192 {
193 public:
199 
203  MGTransferSelect(const AffineConstraints<double> &constraints);
204 
208  virtual ~MGTransferSelect() override = default;
209 
210  // TODO: rewrite docs; make sure defaulted args are actually allowed
238  template <int dim, int spacedim>
239  DEAL_II_DEPRECATED void
241  const DoFHandler<dim, spacedim> &dof,
242  const DoFHandler<dim, spacedim> &mg_dof,
243  unsigned int selected,
244  unsigned int mg_selected,
245  const std::vector<unsigned int> &target_component =
246  std::vector<unsigned int>(),
247  const std::vector<unsigned int> &mg_target_component =
248  std::vector<unsigned int>(),
249  const std::vector<std::set<types::global_dof_index>> &boundary_indices =
250  std::vector<std::set<types::global_dof_index>>());
251 
277  template <int dim, int spacedim>
278  void
279  build(const DoFHandler<dim, spacedim> &dof,
280  unsigned int selected,
281  unsigned int mg_selected,
282  const std::vector<unsigned int> &target_component =
283  std::vector<unsigned int>(),
284  const std::vector<unsigned int> &mg_target_component =
285  std::vector<unsigned int>(),
286  const std::vector<std::set<types::global_dof_index>> &boundary_indices =
287  std::vector<std::set<types::global_dof_index>>());
288 
292  void
293  select(const unsigned int component,
294  const unsigned int mg_component = numbers::invalid_unsigned_int);
295 
296  virtual void
297  prolongate(const unsigned int to_level,
298  Vector<number> & dst,
299  const Vector<number> &src) const override;
300 
301  virtual void
302  restrict_and_add(const unsigned int from_level,
303  Vector<number> & dst,
304  const Vector<number> &src) const override;
305 
312  template <int dim, typename number2, int spacedim>
313  void
314  copy_to_mg(const DoFHandler<dim, spacedim> &mg_dof,
316  const Vector<number2> & src) const;
317 
324  template <int dim, typename number2, int spacedim>
325  void
326  copy_from_mg(const DoFHandler<dim, spacedim> & mg_dof,
327  Vector<number2> & dst,
328  const MGLevelObject<Vector<number>> &src) const;
329 
335  template <int dim, typename number2, int spacedim>
336  void
337  copy_from_mg_add(const DoFHandler<dim, spacedim> & mg_dof,
338  Vector<number2> & dst,
339  const MGLevelObject<Vector<number>> &src) const;
340 
347  template <int dim, typename number2, int spacedim>
348  void
349  copy_to_mg(const DoFHandler<dim, spacedim> &mg_dof,
351  const BlockVector<number2> & src) const;
352 
359  template <int dim, typename number2, int spacedim>
360  void
361  copy_from_mg(const DoFHandler<dim, spacedim> & mg_dof,
362  BlockVector<number2> & dst,
363  const MGLevelObject<Vector<number>> &src) const;
364 
370  template <int dim, typename number2, int spacedim>
371  void
372  copy_from_mg_add(const DoFHandler<dim, spacedim> & mg_dof,
373  BlockVector<number2> & dst,
374  const MGLevelObject<Vector<number>> &src) const;
375 
379  std::size_t
380  memory_consumption() const;
381 
382 private:
386  template <int dim, class OutVector, int spacedim>
387  void
388  do_copy_from_mg(const DoFHandler<dim, spacedim> & mg_dof,
389  OutVector & dst,
390  const MGLevelObject<Vector<number>> &src) const;
391 
395  template <int dim, class OutVector, int spacedim>
396  void
397  do_copy_from_mg_add(const DoFHandler<dim, spacedim> & mg_dof,
398  OutVector & dst,
399  const MGLevelObject<Vector<number>> &src) const;
400 
404  template <int dim, class InVector, int spacedim>
405  void
406  do_copy_to_mg(const DoFHandler<dim, spacedim> &mg_dof,
408  const InVector & src) const;
412  unsigned int selected_component;
416  unsigned int mg_selected_component;
417 
423  std::vector<IndexSet> interface_dofs;
424 
428 public:
430 };
431 
434 //---------------------------------------------------------------------------
435 template <typename number>
436 inline void
437 MGTransferSelect<number>::select(const unsigned int component,
438  const unsigned int mg_component)
439 {
440  selected_component = component;
441  mg_selected_component =
442  (mg_component == numbers::invalid_unsigned_int) ? component : mg_component;
443 }
444 
446 
447 #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:470
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:363
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:362
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:152
std::vector< std::vector< types::global_dof_index > > sizes
unsigned int selected_component