Reference documentation for deal.II version 9.5.0
\(\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\}}\)
Loading...
Searching...
No Matches
mg_transfer_block.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2001 - 2023 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
28
31
32#include <memory>
33
34
36
37
38// Forward declaration
39#ifndef DOXYGEN
40template <int dim, int spacedim>
42class DoFHandler;
43#endif
44
45/*
46 * MGTransferBase is defined in mg_base.h
47 */
48
63{
64public:
70
75
79 std::size_t
80 memory_consumption() const;
81
82protected:
90 template <int dim, int spacedim>
91 void
92 build(const DoFHandler<dim, spacedim> &dof_handler);
93
100 // TODO: rename this to block_mask, in the same way as has already been done
101 // in MGTransferComponent, and give it type BlockMask
102 std::vector<bool> selected;
103
107 unsigned int n_mg_blocks;
108
115 // TODO: rename this to mg_block_mask, in the same way as has already been
116 // done in MGTransferComponent, and give it type BlockMask
117 std::vector<unsigned int> mg_block;
118
122 mutable std::vector<std::vector<types::global_dof_index>> sizes;
123
127 std::vector<types::global_dof_index> block_start;
128
132 std::vector<std::vector<types::global_dof_index>> mg_block_start;
133
138
139private:
140 std::vector<std::shared_ptr<BlockSparsityPattern>> prolongation_sparsities;
141
142protected:
148 std::vector<std::shared_ptr<BlockSparseMatrix<double>>> prolongation_matrices;
149
156 std::vector<std::vector<std::vector<std::pair<unsigned int, unsigned int>>>>
158
165};
166
184template <typename number>
185class MGTransferBlock : public MGTransferBase<BlockVector<number>>,
186 private MGTransferBlockBase
187{
188public:
193
197 virtual ~MGTransferBlock() override;
198
203 void
204 initialize(const std::vector<number> & factors,
206
213 template <int dim, int spacedim>
214 void
215 build(const DoFHandler<dim, spacedim> &dof_handler,
216 const std::vector<bool> & selected);
217
218 virtual void
219 prolongate(const unsigned int to_level,
221 const BlockVector<number> &src) const override;
222
223 virtual void
224 restrict_and_add(const unsigned int from_level,
226 const BlockVector<number> &src) const override;
227
239 template <int dim, typename number2, int spacedim>
240 void
241 copy_to_mg(const DoFHandler<dim, spacedim> & dof_handler,
243 const BlockVector<number2> & src) const;
244
251 template <int dim, typename number2, int spacedim>
252 void
255 const MGLevelObject<BlockVector<number>> &src) const;
256
262 template <int dim, typename number2, int spacedim>
263 void
266 const MGLevelObject<BlockVector<number>> &src) const;
267
269
270private:
275 std::vector<number> factors;
276
282};
283
284
285// TODO:[GK] Update documentation for copy_* functions
286
297template <typename number>
298class MGTransferBlockSelect : public MGTransferBase<Vector<number>>,
299 private MGTransferBlockBase
300{
301public:
307
312
316 virtual ~MGTransferBlockSelect() override = default;
317
328 template <int dim, int spacedim>
329 void
330 build(const DoFHandler<dim, spacedim> &dof_handler, unsigned int selected);
331
335 void
336 select(const unsigned int block);
337
338 virtual void
339 prolongate(const unsigned int to_level,
340 Vector<number> & dst,
341 const Vector<number> &src) const override;
342
343 virtual void
344 restrict_and_add(const unsigned int from_level,
345 Vector<number> & dst,
346 const Vector<number> &src) const override;
347
354 template <int dim, typename number2, int spacedim>
355 void
356 copy_to_mg(const DoFHandler<dim, spacedim> &dof_handler,
358 const Vector<number2> & src) const;
359
366 template <int dim, typename number2, int spacedim>
367 void
369 Vector<number2> & dst,
370 const MGLevelObject<Vector<number>> &src) const;
371
377 template <int dim, typename number2, int spacedim>
378 void
380 Vector<number2> & dst,
381 const MGLevelObject<Vector<number>> &src) const;
382
390 template <int dim, typename number2, int spacedim>
391 void
392 copy_to_mg(const DoFHandler<dim, spacedim> &dof_handler,
394 const BlockVector<number2> & src) const;
395
402 template <int dim, typename number2, int spacedim>
403 void
406 const MGLevelObject<Vector<number>> &src) const;
407
413 template <int dim, typename number2, int spacedim>
414 void
417 const MGLevelObject<Vector<number>> &src) const;
418
422 std::size_t
424
425private:
429 template <int dim, class OutVector, int spacedim>
430 void
432 OutVector & dst,
433 const MGLevelObject<Vector<number>> &src,
434 const unsigned int offset) const;
435
439 template <int dim, class OutVector, int spacedim>
440 void
442 OutVector & dst,
443 const MGLevelObject<Vector<number>> &src,
444 const unsigned int offset) const;
445
449 template <int dim, class InVector, int spacedim>
450 void
453 const InVector & src,
454 const unsigned int offset) const;
458 unsigned int selected_block;
459};
460
463//------------------------- inline function definition ------------------------
464template <typename number>
465inline void
467{
468 selected_block = block;
469}
470
472
473#endif
std::vector< unsigned int > mg_block
std::vector< std::vector< types::global_dof_index > > sizes
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 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 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_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:160
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
#define DeclException0(Exception0)
Definition exceptions.h:465
static ::ExceptionBase & ExcMatricesNotBuilt()