154 Assert(dof_handler.has_level_dofs(),
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 =
162 dof_handler.get_triangulation().n_global_levels();
163 const unsigned int dofs_per_cell = dof_handler.get_fe().n_dofs_per_cell();
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(
197 std::vector<types::global_dof_index> entries(dofs_per_cell);
218 for (
const auto &cell : dof_handler.cell_iterators_on_level(
level))
219 if (cell->has_children() && cell->is_locally_owned_on_level())
225 Assert(cell->n_children() ==
228 for (
unsigned int child = 0; child < cell->n_children(); ++child)
232 dof_handler.get_fe().get_prolongation_matrix(
233 child, cell->refinement_case());
235 Assert(prolongation.n() != 0, ExcNoProlongation());
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)
259#ifdef DEAL_II_WITH_MPI
261 VectorType>::requires_distributed_sparsity_pattern)
270 dof_handler.locally_owned_mg_dofs(
level + 1),
271 dof_handler.get_mpi_communicator(),
272 dsp.row_index_set());
277 *prolongation_matrices[
level],
278 *prolongation_sparsities[
level],
295 for (
const auto &cell : dof_handler.cell_iterators_on_level(
level))
296 if (cell->has_children() && cell->is_locally_owned_on_level())
302 Assert(cell->n_children() ==
305 for (
unsigned int child = 0; child < cell->n_children(); ++child)
308 prolongation = dof_handler.get_fe().get_prolongation_matrix(
309 child, cell->refinement_case());
311 if (this->mg_constrained_dofs !=
nullptr &&
313 for (
unsigned int j = 0;
j < dofs_per_cell; ++
j)
316 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
317 prolongation(i,
j) = 0.;
321 replace(this->mg_constrained_dofs,
326 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
337 this->fill_and_communicate_copy_indices(dof_handler);