155 Assert(dof_handler.has_level_dofs(),
157 "The underlying DoFHandler object has not had its "
158 "distribute_mg_dofs() function called, but this is a prerequisite "
159 "for multigrid transfers. You will need to call this function, "
160 "probably close to where you already call distribute_dofs()."));
162 const unsigned int n_levels =
163 dof_handler.get_triangulation().n_global_levels();
164 const unsigned int dofs_per_cell = dof_handler.get_fe().n_dofs_per_cell();
166 this->sizes.resize(n_levels);
167 for (
unsigned int l = 0; l < n_levels; ++l)
168 this->sizes[l] = dof_handler.n_dofs(l);
180 prolongation_matrices.resize(0);
181 prolongation_sparsities.resize(0);
182 prolongation_matrices.reserve(n_levels - 1);
183 prolongation_sparsities.reserve(n_levels - 1);
185 for (
unsigned int i = 0; i < n_levels - 1; ++i)
187 prolongation_sparsities.emplace_back(
189 prolongation_matrices.emplace_back(
198 std::vector<types::global_dof_index> entries(dofs_per_cell);
221 for (
const auto &cell : dof_handler.cell_iterators_on_level(
level))
222 if (cell->has_children() && cell->is_locally_owned_on_level())
228 Assert(cell->n_children() ==
231 for (
unsigned int child = 0; child < cell->n_children(); ++child)
235 dof_handler.get_fe().get_prolongation_matrix(
236 child, cell->refinement_case());
238 Assert(prolongation.n() != 0, ExcNoProlongation());
242 replace(this->mg_constrained_dofs,
249 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
252 for (
unsigned int j = 0;
j < dofs_per_cell; ++
j)
253 if (prolongation(i,
j) != 0)
262#ifdef DEAL_II_WITH_MPI
264 VectorType>::requires_distributed_sparsity_pattern)
273 dof_handler.locally_owned_mg_dofs(
level + 1),
274 dof_handler.get_communicator(),
275 dsp.row_index_set());
280 *prolongation_matrices[
level],
281 *prolongation_sparsities[
level],
298 for (
const auto &cell : dof_handler.cell_iterators_on_level(
level))
299 if (cell->has_children() && cell->is_locally_owned_on_level())
305 Assert(cell->n_children() ==
308 for (
unsigned int child = 0; child < cell->n_children(); ++child)
311 prolongation = dof_handler.get_fe().get_prolongation_matrix(
312 child, cell->refinement_case());
314 if (this->mg_constrained_dofs !=
nullptr &&
316 for (
unsigned int j = 0;
j < dofs_per_cell; ++
j)
319 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
320 prolongation(i,
j) = 0.;
324 replace(this->mg_constrained_dofs,
329 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
340 this->fill_and_communicate_copy_indices(dof_handler);