36#include <deal.II/multigrid/mg_transfer.templates.h>
47template <
typename VectorType>
48template <
int dim,
int spacedim>
56 copy_indices_global_mine,
57 copy_indices_level_mine);
61 bool my_perform_plain_copy =
67 if (my_perform_plain_copy)
75 for (
const auto ©_index : copy_indices.back())
76 if (copy_index.first != copy_index.second)
78 my_perform_plain_copy =
false;
90 ptria->get_mpi_communicator()) == 1);
92 perform_plain_copy = my_perform_plain_copy;
97template <
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;
112template <
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;
141template <
typename VectorType>
145 std::size_t result =
sizeof(*this);
160 template <
int dim,
int spacedim,
typename Number>
166 const bool transfer_solution_vectors,
172 &ghosted_level_vector)
176 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>>
179 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>>
180 my_copy_indices_global_mine;
182 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>>
183 my_copy_indices_level_mine;
188 my_copy_indices_global_mine,
189 my_copy_indices_level_mine,
190 !transfer_solution_vectors);
202 std::vector<types::global_dof_index> accessed_indices;
203 ghosted_level_vector.resize(0,
206 std::vector<IndexSet> level_index_set(
211 for (
const auto &indices : my_copy_indices_level_mine[l])
212 accessed_indices.push_back(indices.
first);
213 std::vector<types::global_dof_index> accessed_level_indices;
214 for (
const auto &indices : my_copy_indices_global_mine[l])
215 accessed_level_indices.push_back(indices.
second);
216 std::sort(accessed_level_indices.begin(), accessed_level_indices.end());
218 level_index_set[l].add_indices(accessed_level_indices.begin(),
219 accessed_level_indices.end());
220 level_index_set[l].compress();
225 std::sort(accessed_indices.begin(), accessed_indices.end());
226 index_set.add_indices(accessed_indices.begin(), accessed_indices.end());
227 index_set.compress();
236 copy_indices_level_mine.resize(
238 copy_indices_global_mine.resize(
240 for (
unsigned int level = 0;
247 *ghosted_level_vector[
level].get_partitioner();
249 auto translate_indices =
250 [&](
const std::vector<
251 std::pair<types::global_dof_index, types::global_dof_index>>
252 &global_copy_indices,
254 local_copy_indices.
reinit(2, global_copy_indices.size());
255 for (
unsigned int i = 0; i < global_copy_indices.size(); ++i)
258 global_copy_indices[i].
first);
260 global_copy_indices[i].
second);
265 translate_indices(my_copy_indices[
level], copy_indices[
level]);
268 translate_indices(my_copy_indices_level_mine[
level],
269 copy_indices_level_mine[
level]);
272 translate_indices(my_copy_indices_global_mine[
level],
273 copy_indices_global_mine[
level]);
278template <
typename Number,
typename MemorySpace>
279template <
int dim,
int spacedim>
286 fill_internal(mg_dof,
291 this->copy_indices_global_mine,
292 this->copy_indices_level_mine,
293 ghosted_global_vector,
294 ghosted_level_vector);
300 int have_refinement_edge_dofs = 0;
301 if (mg_constrained_dofs !=
nullptr)
302 for (
unsigned int level = 0;
305 if (mg_constrained_dofs->get_refinement_edge_indices(
level).n_elements() >
308 have_refinement_edge_dofs = 1;
314 std::vector<Table<2, unsigned int>> solution_copy_indices_global_mine;
316 solution_ghosted_level_vector;
318 fill_internal(mg_dof,
322 this->solution_copy_indices,
323 solution_copy_indices_global_mine,
324 this->solution_copy_indices_level_mine,
325 solution_ghosted_global_vector,
326 solution_ghosted_level_vector);
330 this->solution_copy_indices = this->copy_indices;
331 this->solution_copy_indices_level_mine = this->copy_indices_level_mine;
332 solution_ghosted_global_vector = ghosted_global_vector;
341 const bool my_perform_renumbered_plain_copy =
342 (this->copy_indices.back().n_cols() ==
344 (this->copy_indices_global_mine.back().n_rows() == 0) &&
345 (this->copy_indices_level_mine.back().n_rows() == 0);
347 bool my_perform_plain_copy =
false;
348 if (my_perform_renumbered_plain_copy)
350 my_perform_plain_copy =
true;
354 for (
unsigned int i = 0; i < this->copy_indices.back().n_cols(); ++i)
355 if (this->copy_indices.back()(0, i) != this->copy_indices.back()(1, i))
357 my_perform_plain_copy =
false;
367 perform_renumbered_plain_copy =
372 if (perform_renumbered_plain_copy)
374 for (
unsigned int i = 0; i < this->copy_indices.back().n_cols(); ++i)
377 ghosted_global_vector.
reinit(0);
378 ghosted_level_vector.resize(0, 0);
379 solution_ghosted_global_vector.reinit(0);
385template <
typename Number,
typename MemorySpace>
391 copy_indices.clear();
392 solution_copy_indices.clear();
393 copy_indices_global_mine.clear();
394 copy_indices_level_mine.clear();
395 solution_copy_indices_level_mine.clear();
396 component_to_block_map.resize(0);
397 mg_constrained_dofs =
nullptr;
398 ghosted_global_vector.
reinit(0);
399 solution_ghosted_global_vector.reinit(0);
400 ghosted_level_vector.resize(0, 0);
401 perform_plain_copy =
false;
402 perform_renumbered_plain_copy =
false;
403 initialize_dof_vector =
nullptr;
408template <
typename Number,
typename MemorySpace>
411 print_indices(std::ostream &os)
const
415 for (
unsigned int i = 0; i < copy_indices[
level].n_cols(); ++i)
416 os <<
"copy_indices[" <<
level <<
"]\t" << copy_indices[
level](0, i)
417 <<
'\t' << copy_indices[
level](1, i) << std::endl;
420 for (
unsigned int level = 0;
level < copy_indices_level_mine.size(); ++
level)
422 for (
unsigned int i = 0; i < copy_indices_level_mine[
level].n_cols(); ++i)
423 os <<
"copy_ifrom [" <<
level <<
"]\t"
424 << copy_indices_level_mine[
level](0, i) <<
'\t'
425 << copy_indices_level_mine[
level](1, i) << std::endl;
427 for (
unsigned int level = 0;
level < copy_indices_global_mine.size(); ++
level)
429 for (
unsigned int i = 0; i < copy_indices_global_mine[
level].n_cols();
431 os <<
"copy_ito [" <<
level <<
"]\t"
432 << copy_indices_global_mine[
level](0, i) <<
'\t'
433 << copy_indices_global_mine[
level](1, i) << std::endl;
439template <
typename Number,
typename MemorySpace>
442 memory_consumption()
const
444 std::size_t result =
sizeof(*this);
450 for (
unsigned int i = ghosted_level_vector.min_level();
451 i <= ghosted_level_vector.max_level();
453 result += ghosted_level_vector[i].memory_consumption();
461#include "mg_level_global_transfer.inst"
const IndexSet & locally_owned_mg_dofs(const unsigned int level) const
const Triangulation< dim, spacedim > & get_triangulation() const
const IndexSet & locally_owned_dofs() const
MPI_Comm get_mpi_communicator() const
size_type n_elements() const
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_partitioner() const
std::size_t memory_consumption() const
void reinit(const size_type size, const bool omit_zeroing_entries=false)
void print_indices(std::ostream &os) const
std::size_t memory_consumption() const
void fill_and_communicate_copy_indices(const DoFHandler< dim, spacedim > &dof_handler)
virtual unsigned int n_global_levels() const
unsigned int global_to_local(const types::global_dof_index global_index) const
virtual void reinit(const IndexSet &locally_owned_indices, const IndexSet &ghost_indices, const MPI_Comm communicator) override
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define AssertDimension(dim1, dim2)
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)
T max(const T &t, const MPI_Comm mpi_communicator)
T min(const T &t, const MPI_Comm mpi_communicator)
void fill_copy_indices(const DoFHandler< dim, spacedim > &dof_handler, const MGConstrainedDoFs *mg_constrained_dofs, std::vector< std::vector< std::pair< types::global_dof_index, types::global_dof_index > > > ©_indices, std::vector< std::vector< std::pair< types::global_dof_index, types::global_dof_index > > > ©_indices_global_mine, std::vector< std::vector< std::pair< types::global_dof_index, types::global_dof_index > > > ©_indices_level_mine, const bool skip_interface_dofs=true)