32 template <
int dim,
int spacedim>
34 pack_particles(std::vector<ParticleIterator<dim, spacedim>> &particles)
36 std::vector<char> buffer;
38 if (particles.size() == 0)
41 buffer.resize(particles.size() *
42 particles.front()->serialized_size_in_bytes());
43 void *current_data = buffer.data();
45 for (
const auto &particle : particles)
47 current_data = particle->write_particle_data_to_memory(current_data);
56 template <
int dim,
int spacedim>
61 , global_number_of_particles(0)
62 , number_of_locally_owned_particles(0)
63 , global_max_particles_per_cell(0)
64 , next_free_particle_index(0)
68 , handle(
numbers::invalid_unsigned_int)
76 template <
int dim,
int spacedim>
80 const unsigned int n_properties)
82 , mapping(&mapping, typeid(*this).name())
83 , property_pool(
std::make_unique<
PropertyPool<dim, spacedim>>(n_properties))
84 , cells_to_particle_cache(
triangulation.n_active_cells(), particles.end())
85 , global_number_of_particles(0)
86 , number_of_locally_owned_particles(0)
87 , global_max_particles_per_cell(0)
88 , next_free_particle_index(0)
92 , handle(
numbers::invalid_unsigned_int)
93 , triangulation_cache(
104 template <
int dim,
int spacedim>
109 for (
const auto &connection : tria_listeners)
110 connection.disconnect();
115 template <
int dim,
int spacedim>
120 const unsigned int n_properties)
125 mapping = &new_mapping;
127 reset_particle_container(particles);
130 property_pool = std::make_unique<PropertyPool<dim, spacedim>>(n_properties);
134 triangulation_cache =
135 std::make_unique<GridTools::Cache<dim, spacedim>>(new_triangulation,
138 cells_to_particle_cache.resize(
triangulation->n_active_cells(),
141 connect_to_triangulation_signals();
146 template <
int dim,
int spacedim>
151 const unsigned int n_properties =
157 property_pool = std::make_unique<PropertyPool<dim, spacedim>>(
162 number_of_locally_owned_particles =
165 global_max_particles_per_cell =
171 particles.insert(particle_container_owned_end(),
174 particles.insert(particle_container_ghost_end(),
178 for (
auto it = particles.begin(); it != particles.end(); ++it)
179 if (!it->particles.empty())
180 cells_to_particle_cache[it->cell->active_cell_index()] = it;
182 ghost_particles_cache.ghost_particles_by_domain =
184 handle = particle_handler.
handle;
189 template <
int dim,
int spacedim>
194 global_number_of_particles = 0;
195 number_of_locally_owned_particles = 0;
196 next_free_particle_index = 0;
197 global_max_particles_per_cell = 0;
202 template <
int dim,
int spacedim>
206 for (
auto &particles_in_cell : particles)
207 for (
auto &particle : particles_in_cell.particles)
209 property_pool->deregister_particle(particle);
211 cells_to_particle_cache.clear();
212 reset_particle_container(particles);
214 cells_to_particle_cache.resize(
triangulation->n_active_cells(),
219 property_pool->clear();
224 template <
int dim,
int spacedim>
228 property_pool->reserve(n_particles);
233 template <
int dim,
int spacedim>
241 past_the_end_iterator =
246 given_particles.clear();
247 for (
unsigned int i = 0; i < 3; ++i)
248 given_particles.emplace_back(
250 past_the_end_iterator);
253 const_cast<typename particle_container::iterator &
>(owned_particles_end) =
254 ++given_particles.begin();
259 template <
int dim,
int spacedim>
264 bool sort_is_necessary =
false;
266 auto previous = particle_container_owned_begin();
267 for (
auto next = previous; next != particle_container_owned_end(); ++next)
271 previous->cell > next->cell)
273 sort_is_necessary =
true;
279 if (sort_is_necessary)
294 reset_particle_container(sorted_particles);
297 for (
const auto &cell :
triangulation->active_cell_iterators())
298 if (!cell->is_artificial())
299 if (cells_to_particle_cache[cell->active_cell_index()] !=
306 typename particle_container::iterator insert_position =
307 cell->is_locally_owned() ? particle_container_owned_end() :
308 --sorted_particles.end();
309 typename particle_container::iterator new_entry =
310 sorted_particles.insert(
311 insert_position,
typename particle_container::value_type());
312 new_entry->cell = cell;
313 new_entry->particles =
314 std::move(cells_to_particle_cache[cell->active_cell_index()]
317 particles = std::move(sorted_particles);
320 cells_to_particle_cache.clear();
321 cells_to_particle_cache.resize(
triangulation->n_active_cells(),
323 for (
auto it = particles.begin(); it != particles.end(); ++it)
324 if (!it->particles.empty())
325 cells_to_particle_cache[it->cell->active_cell_index()] = it;
331 particles.front().particles.empty() &&
333 particles.back().particles.empty() &&
335 owned_particles_end->particles.empty(),
341 for (
const auto &it : cells_to_particle_cache)
342 Assert(it != particles.begin() && it != owned_particles_end &&
343 it != --(particles.end()),
348 for (
auto it = particle_container_owned_begin();
349 it != particle_container_owned_end();
354 std::vector<typename particle_container::iterator> verify_cache(
356 for (
auto it = particles.begin(); it != particles.end(); ++it)
357 if (!it->particles.empty())
358 verify_cache[it->cell->active_cell_index()] = it;
360 for (
unsigned int i = 0; i < verify_cache.size(); ++i)
366 number_of_locally_owned_particles = 0;
369 for (
const auto &particles_in_cell : particles)
372 particles_in_cell.particles.size();
375 result[0] =
std::max(result[0], n_particles_in_cell);
378 if (n_particles_in_cell > 0 &&
379 particles_in_cell.cell->is_locally_owned())
380 number_of_locally_owned_particles += n_particles_in_cell;
383 for (
const auto &particle : particles_in_cell.particles)
384 result[1] =
std::max(result[1], property_pool->get_id(particle));
387 global_number_of_particles =
391 if (global_number_of_particles == 0)
393 next_free_particle_index = 0;
394 global_max_particles_per_cell = 0;
400 next_free_particle_index = result[1] + 1;
401 global_max_particles_per_cell = result[0];
407 template <
int dim,
int spacedim>
413 if (cells_to_particle_cache.size() == 0)
416 if (cell->is_artificial() ==
false)
418 return cells_to_particle_cache[cell->active_cell_index()] !=
420 cells_to_particle_cache[cell->active_cell_index()]
426 ExcMessage(
"You can't ask for the particles on an artificial "
427 "cell since we don't know what exists on these "
435 template <
int dim,
int spacedim>
442 ->particles_in_cell(cell);
447 template <
int dim,
int spacedim>
452 const unsigned int active_cell_index = cell->active_cell_index();
454 if (cell->is_artificial() ==
false)
456 if (cells_to_particle_cache[active_cell_index] == particles.end())
458 return boost::make_iterator_range(
464 const typename particle_container::iterator
465 particles_in_current_cell =
466 cells_to_particle_cache[active_cell_index];
467 typename particle_container::iterator particles_in_next_cell =
468 particles_in_current_cell;
469 ++particles_in_next_cell;
470 return boost::make_iterator_range(
477 ExcMessage(
"You can't ask for the particles on an artificial "
478 "cell since we don't know what exists on these "
486 template <
int dim,
int spacedim>
491 auto &particles_on_cell = particle->particles_in_cell->particles;
496 auto handle = particle->get_handle();
498 property_pool->deregister_particle(handle);
503 const auto cell = particle->get_surrounding_cell();
504 const bool owned_cell = cell->is_locally_owned();
506 --number_of_locally_owned_particles;
508 if (particles_on_cell.size() > 1)
510 particles_on_cell[particle->particle_index_within_cell] =
511 std::move(particles_on_cell.back());
512 particles_on_cell.resize(particles_on_cell.size() - 1);
516 particles.erase(particle->particles_in_cell);
517 cells_to_particle_cache[cell->active_cell_index()] = particles.end();
523 template <
int dim,
int spacedim>
527 &particles_to_remove)
535 return a->particles_in_cell->cell > b->particles_in_cell->cell ||
536 (a->particles_in_cell->cell == b->particles_in_cell->cell &&
537 a->particle_index_within_cell > b->particle_index_within_cell);
540 bool particles_are_sorted =
true;
541 auto previous = particles_to_remove.begin();
542 for (
auto next = previous; next != particles_to_remove.end(); ++next)
544 if (check_greater(*previous, *next))
546 particles_are_sorted =
false;
551 if (particles_are_sorted)
554 for (
auto it = particles_to_remove.rbegin();
555 it != particles_to_remove.rend();
557 remove_particle(*it);
561 std::vector<ParticleHandler<dim, spacedim>::particle_iterator>
562 sorted_particles(particles_to_remove);
563 std::sort(sorted_particles.begin(),
564 sorted_particles.end(),
567 for (
const auto &particle : sorted_particles)
568 remove_particle(particle);
571 update_cached_numbers();
576 template <
int dim,
int spacedim>
591 template <
int dim,
int spacedim>
597 const unsigned int active_cell_index = cell->active_cell_index();
598 typename particle_container::iterator &cache =
599 cells_to_particle_cache[active_cell_index];
600 if (cache == particles.end())
602 const typename particle_container::iterator insert_position =
603 cell->is_locally_owned() ? particle_container_owned_end() :
604 particle_container_ghost_end();
605 cache = particles.emplace(
612 cache->particles.push_back(handle);
617 cache->particles.size() - 1);
622 template <
int dim,
int spacedim>
631 Assert(cell->is_locally_owned(),
632 ExcMessage(
"You tried to insert particles into a cell that is not "
633 "locally owned. This is not supported."));
636 insert_particle(property_pool->register_particle(), cell);
638 data = particle_it->read_particle_data_from_memory(data);
640 ++number_of_locally_owned_particles;
647 template <
int dim,
int spacedim>
660 Assert(cell->is_locally_owned(),
661 ExcMessage(
"You tried to insert particles into a cell that is not "
662 "locally owned. This is not supported."));
665 insert_particle(property_pool->register_particle(), cell);
667 particle_it->set_location(position);
668 particle_it->set_reference_location(reference_position);
669 particle_it->set_id(particle_index);
671 if (properties.
size() != 0)
672 particle_it->set_properties(properties);
674 ++number_of_locally_owned_particles;
681 template <
int dim,
int spacedim>
688 reserve(n_locally_owned_particles() + new_particles.size());
689 for (
const auto &cell_and_particle : new_particles)
690 insert_particle(cell_and_particle.second, cell_and_particle.first);
692 update_cached_numbers();
697 template <
int dim,
int spacedim>
704 update_cached_numbers();
705 reserve(n_locally_owned_particles() + positions.size());
712 get_next_free_particle_index();
715#ifdef DEAL_II_WITH_MPI
716 if (
const auto parallel_triangulation =
721 const int ierr = MPI_Scan(&particles_to_add_locally,
726 parallel_triangulation->get_communicator());
728 local_start_index -= particles_to_add_locally;
732 local_start_index += local_next_particle_index;
734 auto point_locations =
738 auto &cells = std::get<0>(point_locations);
739 auto &local_positions = std::get<1>(point_locations);
740 auto &index_map = std::get<2>(point_locations);
741 auto &missing_points = std::get<3>(point_locations);
747 (void)missing_points;
749 for (
unsigned int i = 0; i < cells.size(); ++i)
750 for (
unsigned int p = 0; p < local_positions[i].size(); ++p)
751 insert_particle(positions[index_map[i][p]],
752 local_positions[i][p],
753 local_start_index + index_map[i][p],
756 update_cached_numbers();
761 template <
int dim,
int spacedim>
762 std::map<unsigned int, IndexSet>
766 & global_bounding_boxes,
767 const std::vector<std::vector<double>> & properties,
768 const std::vector<types::particle_index> &ids)
770 if (!properties.empty())
774 for (
const auto &p : properties)
787 const auto n_global_properties =
791 const auto n_particles_per_proc =
795 std::vector<unsigned int> particle_start_indices(n_mpi_processes);
797 unsigned int particle_start_index = get_next_free_particle_index();
798 for (
unsigned int process = 0; process < particle_start_indices.size();
801 particle_start_indices[process] = particle_start_index;
802 particle_start_index += n_particles_per_proc[process];
806 const auto cells_positions_and_index_maps =
809 global_bounding_boxes);
813 const auto &local_cells_containing_particles =
814 std::get<0>(cells_positions_and_index_maps);
818 const auto &local_reference_positions =
819 std::get<1>(cells_positions_and_index_maps);
822 const auto &original_indices_of_local_particles =
823 std::get<2>(cells_positions_and_index_maps);
826 const auto &local_positions = std::get<3>(cells_positions_and_index_maps);
828 const auto &calling_process_indices =
829 std::get<4>(cells_positions_and_index_maps);
832 std::map<unsigned int, std::vector<unsigned int>>
833 original_process_to_local_particle_indices_tmp;
834 for (
unsigned int i_cell = 0;
835 i_cell < local_cells_containing_particles.size();
838 for (
unsigned int i_particle = 0;
839 i_particle < local_positions[i_cell].size();
842 const unsigned int local_id_on_calling_process =
843 original_indices_of_local_particles[i_cell][i_particle];
844 const unsigned int calling_process =
845 calling_process_indices[i_cell][i_particle];
847 original_process_to_local_particle_indices_tmp[calling_process]
848 .push_back(local_id_on_calling_process);
851 std::map<unsigned int, IndexSet> original_process_to_local_particle_indices;
852 for (
auto &process_and_particle_indices :
853 original_process_to_local_particle_indices_tmp)
855 const unsigned int calling_process = process_and_particle_indices.first;
856 original_process_to_local_particle_indices.insert(
857 {calling_process,
IndexSet(n_particles_per_proc[calling_process])});
858 std::sort(process_and_particle_indices.second.begin(),
859 process_and_particle_indices.second.end());
860 original_process_to_local_particle_indices[calling_process].add_indices(
861 process_and_particle_indices.second.begin(),
862 process_and_particle_indices.second.end());
863 original_process_to_local_particle_indices[calling_process].compress();
871 std::map<unsigned int, std::vector<std::vector<double>>>
872 locally_owned_properties_from_other_processes;
879 std::map<unsigned int, std::vector<types::particle_index>>
880 locally_owned_ids_from_other_processes;
882 if (n_global_properties > 0 || !ids.empty())
887 comm, original_process_to_local_particle_indices);
890 if (n_global_properties > 0)
892 std::map<unsigned int, std::vector<std::vector<double>>>
893 non_locally_owned_properties;
895 for (
const auto &it : send_to_cpu)
897 std::vector<std::vector<double>> properties_to_send(
898 it.second.n_elements(),
899 std::vector<double>(n_properties_per_particle()));
900 unsigned int index = 0;
901 for (
const auto el : it.second)
902 properties_to_send[index++] = properties[el];
903 non_locally_owned_properties.insert(
904 {it.first, properties_to_send});
909 locally_owned_properties_from_other_processes =
913 locally_owned_properties_from_other_processes.size(),
914 original_process_to_local_particle_indices.size());
919 std::map<unsigned int, std::vector<types::particle_index>>
920 non_locally_owned_ids;
921 for (
const auto &it : send_to_cpu)
923 std::vector<types::particle_index> ids_to_send(
924 it.second.n_elements());
925 unsigned int index = 0;
926 for (
const auto el : it.second)
927 ids_to_send[index++] = ids[el];
928 non_locally_owned_ids.insert({it.first, ids_to_send});
933 locally_owned_ids_from_other_processes =
937 original_process_to_local_particle_indices.size());
942 for (
unsigned int i_cell = 0;
943 i_cell < local_cells_containing_particles.size();
946 for (
unsigned int i_particle = 0;
947 i_particle < local_positions[i_cell].size();
950 const unsigned int local_id_on_calling_process =
951 original_indices_of_local_particles[i_cell][i_particle];
953 const unsigned int calling_process =
954 calling_process_indices[i_cell][i_particle];
956 const unsigned int index_within_set =
957 original_process_to_local_particle_indices[calling_process]
958 .index_within_set(local_id_on_calling_process);
960 const unsigned int particle_id =
962 local_id_on_calling_process +
963 particle_start_indices[calling_process] :
964 locally_owned_ids_from_other_processes[calling_process]
968 insert_particle(local_positions[i_cell][i_particle],
969 local_reference_positions[i_cell][i_particle],
971 local_cells_containing_particles[i_cell]);
973 if (n_global_properties > 0)
975 particle_it->set_properties(
976 locally_owned_properties_from_other_processes
977 [calling_process][index_within_set]);
982 update_cached_numbers();
984 return original_process_to_local_particle_indices;
989 template <
int dim,
int spacedim>
990 std::map<unsigned int, IndexSet>
994 &global_bounding_boxes)
998 std::vector<Point<spacedim>> positions;
999 std::vector<std::vector<double>> properties;
1000 std::vector<types::particle_index> ids;
1001 positions.resize(particles.size());
1002 ids.resize(particles.size());
1003 if (n_properties_per_particle() > 0)
1004 properties.resize(particles.size(),
1005 std::vector<double>(n_properties_per_particle()));
1008 for (
const auto &p : particles)
1010 positions[i] = p.get_location();
1011 ids[i] = p.get_id();
1012 if (p.has_properties())
1013 properties[i] = {p.get_properties().begin(),
1014 p.get_properties().end()};
1018 return insert_global_particles(positions,
1019 global_bounding_boxes,
1026 template <
int dim,
int spacedim>
1030 return global_number_of_particles;
1035 template <
int dim,
int spacedim>
1039 return global_max_particles_per_cell;
1044 template <
int dim,
int spacedim>
1048 return number_of_locally_owned_particles;
1053 template <
int dim,
int spacedim>
1057 return property_pool->n_properties_per_slot();
1062 template <
int dim,
int spacedim>
1066 return next_free_particle_index;
1071 template <
int dim,
int spacedim>
1075 IndexSet set(get_next_free_particle_index());
1076 std::vector<types::particle_index> indices;
1077 indices.reserve(n_locally_owned_particles());
1078 for (
const auto &p : *
this)
1079 indices.push_back(p.get_id());
1080 set.add_indices(indices.begin(), indices.end());
1087 template <
int dim,
int spacedim>
1091 return property_pool->n_slots();
1096 template <
int dim,
int spacedim>
1100 const bool add_to_output_vector)
1106 for (
auto it = begin(); it != end(); ++it, ++i)
1108 if (add_to_output_vector)
1109 positions[i] = positions[i] + it->get_location();
1111 positions[i] = it->get_location();
1117 template <
int dim,
int spacedim>
1121 const bool displace_particles)
1127 for (
auto it = begin(); it != end(); ++it, ++i)
1129 if (displace_particles)
1130 it->set_location(it->get_location() + new_positions[i]);
1132 it->set_location(new_positions[i]);
1134 sort_particles_into_subdomains_and_cells();
1139 template <
int dim,
int spacedim>
1143 const bool displace_particles)
1150 for (
auto &particle : *
this)
1153 function.
vector_value(particle_location, new_position);
1154 if (displace_particles)
1155 for (
unsigned int d = 0; d < spacedim; ++d)
1156 particle_location[d] += new_position[d];
1158 for (
unsigned int d = 0; d < spacedim; ++d)
1159 particle_location[d] = new_position[d];
1160 particle.set_location(particle_location);
1162 sort_particles_into_subdomains_and_cells();
1167 template <
int dim,
int spacedim>
1171 return *property_pool;
1189 compare_particle_association(
1190 const unsigned int a,
1191 const unsigned int b,
1195 const double scalar_product_a = center_directions[a] * particle_direction;
1196 const double scalar_product_b = center_directions[b] * particle_direction;
1201 return (scalar_product_a > scalar_product_b);
1207 template <
int dim,
int spacedim>
1223 std::vector<particle_iterator> particles_out_of_cell;
1228 particles_out_of_cell.reserve(n_locally_owned_particles() / 4);
1231 std::vector<Point<spacedim>> real_locations;
1232 std::vector<Point<dim>> reference_locations;
1233 real_locations.reserve(global_max_particles_per_cell);
1234 reference_locations.reserve(global_max_particles_per_cell);
1236 for (
const auto &cell :
triangulation->active_cell_iterators())
1243 if (cell->is_locally_owned() ==
false)
1248 const unsigned int n_pic = n_particles_in_cell(cell);
1249 auto pic = particles_in_cell(cell);
1251 real_locations.clear();
1252 for (
const auto &particle : pic)
1253 real_locations.push_back(particle.get_location());
1255 reference_locations.resize(n_pic);
1256 mapping->transform_points_real_to_unit_cell(cell,
1258 reference_locations);
1260 auto particle = pic.begin();
1261 for (
const auto &p_unit : reference_locations)
1263 if (p_unit[0] == std::numeric_limits<double>::infinity() ||
1265 particles_out_of_cell.push_back(particle);
1267 particle->set_reference_location(p_unit);
1279 std::map<types::subdomain_id, std::vector<particle_iterator>>
1283 std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator>>
1291 using vector_size =
typename std::vector<particle_iterator>::size_type;
1293 std::set<types::subdomain_id> ghost_owners;
1294 if (
const auto parallel_triangulation =
1297 ghost_owners = parallel_triangulation->ghost_owners();
1302 for (
const auto &ghost_owner : ghost_owners)
1303 moved_particles[ghost_owner].reserve(particles_out_of_cell.size() / 4);
1304 for (
const auto &ghost_owner : ghost_owners)
1305 moved_cells[ghost_owner].reserve(particles_out_of_cell.size() / 4);
1310 std::set<typename Triangulation<dim, spacedim>::active_cell_iterator>>
1311 &vertex_to_cells = triangulation_cache->get_vertex_to_cell_map();
1315 const std::vector<std::vector<Tensor<1, spacedim>>>
1316 &vertex_to_cell_centers =
1317 triangulation_cache->get_vertex_to_cell_centers_directions();
1319 std::vector<unsigned int> neighbor_permutation;
1325 invalid_reference_point[0] = std::numeric_limits<double>::infinity();
1326 invalid_point[0] = std::numeric_limits<double>::infinity();
1327 reference_locations.resize(1, invalid_reference_point);
1328 real_locations.resize(1, invalid_point);
1331 for (
auto &out_particle : particles_out_of_cell)
1336 auto current_cell = out_particle->get_surrounding_cell();
1338 real_locations[0] = out_particle->get_location();
1341 bool found_cell =
false;
1345 const unsigned int closest_vertex =
1346 GridTools::find_closest_vertex_of_cell<dim, spacedim>(
1347 current_cell, out_particle->get_location(), *mapping);
1349 out_particle->get_location() - current_cell->vertex(closest_vertex);
1350 vertex_to_particle /= vertex_to_particle.
norm();
1352 const unsigned int closest_vertex_index =
1353 current_cell->vertex_index(closest_vertex);
1354 const unsigned int n_neighbor_cells =
1355 vertex_to_cells[closest_vertex_index].size();
1357 neighbor_permutation.resize(n_neighbor_cells);
1358 for (
unsigned int i = 0; i < n_neighbor_cells; ++i)
1359 neighbor_permutation[i] = i;
1361 const auto &cell_centers =
1362 vertex_to_cell_centers[closest_vertex_index];
1363 std::sort(neighbor_permutation.begin(),
1364 neighbor_permutation.end(),
1365 [&vertex_to_particle, &cell_centers](
const unsigned int a,
1366 const unsigned int b) {
1367 return compare_particle_association(a,
1375 for (
unsigned int i = 0; i < n_neighbor_cells; ++i)
1377 typename std::set<typename Triangulation<dim, spacedim>::
1378 active_cell_iterator>::const_iterator cell =
1379 vertex_to_cells[closest_vertex_index].begin();
1381 std::advance(cell, neighbor_permutation[i]);
1382 mapping->transform_points_real_to_unit_cell(*cell,
1384 reference_locations);
1387 reference_locations[0]))
1389 current_cell = *cell;
1400 std::vector<std::pair<Point<spacedim>,
unsigned int>>
1401 closest_vertex_in_domain;
1402 triangulation_cache->get_used_vertices_rtree().query(
1403 boost::geometry::index::nearest(out_particle->get_location(),
1405 std::back_inserter(closest_vertex_in_domain));
1409 const unsigned int closest_vertex_index_in_domain =
1410 closest_vertex_in_domain[0].second;
1414 for (
const auto &cell :
1415 vertex_to_cells[closest_vertex_index_in_domain])
1417 mapping->transform_points_real_to_unit_cell(
1418 cell, real_locations, reference_locations);
1421 reference_locations[0]))
1423 current_cell = cell;
1435 signals.particle_lost(out_particle,
1436 out_particle->get_surrounding_cell());
1442 out_particle->set_reference_location(reference_locations[0]);
1446 if (current_cell->is_locally_owned())
1449 out_particle->particles_in_cell
1450 ->particles[out_particle->particle_index_within_cell];
1453 const auto old_value = old;
1457 insert_particle(old_value, current_cell);
1461 moved_particles[current_cell->subdomain_id()].push_back(
1463 moved_cells[current_cell->subdomain_id()].push_back(current_cell);
1469#ifdef DEAL_II_WITH_MPI
1470 if (
const auto parallel_triangulation =
1475 parallel_triangulation->get_communicator()) > 1)
1476 send_recv_particles(moved_particles, moved_cells);
1481 remove_particles(particles_out_of_cell);
1484 std::vector<typename PropertyPool<dim, spacedim>::Handle> unsorted_handles;
1485 unsorted_handles.reserve(property_pool->n_registered_slots());
1488 for (
auto &particles_in_cell : particles)
1489 for (
auto &particle : particles_in_cell.particles)
1491 unsorted_handles.push_back(particle);
1492 particle = sorted_handle++;
1495 property_pool->sort_memory_slots(unsorted_handles);
1501 template <
int dim,
int spacedim>
1504 const bool enable_cache)
1507 const auto parallel_triangulation =
1510 if (parallel_triangulation !=
nullptr)
1513 parallel_triangulation->get_communicator()) == 1)
1519#ifndef DEAL_II_WITH_MPI
1523 for (
const auto &cell :
triangulation->active_cell_iterators())
1524 if (cell->is_ghost() &&
1525 cells_to_particle_cache[cell->active_cell_index()] != particles.end())
1527 Assert(cells_to_particle_cache[cell->active_cell_index()]->cell ==
1531 for (
auto &ghost_particle :
1532 cells_to_particle_cache[cell->active_cell_index()]->particles)
1533 property_pool->deregister_particle(ghost_particle);
1536 particles.erase(cells_to_particle_cache[cell->active_cell_index()]);
1537 cells_to_particle_cache[cell->active_cell_index()] = particles.end();
1541 ghost_particles_cache.ghost_particles_by_domain.clear();
1542 ghost_particles_cache.valid =
false;
1544 const std::set<types::subdomain_id> ghost_owners =
1545 parallel_triangulation->ghost_owners();
1546 for (
const auto ghost_owner : ghost_owners)
1547 ghost_particles_cache.ghost_particles_by_domain[ghost_owner].reserve(
1548 n_locally_owned_particles() / 4);
1550 const std::vector<std::set<unsigned int>> vertex_to_neighbor_subdomain =
1551 triangulation_cache->get_vertex_to_neighbor_subdomain();
1553 for (
const auto &cell :
triangulation->active_cell_iterators())
1555 if (cell->is_locally_owned())
1557 std::set<unsigned int> cell_to_neighbor_subdomain;
1558 for (
const unsigned int v : cell->vertex_indices())
1560 cell_to_neighbor_subdomain.insert(
1561 vertex_to_neighbor_subdomain[cell->vertex_index(v)].begin(),
1562 vertex_to_neighbor_subdomain[cell->vertex_index(v)].end());
1565 if (cell_to_neighbor_subdomain.size() > 0)
1568 particles_in_cell(cell);
1570 for (
const auto domain : cell_to_neighbor_subdomain)
1572 for (
typename particle_iterator_range::iterator particle =
1573 particle_range.begin();
1574 particle != particle_range.end();
1576 ghost_particles_cache.ghost_particles_by_domain[domain]
1577 .push_back(particle);
1583 send_recv_particles(
1584 ghost_particles_cache.ghost_particles_by_domain,
1595 template <
int dim,
int spacedim>
1600 const auto parallel_triangulation =
1603 if (parallel_triangulation ==
nullptr ||
1605 parallel_triangulation->get_communicator()) == 1)
1611#ifdef DEAL_II_WITH_MPI
1614 Assert(ghost_particles_cache.valid,
1616 "Ghost particles cannot be updated if they first have not been "
1617 "exchanged at least once with the cache enabled"));
1620 send_recv_particles_properties_and_location(
1621 ghost_particles_cache.ghost_particles_by_domain);
1627#ifdef DEAL_II_WITH_MPI
1628 template <
int dim,
int spacedim>
1637 const bool build_cache)
1643 ghost_particles_cache.valid = build_cache;
1645 const auto parallel_triangulation =
1648 Assert(parallel_triangulation,
1649 ExcMessage(
"This function is only implemented for "
1650 "parallel::TriangulationBase objects."));
1653 const std::set<types::subdomain_id> ghost_owners =
1654 parallel_triangulation->ghost_owners();
1655 const std::vector<types::subdomain_id> neighbors(ghost_owners.begin(),
1656 ghost_owners.end());
1657 const unsigned int n_neighbors = neighbors.size();
1659 if (send_cells.size() != 0)
1665 particles_to_send.end(),
1670 for (
auto send_particles = particles_to_send.begin();
1671 send_particles != particles_to_send.end();
1673 Assert(ghost_owners.find(send_particles->first) != ghost_owners.end(),
1676 std::size_t n_send_particles = 0;
1677 for (
auto send_particles = particles_to_send.begin();
1678 send_particles != particles_to_send.end();
1680 n_send_particles += send_particles->second.size();
1686 std::vector<unsigned int> n_send_data(n_neighbors, 0);
1687 std::vector<unsigned int> send_offsets(n_neighbors, 0);
1688 std::vector<char> send_data;
1693 const unsigned int individual_particle_data_size =
1695 (size_callback ? size_callback() : 0);
1697 const unsigned int individual_total_particle_data_size =
1698 individual_particle_data_size + cellid_size;
1703 if (n_send_particles > 0)
1706 send_data.resize(n_send_particles *
1707 individual_total_particle_data_size);
1709 void *data =
static_cast<void *
>(&send_data.front());
1712 for (
unsigned int i = 0; i < n_neighbors; ++i)
1714 send_offsets[i] =
reinterpret_cast<std::size_t
>(data) -
1715 reinterpret_cast<std::size_t
>(&send_data.front());
1717 const unsigned int n_particles_to_send =
1718 particles_to_send.at(neighbors[i]).size();
1720 Assert(
static_cast<std::size_t
>(n_particles_to_send) *
1721 individual_total_particle_data_size ==
1722 static_cast<std::size_t
>(
1723 n_particles_to_send *
1724 individual_total_particle_data_size),
1725 ExcMessage(
"Overflow when trying to send particle "
1728 for (
unsigned int j = 0; j < n_particles_to_send; ++j)
1734 if (send_cells.size() == 0)
1735 cell = particles_to_send.at(neighbors[i])[j]
1736 ->get_surrounding_cell();
1738 cell = send_cells.at(neighbors[i])[j];
1741 cell->id().template to_binary<dim>();
1742 memcpy(data, &cellid, cellid_size);
1743 data =
static_cast<char *
>(data) + cellid_size;
1745 data = particles_to_send.at(neighbors[i])[j]
1746 ->write_particle_data_to_memory(data);
1749 store_callback(particles_to_send.at(neighbors[i])[j], data);
1751 n_send_data[i] = n_particles_to_send;
1756 std::vector<unsigned int> n_recv_data(n_neighbors);
1757 std::vector<unsigned int> recv_offsets(n_neighbors);
1763 std::vector<MPI_Request> n_requests(2 * n_neighbors);
1764 for (
unsigned int i = 0; i < n_neighbors; ++i)
1766 const int ierr = MPI_Irecv(&(n_recv_data[i]),
1771 parallel_triangulation->get_communicator(),
1772 &(n_requests[2 * i]));
1775 for (
unsigned int i = 0; i < n_neighbors; ++i)
1777 const int ierr = MPI_Isend(&(n_send_data[i]),
1782 parallel_triangulation->get_communicator(),
1783 &(n_requests[2 * i + 1]));
1787 MPI_Waitall(2 * n_neighbors, n_requests.data(), MPI_STATUSES_IGNORE);
1792 unsigned int total_recv_data = 0;
1793 for (
unsigned int neighbor_id = 0; neighbor_id < n_neighbors; ++neighbor_id)
1795 recv_offsets[neighbor_id] = total_recv_data;
1797 n_recv_data[neighbor_id] * individual_total_particle_data_size;
1801 std::vector<char> recv_data(total_recv_data);
1805 std::vector<MPI_Request> requests(2 * n_neighbors);
1806 unsigned int send_ops = 0;
1807 unsigned int recv_ops = 0;
1812 for (
unsigned int i = 0; i < n_neighbors; ++i)
1813 if (n_recv_data[i] > 0)
1816 MPI_Irecv(&(recv_data[recv_offsets[i]]),
1817 n_recv_data[i] * individual_total_particle_data_size,
1821 parallel_triangulation->get_communicator(),
1822 &(requests[send_ops]));
1827 for (
unsigned int i = 0; i < n_neighbors; ++i)
1828 if (n_send_data[i] > 0)
1831 MPI_Isend(&(send_data[send_offsets[i]]),
1832 n_send_data[i] * individual_total_particle_data_size,
1836 parallel_triangulation->get_communicator(),
1837 &(requests[send_ops + recv_ops]));
1842 MPI_Waitall(send_ops + recv_ops, requests.data(), MPI_STATUSES_IGNORE);
1848 const void *recv_data_it =
static_cast<const void *
>(recv_data.data());
1851 auto &ghost_particles_iterators =
1852 ghost_particles_cache.ghost_particles_iterators;
1856 ghost_particles_iterators.clear();
1858 auto &send_pointers_particles = ghost_particles_cache.send_pointers;
1859 send_pointers_particles.assign(n_neighbors + 1, 0);
1861 for (
unsigned int i = 0; i < n_neighbors; ++i)
1862 send_pointers_particles[i + 1] =
1863 send_pointers_particles[i] +
1864 n_send_data[i] * individual_particle_data_size;
1866 auto &recv_pointers_particles = ghost_particles_cache.recv_pointers;
1867 recv_pointers_particles.assign(n_neighbors + 1, 0);
1869 for (
unsigned int i = 0; i < n_neighbors; ++i)
1870 recv_pointers_particles[i + 1] =
1871 recv_pointers_particles[i] +
1872 n_recv_data[i] * individual_particle_data_size;
1874 ghost_particles_cache.neighbors = neighbors;
1876 ghost_particles_cache.send_data.resize(
1877 ghost_particles_cache.send_pointers.back());
1878 ghost_particles_cache.recv_data.resize(
1879 ghost_particles_cache.recv_pointers.back());
1882 while (
reinterpret_cast<std::size_t
>(recv_data_it) -
1883 reinterpret_cast<std::size_t
>(recv_data.data()) <
1887 memcpy(&binary_cellid, recv_data_it, cellid_size);
1888 const CellId id(binary_cellid);
1889 recv_data_it =
static_cast<const char *
>(recv_data_it) + cellid_size;
1894 insert_particle(property_pool->register_particle(), cell);
1895 const typename particle_container::iterator &cache =
1896 cells_to_particle_cache[cell->active_cell_index()];
1901 cache->particles.size() - 1);
1904 particle_it->read_particle_data_from_memory(recv_data_it);
1907 recv_data_it = load_callback(particle_it, recv_data_it);
1910 ghost_particles_iterators.push_back(particle_it);
1913 AssertThrow(recv_data_it == recv_data.data() + recv_data.size(),
1915 "The amount of data that was read into new particles "
1916 "does not match the amount of data sent around."));
1922#ifdef DEAL_II_WITH_MPI
1923 template <
int dim,
int spacedim>
1929 const auto parallel_triangulation =
1933 parallel_triangulation,
1935 "This function is only implemented for parallel::TriangulationBase "
1938 const auto &neighbors = ghost_particles_cache.neighbors;
1939 const auto &send_pointers = ghost_particles_cache.send_pointers;
1940 const auto &recv_pointers = ghost_particles_cache.recv_pointers;
1942 std::vector<char> &send_data = ghost_particles_cache.send_data;
1945 if (send_pointers.back() > 0)
1947 void *data =
static_cast<void *
>(&send_data.front());
1950 for (
const auto i : neighbors)
1951 for (
const auto &p : particles_to_send.at(i))
1953 data = p->write_particle_data_to_memory(data);
1955 data = store_callback(p, data);
1959 std::vector<char> &recv_data = ghost_particles_cache.recv_data;
1963 std::vector<MPI_Request> requests(2 * neighbors.size());
1964 unsigned int send_ops = 0;
1965 unsigned int recv_ops = 0;
1970 for (
unsigned int i = 0; i < neighbors.size(); ++i)
1971 if ((recv_pointers[i + 1] - recv_pointers[i]) > 0)
1974 MPI_Irecv(recv_data.data() + recv_pointers[i],
1975 recv_pointers[i + 1] - recv_pointers[i],
1979 parallel_triangulation->get_communicator(),
1980 &(requests[send_ops]));
1985 for (
unsigned int i = 0; i < neighbors.size(); ++i)
1986 if ((send_pointers[i + 1] - send_pointers[i]) > 0)
1989 MPI_Isend(send_data.data() + send_pointers[i],
1990 send_pointers[i + 1] - send_pointers[i],
1994 parallel_triangulation->get_communicator(),
1995 &(requests[send_ops + recv_ops]));
2000 MPI_Waitall(send_ops + recv_ops, requests.data(), MPI_STATUSES_IGNORE);
2006 const void *recv_data_it =
static_cast<const void *
>(recv_data.data());
2009 auto &ghost_particles_iterators =
2010 ghost_particles_cache.ghost_particles_iterators;
2012 for (
auto &recv_particle : ghost_particles_iterators)
2017 recv_particle->read_particle_data_from_memory(recv_data_it);
2019 Assert(recv_particle->particles_in_cell->cell->is_ghost(),
2023 recv_data_it = load_callback(
2026 recv_particle->particle_index_within_cell),
2030 AssertThrow(recv_data_it == recv_data.data() + recv_data.size(),
2032 "The amount of data that was read into new particles "
2033 "does not match the amount of data sent around."));
2037 template <
int dim,
int spacedim>
2040 const std::function<std::size_t()> & size_callb,
2045 size_callback = size_callb;
2046 store_callback = store_callb;
2047 load_callback = load_callb;
2051 template <
int dim,
int spacedim>
2056 for (
const auto &connection : tria_listeners)
2057 connection.disconnect();
2059 tria_listeners.clear();
2061 tria_listeners.push_back(
triangulation->signals.create.connect([&]() {
2062 this->initialize(*(this->triangulation),
2064 this->property_pool->n_properties_per_slot());
2067 this->tria_listeners.push_back(
2068 this->
triangulation->signals.clear.connect([&]() { this->clear(); }));
2074 tria_listeners.push_back(
2076 [&]() { this->post_mesh_change_action(); }));
2077 tria_listeners.push_back(
2078 triangulation->signals.post_distributed_repartition.connect(
2079 [&]() { this->post_mesh_change_action(); }));
2080 tria_listeners.push_back(
2082 [&]() { this->post_mesh_change_action(); }));
2086 tria_listeners.push_back(
triangulation->signals.post_refinement.connect(
2087 [&]() { this->post_mesh_change_action(); }));
2093 template <
int dim,
int spacedim>
2099 const bool distributed_triangulation =
2102 &(*triangulation)) !=
nullptr;
2103 (void)distributed_triangulation;
2106 distributed_triangulation || number_of_locally_owned_particles == 0,
2108 "Mesh refinement in a non-distributed triangulation is not supported "
2109 "by the ParticleHandler class. Either insert particles after mesh "
2110 "creation, or use a distributed triangulation."));
2114 if (number_of_locally_owned_particles == 0)
2115 cells_to_particle_cache.resize(
triangulation->n_active_cells(),
2121 template <
int dim,
int spacedim>
2125 register_data_attach();
2130 template <
int dim,
int spacedim>
2134 register_data_attach();
2139 template <
int dim,
int spacedim>
2143 register_data_attach();
2148 template <
int dim,
int spacedim>
2153 *distributed_triangulation =
2156 *
>(&(*triangulation)));
2157 (void)distributed_triangulation;
2160 distributed_triangulation !=
nullptr,
2162 "Mesh refinement in a non-distributed triangulation is not supported "
2163 "by the ParticleHandler class. Either insert particles after mesh "
2164 "creation and do not refine afterwards, or use a distributed triangulation."));
2166#ifdef DEAL_II_WITH_P4EST
2167 const auto callback_function =
2172 return this->pack_callback(cell_iterator, cell_status);
2176 callback_function,
true);
2182 template <
int dim,
int spacedim>
2186 const bool serialization =
false;
2187 notify_ready_to_unpack(serialization);
2192 template <
int dim,
int spacedim>
2196 const bool serialization =
true;
2197 notify_ready_to_unpack(serialization);
2201 template <
int dim,
int spacedim>
2204 const bool serialization)
2206 notify_ready_to_unpack(serialization);
2211 template <
int dim,
int spacedim>
2214 const bool serialization)
2217 *distributed_triangulation =
2220 *
>(&(*triangulation)));
2221 (void)distributed_triangulation;
2224 distributed_triangulation !=
nullptr,
2226 "Mesh refinement in a non-distributed triangulation is not supported "
2227 "by the ParticleHandler class. Either insert particles after mesh "
2228 "creation and do not refine afterwards, or use a distributed triangulation."));
2233#ifdef DEAL_II_WITH_P4EST
2239 register_data_attach();
2244 const auto callback_function =
2249 const boost::iterator_range<std::vector<char>::const_iterator>
2251 this->unpack_callback(cell_iterator, cell_status, range_iterator);
2259 update_cached_numbers();
2262 (void)serialization;
2268 template <
int dim,
int spacedim>
2274 std::vector<particle_iterator> stored_particles_on_cell;
2283 const unsigned int n_particles = n_particles_in_cell(cell);
2284 stored_particles_on_cell.reserve(n_particles);
2286 for (
unsigned int i = 0; i < n_particles; ++i)
2288 cells_to_particle_cache[cell->active_cell_index()],
2298 for (
const auto &child : cell->child_iterators())
2300 const unsigned int n_particles = n_particles_in_cell(child);
2302 stored_particles_on_cell.reserve(
2303 stored_particles_on_cell.size() + n_particles);
2305 const typename particle_container::iterator &cache =
2306 cells_to_particle_cache[child->active_cell_index()];
2307 for (
unsigned int i = 0; i < n_particles; ++i)
2308 stored_particles_on_cell.push_back(
2319 return pack_particles(stored_particles_on_cell);
2324 template <
int dim,
int spacedim>
2329 const boost::iterator_range<std::vector<char>::const_iterator> &data_range)
2331 if (data_range.begin() == data_range.end())
2334 const auto cell_to_store_particles =
2340 if (data_range.begin() != data_range.end())
2342 const void *data =
static_cast<const void *
>(&(*data_range.begin()));
2343 const void *end =
static_cast<const void *
>(
2344 &(*data_range.begin()) + (data_range.end() - data_range.begin()));
2347 insert_particle(data, cell_to_store_particles);
2351 "The particle data could not be deserialized successfully. "
2352 "Check that when deserializing the particles you expect "
2353 "the same number of properties that were serialized."));
2356 auto loaded_particles_on_cell = particles_in_cell(cell_to_store_particles);
2371 for (
auto &particle : loaded_particles_on_cell)
2374 mapping->transform_real_to_unit_cell(cell_to_store_particles,
2375 particle.get_location());
2376 particle.set_reference_location(p_unit);
2385 typename particle_container::iterator &cache =
2386 cells_to_particle_cache[cell_to_store_particles
2387 ->active_cell_index()];
2394 auto particle = loaded_particles_on_cell.begin();
2395 for (
unsigned int i = 0; i < cache->particles.size();)
2397 bool found_new_cell =
false;
2399 for (
unsigned int child_index = 0;
2400 child_index < GeometryInfo<dim>::max_children_per_cell;
2404 child = cell->child(child_index);
2410 mapping->transform_real_to_unit_cell(
2411 child, particle->get_location());
2415 found_new_cell =
true;
2416 particle->set_reference_location(p_unit);
2421 if (child_index != 0)
2423 insert_particle(cache->particles[i], child);
2425 cache->particles[i] = cache->particles.back();
2426 cache->particles.resize(
2427 cache->particles.size() - 1);
2441 if (found_new_cell ==
false)
2450 signals.particle_lost(particle,
2451 particle->get_surrounding_cell());
2452 cache->particles[i] = cache->particles.back();
2453 cache->particles.resize(cache->particles.size() - 1);
2457 if (cache->particles.empty())
2459 particles.erase(cache);
2460 cache = particles.end();
2472#include "particle_handler.inst"
std::array< unsigned int, 4 > binary_type
const unsigned int n_components
virtual void vector_value(const Point< dim > &p, Vector< RangeNumberType > &values) const
Abstract base class for mapping classes.
void register_additional_store_load_functions(const std::function< std::size_t()> &size_callback, const std::function< void *(const particle_iterator &, void *)> &store_callback, const std::function< const void *(const particle_iterator &, const void *)> &load_callback)
void exchange_ghost_particles(const bool enable_ghost_cache=false)
types::particle_index n_global_particles() const
unsigned int global_max_particles_per_cell
void unpack_after_coarsening_and_refinement()
void register_data_attach()
internal::GhostParticlePartitioner< dim, spacedim > ghost_particles_cache
particle_container::iterator particle_container_ghost_begin() const
void prepare_for_serialization()
unsigned int n_properties_per_particle() const
types::particle_index global_number_of_particles
void get_particle_positions(VectorType &output_vector, const bool add_to_output_vector=false)
particle_container::iterator particle_container_owned_end() const
void update_cached_numbers()
void prepare_for_coarsening_and_refinement()
particle_container::iterator particle_container_ghost_end() const
boost::iterator_range< particle_iterator > particle_iterator_range
void post_mesh_change_action()
void send_recv_particles(const std::map< types::subdomain_id, std::vector< particle_iterator > > &particles_to_send, const std::map< types::subdomain_id, std::vector< typename Triangulation< dim, spacedim >::active_cell_iterator > > &new_cells_for_particles=std::map< types::subdomain_id, std::vector< typename Triangulation< dim, spacedim >::active_cell_iterator > >(), const bool enable_cache=false)
void send_recv_particles_properties_and_location(const std::map< types::subdomain_id, std::vector< particle_iterator > > &particles_to_send)
types::particle_index number_of_locally_owned_particles
PropertyPool< dim, spacedim > & get_property_pool() const
void initialize(const Triangulation< dim, spacedim > &tria, const Mapping< dim, spacedim > &mapping, const unsigned int n_properties=0)
std::unique_ptr< PropertyPool< dim, spacedim > > property_pool
types::particle_index get_max_local_particle_index() const
void reserve(const std::size_t n_particles)
std::map< unsigned int, IndexSet > insert_global_particles(const std::vector< Point< spacedim > > &positions, const std::vector< std::vector< BoundingBox< spacedim > > > &global_bounding_boxes, const std::vector< std::vector< double > > &properties={}, const std::vector< types::particle_index > &ids={})
void notify_ready_to_unpack(const bool serialization)
void connect_to_triangulation_signals()
void register_load_callback_function(const bool serialization)
void insert_particles(const std::multimap< typename Triangulation< dim, spacedim >::active_cell_iterator, Particle< dim, spacedim > > &particles)
types::particle_index next_free_particle_index
void unpack_callback(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const typename Triangulation< dim, spacedim >::CellStatus status, const boost::iterator_range< std::vector< char >::const_iterator > &data_range)
void register_store_callback_function()
void remove_particle(const particle_iterator &particle)
types::particle_index n_locally_owned_particles() const
void reset_particle_container(particle_container &particles)
types::particle_index n_particles_in_cell(const typename Triangulation< dim, spacedim >::active_cell_iterator &cell) const
void update_ghost_particles()
typename ParticleAccessor< dim, spacedim >::particle_container particle_container
particle_iterator_range particles_in_cell(const typename Triangulation< dim, spacedim >::active_cell_iterator &cell)
SmartPointer< const Triangulation< dim, spacedim >, ParticleHandler< dim, spacedim > > triangulation
particle_iterator insert_particle(const Particle< dim, spacedim > &particle, const typename Triangulation< dim, spacedim >::active_cell_iterator &cell)
void sort_particles_into_subdomains_and_cells()
void remove_particles(const std::vector< particle_iterator > &particles)
types::particle_index n_global_max_particles_per_cell() const
particle_container::iterator particle_container_owned_begin() const
virtual ~ParticleHandler()
void copy_from(const ParticleHandler< dim, spacedim > &particle_handler)
SmartPointer< const Mapping< dim, spacedim >, ParticleHandler< dim, spacedim > > mapping
std::enable_if< std::is_convertible< VectorType *, Function< spacedim > * >::value==false >::type set_particle_positions(const VectorType &input_vector, const bool displace_particles=true)
types::particle_index get_next_free_particle_index() const
particle_container particles
std::vector< char > pack_callback(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const typename Triangulation< dim, spacedim >::CellStatus status) const
IndexSet locally_owned_particle_ids() const
void set_property_pool(PropertyPool< dim, spacedim > &property_pool)
const Point< dim > & get_reference_location() const
const Point< spacedim > & get_location() const
std::size_t serialized_size_in_bytes() const
const ArrayView< double > get_properties()
types::particle_index get_id() const
numbers::NumberTraits< Number >::real_type norm() const
IteratorState::IteratorStates state() const
void notify_ready_to_unpack(const unsigned int handle, const std::function< void(const cell_iterator &, const CellStatus, const boost::iterator_range< std::vector< char >::const_iterator > &)> &unpack_callback)
unsigned int register_data_attach(const std::function< std::vector< char >(const cell_iterator &, const CellStatus)> &pack_callback, const bool returns_variable_size_data)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertThrowMPI(error_code)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcPointNotAvailableHere()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
TriaIterator< CellAccessor< dim, spacedim > > cell_iterator
@ past_the_end
Iterator reached end of container.
@ valid
Iterator points to a valid object.
std::vector< T > all_gather(const MPI_Comm &comm, const T &object_to_send)
T sum(const T &t, const MPI_Comm &mpi_communicator)
unsigned int n_mpi_processes(const MPI_Comm &mpi_communicator)
T max(const T &t, const MPI_Comm &mpi_communicator)
std::map< unsigned int, T > some_to_some(const MPI_Comm &comm, const std::map< unsigned int, T > &objects_to_send)
const types::subdomain_id artificial_subdomain_id
static const unsigned int invalid_unsigned_int
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
unsigned int subdomain_id
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation
#define DEAL_II_PARTICLE_INDEX_MPI_TYPE