Reference documentation for deal.II version 8.1.0
mg_transfer_component.h
1 // ---------------------------------------------------------------------
2 // @f$Id: mg_transfer_component.h 30253 2013-08-07 21:06:29Z bangerth @f$
3 //
4 // Copyright (C) 2001 - 2013 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // The deal.II library is free software; you can use it, redistribute
9 // it, and/or modify it under the terms of the GNU Lesser General
10 // Public License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // The full text of the license can be found in the file LICENSE at
13 // the top level of the deal.II distribution.
14 //
15 // ---------------------------------------------------------------------
16 
17 #ifndef __deal2__mg_transfer_component_h
18 #define __deal2__mg_transfer_component_h
19 
20 #include <deal.II/base/config.h>
21 
22 #include <deal.II/base/std_cxx1x/shared_ptr.h>
23 #include <deal.II/lac/block_vector.h>
24 #include <deal.II/lac/constraint_matrix.h>
25 #include <deal.II/lac/sparsity_pattern.h>
26 #include <deal.II/lac/block_sparsity_pattern.h>
27 #include <deal.II/lac/vector_memory.h>
28 
29 #include <deal.II/base/mg_level_object.h>
30 #include <deal.II/dofs/dof_handler.h>
31 #include <deal.II/fe/component_mask.h>
32 #include <deal.II/multigrid/mg_base.h>
33 
34 
35 
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:
83  template <int dim, int spacedim>
85  const DoFHandler<dim,spacedim> &mg_dof);
86 
99 
112 
118  std::vector<unsigned int> target_component;
119 
125  std::vector<unsigned int> mg_target_component;
126 
130  mutable std::vector<std::vector<types::global_dof_index> > sizes;
131 
135  std::vector<types::global_dof_index> component_start;
136 
141  std::vector<std::vector<types::global_dof_index> > mg_component_start;
142 
147  DeclException0(ExcMatricesNotBuilt);
148 
149 private:
150  std::vector<std_cxx1x::shared_ptr<BlockSparsityPattern> > prolongation_sparsities;
151 
152 protected:
153 
162  std::vector<std_cxx1x::shared_ptr<BlockSparseMatrix<double> > > prolongation_matrices;
163 
170  std::vector<std::vector<std::pair<types::global_dof_index, unsigned int> > >
172 
179  std::vector<std::set<types::global_dof_index> > boundary_indices;
180 };
181 
182 //TODO:[GK] Update documentation for copy_* functions
183 
184 //TODO: Use same kind of template argument as MGTransferSelect
185 
198 template <typename number>
199 class MGTransferSelect : public MGTransferBase<Vector<number> >,
201 {
202 public:
210  MGTransferSelect ();
211 
215  MGTransferSelect (const ConstraintMatrix &constraints);
216 
220  virtual ~MGTransferSelect ();
221 
222 //TODO: rewrite docs; make sure defaulted args are actually allowed
264  template <int dim, int spacedim>
265  void build_matrices (const DoFHandler<dim,spacedim> &dof,
266  const DoFHandler<dim,spacedim> &mg_dof,
267  unsigned int selected,
268  unsigned int mg_selected,
269  const std::vector<unsigned int> &target_component
270  = std::vector<unsigned int>(),
271  const std::vector<unsigned int> &mg_target_component
272  = std::vector<unsigned int>(),
273  const std::vector<std::set<types::global_dof_index> > &boundary_indices
274  = std::vector<std::set<types::global_dof_index> >()
275  );
276 
281  void select (const unsigned int component,
282  const unsigned int mg_component = numbers::invalid_unsigned_int);
283 
284  virtual void prolongate (const unsigned int to_level,
285  Vector<number> &dst,
286  const Vector<number> &src) const;
287 
288  virtual void restrict_and_add (const unsigned int from_level,
289  Vector<number> &dst,
290  const Vector<number> &src) const;
291 
296  template <int dim, typename number2, int spacedim>
297  void
298  copy_to_mg (const DoFHandler<dim,spacedim> &mg_dof,
300  const Vector<number2> &src) const;
301 
311  template <int dim, typename number2, int spacedim>
312  void
313  copy_from_mg (const DoFHandler<dim,spacedim> &mg_dof,
314  Vector<number2> &dst,
315  const MGLevelObject<Vector<number> > &src) const;
316 
325  template <int dim, typename number2, int spacedim>
326  void
327  copy_from_mg_add (const DoFHandler<dim,spacedim> &mg_dof,
328  Vector<number2> &dst,
329  const MGLevelObject<Vector<number> > &src) const;
330 
335  template <int dim, typename number2, int spacedim>
336  void
337  copy_to_mg (const DoFHandler<dim,spacedim> &mg_dof,
339  const BlockVector<number2> &src) const;
340 
351  template <int dim, typename number2, int spacedim>
352  void
353  copy_from_mg (const DoFHandler<dim,spacedim> &mg_dof,
355  const MGLevelObject<Vector<number> > &src) const;
356 
365  template <int dim, typename number2, int spacedim>
366  void
367  copy_from_mg_add (const DoFHandler<dim,spacedim> &mg_dof,
369  const MGLevelObject<Vector<number> > &src) const;
370 
374  std::size_t memory_consumption () const;
375 
376 private:
381  template <int dim, class OutVector, int spacedim>
382  void
383  do_copy_from_mg (const DoFHandler<dim,spacedim> &mg_dof,
384  OutVector &dst,
385  const MGLevelObject<Vector<number> > &src) const;
386 
391  template <int dim, class OutVector, int spacedim>
392  void
393  do_copy_from_mg_add (const DoFHandler<dim,spacedim> &mg_dof,
394  OutVector &dst,
395  const MGLevelObject<Vector<number> > &src) const;
396 
401  template <int dim, class InVector, int spacedim>
402  void
403  do_copy_to_mg (const DoFHandler<dim,spacedim> &mg_dof,
405  const InVector &src) const;
409  unsigned int selected_component;
413  unsigned int mg_selected_component;
414 
425  std::vector<std::vector<bool> > interface_dofs;
426 
431 public:
433 };
434 
437 //---------------------------------------------------------------------------
438 template <typename number>
439 inline void
440 MGTransferSelect<number>::select(const unsigned int component,
441  const unsigned int mg_component)
442 {
443  selected_component = component;
444  mg_selected_component = (mg_component == numbers::invalid_unsigned_int)
445  ? component
446  : mg_component;
447 }
448 
449 DEAL_II_NAMESPACE_CLOSE
450 
451 #endif
static const unsigned int invalid_unsigned_int
Definition: types.h:191
std::vector< std::set< types::global_dof_index > > boundary_indices
std::size_t memory_consumption() const
std::vector< unsigned int > target_component
DeclException0(ExcMatricesNotBuilt)
void select(const unsigned int component, const unsigned int mg_component=numbers::invalid_unsigned_int)
std::vector< types::global_dof_index > component_start
std::vector< std::vector< bool > > interface_dofs
std::vector< std::vector< std::pair< types::global_dof_index, unsigned int > > > copy_to_and_from_indices
unsigned int mg_selected_component
std::vector< unsigned int > mg_target_component
SmartPointer< const ConstraintMatrix > constraints
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_cxx1x::shared_ptr< BlockSparseMatrix< double > > > prolongation_matrices
std::vector< std::vector< types::global_dof_index > > sizes
unsigned int selected_component