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_component.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_component_h
17#define dealii_mg_transfer_component_h
18
19#include <deal.II/base/config.h>
20
22
24
26
32
34
35#include <memory>
36
37
38
40
41// Forward declaration
42#ifndef DOXYGEN
43template <int dim, int spacedim>
44class DoFHandler;
45#endif
46
47/*
48 * MGTransferBase is defined in mg_base.h
49 */
50
53
62{
63public:
67 std::size_t
68 memory_consumption() const;
69
70
71protected:
82 template <int dim, int spacedim>
83 void
84 build(const DoFHandler<dim, spacedim> &dof_handler);
85
98 template <int dim, int spacedim>
101 const DoFHandler<dim, spacedim> &mg_dof);
102
111
120
124 std::vector<unsigned int> target_component;
125
129 std::vector<unsigned int> mg_target_component;
130
134 mutable std::vector<std::vector<types::global_dof_index>> sizes;
135
139 std::vector<types::global_dof_index> component_start;
140
144 std::vector<std::vector<types::global_dof_index>> mg_component_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
166 std::vector<std::vector<std::pair<types::global_dof_index, unsigned int>>>
168
173 std::vector<std::set<types::global_dof_index>> boundary_indices;
174};
175
176// TODO:[GK] Update documentation for copy_* functions
177
178// TODO: Use same kind of template argument as MGTransferSelect
179
189template <typename number>
190class MGTransferSelect : public MGTransferBase<Vector<number>>,
192{
193public:
199
204
208 virtual ~MGTransferSelect() override = default;
209
210 // TODO: rewrite docs; make sure defaulted args are actually allowed
238 template <int dim, int spacedim>
241 const DoFHandler<dim, spacedim> &dof,
242 const DoFHandler<dim, spacedim> &mg_dof,
243 unsigned int selected,
244 unsigned int mg_selected,
245 const std::vector<unsigned int> &target_component =
246 std::vector<unsigned int>(),
247 const std::vector<unsigned int> &mg_target_component =
248 std::vector<unsigned int>(),
249 const std::vector<std::set<types::global_dof_index>> &boundary_indices =
250 std::vector<std::set<types::global_dof_index>>());
251
277 template <int dim, int spacedim>
278 void
280 unsigned int selected,
281 unsigned int mg_selected,
282 const std::vector<unsigned int> &target_component =
283 std::vector<unsigned int>(),
284 const std::vector<unsigned int> &mg_target_component =
285 std::vector<unsigned int>(),
286 const std::vector<std::set<types::global_dof_index>> &boundary_indices =
287 std::vector<std::set<types::global_dof_index>>());
288
292 void
293 select(const unsigned int component,
294 const unsigned int mg_component = numbers::invalid_unsigned_int);
295
296 virtual void
297 prolongate(const unsigned int to_level,
298 Vector<number> & dst,
299 const Vector<number> &src) const override;
300
301 virtual void
302 restrict_and_add(const unsigned int from_level,
303 Vector<number> & dst,
304 const Vector<number> &src) const override;
305
312 template <int dim, typename number2, int spacedim>
313 void
316 const Vector<number2> & src) const;
317
324 template <int dim, typename number2, int spacedim>
325 void
327 Vector<number2> & dst,
328 const MGLevelObject<Vector<number>> &src) const;
329
335 template <int dim, typename number2, int spacedim>
336 void
338 Vector<number2> & dst,
339 const MGLevelObject<Vector<number>> &src) const;
340
347 template <int dim, typename number2, int spacedim>
348 void
351 const BlockVector<number2> & src) const;
352
359 template <int dim, typename number2, int spacedim>
360 void
363 const MGLevelObject<Vector<number>> &src) const;
364
370 template <int dim, typename number2, int spacedim>
371 void
374 const MGLevelObject<Vector<number>> &src) const;
375
379 std::size_t
381
382private:
386 template <int dim, class OutVector, int spacedim>
387 void
389 OutVector & dst,
390 const MGLevelObject<Vector<number>> &src) const;
391
395 template <int dim, class OutVector, int spacedim>
396 void
398 OutVector & dst,
399 const MGLevelObject<Vector<number>> &src) const;
400
404 template <int dim, class InVector, int spacedim>
405 void
408 const InVector & src) const;
412 unsigned int selected_component;
417
423 std::vector<IndexSet> interface_dofs;
424
428public:
430};
431
434//---------------------------------------------------------------------------
435template <typename number>
436inline void
437MGTransferSelect<number>::select(const unsigned int component,
438 const unsigned int mg_component)
439{
440 selected_component = component;
441 mg_selected_component =
442 (mg_component == numbers::invalid_unsigned_int) ? component : mg_component;
443}
444
446
447#endif
std::vector< unsigned int > mg_target_component
std::vector< unsigned int > target_component
void build_matrices(const DoFHandler< dim, spacedim > &dof, const DoFHandler< dim, spacedim > &mg_dof)
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:149
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 build_matrices(const DoFHandler< dim, spacedim > &dof, const DoFHandler< dim, spacedim > &mg_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 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
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:215
SmartPointer< const AffineConstraints< double > > constraints
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:232
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_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()
static const unsigned int invalid_unsigned_int
Definition: types.h:196