deal.II version 9.8.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_component.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2001 - 2025 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_mg_transfer_component_h
14#define dealii_mg_transfer_component_h
15
16#include <deal.II/base/config.h>
17
19
21
23
28
30
31#include <memory>
32#include <set>
33
34
36
37// Forward declaration
38#ifndef DOXYGEN
39template <int dim, int spacedim>
41class DoFHandler;
42#endif
43
44/*
45 * MGTransferBase is defined in mg_base.h
46 */
47
52
61{
62public:
66 std::size_t
67 memory_consumption() const;
68
69
70protected:
81 template <int dim, int spacedim>
82 void
83 build(const DoFHandler<dim, spacedim> &dof_handler);
84
93
102
106 std::vector<unsigned int> target_component;
107
111 std::vector<unsigned int> mg_target_component;
112
116 mutable std::vector<std::vector<types::global_dof_index>> sizes;
117
121 std::vector<types::global_dof_index> component_start;
122
126 std::vector<std::vector<types::global_dof_index>> mg_component_start;
127
132
133private:
134 std::vector<std::shared_ptr<BlockSparsityPattern>> prolongation_sparsities;
135
136protected:
142 std::vector<std::shared_ptr<BlockSparseMatrix<double>>> prolongation_matrices;
143
148 std::vector<std::vector<std::pair<types::global_dof_index, unsigned int>>>
150
155 std::vector<std::set<types::global_dof_index>> boundary_indices;
156};
157
158// TODO:[GK] Update documentation for copy_* functions
159
160// TODO: Use same kind of template argument as MGTransferSelect
161
171template <typename number>
172class MGTransferSelect : public MGTransferBase<Vector<number>>,
174{
175public:
181
186
190 virtual ~MGTransferSelect() override = default;
191
192 // TODO: rewrite docs; make sure defaulted args are actually allowed
220 template <int dim, int spacedim>
221 void
223 unsigned int selected,
224 unsigned int mg_selected,
225 const std::vector<unsigned int> &target_component =
226 std::vector<unsigned int>(),
227 const std::vector<unsigned int> &mg_target_component =
228 std::vector<unsigned int>(),
229 const std::vector<std::set<types::global_dof_index>> &boundary_indices =
230 std::vector<std::set<types::global_dof_index>>());
231
235 void
236 select(const unsigned int component,
237 const unsigned int mg_component = numbers::invalid_unsigned_int);
238
239 virtual void
240 prolongate(const unsigned int to_level,
241 Vector<number> &dst,
242 const Vector<number> &src) const override;
243
244 virtual void
245 restrict_and_add(const unsigned int from_level,
246 Vector<number> &dst,
247 const Vector<number> &src) const override;
248
255 template <int dim, typename number2, int spacedim>
256 void
259 const Vector<number2> &src) const;
260
267 template <int dim, typename number2, int spacedim>
268 void
270 Vector<number2> &dst,
271 const MGLevelObject<Vector<number>> &src) const;
272
278 template <int dim, typename number2, int spacedim>
279 void
281 Vector<number2> &dst,
282 const MGLevelObject<Vector<number>> &src) const;
283
290 template <int dim, typename number2, int spacedim>
291 void
294 const BlockVector<number2> &src) const;
295
302 template <int dim, typename number2, int spacedim>
303 void
306 const MGLevelObject<Vector<number>> &src) const;
307
313 template <int dim, typename number2, int spacedim>
314 void
317 const MGLevelObject<Vector<number>> &src) const;
318
322 std::size_t
324
325private:
329 template <int dim, class OutVector, int spacedim>
330 void
332 OutVector &dst,
333 const MGLevelObject<Vector<number>> &src) const;
334
338 template <int dim, class OutVector, int spacedim>
339 void
341 OutVector &dst,
342 const MGLevelObject<Vector<number>> &src) const;
343
347 template <int dim, class InVector, int spacedim>
348 void
351 const InVector &src) const;
355 unsigned int selected_component;
360
366 std::vector<IndexSet> interface_dofs;
367
371public:
373};
374
376
377//---------------------------------------------------------------------------
378template <typename number>
379inline void
380MGTransferSelect<number>::select(const unsigned int component,
381 const unsigned int mg_component)
382{
383 selected_component = component;
385 (mg_component == numbers::invalid_unsigned_int) ? component : mg_component;
386}
387
389
390#endif
std::vector< unsigned int > mg_target_component
std::vector< unsigned int > target_component
std::vector< types::global_dof_index > component_start
std::vector< std::shared_ptr< BlockSparseMatrix< double > > > prolongation_matrices
std::vector< std::vector< std::pair< types::global_dof_index, unsigned int > > > copy_to_and_from_indices
std::vector< std::vector< types::global_dof_index > > mg_component_start
std::vector< std::shared_ptr< BlockSparsityPattern > > prolongation_sparsities
void build(const DoFHandler< dim, spacedim > &dof_handler)
std::vector< std::vector< types::global_dof_index > > sizes
std::size_t memory_consumption() const
Definition multigrid.cc:147
std::vector< std::set< types::global_dof_index > > boundary_indices
void do_copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< Vector< number > > &dst, const InVector &src) const
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
void do_copy_from_mg_add(const DoFHandler< dim, spacedim > &mg_dof, OutVector &dst, const MGLevelObject< Vector< number > > &src) const
void copy_from_mg_add(const DoFHandler< dim, spacedim > &mg_dof, BlockVector< number2 > &dst, const MGLevelObject< Vector< number > > &src) const
ObserverPointer< const AffineConstraints< double > > constraints
void do_copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, OutVector &dst, const MGLevelObject< Vector< number > > &src) const
void copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, BlockVector< number2 > &dst, const MGLevelObject< Vector< number > > &src) const
virtual void prolongate(const unsigned int to_level, Vector< number > &dst, const Vector< number > &src) const override
Definition multigrid.cc:213
unsigned int mg_selected_component
unsigned int selected_component
void copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< Vector< number > > &dst, const BlockVector< number2 > &src) const
virtual ~MGTransferSelect() override=default
void build(const DoFHandler< dim, spacedim > &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 > >())
void select(const unsigned int component, const unsigned int mg_component=numbers::invalid_unsigned_int)
void copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, Vector< number2 > &dst, const MGLevelObject< Vector< number > > &src) const
virtual void restrict_and_add(const unsigned int from_level, Vector< number > &dst, const Vector< number > &src) const override
Definition multigrid.cc:230
std::vector< IndexSet > interface_dofs
void copy_from_mg_add(const DoFHandler< dim, spacedim > &mg_dof, Vector< number2 > &dst, const MGLevelObject< Vector< number > > &src) const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:246
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define DeclException0(Exception0)
static ::ExceptionBase & ExcMatricesNotBuilt()
constexpr unsigned int invalid_unsigned_int
Definition types.h:236