153 Assert(dof_handler.has_level_dofs(),
155 "The underlying DoFHandler object has not had its "
156 "distribute_mg_dofs() function called, but this is a prerequisite "
157 "for multigrid transfers. You will need to call this function, "
158 "probably close to where you already call distribute_dofs()."));
160 const unsigned int n_levels =
161 dof_handler.get_triangulation().n_global_levels();
162 const unsigned int dofs_per_cell = dof_handler.get_fe().n_dofs_per_cell();
164 this->
sizes.resize(n_levels);
165 for (
unsigned int l = 0; l < n_levels; ++l)
166 this->
sizes[l] = dof_handler.n_dofs(l);
183 for (
unsigned int i = 0; i < n_levels - 1; ++i)
194 std::vector<types::global_dof_index> dof_indices_parent(dofs_per_cell);
195 std::vector<types::global_dof_index> dof_indices_child(dofs_per_cell);
196 std::vector<types::global_dof_index> entries(dofs_per_cell);
203 for (
unsigned int level = 0; level < n_levels - 1; ++level)
212 const IndexSet level_p1_relevant_dofs =
216 level_p1_relevant_dofs);
217 for (
const auto &cell : dof_handler.cell_iterators_on_level(level))
218 if (cell->has_children() && cell->is_locally_owned_on_level())
220 cell->get_mg_dof_indices(dof_indices_parent);
222 replace(this->mg_constrained_dofs, level, dof_indices_parent);
224 Assert(cell->n_children() ==
227 for (
unsigned int child = 0; child < cell->n_children(); ++child)
231 dof_handler.get_fe().get_prolongation_matrix(
232 child, cell->refinement_case());
236 cell->child(child)->get_mg_dof_indices(dof_indices_child);
238 replace(this->mg_constrained_dofs,
245 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
248 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
249 if (prolongation(i, j) != 0)
250 entries.push_back(dof_indices_parent[j]);
258#ifdef DEAL_II_WITH_MPI
260 VectorType>::requires_distributed_sparsity_pattern)
269 dof_handler.locally_owned_mg_dofs(level + 1),
270 dof_handler.get_mpi_communicator(),
294 for (
const auto &cell : dof_handler.cell_iterators_on_level(level))
295 if (cell->has_children() && cell->is_locally_owned_on_level())
297 cell->get_mg_dof_indices(dof_indices_parent);
299 replace(this->mg_constrained_dofs, level, dof_indices_parent);
301 Assert(cell->n_children() ==
304 for (
unsigned int child = 0; child < cell->n_children(); ++child)
307 prolongation = dof_handler.get_fe().get_prolongation_matrix(
308 child, cell->refinement_case());
310 if (this->mg_constrained_dofs !=
nullptr &&
312 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
314 level, dof_indices_parent[j]))
315 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
316 prolongation(i, j) = 0.;
318 cell->child(child)->get_mg_dof_indices(dof_indices_child);
320 replace(this->mg_constrained_dofs,
325 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
328 dof_indices_parent.data(),