Reference documentation for deal.II version 9.0.0
mg_transfer_component.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2001 - 2017 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 at
12 // the top level of the deal.II distribution.
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/lac/block_vector.h>
22 #include <deal.II/lac/constraint_matrix.h>
23 #include <deal.II/lac/sparsity_pattern.h>
24 #include <deal.II/lac/block_sparsity_pattern.h>
25 #include <deal.II/lac/vector_memory.h>
26 
27 #include <deal.II/base/mg_level_object.h>
28 #include <deal.II/dofs/dof_handler.h>
29 #include <deal.II/fe/component_mask.h>
30 #include <deal.II/multigrid/mg_base.h>
31 
32 #include <memory>
33 
34 
35 
36 DEAL_II_NAMESPACE_OPEN
37 
38 
39 template <int dim, int spacedim> class DoFHandler;
40 
41 /*
42  * MGTransferBase is defined in mg_base.h
43  */
44 
47 
58 {
59 public:
63  std::size_t memory_consumption () const;
64 
65 
66 protected:
77  template <int dim, int spacedim>
79  const DoFHandler<dim,spacedim> &mg_dof);
80 
89 
98 
102  std::vector<unsigned int> target_component;
103 
107  std::vector<unsigned int> mg_target_component;
108 
112  mutable std::vector<std::vector<types::global_dof_index> > sizes;
113 
117  std::vector<types::global_dof_index> component_start;
118 
122  std::vector<std::vector<types::global_dof_index> > mg_component_start;
123 
128 
129 private:
130  std::vector<std::shared_ptr<BlockSparsityPattern> > prolongation_sparsities;
131 
132 protected:
133 
139  std::vector<std::shared_ptr<BlockSparseMatrix<double> > > prolongation_matrices;
140 
145  std::vector<std::vector<std::pair<types::global_dof_index, unsigned int> > >
147 
152  std::vector<std::set<types::global_dof_index> > boundary_indices;
153 };
154 
155 //TODO:[GK] Update documentation for copy_* functions
156 
157 //TODO: Use same kind of template argument as MGTransferSelect
158 
170 template <typename number>
171 class MGTransferSelect : public MGTransferBase<Vector<number> >,
173 {
174 public:
179  MGTransferSelect ();
180 
185 
189  virtual ~MGTransferSelect () = default;
190 
191 //TODO: rewrite docs; make sure defaulted args are actually allowed
217  template <int dim, int spacedim>
218  void build_matrices (const DoFHandler<dim,spacedim> &dof,
219  const DoFHandler<dim,spacedim> &mg_dof,
220  unsigned int selected,
221  unsigned int mg_selected,
222  const std::vector<unsigned int> &target_component
223  = std::vector<unsigned int>(),
224  const std::vector<unsigned int> &mg_target_component
225  = std::vector<unsigned int>(),
226  const std::vector<std::set<types::global_dof_index> > &boundary_indices
227  = std::vector<std::set<types::global_dof_index> >()
228  );
229 
233  void select (const unsigned int component,
234  const unsigned int mg_component = numbers::invalid_unsigned_int);
235 
236  virtual void prolongate (const unsigned int to_level,
237  Vector<number> &dst,
238  const Vector<number> &src) const;
239 
240  virtual void restrict_and_add (const unsigned int from_level,
241  Vector<number> &dst,
242  const Vector<number> &src) const;
243 
250  template <int dim, typename number2, int spacedim>
251  void
252  copy_to_mg (const DoFHandler<dim,spacedim> &mg_dof,
254  const Vector<number2> &src) const;
255 
262  template <int dim, typename number2, int spacedim>
263  void
264  copy_from_mg (const DoFHandler<dim,spacedim> &mg_dof,
265  Vector<number2> &dst,
266  const MGLevelObject<Vector<number> > &src) const;
267 
273  template <int dim, typename number2, int spacedim>
274  void
276  Vector<number2> &dst,
277  const MGLevelObject<Vector<number> > &src) const;
278 
285  template <int dim, typename number2, int spacedim>
286  void
287  copy_to_mg (const DoFHandler<dim,spacedim> &mg_dof,
289  const BlockVector<number2> &src) const;
290 
297  template <int dim, typename number2, int spacedim>
298  void
299  copy_from_mg (const DoFHandler<dim,spacedim> &mg_dof,
301  const MGLevelObject<Vector<number> > &src) const;
302 
308  template <int dim, typename number2, int spacedim>
309  void
312  const MGLevelObject<Vector<number> > &src) const;
313 
317  std::size_t memory_consumption () const;
318 
319 private:
323  template <int dim, class OutVector, int spacedim>
324  void
326  OutVector &dst,
327  const MGLevelObject<Vector<number> > &src) const;
328 
332  template <int dim, class OutVector, int spacedim>
333  void
335  OutVector &dst,
336  const MGLevelObject<Vector<number> > &src) const;
337 
341  template <int dim, class InVector, int spacedim>
342  void
345  const InVector &src) const;
349  unsigned int selected_component;
353  unsigned int mg_selected_component;
354 
360  std::vector<IndexSet> interface_dofs;
361 
365 public:
367 };
368 
371 //---------------------------------------------------------------------------
372 template <typename number>
373 inline void
374 MGTransferSelect<number>::select(const unsigned int component,
375  const unsigned int mg_component)
376 {
377  selected_component = component;
378  mg_selected_component = (mg_component == numbers::invalid_unsigned_int)
379  ? component
380  : mg_component;
381 }
382 
383 DEAL_II_NAMESPACE_CLOSE
384 
385 #endif
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::vector< std::shared_ptr< BlockSparseMatrix< double > > > prolongation_matrices
static const unsigned int invalid_unsigned_int
Definition: types.h:173
void do_copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, OutVector &dst, const MGLevelObject< Vector< number > > &src) const
std::vector< std::set< types::global_dof_index > > boundary_indices
static ::ExceptionBase & ExcMatricesNotBuilt()
std::vector< unsigned int > target_component
void copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, Vector< number2 > &dst, const MGLevelObject< Vector< number > > &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 select(const unsigned int component, const unsigned int mg_component=numbers::invalid_unsigned_int)
void copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< Vector< number > > &dst, const Vector< number2 > &src) const
std::size_t memory_consumption() const
Definition: multigrid.cc:150
std::vector< types::global_dof_index > component_start
#define DeclException0(Exception0)
Definition: exceptions.h:323
std::vector< std::vector< std::pair< types::global_dof_index, unsigned int > > > copy_to_and_from_indices
virtual void restrict_and_add(const unsigned int from_level, Vector< number > &dst, const Vector< number > &src) const
Definition: multigrid.cc:236
unsigned int mg_selected_component
std::vector< unsigned int > mg_target_component
virtual ~MGTransferSelect()=default
std::vector< IndexSet > interface_dofs
void do_copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< Vector< number > > &dst, const InVector &src) const
SmartPointer< const ConstraintMatrix > constraints
void do_copy_from_mg_add(const DoFHandler< dim, spacedim > &mg_dof, OutVector &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
virtual void prolongate(const unsigned int to_level, Vector< number > &dst, const Vector< number > &src) const
Definition: multigrid.cc:220
unsigned int selected_component