37 #include <deal.II/multigrid/mg_transfer.templates.h>
48 template <
typename VectorType>
49 template <
int dim,
int spacedim>
57 copy_indices_global_mine,
58 copy_indices_level_mine);
62 bool my_perform_plain_copy =
68 if (my_perform_plain_copy)
76 for (
const auto ©_index : copy_indices.back())
77 if (copy_index.first != copy_index.second)
79 my_perform_plain_copy =
false;
90 ptria->get_communicator()) == 1);
92 perform_plain_copy = my_perform_plain_copy;
97 template <
typename VectorType>
102 copy_indices.clear();
103 copy_indices_global_mine.clear();
104 copy_indices_level_mine.clear();
105 component_to_block_map.resize(0);
106 mg_constrained_dofs =
nullptr;
107 perform_plain_copy =
false;
112 template <
typename VectorType>
118 for (
unsigned int i = 0; i < copy_indices[
level].size(); ++i)
119 os <<
"copy_indices[" <<
level <<
"]\t" << copy_indices[
level][i].
first
120 <<
'\t' << copy_indices[
level][i].
second << std::endl;
123 for (
unsigned int level = 0;
level < copy_indices_level_mine.size(); ++
level)
125 for (
unsigned int i = 0; i < copy_indices_level_mine[
level].size(); ++i)
126 os <<
"copy_ifrom [" <<
level <<
"]\t"
127 << copy_indices_level_mine[
level][i].
first <<
'\t'
128 << copy_indices_level_mine[
level][i].
second << std::endl;
130 for (
unsigned int level = 0;
level < copy_indices_global_mine.size(); ++
level)
132 for (
unsigned int i = 0; i < copy_indices_global_mine[
level].size(); ++i)
133 os <<
"copy_ito [" <<
level <<
"]\t"
134 << copy_indices_global_mine[
level][i].
first <<
'\t'
135 << copy_indices_global_mine[
level][i].
second << std::endl;
141 template <
typename VectorType>
145 std::size_t result =
sizeof(*this);
160 template <
int dim,
int spacedim,
typename Number>
169 const bool transfer_solution_vectors,
175 &ghosted_level_vector)
179 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>>
182 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>>
183 my_copy_indices_global_mine;
185 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>>
186 my_copy_indices_level_mine;
191 my_copy_indices_global_mine,
192 my_copy_indices_level_mine,
193 !transfer_solution_vectors);
205 std::vector<types::global_dof_index> accessed_indices;
206 ghosted_level_vector.resize(0,
209 std::vector<IndexSet> level_index_set(
214 for (
const auto &indices : my_copy_indices_level_mine[
l])
215 accessed_indices.push_back(indices.first);
216 std::vector<types::global_dof_index> accessed_level_indices;
217 for (
const auto &indices : my_copy_indices_global_mine[
l])
218 accessed_level_indices.push_back(indices.second);
219 std::sort(accessed_level_indices.begin(), accessed_level_indices.end());
221 level_index_set[
l].add_indices(accessed_level_indices.begin(),
222 accessed_level_indices.end());
223 level_index_set[
l].compress();
228 std::sort(accessed_indices.begin(), accessed_indices.end());
229 index_set.add_indices(accessed_indices.begin(), accessed_indices.end());
230 index_set.compress();
239 copy_indices_level_mine.resize(
241 copy_indices_global_mine.resize(
243 for (
unsigned int level = 0;
250 *ghosted_level_vector[
level].get_partitioner();
252 auto translate_indices =
253 [&](
const std::vector<
254 std::pair<types::global_dof_index, types::global_dof_index>>
255 & global_copy_indices,
257 local_copy_indices.
reinit(2, global_copy_indices.size());
258 for (
unsigned int i = 0; i < global_copy_indices.size(); ++i)
261 global_copy_indices[i].
first);
263 global_copy_indices[i].
second);
268 translate_indices(my_copy_indices[
level], copy_indices[
level]);
271 translate_indices(my_copy_indices_level_mine[
level],
272 copy_indices_level_mine[
level]);
275 translate_indices(my_copy_indices_global_mine[
level],
276 copy_indices_global_mine[
level]);
281 template <
typename Number>
282 template <
int dim,
int spacedim>
293 fill_internal(mg_dof,
298 this->copy_indices_global_mine,
299 this->copy_indices_level_mine,
300 ghosted_global_vector,
301 ghosted_level_vector);
307 int have_refinement_edge_dofs = 0;
308 if (mg_constrained_dofs !=
nullptr)
309 for (
unsigned int level = 0;
312 if (mg_constrained_dofs->get_refinement_edge_indices(
level).n_elements() >
315 have_refinement_edge_dofs = 1;
319 fill_internal(mg_dof,
323 this->solution_copy_indices,
324 this->solution_copy_indices_global_mine,
325 this->solution_copy_indices_level_mine,
326 solution_ghosted_global_vector,
327 solution_ghosted_level_vector);
330 this->solution_copy_indices = this->copy_indices;
331 this->solution_copy_indices_global_mine = this->copy_indices_global_mine;
332 this->solution_copy_indices_level_mine = this->copy_indices_level_mine;
333 solution_ghosted_global_vector = ghosted_global_vector;
334 solution_ghosted_level_vector = ghosted_level_vector;
337 bool my_perform_renumbered_plain_copy =
338 (this->copy_indices.back().n_cols() ==
340 bool my_perform_plain_copy =
false;
341 if (my_perform_renumbered_plain_copy)
343 my_perform_plain_copy =
true;
350 for (
unsigned int i = 0; i < this->copy_indices.back().n_cols(); ++i)
351 if (this->copy_indices.back()(0, i) != this->copy_indices.back()(1, i))
353 my_perform_plain_copy =
false;
363 perform_renumbered_plain_copy =
368 if (perform_renumbered_plain_copy)
370 for (
unsigned int i = 0; i < this->copy_indices.back().n_cols(); ++i)
373 ghosted_global_vector.
reinit(0);
374 ghosted_level_vector.resize(0, 0);
375 solution_ghosted_global_vector.reinit(0);
376 solution_ghosted_level_vector.resize(0, 0);
382 template <
typename Number>
387 copy_indices.
clear();
388 copy_indices_global_mine.clear();
389 copy_indices_level_mine.clear();
390 component_to_block_map.resize(0);
391 mg_constrained_dofs =
nullptr;
392 ghosted_global_vector.
reinit(0);
393 ghosted_level_vector.resize(0, 0);
394 perform_plain_copy =
false;
395 perform_renumbered_plain_copy =
false;
400 template <
typename Number>
403 print_indices(std::ostream &os)
const
407 for (
unsigned int i = 0; i < copy_indices[
level].n_cols(); ++i)
408 os <<
"copy_indices[" <<
level <<
"]\t" << copy_indices[
level](0, i)
409 <<
'\t' << copy_indices[
level](1, i) << std::endl;
412 for (
unsigned int level = 0;
level < copy_indices_level_mine.size(); ++
level)
414 for (
unsigned int i = 0; i < copy_indices_level_mine[
level].n_cols(); ++i)
415 os <<
"copy_ifrom [" <<
level <<
"]\t"
416 << copy_indices_level_mine[
level](0, i) <<
'\t'
417 << copy_indices_level_mine[
level](1, i) << std::endl;
419 for (
unsigned int level = 0;
level < copy_indices_global_mine.size(); ++
level)
421 for (
unsigned int i = 0; i < copy_indices_global_mine[
level].n_cols();
423 os <<
"copy_ito [" <<
level <<
"]\t"
424 << copy_indices_global_mine[
level](0, i) <<
'\t'
425 << copy_indices_global_mine[
level](1, i) << std::endl;
431 template <
typename Number>
436 std::size_t result =
sizeof(*this);
442 for (
unsigned int i = ghosted_level_vector.min_level();
443 i <= ghosted_level_vector.max_level();
445 result += ghosted_level_vector[i].memory_consumption();
453 #include "mg_level_global_transfer.inst"