Debian Codegraph @

include/deal.II/multigrid/mg_transfer_internal.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2016 - 2024 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
16 #ifndef dealii_mg_transfer_internal_h
17 #define dealii_mg_transfer_internal_h
18
19 #include <deal.II/base/config.h>
20
21 #include <deal.II/base/mg_level_object.h>
22
23 #include <deal.II/dofs/dof_handler.h>
24
25 #include <deal.II/lac/la_parallel_vector.h>
26
27 #include <deal.II/multigrid/mg_constrained_dofs.h>
28
29 DEAL_II_NAMESPACE_OPEN
30
31 namespace internal
32 {
33 namespace MGTransfer
34 {
35 /**
36 * Internal function for filling the copy indices from global to level
37 * indices
38 *
39 * If @p skip_interface_dofs is false, the mapping will also contain
40 * DoFs at the interface between levels. This is desirable when
41 * transferring solution vectors instead of residuals.
42 */
43 template <int dim, int spacedim>
44 void
45 fill_copy_indices(
46 const DoFHandler<dim, spacedim> &dof_handler,
47 const MGConstrainedDoFs *mg_constrained_dofs,
48 std::vector<std::vector<
49 std::pair<types::global_dof_index, types::global_dof_index>>>
50 &copy_indices,
51 std::vector<std::vector<
52 std::pair<types::global_dof_index, types::global_dof_index>>>
53 &copy_indices_global_mine,
54 std::vector<std::vector<
55 std::pair<types::global_dof_index, types::global_dof_index>>>
56 &copy_indices_level_mine,
57 const bool skip_interface_dofs = true);
58
59
60
61 /**
62 * Given the collection of child cells in lexicographic ordering as seen
63 * from the parent, this function computes the first index of the given
64 * child
65 */
66 template <int dim>
67 unsigned int
68 compute_shift_within_children(const unsigned int child,
69 const unsigned int fe_shift_1d,
70 const unsigned int fe_degree);
71
72 /**
73 * A structure that stores data related to the finite element contained in
74 * the DoFHandler. Used only for the initialization using
75 * <tt>setup_transfer</tt>.
76 */
77 template <typename Number>
78 struct ElementInfo
79 {
80 /**
81 * A variable storing the degree of the finite element. The selection of
82 * the computational kernel is based on this number.
83 */
84 unsigned int fe_degree;
85
86 /**
87 * A variable storing whether the element is continuous and there is a
88 * joint degree of freedom in the center of the 1d line.
89 */
90 bool element_is_continuous;
91
92 /**
93 * A variable storing the number of components in the finite element.
94 */
95 unsigned int n_components;
96
97 /**
98 * A variable storing the number of degrees of freedom on all child cells.
99 * It is <tt>2<sup>dim</sup>*fe.n_dofs_per_cell()</tt> for DG elements and
100 * somewhat less for continuous elements.
101 */
102 unsigned int n_child_cell_dofs;
103
104 /**
105 * An array that holds the numbering between the numbering of degrees of
106 * freedom in the finite element and the lexicographic numbering needed
107 * for the tensor product application.
108 */
109 std::vector<unsigned int> lexicographic_numbering;
110
111 /**
112 * This variable holds the one-dimensional embedding (prolongation) matrix
113 * from parent element to all the children.
114 */
115 std::vector<Number> prolongation_matrix_1d;
116 };
117
118 /**
119 * Set up most of the internal data structures of MGTransferMatrixFree
120 */
121 template <int dim, typename Number>
122 void
123 setup_transfer(
124 const DoFHandler<dim> &dof_handler,
125 const MGConstrainedDoFs *mg_constrained_dofs,
126 const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
127 &external_partitioners,
128 ElementInfo<Number> &elem_info,
129 std::vector<std::vector<unsigned int>> &level_dof_indices,
130 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
131 &parent_child_connect,
132 std::vector<unsigned int> &n_owned_level_cells,
133 std::vector<std::vector<std::vector<unsigned short>>> &dirichlet_indices,
134 std::vector<std::vector<Number>> &weights_on_refined,
135 std::vector<Table<2, unsigned int>> &copy_indices_global_mine,
136 MGLevelObject<std::shared_ptr<const Utilities::MPI::Partitioner>>
137 &vector_partitioners);
138
139
140
141 /**
142 * Helper function for setup_transfer. Checks for identity constrained
143 * dofs and replace with the indices of the dofs to which they are
144 * constrained
145 */
146 void
147 resolve_identity_constraints(
148 const MGConstrainedDoFs *mg_constrained_dofs,
149 const unsigned int level,
150 std::vector<types::global_dof_index> &dof_indices);
151
152 } // namespace MGTransfer
153 } // namespace internal
154
155 DEAL_II_NAMESPACE_CLOSE
156
157 #endif