17 #include <deal.II/base/function.h> 18 #include <deal.II/base/logstream.h> 20 #include <deal.II/dofs/dof_accessor.h> 22 #include <deal.II/fe/fe.h> 24 #include <deal.II/grid/tria.h> 25 #include <deal.II/grid/tria_iterator.h> 27 #include <deal.II/lac/block_vector.h> 28 #include <deal.II/lac/la_parallel_block_vector.h> 29 #include <deal.II/lac/la_parallel_vector.h> 30 #include <deal.II/lac/trilinos_epetra_vector.h> 31 #include <deal.II/lac/trilinos_parallel_block_vector.h> 32 #include <deal.II/lac/trilinos_vector.h> 33 #include <deal.II/lac/vector.h> 35 #include <deal.II/multigrid/mg_tools.h> 36 #include <deal.II/multigrid/mg_transfer.h> 37 #include <deal.II/multigrid/mg_transfer.templates.h> 38 #include <deal.II/multigrid/mg_transfer_internal.h> 42 DEAL_II_NAMESPACE_OPEN
48 template <
typename VectorType>
49 template <
int dim,
int spacedim>
54 internal::MGTransfer::fill_copy_indices(mg_dof,
57 copy_indices_global_mine,
58 copy_indices_level_mine);
62 bool my_perform_plain_copy =
68 if (my_perform_plain_copy)
76 for (
unsigned int i = 0; i < copy_indices.back().size(); ++i)
77 if (copy_indices.back()[i].first != copy_indices.back()[i].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>
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
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>
168 const MPI_Comm mpi_communicator,
169 const bool transfer_solution_vectors,
170 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
172 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
173 ©_indices_global_mine,
174 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
175 & copy_indices_level_mine,
178 &ghosted_level_vector)
182 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>>
185 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>>
186 my_copy_indices_global_mine;
188 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>>
189 my_copy_indices_level_mine;
191 internal::MGTransfer::fill_copy_indices(mg_dof,
194 my_copy_indices_global_mine,
195 my_copy_indices_level_mine,
196 !transfer_solution_vectors);
208 std::vector<types::global_dof_index> accessed_indices;
209 ghosted_level_vector.resize(0,
212 std::vector<IndexSet> level_index_set(
217 for (
unsigned int i = 0; i < my_copy_indices_level_mine[l].size(); ++i)
218 accessed_indices.push_back(my_copy_indices_level_mine[l][i].first);
219 std::vector<types::global_dof_index> accessed_level_indices;
220 for (
unsigned int i = 0; i < my_copy_indices_global_mine[l].size(); ++i)
221 accessed_level_indices.push_back(
222 my_copy_indices_global_mine[l][i].second);
223 std::sort(accessed_level_indices.begin(), accessed_level_indices.end());
225 level_index_set[l].add_indices(accessed_level_indices.begin(),
226 accessed_level_indices.end());
227 level_index_set[l].compress();
232 std::sort(accessed_indices.begin(), accessed_indices.end());
233 index_set.add_indices(accessed_indices.begin(), accessed_indices.end());
234 index_set.compress();
243 copy_indices_level_mine.resize(
245 copy_indices_global_mine.resize(
247 for (
unsigned int level = 0;
254 *ghosted_level_vector[level].get_partitioner();
257 copy_indices[level].resize(my_copy_indices[level].size());
258 for (
unsigned int i = 0; i < my_copy_indices[level].size(); ++i)
259 copy_indices[level][i] = std::pair<unsigned int, unsigned int>(
262 my_copy_indices[level][i].second));
266 copy_indices_level_mine[level].resize(
267 my_copy_indices_level_mine[level].size());
268 for (
unsigned int i = 0; i < my_copy_indices_level_mine[level].size();
270 copy_indices_level_mine[level][i] =
271 std::pair<unsigned int, unsigned int>(
273 my_copy_indices_level_mine[level][i].first),
275 my_copy_indices_level_mine[level][i].second));
279 copy_indices_global_mine[level].resize(
280 my_copy_indices_global_mine[level].size());
281 for (
unsigned int i = 0; i < my_copy_indices_global_mine[level].size();
283 copy_indices_global_mine[level][i] =
284 std::pair<unsigned int, unsigned int>(
286 my_copy_indices_global_mine[level][i].first),
288 my_copy_indices_global_mine[level][i].second));
293 template <
typename Number>
294 template <
int dim,
int spacedim>
302 const MPI_Comm mpi_communicator =
305 fill_internal(mg_dof,
310 this->copy_indices_global_mine,
311 this->copy_indices_level_mine,
312 ghosted_global_vector,
313 ghosted_level_vector);
315 fill_internal(mg_dof,
319 this->solution_copy_indices,
320 this->solution_copy_indices_global_mine,
321 this->solution_copy_indices_level_mine,
322 solution_ghosted_global_vector,
323 solution_ghosted_level_vector);
325 bool my_perform_renumbered_plain_copy =
326 (this->copy_indices.back().size() ==
328 bool my_perform_plain_copy =
false;
329 if (my_perform_renumbered_plain_copy)
331 my_perform_plain_copy =
true;
338 for (
unsigned int i = 0; i < this->copy_indices.back().size(); ++i)
339 if (this->copy_indices.back()[i].first !=
340 this->copy_indices.back()[i].second)
342 my_perform_plain_copy =
false;
352 perform_renumbered_plain_copy =
357 if (perform_renumbered_plain_copy)
359 ghosted_global_vector.reinit(0);
360 ghosted_level_vector.resize(0, 0);
361 solution_ghosted_global_vector.reinit(0);
362 solution_ghosted_level_vector.resize(0, 0);
368 template <
typename Number>
373 copy_indices.
clear();
374 copy_indices_global_mine.clear();
375 copy_indices_level_mine.clear();
376 component_to_block_map.resize(0);
377 mg_constrained_dofs =
nullptr;
378 ghosted_global_vector.reinit(0);
379 ghosted_level_vector.resize(0, 0);
380 perform_plain_copy =
false;
381 perform_renumbered_plain_copy =
false;
386 template <
typename Number>
389 print_indices(std::ostream &os)
const 391 for (
unsigned int level = 0; level < copy_indices.size(); ++level)
393 for (
unsigned int i = 0; i < copy_indices[level].size(); ++i)
394 os <<
"copy_indices[" << level <<
"]\t" << copy_indices[level][i].first
395 <<
'\t' << copy_indices[level][i].second << std::endl;
398 for (
unsigned int level = 0; level < copy_indices_level_mine.size(); ++level)
400 for (
unsigned int i = 0; i < copy_indices_level_mine[level].size(); ++i)
401 os <<
"copy_ifrom [" << level <<
"]\t" 402 << copy_indices_level_mine[level][i].first <<
'\t' 403 << copy_indices_level_mine[level][i].second << std::endl;
405 for (
unsigned int level = 0; level < copy_indices_global_mine.size(); ++level)
407 for (
unsigned int i = 0; i < copy_indices_global_mine[level].size(); ++i)
408 os <<
"copy_ito [" << level <<
"]\t" 409 << copy_indices_global_mine[level][i].first <<
'\t' 410 << copy_indices_global_mine[level][i].second << std::endl;
416 template <
typename Number>
421 std::size_t result =
sizeof(*this);
426 result += ghosted_global_vector.memory_consumption();
427 for (
unsigned int i = ghosted_level_vector.min_level();
428 i <= ghosted_level_vector.max_level();
430 result += ghosted_level_vector[i].memory_consumption();
438 #include "mg_level_global_transfer.inst" 445 DEAL_II_NAMESPACE_CLOSE
std::size_t memory_consumption() const
void reinit(const size_type size, const bool omit_zeroing_entries=false)
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_partitioner() const
#define AssertDimension(dim1, dim2)
size_type n_elements() const
const Triangulation< dim, spacedim > & get_triangulation() const
virtual MPI_Comm get_communicator() const
void fill_and_communicate_copy_indices(const DoFHandler< dim, spacedim > &mg_dof)
unsigned int global_to_local(const types::global_dof_index global_index) const
const IndexSet & locally_owned_mg_dofs(const unsigned int level) const
void print_indices(std::ostream &os) const
T min(const T &t, const MPI_Comm &mpi_communicator)
const IndexSet & locally_owned_dofs() const
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)