82 const VectorType &src)
const
84 Assert((to_level >= 1) && (to_level <= prolongation_matrices.size()),
85 ExcIndexRange(to_level, 1, prolongation_matrices.size() + 1));
87 if (this->mg_constrained_dofs !=
nullptr &&
88 this->mg_constrained_dofs->get_user_constraint_matrix(to_level - 1)
92 VectorType copy_src(src);
93 this->mg_constrained_dofs->get_user_constraint_matrix(to_level - 1)
94 .distribute(copy_src);
95 prolongation_matrices[to_level - 1]->vmult(dst, copy_src);
99 prolongation_matrices[to_level - 1]->vmult(dst, src);
156 "The underlying DoFHandler object has not had its "
157 "distribute_mg_dofs() function called, but this is a prerequisite "
158 "for multigrid transfers. You will need to call this function, "
159 "probably close to where you already call distribute_dofs()."));
161 const unsigned int n_levels =
165 this->sizes.resize(n_levels);
166 for (
unsigned int l = 0; l < n_levels; ++l)
167 this->sizes[l] = dof_handler.
n_dofs(l);
179 prolongation_matrices.resize(0);
180 prolongation_sparsities.resize(0);
181 prolongation_matrices.reserve(n_levels - 1);
182 prolongation_sparsities.reserve(n_levels - 1);
184 for (
unsigned int i = 0; i < n_levels - 1; ++i)
186 prolongation_sparsities.emplace_back(
188 prolongation_matrices.emplace_back(
195 std::vector<types::global_dof_index> dof_indices_parent(dofs_per_cell);
196 std::vector<types::global_dof_index> dof_indices_child(dofs_per_cell);
197 std::vector<types::global_dof_index> entries(dofs_per_cell);
213 const IndexSet level_p1_relevant_dofs =
217 level_p1_relevant_dofs);
219 if (cell->has_children() && cell->is_locally_owned_on_level())
221 cell->get_mg_dof_indices(dof_indices_parent);
223 replace(this->mg_constrained_dofs,
level, dof_indices_parent);
225 Assert(cell->n_children() ==
228 for (
unsigned int child = 0; child < cell->n_children(); ++child)
233 child, cell->refinement_case());
235 Assert(prolongation.
n() != 0, ExcNoProlongation());
237 cell->child(child)->get_mg_dof_indices(dof_indices_child);
239 replace(this->mg_constrained_dofs,
246 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
249 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
250 if (prolongation(i, j) != 0)
251 entries.push_back(dof_indices_parent[j]);
259#ifdef DEAL_II_WITH_MPI
261 VectorType>::requires_distributed_sparsity_pattern)
277 *prolongation_matrices[
level],
278 *prolongation_sparsities[
level],
296 if (cell->has_children() && cell->is_locally_owned_on_level())
298 cell->get_mg_dof_indices(dof_indices_parent);
300 replace(this->mg_constrained_dofs,
level, dof_indices_parent);
302 Assert(cell->n_children() ==
305 for (
unsigned int child = 0; child < cell->n_children(); ++child)
309 child, cell->refinement_case());
311 if (this->mg_constrained_dofs !=
nullptr &&
313 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
315 level, dof_indices_parent[j]))
316 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
317 prolongation(i, j) = 0.;
319 cell->child(child)->get_mg_dof_indices(dof_indices_child);
321 replace(this->mg_constrained_dofs,
326 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
327 prolongation_matrices[
level]->set(dof_indices_child[i],
329 dof_indices_parent.data(),
337 this->fill_and_communicate_copy_indices(dof_handler);