Reference documentation for deal.II version 8.5.1
mg_transfer_component.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2001 - 2015 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/base/std_cxx11/shared_ptr.h>
22 #include <deal.II/lac/block_vector.h>
23 #include <deal.II/lac/constraint_matrix.h>
24 #include <deal.II/lac/sparsity_pattern.h>
25 #include <deal.II/lac/block_sparsity_pattern.h>
26 #include <deal.II/lac/vector_memory.h>
27 
28 #include <deal.II/base/mg_level_object.h>
29 #include <deal.II/dofs/dof_handler.h>
30 #include <deal.II/fe/component_mask.h>
31 #include <deal.II/multigrid/mg_base.h>
32 
33 
34 
35 DEAL_II_NAMESPACE_OPEN
36 
37 
38 template <int dim, int spacedim> class DoFHandler;
39 
40 /*
41  * MGTransferBase is defined in mg_base.h
42  */
43 
46 
57 {
58 public:
62  std::size_t memory_consumption () const;
63 
64 
65 protected:
76  template <int dim, int spacedim>
78  const DoFHandler<dim,spacedim> &mg_dof);
79 
88 
97 
101  std::vector<unsigned int> target_component;
102 
106  std::vector<unsigned int> mg_target_component;
107 
111  mutable std::vector<std::vector<types::global_dof_index> > sizes;
112 
116  std::vector<types::global_dof_index> component_start;
117 
121  std::vector<std::vector<types::global_dof_index> > mg_component_start;
122 
127 
128 private:
129  std::vector<std_cxx11::shared_ptr<BlockSparsityPattern> > prolongation_sparsities;
130 
131 protected:
132 
138  std::vector<std_cxx11::shared_ptr<BlockSparseMatrix<double> > > prolongation_matrices;
139 
144  std::vector<std::vector<std::pair<types::global_dof_index, unsigned int> > >
146 
151  std::vector<std::set<types::global_dof_index> > boundary_indices;
152 };
153 
154 //TODO:[GK] Update documentation for copy_* functions
155 
156 //TODO: Use same kind of template argument as MGTransferSelect
157 
169 template <typename number>
170 class MGTransferSelect : public MGTransferBase<Vector<number> >,
172 {
173 public:
178  MGTransferSelect ();
179 
184 
188  virtual ~MGTransferSelect ();
189 
190 //TODO: rewrite docs; make sure defaulted args are actually allowed
216  template <int dim, int spacedim>
217  void build_matrices (const DoFHandler<dim,spacedim> &dof,
218  const DoFHandler<dim,spacedim> &mg_dof,
219  unsigned int selected,
220  unsigned int mg_selected,
221  const std::vector<unsigned int> &target_component
222  = std::vector<unsigned int>(),
223  const std::vector<unsigned int> &mg_target_component
224  = std::vector<unsigned int>(),
225  const std::vector<std::set<types::global_dof_index> > &boundary_indices
226  = std::vector<std::set<types::global_dof_index> >()
227  );
228 
232  void select (const unsigned int component,
233  const unsigned int mg_component = numbers::invalid_unsigned_int);
234 
235  virtual void prolongate (const unsigned int to_level,
236  Vector<number> &dst,
237  const Vector<number> &src) const;
238 
239  virtual void restrict_and_add (const unsigned int from_level,
240  Vector<number> &dst,
241  const Vector<number> &src) const;
242 
246  template <int dim, typename number2, int spacedim>
247  void
248  copy_to_mg (const DoFHandler<dim,spacedim> &mg_dof,
250  const Vector<number2> &src) const;
251 
258  template <int dim, typename number2, int spacedim>
259  void
260  copy_from_mg (const DoFHandler<dim,spacedim> &mg_dof,
261  Vector<number2> &dst,
262  const MGLevelObject<Vector<number> > &src) const;
263 
269  template <int dim, typename number2, int spacedim>
270  void
272  Vector<number2> &dst,
273  const MGLevelObject<Vector<number> > &src) const;
274 
278  template <int dim, typename number2, int spacedim>
279  void
280  copy_to_mg (const DoFHandler<dim,spacedim> &mg_dof,
282  const BlockVector<number2> &src) const;
283 
290  template <int dim, typename number2, int spacedim>
291  void
292  copy_from_mg (const DoFHandler<dim,spacedim> &mg_dof,
294  const MGLevelObject<Vector<number> > &src) const;
295 
301  template <int dim, typename number2, int spacedim>
302  void
305  const MGLevelObject<Vector<number> > &src) const;
306 
310  std::size_t memory_consumption () const;
311 
312 private:
316  template <int dim, class OutVector, int spacedim>
317  void
319  OutVector &dst,
320  const MGLevelObject<Vector<number> > &src) const;
321 
325  template <int dim, class OutVector, int spacedim>
326  void
328  OutVector &dst,
329  const MGLevelObject<Vector<number> > &src) const;
330 
334  template <int dim, class InVector, int spacedim>
335  void
338  const InVector &src) const;
342  unsigned int selected_component;
346  unsigned int mg_selected_component;
347 
353  std::vector<IndexSet> interface_dofs;
354 
358 public:
360 };
361 
364 //---------------------------------------------------------------------------
365 template <typename number>
366 inline void
367 MGTransferSelect<number>::select(const unsigned int component,
368  const unsigned int mg_component)
369 {
370  selected_component = component;
371  mg_selected_component = (mg_component == numbers::invalid_unsigned_int)
372  ? component
373  : mg_component;
374 }
375 
376 DEAL_II_NAMESPACE_CLOSE
377 
378 #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 > >())
static const unsigned int invalid_unsigned_int
Definition: types.h:170
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
std::vector< std_cxx11::shared_ptr< BlockSparseMatrix< double > > > prolongation_matrices
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:541
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:239
unsigned int mg_selected_component
std::vector< unsigned int > mg_target_component
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
virtual ~MGTransferSelect()
Definition: multigrid.cc:218
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:223
unsigned int selected_component