Reference documentation for deal.II version 8.5.1
mg_transfer_block.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2001 - 2016 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_block_h
17 #define dealii__mg_transfer_block_h
18 
19 #include <deal.II/base/config.h>
20 
21 #include <deal.II/lac/block_vector.h>
22 #include <deal.II/lac/sparsity_pattern.h>
23 #include <deal.II/lac/block_sparsity_pattern.h>
24 #include <deal.II/lac/vector_memory.h>
25 #include <deal.II/lac/block_matrix_array.h>
26 
27 #include <deal.II/multigrid/mg_base.h>
28 #include <deal.II/multigrid/mg_constrained_dofs.h>
29 #include <deal.II/base/mg_level_object.h>
30 
31 
32 
33 #include <deal.II/dofs/dof_handler.h>
34 
35 #include <deal.II/base/std_cxx11/shared_ptr.h>
36 
37 
38 DEAL_II_NAMESPACE_OPEN
39 
40 
41 template <int dim, int spacedim> class DoFHandler;
42 
43 /*
44  * MGTransferBase is defined in mg_base.h
45  */
46 
49 
61 {
62 public:
68 
73 
79  MGTransferBlockBase (const ConstraintMatrix &constraints,
80  const MGConstrainedDoFs &mg_constrained_dofs) DEAL_II_DEPRECATED;
81 
85  std::size_t memory_consumption () const;
86 
87 protected:
95  template <int dim, int spacedim>
97  const DoFHandler<dim,spacedim> &mg_dof);
98 
105 //TODO: rename this to block_mask, in the same way as has already been done in MGTransferComponent, and give it type BlockMask
106  std::vector<bool> selected;
107 
111  unsigned int n_mg_blocks;
112 
119 //TODO: rename this to mg_block_mask, in the same way as has already been done in MGTransferComponent, and give it type BlockMask
120  std::vector<unsigned int> mg_block;
121 
125  mutable std::vector<std::vector<types::global_dof_index> > sizes;
126 
130  std::vector<types::global_dof_index> block_start;
131 
135  std::vector<std::vector<types::global_dof_index> > mg_block_start;
136 
141 
142 private:
143  std::vector<std_cxx11::shared_ptr<BlockSparsityPattern> > prolongation_sparsities;
144 
145 protected:
146 
152  std::vector<std_cxx11::shared_ptr<BlockSparseMatrix<double> > > prolongation_matrices;
153 
160  std::vector<std::vector<std::vector<std::pair<unsigned int, unsigned int> > > >
162 
168 };
169 
189 template <typename number>
190 class MGTransferBlock : public MGTransferBase<BlockVector<number> >,
191  private MGTransferBlockBase
192 {
193 public:
197  MGTransferBlock();
198 
202  virtual ~MGTransferBlock ();
203 
208  void initialize (const std::vector<number> &factors,
210 
217  template<int dim, int spacedim>
218  void build_matrices (const DoFHandler<dim,spacedim> &dof,
219  const DoFHandler<dim,spacedim> &mg_dof,
220  const std::vector<bool> &selected);
221 
222  virtual void prolongate (const unsigned int to_level,
223  BlockVector<number> &dst,
224  const BlockVector<number> &src) const;
225 
226  virtual void restrict_and_add (const unsigned int from_level,
227  BlockVector<number> &dst,
228  const BlockVector<number> &src) const;
229 
238  template <int dim, typename number2, int spacedim>
239  void
240  copy_to_mg (const DoFHandler<dim,spacedim> &mg_dof,
242  const BlockVector<number2> &src) const;
243 
250  template <int dim, typename number2, int spacedim>
251  void
252  copy_from_mg (const DoFHandler<dim,spacedim> &mg_dof,
254  const MGLevelObject<BlockVector<number> > &src) const;
255 
261  template <int dim, typename number2, int spacedim>
262  void
265  const MGLevelObject<BlockVector<number> > &src) const;
266 
268 
269 private:
274  std::vector<number> factors;
275 
281 };
282 
283 
284 //TODO:[GK] Update documentation for copy_* functions
285 
298 template <typename number>
299 class MGTransferBlockSelect : public MGTransferBase<Vector<number> >,
300  private MGTransferBlockBase
301 {
302 public:
308 
313 
319  MGTransferBlockSelect (const ConstraintMatrix &constraints,
320  const MGConstrainedDoFs &mg_constrained_dofs) DEAL_II_DEPRECATED;
321 
325  virtual ~MGTransferBlockSelect ();
326 
339  template<int dim, int spacedim>
340  void build_matrices (const DoFHandler<dim,spacedim> &dof,
341  const DoFHandler<dim,spacedim> &mg_dof,
342  unsigned int selected);
343 
347  void select (const unsigned int block);
348 
349  virtual void prolongate (const unsigned int to_level,
350  Vector<number> &dst,
351  const Vector<number> &src) const;
352 
353  virtual void restrict_and_add (const unsigned int from_level,
354  Vector<number> &dst,
355  const Vector<number> &src) const;
356 
361  template <int dim, typename number2, int spacedim>
362  void
363  copy_to_mg (const DoFHandler<dim,spacedim> &mg_dof,
365  const Vector<number2> &src) const;
366 
373  template <int dim, typename number2, int spacedim>
374  void
375  copy_from_mg (const DoFHandler<dim,spacedim> &mg_dof,
376  Vector<number2> &dst,
377  const MGLevelObject<Vector<number> > &src) const;
378 
384  template <int dim, typename number2, int spacedim>
385  void
387  Vector<number2> &dst,
388  const MGLevelObject<Vector<number> > &src) const;
389 
394  template <int dim, typename number2, int spacedim>
395  void
396  copy_to_mg (const DoFHandler<dim,spacedim> &mg_dof,
398  const BlockVector<number2> &src) const;
399 
406  template <int dim, typename number2, int spacedim>
407  void
408  copy_from_mg (const DoFHandler<dim,spacedim> &mg_dof,
410  const MGLevelObject<Vector<number> > &src) const;
411 
417  template <int dim, typename number2, int spacedim>
418  void
421  const MGLevelObject<Vector<number> > &src) const;
422 
426  std::size_t memory_consumption () const;
427 
428 private:
432  template <int dim, class OutVector, int spacedim>
433  void
435  OutVector &dst,
436  const MGLevelObject<Vector<number> > &src,
437  const unsigned int offset) const;
438 
442  template <int dim, class OutVector, int spacedim>
443  void
445  OutVector &dst,
446  const MGLevelObject<Vector<number> > &src,
447  const unsigned int offset) const;
448 
452  template <int dim, class InVector, int spacedim>
453  void
456  const InVector &src,
457  const unsigned int offset) const;
461  unsigned int selected_block;
462 };
463 
466 //----------inline function definition--------------------------------------------------
467 template <typename number>
468 inline void
469 MGTransferBlockSelect<number>::select(const unsigned int block)
470 {
471  selected_block = block;
472 }
473 
474 DEAL_II_NAMESPACE_CLOSE
475 
476 #endif
void build_matrices(const DoFHandler< dim, spacedim > &dof, const DoFHandler< dim, spacedim > &mg_dof)
void copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, Vector< number2 > &dst, const MGLevelObject< Vector< number > > &src) const
void copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, BlockVector< number2 > &dst, const MGLevelObject< BlockVector< number > > &src) const
std::size_t memory_consumption() const
Definition: multigrid.cc:176
virtual void prolongate(const unsigned int to_level, BlockVector< number > &dst, const BlockVector< number > &src) const
Definition: multigrid.cc:86
void copy_from_mg_add(const DoFHandler< dim, spacedim > &mg_dof, Vector< number2 > &dst, const MGLevelObject< Vector< number > > &src) const
void do_copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, OutVector &dst, const MGLevelObject< Vector< number > > &src, const unsigned int offset) const
std::vector< types::global_dof_index > block_start
SmartPointer< const MGConstrainedDoFs, MGTransferBlockBase > mg_constrained_dofs
void copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< Vector< number > > &dst, const Vector< number2 > &src) const
void do_copy_from_mg_add(const DoFHandler< dim, spacedim > &mg_dof, OutVector &dst, const MGLevelObject< Vector< number > > &src, const unsigned int offset) const
void do_copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< Vector< number > > &dst, const InVector &src, const unsigned int offset) const
void copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< BlockVector< number > > &dst, const BlockVector< number2 > &src) const
std::vector< std::vector< types::global_dof_index > > sizes
std::vector< std_cxx11::shared_ptr< BlockSparseMatrix< double > > > prolongation_matrices
virtual void restrict_and_add(const unsigned int from_level, BlockVector< number > &dst, const BlockVector< number > &src) const
Definition: multigrid.cc:111
#define DeclException0(Exception0)
Definition: exceptions.h:541
virtual ~MGTransferBlock()
Definition: multigrid.cc:69
void initialize(const std::vector< number > &factors, VectorMemory< Vector< number > > &memory)
Definition: multigrid.cc:77
void select(const unsigned int block)
std::vector< std::vector< std::vector< std::pair< unsigned int, unsigned int > > > > copy_indices
std::vector< unsigned int > mg_block
static ::ExceptionBase & ExcMatricesNotBuilt()
virtual void prolongate(const unsigned int to_level, Vector< number > &dst, const Vector< number > &src) const
Definition: multigrid.cc:290
void build_matrices(const DoFHandler< dim, spacedim > &dof, const DoFHandler< dim, spacedim > &mg_dof, unsigned int selected)
std::vector< std::vector< types::global_dof_index > > mg_block_start
SmartPointer< VectorMemory< Vector< number > >, MGTransferBlock< number > > memory
std::size_t memory_consumption() const
void build_matrices(const DoFHandler< dim, spacedim > &dof, const DoFHandler< dim, spacedim > &mg_dof, const std::vector< bool > &selected)
std::vector< number > factors
virtual ~MGTransferBlockSelect()
Definition: multigrid.cc:283
virtual void restrict_and_add(const unsigned int from_level, Vector< number > &dst, const Vector< number > &src) const
Definition: multigrid.cc:305
std::vector< bool > selected
void copy_from_mg_add(const DoFHandler< dim, spacedim > &mg_dof, BlockVector< number2 > &dst, const MGLevelObject< BlockVector< number > > &src) const