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 (
const auto &indices : my_copy_indices_level_mine[l])
218 accessed_indices.push_back(indices.first);
219 std::vector<types::global_dof_index> accessed_level_indices;
220 for (
const auto &indices : my_copy_indices_global_mine[l])
221 accessed_level_indices.push_back(indices.second);
222 std::sort(accessed_level_indices.begin(), accessed_level_indices.end());
224 level_index_set[l].add_indices(accessed_level_indices.begin(),
225 accessed_level_indices.end());
226 level_index_set[l].compress();
231 std::sort(accessed_indices.begin(), accessed_indices.end());
232 index_set.add_indices(accessed_indices.begin(), accessed_indices.end());
233 index_set.compress();
242 copy_indices_level_mine.resize(
244 copy_indices_global_mine.resize(
246 for (
unsigned int level = 0;
253 *ghosted_level_vector[level].get_partitioner();
256 copy_indices[level].resize(my_copy_indices[level].size());
257 for (
unsigned int i = 0; i < my_copy_indices[level].size(); ++i)
258 copy_indices[level][i] = std::pair<unsigned int, unsigned int>(
261 my_copy_indices[level][i].second));
265 copy_indices_level_mine[level].resize(
266 my_copy_indices_level_mine[level].size());
267 for (
unsigned int i = 0; i < my_copy_indices_level_mine[level].size();
269 copy_indices_level_mine[level][i] =
270 std::pair<unsigned int, unsigned int>(
272 my_copy_indices_level_mine[level][i].first),
274 my_copy_indices_level_mine[level][i].second));
278 copy_indices_global_mine[level].resize(
279 my_copy_indices_global_mine[level].size());
280 for (
unsigned int i = 0; i < my_copy_indices_global_mine[level].size();
282 copy_indices_global_mine[level][i] =
283 std::pair<unsigned int, unsigned int>(
285 my_copy_indices_global_mine[level][i].first),
287 my_copy_indices_global_mine[level][i].second));
292 template <
typename Number>
293 template <
int dim,
int spacedim>
301 const MPI_Comm mpi_communicator =
304 fill_internal(mg_dof,
309 this->copy_indices_global_mine,
310 this->copy_indices_level_mine,
311 ghosted_global_vector,
312 ghosted_level_vector);
314 fill_internal(mg_dof,
318 this->solution_copy_indices,
319 this->solution_copy_indices_global_mine,
320 this->solution_copy_indices_level_mine,
321 solution_ghosted_global_vector,
322 solution_ghosted_level_vector);
324 bool my_perform_renumbered_plain_copy =
325 (this->copy_indices.back().size() ==
327 bool my_perform_plain_copy =
false;
328 if (my_perform_renumbered_plain_copy)
330 my_perform_plain_copy =
true;
337 for (
unsigned int i = 0; i < this->copy_indices.back().size(); ++i)
338 if (this->copy_indices.back()[i].first !=
339 this->copy_indices.back()[i].second)
341 my_perform_plain_copy =
false;
351 perform_renumbered_plain_copy =
356 if (perform_renumbered_plain_copy)
358 ghosted_global_vector.
reinit(0);
359 ghosted_level_vector.resize(0, 0);
360 solution_ghosted_global_vector.reinit(0);
361 solution_ghosted_level_vector.resize(0, 0);
367 template <
typename Number>
372 copy_indices.
clear();
373 copy_indices_global_mine.clear();
374 copy_indices_level_mine.clear();
375 component_to_block_map.resize(0);
376 mg_constrained_dofs =
nullptr;
377 ghosted_global_vector.
reinit(0);
378 ghosted_level_vector.resize(0, 0);
379 perform_plain_copy =
false;
380 perform_renumbered_plain_copy =
false;
385 template <
typename Number>
388 print_indices(std::ostream &os)
const 390 for (
unsigned int level = 0; level < copy_indices.size(); ++level)
392 for (
unsigned int i = 0; i < copy_indices[level].size(); ++i)
393 os <<
"copy_indices[" << level <<
"]\t" << copy_indices[level][i].first
394 <<
'\t' << copy_indices[level][i].second << std::endl;
397 for (
unsigned int level = 0; level < copy_indices_level_mine.size(); ++level)
399 for (
unsigned int i = 0; i < copy_indices_level_mine[level].size(); ++i)
400 os <<
"copy_ifrom [" << level <<
"]\t" 401 << copy_indices_level_mine[level][i].first <<
'\t' 402 << copy_indices_level_mine[level][i].second << std::endl;
404 for (
unsigned int level = 0; level < copy_indices_global_mine.size(); ++level)
406 for (
unsigned int i = 0; i < copy_indices_global_mine[level].size(); ++i)
407 os <<
"copy_ito [" << level <<
"]\t" 408 << copy_indices_global_mine[level][i].first <<
'\t' 409 << copy_indices_global_mine[level][i].second << std::endl;
415 template <
typename Number>
420 std::size_t result =
sizeof(*this);
426 for (
unsigned int i = ghosted_level_vector.min_level();
427 i <= ghosted_level_vector.max_level();
429 result += ghosted_level_vector[i].memory_consumption();
437 #include "mg_level_global_transfer.inst" 444 DEAL_II_NAMESPACE_CLOSE
virtual std::size_t memory_consumption() const override
const Triangulation< dim, spacedim > & get_triangulation() const
#define AssertDimension(dim1, dim2)
std::size_t memory_consumption() const
void reinit(const size_type size, const bool omit_zeroing_entries=false)
unsigned int global_to_local(const types::global_dof_index global_index) const
void print_indices(std::ostream &os) const
void fill_and_communicate_copy_indices(const DoFHandler< dim, spacedim > &mg_dof)
virtual MPI_Comm get_communicator() const
const IndexSet & locally_owned_mg_dofs(const unsigned int level) const
T min(const T &t, const MPI_Comm &mpi_communicator)
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_partitioner() const
const IndexSet & locally_owned_dofs() const
size_type n_elements() const
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)