Reference documentation for deal.II version 9.3.3
\(\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_block.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_block_h
17#define dealii_mg_transfer_block_h
18
19#include <deal.II/base/config.h>
20
22
24
29
32
33#include <memory>
34
35
37
38
39// Forward declaration
40#ifndef DOXYGEN
41template <int dim, int spacedim>
42class DoFHandler;
43#endif
44
45/*
46 * MGTransferBase is defined in mg_base.h
47 */
48
51
61{
62public:
68
73
77 std::size_t
78 memory_consumption() const;
79
80protected:
88 template <int dim, int spacedim>
89 void
90 build(const DoFHandler<dim, spacedim> &dof_handler);
91
101 template <int dim, int spacedim>
104 const DoFHandler<dim, spacedim> &mg_dof);
105
112 // TODO: rename this to block_mask, in the same way as has already been done
113 // in MGTransferComponent, and give it type BlockMask
114 std::vector<bool> selected;
115
119 unsigned int n_mg_blocks;
120
127 // TODO: rename this to mg_block_mask, in the same way as has already been
128 // done in MGTransferComponent, and give it type BlockMask
129 std::vector<unsigned int> mg_block;
130
134 mutable std::vector<std::vector<types::global_dof_index>> sizes;
135
139 std::vector<types::global_dof_index> block_start;
140
144 std::vector<std::vector<types::global_dof_index>> mg_block_start;
145
150
151private:
152 std::vector<std::shared_ptr<BlockSparsityPattern>> prolongation_sparsities;
153
154protected:
160 std::vector<std::shared_ptr<BlockSparseMatrix<double>>> prolongation_matrices;
161
168 std::vector<std::vector<std::vector<std::pair<unsigned int, unsigned int>>>>
170
177};
178
196template <typename number>
197class MGTransferBlock : public MGTransferBase<BlockVector<number>>,
198 private MGTransferBlockBase
199{
200public:
205
209 virtual ~MGTransferBlock() override;
210
215 void
216 initialize(const std::vector<number> & factors,
218
225 template <int dim, int spacedim>
226 void
227 build(const DoFHandler<dim, spacedim> &dof_handler,
228 const std::vector<bool> & selected);
229
238 template <int dim, int spacedim>
241 const DoFHandler<dim, spacedim> &mg_dof,
242 const std::vector<bool> & selected);
243
244 virtual void
245 prolongate(const unsigned int to_level,
247 const BlockVector<number> &src) const override;
248
249 virtual void
250 restrict_and_add(const unsigned int from_level,
252 const BlockVector<number> &src) const override;
253
265 template <int dim, typename number2, int spacedim>
266 void
267 copy_to_mg(const DoFHandler<dim, spacedim> & dof_handler,
269 const BlockVector<number2> & src) const;
270
277 template <int dim, typename number2, int spacedim>
278 void
281 const MGLevelObject<BlockVector<number>> &src) const;
282
288 template <int dim, typename number2, int spacedim>
289 void
292 const MGLevelObject<BlockVector<number>> &src) const;
293
295
296private:
301 std::vector<number> factors;
302
308};
309
310
311// TODO:[GK] Update documentation for copy_* functions
312
323template <typename number>
324class MGTransferBlockSelect : public MGTransferBase<Vector<number>>,
325 private MGTransferBlockBase
326{
327public:
333
338
342 virtual ~MGTransferBlockSelect() override = default;
343
354 template <int dim, int spacedim>
355 void
356 build(const DoFHandler<dim, spacedim> &dof_handler, unsigned int selected);
357
371 template <int dim, int spacedim>
374 const DoFHandler<dim, spacedim> &mg_dof,
375 unsigned int selected);
376
380 void
381 select(const unsigned int block);
382
383 virtual void
384 prolongate(const unsigned int to_level,
385 Vector<number> & dst,
386 const Vector<number> &src) const override;
387
388 virtual void
389 restrict_and_add(const unsigned int from_level,
390 Vector<number> & dst,
391 const Vector<number> &src) const override;
392
399 template <int dim, typename number2, int spacedim>
400 void
401 copy_to_mg(const DoFHandler<dim, spacedim> &dof_handler,
403 const Vector<number2> & src) const;
404
411 template <int dim, typename number2, int spacedim>
412 void
414 Vector<number2> & dst,
415 const MGLevelObject<Vector<number>> &src) const;
416
422 template <int dim, typename number2, int spacedim>
423 void
425 Vector<number2> & dst,
426 const MGLevelObject<Vector<number>> &src) const;
427
435 template <int dim, typename number2, int spacedim>
436 void
437 copy_to_mg(const DoFHandler<dim, spacedim> &dof_handler,
439 const BlockVector<number2> & src) const;
440
447 template <int dim, typename number2, int spacedim>
448 void
451 const MGLevelObject<Vector<number>> &src) const;
452
458 template <int dim, typename number2, int spacedim>
459 void
462 const MGLevelObject<Vector<number>> &src) const;
463
467 std::size_t
469
470private:
474 template <int dim, class OutVector, int spacedim>
475 void
477 OutVector & dst,
478 const MGLevelObject<Vector<number>> &src,
479 const unsigned int offset) const;
480
484 template <int dim, class OutVector, int spacedim>
485 void
487 OutVector & dst,
488 const MGLevelObject<Vector<number>> &src,
489 const unsigned int offset) const;
490
494 template <int dim, class InVector, int spacedim>
495 void
498 const InVector & src,
499 const unsigned int offset) const;
503 unsigned int selected_block;
504};
505
508//------------------------- inline function definition ------------------------
509template <typename number>
510inline void
512{
513 selected_block = block;
514}
515
517
518#endif
std::vector< unsigned int > mg_block
std::vector< std::vector< types::global_dof_index > > sizes
void build_matrices(const DoFHandler< dim, spacedim > &dof, const DoFHandler< dim, spacedim > &mg_dof)
void build(const DoFHandler< dim, spacedim > &dof_handler)
std::vector< bool > selected
std::vector< types::global_dof_index > block_start
std::vector< std::shared_ptr< BlockSparseMatrix< double > > > prolongation_matrices
std::vector< std::shared_ptr< BlockSparsityPattern > > prolongation_sparsities
SmartPointer< const MGConstrainedDoFs, MGTransferBlockBase > mg_constrained_dofs
std::vector< std::vector< types::global_dof_index > > mg_block_start
std::size_t memory_consumption() const
Definition: multigrid.cc:174
std::vector< std::vector< std::vector< std::pair< unsigned int, unsigned int > > > > copy_indices
void copy_to_mg(const DoFHandler< dim, spacedim > &dof_handler, MGLevelObject< Vector< number > > &dst, const Vector< number2 > &src) const
void do_copy_to_mg(const DoFHandler< dim, spacedim > &dof_handler, MGLevelObject< Vector< number > > &dst, const InVector &src, const unsigned int offset) const
void copy_from_mg(const DoFHandler< dim, spacedim > &dof_handler, BlockVector< number2 > &dst, const MGLevelObject< Vector< number > > &src) const
virtual ~MGTransferBlockSelect() override=default
virtual void prolongate(const unsigned int to_level, Vector< number > &dst, const Vector< number > &src) const override
Definition: multigrid.cc:266
void build(const DoFHandler< dim, spacedim > &dof_handler, unsigned int selected)
virtual void restrict_and_add(const unsigned int from_level, Vector< number > &dst, const Vector< number > &src) const override
Definition: multigrid.cc:289
void copy_from_mg_add(const DoFHandler< dim, spacedim > &dof_handler, BlockVector< number2 > &dst, const MGLevelObject< Vector< number > > &src) const
void copy_from_mg_add(const DoFHandler< dim, spacedim > &dof_handler, Vector< number2 > &dst, const MGLevelObject< Vector< number > > &src) const
std::size_t memory_consumption() const
void build_matrices(const DoFHandler< dim, spacedim > &dof, const DoFHandler< dim, spacedim > &mg_dof, unsigned int selected)
void do_copy_from_mg(const DoFHandler< dim, spacedim > &dof_handler, OutVector &dst, const MGLevelObject< Vector< number > > &src, const unsigned int offset) const
void do_copy_from_mg_add(const DoFHandler< dim, spacedim > &dof_handler, OutVector &dst, const MGLevelObject< Vector< number > > &src, const unsigned int offset) const
void select(const unsigned int block)
void copy_from_mg(const DoFHandler< dim, spacedim > &dof_handler, Vector< number2 > &dst, const MGLevelObject< Vector< number > > &src) const
std::vector< number > factors
void copy_from_mg(const DoFHandler< dim, spacedim > &dof_handler, BlockVector< number2 > &dst, const MGLevelObject< BlockVector< number > > &src) const
virtual void prolongate(const unsigned int to_level, BlockVector< number > &dst, const BlockVector< number > &src) const override
Definition: multigrid.cc:78
void build(const DoFHandler< dim, spacedim > &dof_handler, const std::vector< bool > &selected)
virtual void restrict_and_add(const unsigned int from_level, BlockVector< number > &dst, const BlockVector< number > &src) const override
Definition: multigrid.cc:111
void copy_from_mg_add(const DoFHandler< dim, spacedim > &dof_handler, BlockVector< number2 > &dst, const MGLevelObject< BlockVector< number > > &src) const
virtual ~MGTransferBlock() override
Definition: multigrid.cc:59
void build_matrices(const DoFHandler< dim, spacedim > &dof, const DoFHandler< dim, spacedim > &mg_dof, const std::vector< bool > &selected)
void copy_to_mg(const DoFHandler< dim, spacedim > &dof_handler, MGLevelObject< BlockVector< number > > &dst, const BlockVector< number2 > &src) const
void initialize(const std::vector< number > &factors, VectorMemory< Vector< number > > &memory)
Definition: multigrid.cc:68
SmartPointer< VectorMemory< Vector< number > >, MGTransferBlock< number > > memory
#define DEAL_II_DEPRECATED
Definition: config.h:162
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:402
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403
#define DeclException0(Exception0)
Definition: exceptions.h:470
static ::ExceptionBase & ExcMatricesNotBuilt()