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/petsc_vector.h> 25 #include <deal.II/lac/petsc_block_vector.h> 26 #include <deal.II/lac/trilinos_vector.h> 27 #include <deal.II/lac/trilinos_block_vector.h> 28 #include <deal.II/grid/tria.h> 29 #include <deal.II/grid/tria_iterator.h> 30 #include <deal.II/fe/fe.h> 31 #include <deal.II/dofs/dof_accessor.h> 32 #include <deal.II/multigrid/mg_tools.h> 33 #include <deal.II/multigrid/mg_transfer.h> 34 #include <deal.II/multigrid/mg_transfer.templates.h> 35 #include <deal.II/multigrid/mg_transfer_internal.h> 39 DEAL_II_NAMESPACE_OPEN
45 template <
typename VectorType>
46 template <
int dim,
int spacedim>
51 internal::MGTransfer::fill_copy_indices(mg_dof, mg_constrained_dofs, copy_indices,
52 copy_indices_global_mine, copy_indices_level_mine);
61 if (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 perform_plain_copy =
false;
89 template <
typename VectorType>
95 copy_indices_global_mine.clear();
96 copy_indices_level_mine.clear();
97 component_to_block_map.resize(0);
98 mg_constrained_dofs = 0;
103 template <
typename VectorType>
107 for (
unsigned int level = 0; level<copy_indices.size(); ++level)
109 for (
unsigned int i=0; i<copy_indices[level].size(); ++i)
110 os <<
"copy_indices[" << level
111 <<
"]\t" << copy_indices[level][i].first <<
'\t' << copy_indices[level][i].second << std::endl;
114 for (
unsigned int level = 0; level<copy_indices_level_mine.size(); ++level)
116 for (
unsigned int i=0; i<copy_indices_level_mine[level].size(); ++i)
117 os <<
"copy_ifrom [" << level
118 <<
"]\t" << copy_indices_level_mine[level][i].first <<
'\t' << copy_indices_level_mine[level][i].second << std::endl;
120 for (
unsigned int level = 0; level<copy_indices_global_mine.size(); ++level)
122 for (
unsigned int i=0; i<copy_indices_global_mine[level].size(); ++i)
123 os <<
"copy_ito [" << level
124 <<
"]\t" << copy_indices_global_mine[level][i].first <<
'\t' << copy_indices_global_mine[level][i].second << std::endl;
130 template <
typename VectorType>
134 std::size_t result =
sizeof(*this);
148 template <
typename Number>
149 template <
int dim,
int spacedim>
155 std::vector<std::vector<std::pair<types::global_dof_index, types::global_dof_index> > >
157 std::vector<std::vector<std::pair<types::global_dof_index, types::global_dof_index> > >
158 my_copy_indices_global_mine;
159 std::vector<std::vector<std::pair<types::global_dof_index, types::global_dof_index> > >
160 my_copy_indices_level_mine;
162 internal::MGTransfer::fill_copy_indices(mg_dof, mg_constrained_dofs, my_copy_indices,
163 my_copy_indices_global_mine, my_copy_indices_level_mine);
180 std::vector<types::global_dof_index> accessed_indices;
182 std::vector<IndexSet> level_index_set(mg_dof.
get_triangulation().n_global_levels());
185 for (
unsigned int i=0; i<my_copy_indices_level_mine[l].size(); ++i)
186 accessed_indices.push_back(my_copy_indices_level_mine[l][i].first);
187 std::vector<types::global_dof_index> accessed_level_indices;
188 for (
unsigned int i=0; i<my_copy_indices_global_mine[l].size(); ++i)
189 accessed_level_indices.push_back(my_copy_indices_global_mine[l][i].second);
190 std::sort(accessed_level_indices.begin(), accessed_level_indices.end());
192 level_index_set[l].add_indices(accessed_level_indices.begin(),
193 accessed_level_indices.end());
194 level_index_set[l].compress();
199 std::sort(accessed_indices.begin(), accessed_indices.end());
200 index_set.add_indices(accessed_indices.begin(), accessed_indices.end());
201 index_set.compress();
210 this->copy_indices_level_mine.resize(mg_dof.
get_triangulation().n_global_levels());
211 this->copy_indices_global_mine.resize(mg_dof.
get_triangulation().n_global_levels());
212 for (
unsigned int level=0; level<mg_dof.
get_triangulation().n_global_levels(); ++level)
215 *ghosted_global_vector.get_partitioner();
217 *ghosted_level_vector[level].get_partitioner();
220 this->copy_indices[level].resize(my_copy_indices[level].size());
221 for (
unsigned int i=0; i<my_copy_indices[level].size(); ++i)
222 this->copy_indices[level][i] =
223 std::pair<unsigned int,unsigned int>
229 this->copy_indices_level_mine[level].
230 resize(my_copy_indices_level_mine[level].size());
231 for (
unsigned int i=0; i<my_copy_indices_level_mine[level].size(); ++i)
232 this->copy_indices_level_mine[level][i] =
233 std::pair<unsigned int,unsigned int>
234 (global_partitioner.
global_to_local(my_copy_indices_level_mine[level][i].first),
235 level_partitioner.
global_to_local(my_copy_indices_level_mine[level][i].second));
239 this->copy_indices_global_mine[level].
240 resize(my_copy_indices_global_mine[level].size());
241 for (
unsigned int i=0; i<my_copy_indices_global_mine[level].size(); ++i)
242 this->copy_indices_global_mine[level][i] =
243 std::pair<unsigned int,unsigned int>
244 (global_partitioner.
global_to_local(my_copy_indices_global_mine[level][i].first),
245 level_partitioner.
global_to_local(my_copy_indices_global_mine[level][i].second));
248 perform_plain_copy = this->copy_indices.back().size()
250 if (perform_plain_copy)
258 for (
unsigned int i=0; i<this->copy_indices.back().size(); ++i)
259 if (this->copy_indices.back()[i].first !=
260 this->copy_indices.back()[i].second)
262 perform_plain_copy =
false;
271 if (perform_plain_copy)
273 ghosted_global_vector.reinit(0);
274 ghosted_level_vector.resize(0, 0);
280 template <
typename Number>
285 copy_indices.
clear();
286 copy_indices_global_mine.clear();
287 copy_indices_level_mine.clear();
288 component_to_block_map.resize(0);
289 mg_constrained_dofs = 0;
290 ghosted_global_vector.reinit(0);
291 ghosted_level_vector.resize(0, 0);
296 template <
typename Number>
300 for (
unsigned int level = 0; level<copy_indices.size(); ++level)
302 for (
unsigned int i=0; i<copy_indices[level].size(); ++i)
303 os <<
"copy_indices[" << level
304 <<
"]\t" << copy_indices[level][i].first <<
'\t' << copy_indices[level][i].second << std::endl;
307 for (
unsigned int level = 0; level<copy_indices_level_mine.size(); ++level)
309 for (
unsigned int i=0; i<copy_indices_level_mine[level].size(); ++i)
310 os <<
"copy_ifrom [" << level
311 <<
"]\t" << copy_indices_level_mine[level][i].first <<
'\t' << copy_indices_level_mine[level][i].second << std::endl;
313 for (
unsigned int level = 0; level<copy_indices_global_mine.size(); ++level)
315 for (
unsigned int i=0; i<copy_indices_global_mine[level].size(); ++i)
316 os <<
"copy_ito [" << level
317 <<
"]\t" << copy_indices_global_mine[level][i].first <<
'\t' << copy_indices_global_mine[level][i].second << std::endl;
323 template <
typename Number>
327 std::size_t result =
sizeof(*this);
332 result += ghosted_global_vector.memory_consumption();
333 for (
unsigned int i=ghosted_level_vector.min_level();
334 i<=ghosted_level_vector.max_level(); ++i)
335 result += ghosted_level_vector[i].memory_consumption();
343 #include "mg_level_global_transfer.inst" 350 DEAL_II_NAMESPACE_CLOSE
#define AssertDimension(dim1, dim2)
std::size_t memory_consumption() const
const Triangulation< dim, spacedim > & get_tria() const 1
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
std_cxx11::enable_if< std_cxx11::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
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