deal.II version GIT relicensing-2289-g1e5549a87a 2024-12-21 21:30:00+00:00
\(\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: LGPL-2.1-or-later
4// Copyright (C) 2001 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_mg_transfer_component_h
16#define dealii_mg_transfer_component_h
17
18#include <deal.II/base/config.h>
19
21
23
25
30
32
33#include <memory>
34
35
36
38
39// Forward declaration
40#ifndef DOXYGEN
41template <int dim, int spacedim>
43class DoFHandler;
44#endif
45
46/*
47 * MGTransferBase is defined in mg_base.h
48 */
49
63{
64public:
68 std::size_t
69 memory_consumption() const;
70
71
72protected:
83 template <int dim, int spacedim>
84 void
85 build(const DoFHandler<dim, spacedim> &dof_handler);
86
95
104
108 std::vector<unsigned int> target_component;
109
113 std::vector<unsigned int> mg_target_component;
114
118 mutable std::vector<std::vector<types::global_dof_index>> sizes;
119
123 std::vector<types::global_dof_index> component_start;
124
128 std::vector<std::vector<types::global_dof_index>> mg_component_start;
129
134
135private:
136 std::vector<std::shared_ptr<BlockSparsityPattern>> prolongation_sparsities;
137
138protected:
144 std::vector<std::shared_ptr<BlockSparseMatrix<double>>> prolongation_matrices;
145
150 std::vector<std::vector<std::pair<types::global_dof_index, unsigned int>>>
152
157 std::vector<std::set<types::global_dof_index>> boundary_indices;
158};
159
160// TODO:[GK] Update documentation for copy_* functions
161
162// TODO: Use same kind of template argument as MGTransferSelect
163
173template <typename number>
174class MGTransferSelect : public MGTransferBase<Vector<number>>,
176{
177public:
183
188
192 virtual ~MGTransferSelect() override = default;
193
194 // 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
377//---------------------------------------------------------------------------
378template <typename number>
379inline void
380MGTransferSelect<number>::select(const unsigned int component,
381 const unsigned int mg_component)
382{
383 selected_component = component;
384 mg_selected_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:498
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:175
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
#define DeclException0(Exception0)
Definition exceptions.h:466
static ::ExceptionBase & ExcMatricesNotBuilt()
static const unsigned int invalid_unsigned_int
Definition types.h:220