36#include <deal.II/multigrid/mg_transfer.templates.h>
47template <
typename VectorType>
48template <
int dim,
int spacedim>
61 bool my_perform_plain_copy =
67 if (my_perform_plain_copy)
76 if (copy_index.first != copy_index.second)
78 my_perform_plain_copy =
false;
90 ptria->get_mpi_communicator()) == 1);
97template <
typename VectorType>
112template <
typename VectorType>
116 for (
unsigned int level = 0; level <
copy_indices.size(); ++level)
118 for (
unsigned int i = 0; i <
copy_indices[level].size(); ++i)
119 os <<
"copy_indices[" << level <<
"]\t" <<
copy_indices[level][i].first
126 os <<
"copy_ifrom [" << level <<
"]\t"
133 os <<
"copy_ito [" << level <<
"]\t"
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,
300 int have_refinement_edge_dofs = 0;
302 for (
unsigned int level = 0;
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;
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>
408template <
typename Number,
typename MemorySpace>
411 print_indices(std::ostream &os)
const
413 for (
unsigned int level = 0; level <
copy_indices.size(); ++level)
415 for (
unsigned int i = 0; i <
copy_indices[level].n_cols(); ++i)
416 os <<
"copy_indices[" << level <<
"]\t" <<
copy_indices[level](0, i)
423 os <<
"copy_ifrom [" << level <<
"]\t"
431 os <<
"copy_ito [" << level <<
"]\t"
439template <
typename Number,
typename MemorySpace>
442 memory_consumption()
const
444 std::size_t result =
sizeof(*this);
461#include "multigrid/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
void reinit(const size_type size, const bool omit_zeroing_entries=false)
std::vector< Table< 2, unsigned int > > solution_copy_indices_level_mine
std::vector< Table< 2, unsigned int > > copy_indices_level_mine
std::vector< Table< 2, unsigned int > > solution_copy_indices
std::vector< unsigned int > component_to_block_map
ObserverPointer< const MGConstrainedDoFs > mg_constrained_dofs
bool perform_renumbered_plain_copy
LinearAlgebra::distributed::Vector< Number, MemorySpace > ghosted_global_vector
std::function< void(const unsigned int, LinearAlgebra::distributed::Vector< Number, MemorySpace > &)> initialize_dof_vector
LinearAlgebra::distributed::Vector< Number, MemorySpace > solution_ghosted_global_vector
std::vector< Table< 2, unsigned int > > copy_indices_global_mine
std::vector< types::global_dof_index > sizes
std::vector< Table< 2, unsigned int > > copy_indices
MGLevelObject< LinearAlgebra::distributed::Vector< Number, MemorySpace > > ghosted_level_vector
void print_indices(std::ostream &os) const
std::vector< std::vector< std::pair< types::global_dof_index, types::global_dof_index > > > copy_indices_level_mine
std::size_t memory_consumption() const
ObserverPointer< const MGConstrainedDoFs > mg_constrained_dofs
std::vector< std::vector< std::pair< types::global_dof_index, types::global_dof_index > > > copy_indices
void fill_and_communicate_copy_indices(const DoFHandler< dim, spacedim > &dof_handler)
std::vector< unsigned int > component_to_block_map
std::vector< types::global_dof_index > sizes
std::vector< std::vector< std::pair< types::global_dof_index, types::global_dof_index > > > copy_indices_global_mine
virtual unsigned int n_global_levels() const
unsigned int global_to_local(const types::global_dof_index global_index) const
#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)