48 template <
typename VectorType>
52 this->mg_constrained_dofs = &mg_c;
57 template <
typename VectorType>
62 this->mg_constrained_dofs = &mg_c;
67 template <
typename VectorType>
72 prolongation_matrices.resize(0);
73 prolongation_sparsities.resize(0);
74 interface_dofs.resize(0);
79 template <
typename VectorType>
85 Assert((to_level >= 1) && (to_level <= prolongation_matrices.size()),
86 ExcIndexRange(to_level, 1, prolongation_matrices.size() + 1));
89 if (this->mg_constrained_dofs !=
nullptr)
90 Assert(this->mg_constrained_dofs->get_user_constraint_matrix(to_level - 1)
96 prolongation_matrices[to_level - 1]->vmult(dst, src);
101 template <
typename VectorType>
107 Assert((from_level >= 1) && (from_level <= prolongation_matrices.size()),
108 ExcIndexRange(from_level, 1, prolongation_matrices.size() + 1));
111 prolongation_matrices[from_level - 1]->Tvmult_add(dst, src);
123 const unsigned int level,
124 std::vector<types::global_dof_index> &dof_indices)
126 if (mg_constrained_dofs !=
nullptr &&
128 for (
auto &ind : dof_indices)
144 template <
typename VectorType>
145 template <
int dim,
int spacedim>
150 const unsigned int n_levels =
152 const unsigned int dofs_per_cell = dof_handler.
get_fe().dofs_per_cell;
154 this->sizes.resize(n_levels);
155 for (
unsigned int l = 0;
l < n_levels; ++
l)
156 this->sizes[
l] = dof_handler.
n_dofs(
l);
168 prolongation_matrices.resize(0);
169 prolongation_sparsities.resize(0);
170 prolongation_matrices.reserve(n_levels - 1);
171 prolongation_sparsities.reserve(n_levels - 1);
173 for (
unsigned int i = 0; i < n_levels - 1; ++i)
175 prolongation_sparsities.emplace_back(
177 prolongation_matrices.emplace_back(
184 std::vector<types::global_dof_index> dof_indices_parent(dofs_per_cell);
185 std::vector<types::global_dof_index> dof_indices_child(dofs_per_cell);
186 std::vector<types::global_dof_index> entries(dofs_per_cell);
205 level_p1_relevant_dofs);
208 level_p1_relevant_dofs);
211 for (cell = dof_handler.
begin(
level); cell != endc; ++cell)
212 if (cell->has_children() &&
215 cell->level_subdomain_id() ==
218 cell->get_mg_dof_indices(dof_indices_parent);
220 replace(this->mg_constrained_dofs,
level, dof_indices_parent);
222 Assert(cell->n_children() ==
225 for (
unsigned int child = 0; child < cell->n_children(); ++child)
229 dof_handler.
get_fe().get_prolongation_matrix(
230 child, cell->refinement_case());
232 Assert(prolongation.
n() != 0, ExcNoProlongation());
234 cell->child(child)->get_mg_dof_indices(dof_indices_child);
236 replace(this->mg_constrained_dofs,
243 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
246 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
247 if (prolongation(i, j) != 0)
248 entries.push_back(dof_indices_parent[j]);
256 #ifdef DEAL_II_WITH_MPI
258 VectorType>::requires_distributed_sparsity_pattern)
269 MPI_Comm communicator = dist_tria !=
nullptr ?
283 *prolongation_matrices[
level],
284 *prolongation_sparsities[
level],
301 for (cell = dof_handler.
begin(
level); cell != endc; ++cell)
302 if (cell->has_children() &&
305 cell->level_subdomain_id() ==
308 cell->get_mg_dof_indices(dof_indices_parent);
310 replace(this->mg_constrained_dofs,
level, dof_indices_parent);
312 Assert(cell->n_children() ==
315 for (
unsigned int child = 0; child < cell->n_children(); ++child)
318 prolongation = dof_handler.
get_fe().get_prolongation_matrix(
319 child, cell->refinement_case());
321 if (this->mg_constrained_dofs !=
nullptr &&
323 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
325 level, dof_indices_parent[j]))
326 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
327 prolongation(i, j) = 0.;
329 cell->child(child)->get_mg_dof_indices(dof_indices_child);
331 replace(this->mg_constrained_dofs,
336 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
337 prolongation_matrices[
level]->
set(dof_indices_child[i],
339 dof_indices_parent.data(),
347 this->fill_and_communicate_copy_indices(dof_handler);
352 template <
typename VectorType>
353 template <
int dim,
int spacedim>
363 template <
typename VectorType>
367 for (
unsigned int level = 0;
level < prolongation_matrices.size(); ++
level)
369 os <<
"Level " <<
level << std::endl;
370 prolongation_matrices[
level]->print(os);
377 template <
typename VectorType>
382 for (
unsigned int i = 0; i < prolongation_matrices.size(); ++i)
384 prolongation_sparsities[i]->memory_consumption();
391 #include "mg_transfer_prebuilt.inst"