17 #include <deal.II/base/logstream.h> 18 #include <deal.II/base/function.h> 20 #include <deal.II/lac/vector.h> 21 #include <deal.II/lac/block_vector.h> 22 #include <deal.II/lac/la_parallel_vector.h> 23 #include <deal.II/lac/la_parallel_block_vector.h> 24 #include <deal.II/lac/trilinos_epetra_vector.h> 25 #include <deal.II/lac/trilinos_vector.h> 26 #include <deal.II/lac/trilinos_parallel_block_vector.h> 27 #include <deal.II/grid/tria.h> 28 #include <deal.II/grid/tria_iterator.h> 29 #include <deal.II/fe/fe.h> 30 #include <deal.II/dofs/dof_accessor.h> 31 #include <deal.II/multigrid/mg_tools.h> 32 #include <deal.II/multigrid/mg_transfer.h> 33 #include <deal.II/multigrid/mg_transfer.templates.h> 34 #include <deal.II/multigrid/mg_transfer_internal.h> 38 DEAL_II_NAMESPACE_OPEN
44 template <
typename VectorType>
45 template <
int dim,
int spacedim>
50 internal::MGTransfer::fill_copy_indices(mg_dof, mg_constrained_dofs, copy_indices,
51 copy_indices_global_mine, copy_indices_level_mine);
56 my_perform_plain_copy =
61 if (my_perform_plain_copy)
69 for (
unsigned int i=0; i<copy_indices.back().size(); ++i)
70 if (copy_indices.back()[i].first != copy_indices.back()[i].second)
72 my_perform_plain_copy =
false;
84 ptria->get_communicator())
88 perform_plain_copy = my_perform_plain_copy;
93 template <
typename VectorType>
99 copy_indices_global_mine.clear();
100 copy_indices_level_mine.clear();
101 component_to_block_map.resize(0);
102 mg_constrained_dofs =
nullptr;
103 perform_plain_copy =
false;
108 template <
typename VectorType>
112 for (
unsigned int level = 0; level<copy_indices.size(); ++level)
114 for (
unsigned int i=0; i<copy_indices[level].size(); ++i)
115 os <<
"copy_indices[" << level
116 <<
"]\t" << copy_indices[level][i].first <<
'\t' << copy_indices[level][i].second << std::endl;
119 for (
unsigned int level = 0; level<copy_indices_level_mine.size(); ++level)
121 for (
unsigned int i=0; i<copy_indices_level_mine[level].size(); ++i)
122 os <<
"copy_ifrom [" << level
123 <<
"]\t" << copy_indices_level_mine[level][i].first <<
'\t' << copy_indices_level_mine[level][i].second << std::endl;
125 for (
unsigned int level = 0; level<copy_indices_global_mine.size(); ++level)
127 for (
unsigned int i=0; i<copy_indices_global_mine[level].size(); ++i)
128 os <<
"copy_ito [" << level
129 <<
"]\t" << copy_indices_global_mine[level][i].first <<
'\t' << copy_indices_global_mine[level][i].second << std::endl;
135 template <
typename VectorType>
139 std::size_t result =
sizeof(*this);
154 template <
int dim,
int spacedim,
typename Number>
157 const MPI_Comm mpi_communicator,
158 const bool transfer_solution_vectors,
159 std::vector<std::vector<std::pair<unsigned int, unsigned int> > > ©_indices,
160 std::vector<std::vector<std::pair<unsigned int, unsigned int> > > ©_indices_global_mine,
161 std::vector<std::vector<std::pair<unsigned int, unsigned int> > > ©_indices_level_mine,
166 std::vector<std::vector<std::pair<types::global_dof_index, types::global_dof_index> > >
168 std::vector<std::vector<std::pair<types::global_dof_index, types::global_dof_index> > >
169 my_copy_indices_global_mine;
170 std::vector<std::vector<std::pair<types::global_dof_index, types::global_dof_index> > >
171 my_copy_indices_level_mine;
173 internal::MGTransfer::fill_copy_indices(mg_dof, mg_constrained_dofs, my_copy_indices,
174 my_copy_indices_global_mine, my_copy_indices_level_mine,
175 !transfer_solution_vectors);
187 std::vector<types::global_dof_index> accessed_indices;
189 std::vector<IndexSet> level_index_set(mg_dof.
get_triangulation().n_global_levels());
192 for (
unsigned int i=0; i<my_copy_indices_level_mine[l].size(); ++i)
193 accessed_indices.push_back(my_copy_indices_level_mine[l][i].first);
194 std::vector<types::global_dof_index> accessed_level_indices;
195 for (
unsigned int i=0; i<my_copy_indices_global_mine[l].size(); ++i)
196 accessed_level_indices.push_back(my_copy_indices_global_mine[l][i].second);
197 std::sort(accessed_level_indices.begin(), accessed_level_indices.end());
199 level_index_set[l].add_indices(accessed_level_indices.begin(),
200 accessed_level_indices.end());
201 level_index_set[l].compress();
206 std::sort(accessed_indices.begin(), accessed_indices.end());
207 index_set.add_indices(accessed_indices.begin(), accessed_indices.end());
208 index_set.compress();
219 for (
unsigned int level=0; level<mg_dof.
get_triangulation().n_global_levels(); ++level)
224 *ghosted_level_vector[level].get_partitioner();
227 copy_indices[level].resize(my_copy_indices[level].size());
228 for (
unsigned int i=0; i<my_copy_indices[level].size(); ++i)
229 copy_indices[level][i] =
230 std::pair<unsigned int,unsigned int>
236 copy_indices_level_mine[level].
237 resize(my_copy_indices_level_mine[level].size());
238 for (
unsigned int i=0; i<my_copy_indices_level_mine[level].size(); ++i)
239 copy_indices_level_mine[level][i] =
240 std::pair<unsigned int,unsigned int>
241 (global_partitioner.
global_to_local(my_copy_indices_level_mine[level][i].first),
242 level_partitioner.
global_to_local(my_copy_indices_level_mine[level][i].second));
246 copy_indices_global_mine[level].
247 resize(my_copy_indices_global_mine[level].size());
248 for (
unsigned int i=0; i<my_copy_indices_global_mine[level].size(); ++i)
249 copy_indices_global_mine[level][i] =
250 std::pair<unsigned int,unsigned int>
251 (global_partitioner.
global_to_local(my_copy_indices_global_mine[level][i].first),
252 level_partitioner.
global_to_local(my_copy_indices_global_mine[level][i].second));
257 template <
typename Number>
258 template <
int dim,
int spacedim>
267 const MPI_Comm mpi_communicator = ptria !=
nullptr ? ptria->
get_communicator() :
270 fill_internal(mg_dof,
275 this->copy_indices_global_mine,
276 this->copy_indices_level_mine,
277 ghosted_global_vector,
278 ghosted_level_vector);
280 fill_internal(mg_dof,
284 this->solution_copy_indices,
285 this->solution_copy_indices_global_mine,
286 this->solution_copy_indices_level_mine,
287 solution_ghosted_global_vector,
288 solution_ghosted_level_vector);
290 bool my_perform_renumbered_plain_copy = (this->copy_indices.back().size() ==
292 bool my_perform_plain_copy =
false;
293 if (my_perform_renumbered_plain_copy)
295 my_perform_plain_copy =
true;
302 for (
unsigned int i=0; i<this->copy_indices.back().size(); ++i)
303 if (this->copy_indices.back()[i].first !=
304 this->copy_indices.back()[i].second)
306 my_perform_plain_copy =
false;
316 perform_renumbered_plain_copy =
321 if (perform_renumbered_plain_copy)
323 ghosted_global_vector.
reinit(0);
324 ghosted_level_vector.resize(0, 0);
325 solution_ghosted_global_vector.reinit(0);
326 solution_ghosted_level_vector.resize(0, 0);
332 template <
typename Number>
337 copy_indices.
clear();
338 copy_indices_global_mine.clear();
339 copy_indices_level_mine.clear();
340 component_to_block_map.resize(0);
341 mg_constrained_dofs =
nullptr;
342 ghosted_global_vector.
reinit(0);
343 ghosted_level_vector.resize(0, 0);
344 perform_plain_copy =
false;
345 perform_renumbered_plain_copy =
false;
350 template <
typename Number>
354 for (
unsigned int level = 0; level<copy_indices.size(); ++level)
356 for (
unsigned int i=0; i<copy_indices[level].size(); ++i)
357 os <<
"copy_indices[" << level
358 <<
"]\t" << copy_indices[level][i].first <<
'\t' << copy_indices[level][i].second << std::endl;
361 for (
unsigned int level = 0; level<copy_indices_level_mine.size(); ++level)
363 for (
unsigned int i=0; i<copy_indices_level_mine[level].size(); ++i)
364 os <<
"copy_ifrom [" << level
365 <<
"]\t" << copy_indices_level_mine[level][i].first <<
'\t' << copy_indices_level_mine[level][i].second << std::endl;
367 for (
unsigned int level = 0; level<copy_indices_global_mine.size(); ++level)
369 for (
unsigned int i=0; i<copy_indices_global_mine[level].size(); ++i)
370 os <<
"copy_ito [" << level
371 <<
"]\t" << copy_indices_global_mine[level][i].first <<
'\t' << copy_indices_global_mine[level][i].second << std::endl;
377 template <
typename Number>
381 std::size_t result =
sizeof(*this);
387 for (
unsigned int i=ghosted_level_vector.min_level();
388 i<=ghosted_level_vector.max_level(); ++i)
389 result += ghosted_level_vector[i].memory_consumption();
397 #include "mg_level_global_transfer.inst" 404 DEAL_II_NAMESPACE_CLOSE
void reinit(const size_type size, const bool omit_zeroing_entries=false)
#define AssertDimension(dim1, dim2)
std::size_t memory_consumption() const
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 std::size_t memory_consumption() const override
virtual MPI_Comm get_communicator() const
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_partitioner() const
const IndexSet & locally_owned_mg_dofs(const unsigned int level) const
T min(const T &t, const MPI_Comm &mpi_communicator)
const Triangulation< dim, spacedim > & get_triangulation() 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)