32 template <
int dim,
int spacedim>
34 pack_particles(std::vector<ParticleIterator<dim, spacedim>> &particles)
36 std::vector<char> buffer;
38 if (particles.empty())
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 , tria_attached_data_index(
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 , tria_attached_data_index(
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 =
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;
402 next_free_particle_index = result[1] + 1;
403 global_max_particles_per_cell = result[0];
409 template <
int dim,
int spacedim>
415 if (cells_to_particle_cache.empty())
418 if (cell->is_artificial() ==
false)
420 return cells_to_particle_cache[cell->active_cell_index()] !=
422 cells_to_particle_cache[cell->active_cell_index()]
428 ExcMessage(
"You can't ask for the particles on an artificial "
429 "cell since we don't know what exists on these "
437 template <
int dim,
int spacedim>
444 ->particles_in_cell(cell);
449 template <
int dim,
int spacedim>
454 const unsigned int active_cell_index = cell->active_cell_index();
456 if (cell->is_artificial() ==
false)
458 if (cells_to_particle_cache[active_cell_index] == particles.end())
460 return boost::make_iterator_range(
466 const typename particle_container::iterator
467 particles_in_current_cell =
468 cells_to_particle_cache[active_cell_index];
469 typename particle_container::iterator particles_in_next_cell =
470 particles_in_current_cell;
471 ++particles_in_next_cell;
472 return boost::make_iterator_range(
479 ExcMessage(
"You can't ask for the particles on an artificial "
480 "cell since we don't know what exists on these "
488 template <
int dim,
int spacedim>
493 auto &particles_on_cell = particle->particles_in_cell->particles;
498 auto handle = particle->get_handle();
500 property_pool->deregister_particle(handle);
505 const auto cell = particle->get_surrounding_cell();
506 const bool owned_cell = cell->is_locally_owned();
508 --number_of_locally_owned_particles;
510 if (particles_on_cell.size() > 1)
512 particles_on_cell[particle->particle_index_within_cell] =
513 std::move(particles_on_cell.back());
514 particles_on_cell.resize(particles_on_cell.size() - 1);
518 particles.erase(particle->particles_in_cell);
519 cells_to_particle_cache[cell->active_cell_index()] = particles.end();
525 template <
int dim,
int spacedim>
529 &particles_to_remove)
537 return a->particles_in_cell->cell > b->particles_in_cell->cell ||
538 (a->particles_in_cell->cell == b->particles_in_cell->cell &&
539 a->particle_index_within_cell > b->particle_index_within_cell);
542 bool particles_are_sorted =
true;
543 auto previous = particles_to_remove.begin();
544 for (
auto next = previous; next != particles_to_remove.end(); ++next)
546 if (check_greater(*previous, *next))
548 particles_are_sorted =
false;
553 if (particles_are_sorted)
556 for (
auto it = particles_to_remove.rbegin();
557 it != particles_to_remove.rend();
559 remove_particle(*it);
563 std::vector<ParticleHandler<dim, spacedim>::particle_iterator>
564 sorted_particles(particles_to_remove);
565 std::sort(sorted_particles.begin(),
566 sorted_particles.end(),
569 for (
const auto &particle : sorted_particles)
570 remove_particle(particle);
573 update_cached_numbers();
578 template <
int dim,
int spacedim>
593 template <
int dim,
int spacedim>
599 const unsigned int active_cell_index = cell->active_cell_index();
600 typename particle_container::iterator &cache =
601 cells_to_particle_cache[active_cell_index];
602 if (cache == particles.end())
604 const typename particle_container::iterator insert_position =
605 cell->is_locally_owned() ? particle_container_owned_end() :
606 particle_container_ghost_end();
607 cache = particles.emplace(
614 cache->particles.push_back(handle);
619 cache->particles.size() - 1);
624 template <
int dim,
int spacedim>
633 Assert(cell->is_locally_owned(),
634 ExcMessage(
"You tried to insert particles into a cell that is not "
635 "locally owned. This is not supported."));
638 insert_particle(property_pool->register_particle(), cell);
640 data = particle_it->read_particle_data_from_memory(
data);
642 ++number_of_locally_owned_particles;
649 template <
int dim,
int spacedim>
662 Assert(cell->is_locally_owned(),
663 ExcMessage(
"You tried to insert particles into a cell that is not "
664 "locally owned. This is not supported."));
667 insert_particle(property_pool->register_particle(), cell);
669 particle_it->set_location(position);
670 particle_it->set_reference_location(reference_position);
671 particle_it->set_id(particle_index);
673 if (properties.
size() != 0)
674 particle_it->set_properties(properties);
676 ++number_of_locally_owned_particles;
683 template <
int dim,
int spacedim>
690 reserve(n_locally_owned_particles() + new_particles.size());
691 for (
const auto &cell_and_particle : new_particles)
692 insert_particle(cell_and_particle.second, cell_and_particle.first);
694 update_cached_numbers();
699 template <
int dim,
int spacedim>
706 update_cached_numbers();
707 reserve(n_locally_owned_particles() + positions.size());
714 get_next_free_particle_index();
717#ifdef DEAL_II_WITH_MPI
718 if (
const auto parallel_triangulation =
724 MPI_Scan(&particles_to_add_locally,
729 parallel_triangulation->get_mpi_communicator());
731 local_start_index -= particles_to_add_locally;
735 local_start_index += local_next_particle_index;
737 auto point_locations =
741 auto &cells = std::get<0>(point_locations);
742 auto &local_positions = std::get<1>(point_locations);
743 auto &index_map = std::get<2>(point_locations);
744 auto &missing_points = std::get<3>(point_locations);
750 (void)missing_points;
752 for (
unsigned int i = 0; i < cells.size(); ++i)
753 for (
unsigned int p = 0; p < local_positions[i].size(); ++p)
754 insert_particle(positions[index_map[i][p]],
755 local_positions[i][p],
756 local_start_index + index_map[i][p],
759 update_cached_numbers();
764 template <
int dim,
int spacedim>
765 std::map<unsigned int, IndexSet>
769 &global_bounding_boxes,
770 const std::vector<std::vector<double>> &properties,
771 const std::vector<types::particle_index> &ids)
773 if (!properties.empty())
777 for (
const auto &p : properties)
790 const auto n_global_properties =
794 const auto n_particles_per_proc =
798 std::vector<unsigned int> particle_start_indices(n_mpi_processes);
800 unsigned int particle_start_index = get_next_free_particle_index();
801 for (
unsigned int process = 0; process < particle_start_indices.size();
804 particle_start_indices[process] = particle_start_index;
805 particle_start_index += n_particles_per_proc[process];
809 const auto cells_positions_and_index_maps =
812 global_bounding_boxes);
816 const auto &local_cells_containing_particles =
817 std::get<0>(cells_positions_and_index_maps);
821 const auto &local_reference_positions =
822 std::get<1>(cells_positions_and_index_maps);
825 const auto &original_indices_of_local_particles =
826 std::get<2>(cells_positions_and_index_maps);
829 const auto &local_positions = std::get<3>(cells_positions_and_index_maps);
831 const auto &calling_process_indices =
832 std::get<4>(cells_positions_and_index_maps);
835 std::map<unsigned int, std::vector<unsigned int>>
836 original_process_to_local_particle_indices_tmp;
837 for (
unsigned int i_cell = 0;
838 i_cell < local_cells_containing_particles.size();
841 for (
unsigned int i_particle = 0;
842 i_particle < local_positions[i_cell].size();
845 const unsigned int local_id_on_calling_process =
846 original_indices_of_local_particles[i_cell][i_particle];
847 const unsigned int calling_process =
848 calling_process_indices[i_cell][i_particle];
850 original_process_to_local_particle_indices_tmp[calling_process]
851 .push_back(local_id_on_calling_process);
854 std::map<unsigned int, IndexSet> original_process_to_local_particle_indices;
855 for (
auto &process_and_particle_indices :
856 original_process_to_local_particle_indices_tmp)
858 const unsigned int calling_process = process_and_particle_indices.first;
859 original_process_to_local_particle_indices.insert(
860 {calling_process,
IndexSet(n_particles_per_proc[calling_process])});
861 std::sort(process_and_particle_indices.second.begin(),
862 process_and_particle_indices.second.end());
863 original_process_to_local_particle_indices[calling_process].add_indices(
864 process_and_particle_indices.second.begin(),
865 process_and_particle_indices.second.end());
866 original_process_to_local_particle_indices[calling_process].compress();
874 std::map<unsigned int, std::vector<std::vector<double>>>
875 locally_owned_properties_from_other_processes;
882 std::map<unsigned int, std::vector<types::particle_index>>
883 locally_owned_ids_from_other_processes;
885 if (n_global_properties > 0 || !ids.empty())
890 comm, original_process_to_local_particle_indices);
893 if (n_global_properties > 0)
895 std::map<unsigned int, std::vector<std::vector<double>>>
896 non_locally_owned_properties;
898 for (
const auto &it : send_to_cpu)
900 std::vector<std::vector<double>> properties_to_send(
901 it.second.n_elements(),
902 std::vector<double>(n_properties_per_particle()));
903 unsigned int index = 0;
904 for (
const auto el : it.second)
905 properties_to_send[index++] = properties[el];
906 non_locally_owned_properties.insert(
907 {it.first, properties_to_send});
912 locally_owned_properties_from_other_processes =
916 locally_owned_properties_from_other_processes.size(),
917 original_process_to_local_particle_indices.size());
922 std::map<unsigned int, std::vector<types::particle_index>>
923 non_locally_owned_ids;
924 for (
const auto &it : send_to_cpu)
926 std::vector<types::particle_index> ids_to_send(
927 it.second.n_elements());
928 unsigned int index = 0;
929 for (
const auto el : it.second)
930 ids_to_send[index++] = ids[el];
931 non_locally_owned_ids.insert({it.first, ids_to_send});
936 locally_owned_ids_from_other_processes =
940 original_process_to_local_particle_indices.size());
945 for (
unsigned int i_cell = 0;
946 i_cell < local_cells_containing_particles.size();
949 for (
unsigned int i_particle = 0;
950 i_particle < local_positions[i_cell].size();
953 const unsigned int local_id_on_calling_process =
954 original_indices_of_local_particles[i_cell][i_particle];
956 const unsigned int calling_process =
957 calling_process_indices[i_cell][i_particle];
959 const unsigned int index_within_set =
960 original_process_to_local_particle_indices[calling_process]
961 .index_within_set(local_id_on_calling_process);
963 const unsigned int particle_id =
965 local_id_on_calling_process +
966 particle_start_indices[calling_process] :
967 locally_owned_ids_from_other_processes[calling_process]
971 insert_particle(local_positions[i_cell][i_particle],
972 local_reference_positions[i_cell][i_particle],
974 local_cells_containing_particles[i_cell]);
976 if (n_global_properties > 0)
978 particle_it->set_properties(
979 locally_owned_properties_from_other_processes
980 [calling_process][index_within_set]);
985 update_cached_numbers();
987 return original_process_to_local_particle_indices;
992 template <
int dim,
int spacedim>
993 std::map<unsigned int, IndexSet>
997 &global_bounding_boxes)
1001 std::vector<Point<spacedim>> positions;
1002 std::vector<std::vector<double>> properties;
1003 std::vector<types::particle_index> ids;
1004 positions.resize(particles.size());
1005 ids.resize(particles.size());
1006 if (n_properties_per_particle() > 0)
1007 properties.resize(particles.size(),
1008 std::vector<double>(n_properties_per_particle()));
1011 for (
const auto &p : particles)
1013 positions[i] = p.get_location();
1014 ids[i] = p.get_id();
1015 if (p.has_properties())
1016 properties[i] = {p.get_properties().begin(),
1017 p.get_properties().end()};
1021 return insert_global_particles(positions,
1022 global_bounding_boxes,
1029 template <
int dim,
int spacedim>
1033 return global_number_of_particles;
1038 template <
int dim,
int spacedim>
1042 return global_max_particles_per_cell;
1047 template <
int dim,
int spacedim>
1051 return number_of_locally_owned_particles;
1056 template <
int dim,
int spacedim>
1060 return property_pool->n_properties_per_slot();
1065 template <
int dim,
int spacedim>
1069 return next_free_particle_index;
1074 template <
int dim,
int spacedim>
1078 IndexSet set(get_next_free_particle_index());
1079 std::vector<types::particle_index> indices;
1080 indices.reserve(n_locally_owned_particles());
1081 for (
const auto &p : *
this)
1082 indices.push_back(p.get_id());
1090 template <
int dim,
int spacedim>
1094 return property_pool->n_slots();
1099 template <
int dim,
int spacedim>
1103 const bool add_to_output_vector)
1109 for (
auto it = begin(); it != end(); ++it, ++i)
1111 if (add_to_output_vector)
1112 positions[i] = positions[i] + it->get_location();
1114 positions[i] = it->get_location();
1120 template <
int dim,
int spacedim>
1124 const bool displace_particles)
1130 for (
auto it = begin(); it != end(); ++it, ++i)
1133 if (displace_particles)
1134 location += new_positions[i];
1136 location = new_positions[i];
1138 sort_particles_into_subdomains_and_cells();
1143 template <
int dim,
int spacedim>
1147 const bool displace_particles)
1154 for (
auto &particle : *
this)
1157 function.
vector_value(particle_location, new_position);
1158 if (displace_particles)
1159 for (
unsigned int d = 0; d < spacedim; ++d)
1160 particle_location[d] += new_position[d];
1162 for (
unsigned int d = 0; d < spacedim; ++d)
1163 particle_location[d] = new_position[d];
1165 sort_particles_into_subdomains_and_cells();
1170 template <
int dim,
int spacedim>
1174 return *property_pool;
1192 compare_particle_association(
1193 const unsigned int a,
1194 const unsigned int b,
1198 const double scalar_product_a = center_directions[a] * particle_direction;
1199 const double scalar_product_b = center_directions[b] * particle_direction;
1204 return (scalar_product_a > scalar_product_b);
1210 template <
int dim,
int spacedim>
1226 std::vector<particle_iterator> particles_out_of_cell;
1231 particles_out_of_cell.reserve(n_locally_owned_particles() / 4);
1234 std::vector<Point<spacedim>> real_locations;
1235 std::vector<Point<dim>> reference_locations;
1236 real_locations.reserve(global_max_particles_per_cell);
1237 reference_locations.reserve(global_max_particles_per_cell);
1239 for (
const auto &cell :
triangulation->active_cell_iterators())
1246 if (cell->is_locally_owned() ==
false)
1251 const unsigned int n_pic = n_particles_in_cell(cell);
1252 auto pic = particles_in_cell(cell);
1254 real_locations.clear();
1255 for (
const auto &particle : pic)
1256 real_locations.push_back(particle.get_location());
1258 reference_locations.resize(n_pic);
1259 mapping->transform_points_real_to_unit_cell(cell,
1261 reference_locations);
1263 auto particle = pic.begin();
1264 for (
const auto &p_unit : reference_locations)
1268 tolerance_inside_cell))
1269 particle->set_reference_location(p_unit);
1271 particles_out_of_cell.push_back(particle);
1283 std::map<types::subdomain_id, std::vector<particle_iterator>>
1287 std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator>>
1295 using vector_size =
typename std::vector<particle_iterator>::size_type;
1297 std::set<types::subdomain_id> ghost_owners;
1298 if (
const auto parallel_triangulation =
1301 ghost_owners = parallel_triangulation->ghost_owners();
1306 for (
const auto &ghost_owner : ghost_owners)
1307 moved_particles[ghost_owner].reserve(particles_out_of_cell.size() / 4);
1308 for (
const auto &ghost_owner : ghost_owners)
1309 moved_cells[ghost_owner].reserve(particles_out_of_cell.size() / 4);
1314 std::set<typename Triangulation<dim, spacedim>::active_cell_iterator>>
1315 &vertex_to_cells = triangulation_cache->get_vertex_to_cell_map();
1319 const std::vector<std::vector<Tensor<1, spacedim>>>
1320 &vertex_to_cell_centers =
1321 triangulation_cache->get_vertex_to_cell_centers_directions();
1323 std::vector<unsigned int> search_order;
1329 invalid_reference_point[0] = std::numeric_limits<double>::infinity();
1330 invalid_point[0] = std::numeric_limits<double>::infinity();
1331 reference_locations.resize(1, invalid_reference_point);
1332 real_locations.resize(1, invalid_point);
1335 for (
auto &out_particle : particles_out_of_cell)
1340 auto current_cell = out_particle->get_surrounding_cell();
1342 real_locations[0] = out_particle->get_location();
1345 bool found_cell =
false;
1349 const unsigned int closest_vertex =
1350 GridTools::find_closest_vertex_of_cell<dim, spacedim>(
1351 current_cell, out_particle->get_location(), *mapping);
1352 const unsigned int closest_vertex_index =
1353 current_cell->vertex_index(closest_vertex);
1355 const auto &candidate_cells = vertex_to_cells[closest_vertex_index];
1356 const unsigned int n_candidate_cells = candidate_cells.size();
1360 search_order.resize(n_candidate_cells);
1361 for (
unsigned int i = 0; i < n_candidate_cells; ++i)
1362 search_order[i] = i;
1368 out_particle->get_location() - current_cell->vertex(closest_vertex);
1373 1e4 * std::numeric_limits<double>::epsilon() *
1374 std::numeric_limits<double>::epsilon() *
1375 vertex_to_cell_centers[closest_vertex_index][0].norm_square())
1377 vertex_to_particle /= vertex_to_particle.
norm();
1378 const auto &vertex_to_cells =
1379 vertex_to_cell_centers[closest_vertex_index];
1381 std::sort(search_order.begin(),
1383 [&vertex_to_particle,
1384 &vertex_to_cells](
const unsigned int a,
1385 const unsigned int b) {
1386 return compare_particle_association(
1387 a, b, vertex_to_particle, vertex_to_cells);
1393 for (
unsigned int i = 0; i < n_candidate_cells; ++i)
1397 const_iterator candidate_cell = candidate_cells.begin();
1399 std::advance(candidate_cell, search_order[i]);
1400 mapping->transform_points_real_to_unit_cell(*candidate_cell,
1402 reference_locations);
1405 tolerance_inside_cell))
1407 current_cell = *candidate_cell;
1423#if defined(DEAL_II_WITH_BOOST_BUNDLED) || \
1424 !(defined(__clang_major__) && __clang_major__ >= 16) || \
1425 BOOST_VERSION >= 108100
1427 std::vector<std::pair<Point<spacedim>,
unsigned int>>
1428 closest_vertex_in_domain;
1429 triangulation_cache->get_used_vertices_rtree().query(
1430 boost::geometry::index::nearest(out_particle->get_location(),
1432 std::back_inserter(closest_vertex_in_domain));
1436 const unsigned int closest_vertex_index_in_domain =
1437 closest_vertex_in_domain[0].second;
1439 const unsigned int closest_vertex_index_in_domain =
1442 out_particle->get_location());
1447 for (
const auto &cell :
1448 vertex_to_cells[closest_vertex_index_in_domain])
1450 mapping->transform_points_real_to_unit_cell(
1451 cell, real_locations, reference_locations);
1454 reference_locations[0], tolerance_inside_cell))
1456 current_cell = cell;
1468 signals.particle_lost(out_particle,
1469 out_particle->get_surrounding_cell());
1475 out_particle->set_reference_location(reference_locations[0]);
1479 if (current_cell->is_locally_owned())
1482 out_particle->particles_in_cell
1483 ->particles[out_particle->particle_index_within_cell];
1486 const auto old_value = old;
1490 insert_particle(old_value, current_cell);
1494 moved_particles[current_cell->subdomain_id()].push_back(
1496 moved_cells[current_cell->subdomain_id()].push_back(current_cell);
1502#ifdef DEAL_II_WITH_MPI
1503 if (
const auto parallel_triangulation =
1508 parallel_triangulation->get_mpi_communicator()) > 1)
1509 send_recv_particles(moved_particles, moved_cells);
1514 remove_particles(particles_out_of_cell);
1517 std::vector<typename PropertyPool<dim, spacedim>::Handle> unsorted_handles;
1518 unsorted_handles.reserve(property_pool->n_registered_slots());
1521 for (
auto &particles_in_cell : particles)
1522 for (
auto &particle : particles_in_cell.particles)
1524 unsorted_handles.push_back(particle);
1525 particle = sorted_handle++;
1528 property_pool->sort_memory_slots(unsorted_handles);
1534 template <
int dim,
int spacedim>
1537 const bool enable_cache)
1540 const auto parallel_triangulation =
1543 if (parallel_triangulation !=
nullptr)
1546 parallel_triangulation->get_mpi_communicator()) == 1)
1552#ifndef DEAL_II_WITH_MPI
1556 for (
const auto &cell :
triangulation->active_cell_iterators())
1557 if (cell->is_ghost() &&
1558 cells_to_particle_cache[cell->active_cell_index()] != particles.end())
1560 Assert(cells_to_particle_cache[cell->active_cell_index()]->cell ==
1564 for (
auto &ghost_particle :
1565 cells_to_particle_cache[cell->active_cell_index()]->particles)
1566 property_pool->deregister_particle(ghost_particle);
1569 particles.erase(cells_to_particle_cache[cell->active_cell_index()]);
1570 cells_to_particle_cache[cell->active_cell_index()] = particles.end();
1574 ghost_particles_cache.ghost_particles_by_domain.clear();
1575 ghost_particles_cache.valid =
false;
1582 const std::map<unsigned int, std::set<types::subdomain_id>>
1584 triangulation_cache->get_vertices_with_ghost_neighbors();
1586 const std::set<types::subdomain_id> ghost_owners =
1587 parallel_triangulation->ghost_owners();
1588 for (
const auto ghost_owner : ghost_owners)
1589 ghost_particles_cache.ghost_particles_by_domain[ghost_owner].reserve(
1590 n_locally_owned_particles() / 4);
1592 const std::vector<std::set<unsigned int>> vertex_to_neighbor_subdomain =
1593 triangulation_cache->get_vertex_to_neighbor_subdomain();
1595 for (
const auto &cell :
triangulation->active_cell_iterators())
1597 if (cell->is_locally_owned())
1599 std::set<unsigned int> cell_to_neighbor_subdomain;
1600 for (
const unsigned int v : cell->vertex_indices())
1602 const auto vertex_ghost_neighbors =
1604 if (vertex_ghost_neighbors !=
1607 cell_to_neighbor_subdomain.insert(
1608 vertex_ghost_neighbors->second.begin(),
1609 vertex_ghost_neighbors->second.end());
1613 if (cell_to_neighbor_subdomain.size() > 0)
1616 particles_in_cell(cell);
1618 for (
const auto domain : cell_to_neighbor_subdomain)
1620 for (
typename particle_iterator_range::iterator particle =
1621 particle_range.begin();
1622 particle != particle_range.end();
1624 ghost_particles_cache.ghost_particles_by_domain[domain]
1625 .push_back(particle);
1631 send_recv_particles(
1632 ghost_particles_cache.ghost_particles_by_domain,
1643 template <
int dim,
int spacedim>
1648 const auto parallel_triangulation =
1651 if (parallel_triangulation ==
nullptr ||
1653 parallel_triangulation->get_mpi_communicator()) == 1)
1659#ifdef DEAL_II_WITH_MPI
1662 Assert(ghost_particles_cache.valid,
1664 "Ghost particles cannot be updated if they first have not been "
1665 "exchanged at least once with the cache enabled"));
1668 send_recv_particles_properties_and_location(
1669 ghost_particles_cache.ghost_particles_by_domain);
1675#ifdef DEAL_II_WITH_MPI
1676 template <
int dim,
int spacedim>
1685 const bool build_cache)
1691 ghost_particles_cache.valid = build_cache;
1693 const auto parallel_triangulation =
1696 Assert(parallel_triangulation,
1697 ExcMessage(
"This function is only implemented for "
1698 "parallel::TriangulationBase objects."));
1701 const std::set<types::subdomain_id> ghost_owners =
1702 parallel_triangulation->ghost_owners();
1703 const std::vector<types::subdomain_id> neighbors(ghost_owners.begin(),
1704 ghost_owners.end());
1705 const unsigned int n_neighbors = neighbors.size();
1707 if (send_cells.size() != 0)
1713 particles_to_send.end(),
1718 for (
auto send_particles = particles_to_send.begin();
1719 send_particles != particles_to_send.end();
1721 Assert(ghost_owners.find(send_particles->first) != ghost_owners.end(),
1724 std::size_t n_send_particles = 0;
1725 for (
auto send_particles = particles_to_send.begin();
1726 send_particles != particles_to_send.end();
1728 n_send_particles += send_particles->second.size();
1734 std::vector<unsigned int> n_send_data(n_neighbors, 0);
1735 std::vector<unsigned int> send_offsets(n_neighbors, 0);
1736 std::vector<char> send_data;
1741 const unsigned int individual_particle_data_size =
1743 (size_callback ? size_callback() : 0);
1745 const unsigned int individual_total_particle_data_size =
1746 individual_particle_data_size + cellid_size;
1751 if (n_send_particles > 0)
1754 send_data.resize(n_send_particles *
1755 individual_total_particle_data_size);
1757 void *
data =
static_cast<void *
>(&send_data.front());
1760 for (
unsigned int i = 0; i < n_neighbors; ++i)
1762 send_offsets[i] =
reinterpret_cast<std::size_t
>(
data) -
1763 reinterpret_cast<std::size_t
>(&send_data.front());
1765 const unsigned int n_particles_to_send =
1766 particles_to_send.at(neighbors[i]).size();
1768 Assert(
static_cast<std::size_t
>(n_particles_to_send) *
1769 individual_total_particle_data_size ==
1770 static_cast<std::size_t
>(
1771 n_particles_to_send *
1772 individual_total_particle_data_size),
1773 ExcMessage(
"Overflow when trying to send particle "
1776 for (
unsigned int j = 0; j < n_particles_to_send; ++j)
1782 if (send_cells.empty())
1783 cell = particles_to_send.at(neighbors[i])[j]
1784 ->get_surrounding_cell();
1786 cell = send_cells.at(neighbors[i])[j];
1789 cell->id().template to_binary<dim>();
1790 memcpy(
data, &cellid, cellid_size);
1791 data =
static_cast<char *
>(
data) + cellid_size;
1793 data = particles_to_send.at(neighbors[i])[j]
1794 ->write_particle_data_to_memory(
data);
1797 store_callback(particles_to_send.at(neighbors[i])[j],
data);
1799 n_send_data[i] = n_particles_to_send;
1804 std::vector<unsigned int> n_recv_data(n_neighbors);
1805 std::vector<unsigned int> recv_offsets(n_neighbors);
1811 std::vector<MPI_Request> n_requests(2 * n_neighbors);
1812 for (
unsigned int i = 0; i < n_neighbors; ++i)
1815 MPI_Irecv(&(n_recv_data[i]),
1820 parallel_triangulation->get_mpi_communicator(),
1821 &(n_requests[2 * i]));
1824 for (
unsigned int i = 0; i < n_neighbors; ++i)
1827 MPI_Isend(&(n_send_data[i]),
1832 parallel_triangulation->get_mpi_communicator(),
1833 &(n_requests[2 * i + 1]));
1837 MPI_Waitall(2 * n_neighbors, n_requests.data(), MPI_STATUSES_IGNORE);
1842 unsigned int total_recv_data = 0;
1843 for (
unsigned int neighbor_id = 0; neighbor_id < n_neighbors; ++neighbor_id)
1845 recv_offsets[neighbor_id] = total_recv_data;
1847 n_recv_data[neighbor_id] * individual_total_particle_data_size;
1851 std::vector<char> recv_data(total_recv_data);
1855 std::vector<MPI_Request> requests(2 * n_neighbors);
1856 unsigned int send_ops = 0;
1857 unsigned int recv_ops = 0;
1862 for (
unsigned int i = 0; i < n_neighbors; ++i)
1863 if (n_recv_data[i] > 0)
1866 MPI_Irecv(&(recv_data[recv_offsets[i]]),
1867 n_recv_data[i] * individual_total_particle_data_size,
1871 parallel_triangulation->get_mpi_communicator(),
1872 &(requests[send_ops]));
1877 for (
unsigned int i = 0; i < n_neighbors; ++i)
1878 if (n_send_data[i] > 0)
1881 MPI_Isend(&(send_data[send_offsets[i]]),
1882 n_send_data[i] * individual_total_particle_data_size,
1886 parallel_triangulation->get_mpi_communicator(),
1887 &(requests[send_ops + recv_ops]));
1892 MPI_Waitall(send_ops + recv_ops, requests.data(), MPI_STATUSES_IGNORE);
1898 const void *recv_data_it =
static_cast<const void *
>(recv_data.data());
1901 auto &ghost_particles_iterators =
1902 ghost_particles_cache.ghost_particles_iterators;
1906 ghost_particles_iterators.clear();
1908 auto &send_pointers_particles = ghost_particles_cache.send_pointers;
1909 send_pointers_particles.assign(n_neighbors + 1, 0);
1911 for (
unsigned int i = 0; i < n_neighbors; ++i)
1912 send_pointers_particles[i + 1] =
1913 send_pointers_particles[i] +
1914 n_send_data[i] * individual_particle_data_size;
1916 auto &recv_pointers_particles = ghost_particles_cache.recv_pointers;
1917 recv_pointers_particles.assign(n_neighbors + 1, 0);
1919 for (
unsigned int i = 0; i < n_neighbors; ++i)
1920 recv_pointers_particles[i + 1] =
1921 recv_pointers_particles[i] +
1922 n_recv_data[i] * individual_particle_data_size;
1924 ghost_particles_cache.neighbors = neighbors;
1926 ghost_particles_cache.send_data.resize(
1927 ghost_particles_cache.send_pointers.back());
1928 ghost_particles_cache.recv_data.resize(
1929 ghost_particles_cache.recv_pointers.back());
1932 while (
reinterpret_cast<std::size_t
>(recv_data_it) -
1933 reinterpret_cast<std::size_t
>(recv_data.data()) <
1937 memcpy(&binary_cellid, recv_data_it, cellid_size);
1938 const CellId id(binary_cellid);
1939 recv_data_it =
static_cast<const char *
>(recv_data_it) + cellid_size;
1944 insert_particle(property_pool->register_particle(), cell);
1945 const typename particle_container::iterator &cache =
1946 cells_to_particle_cache[cell->active_cell_index()];
1951 cache->particles.size() - 1);
1954 particle_it->read_particle_data_from_memory(recv_data_it);
1957 recv_data_it = load_callback(particle_it, recv_data_it);
1960 ghost_particles_iterators.push_back(particle_it);
1963 AssertThrow(recv_data_it == recv_data.data() + recv_data.size(),
1965 "The amount of data that was read into new particles "
1966 "does not match the amount of data sent around."));
1972#ifdef DEAL_II_WITH_MPI
1973 template <
int dim,
int spacedim>
1979 const auto parallel_triangulation =
1983 parallel_triangulation,
1985 "This function is only implemented for parallel::TriangulationBase "
1988 const auto &neighbors = ghost_particles_cache.neighbors;
1989 const auto &send_pointers = ghost_particles_cache.send_pointers;
1990 const auto &recv_pointers = ghost_particles_cache.recv_pointers;
1992 std::vector<char> &send_data = ghost_particles_cache.send_data;
1995 if (send_pointers.back() > 0)
1997 void *
data =
static_cast<void *
>(&send_data.front());
2000 for (
const auto i : neighbors)
2001 for (
const auto &p : particles_to_send.at(i))
2003 data = p->write_particle_data_to_memory(
data);
2009 std::vector<char> &recv_data = ghost_particles_cache.recv_data;
2013 std::vector<MPI_Request> requests(2 * neighbors.size());
2014 unsigned int send_ops = 0;
2015 unsigned int recv_ops = 0;
2020 for (
unsigned int i = 0; i < neighbors.size(); ++i)
2021 if ((recv_pointers[i + 1] - recv_pointers[i]) > 0)
2024 MPI_Irecv(recv_data.data() + recv_pointers[i],
2025 recv_pointers[i + 1] - recv_pointers[i],
2029 parallel_triangulation->get_mpi_communicator(),
2030 &(requests[send_ops]));
2035 for (
unsigned int i = 0; i < neighbors.size(); ++i)
2036 if ((send_pointers[i + 1] - send_pointers[i]) > 0)
2039 MPI_Isend(send_data.data() + send_pointers[i],
2040 send_pointers[i + 1] - send_pointers[i],
2044 parallel_triangulation->get_mpi_communicator(),
2045 &(requests[send_ops + recv_ops]));
2050 MPI_Waitall(send_ops + recv_ops, requests.data(), MPI_STATUSES_IGNORE);
2056 const void *recv_data_it =
static_cast<const void *
>(recv_data.data());
2059 auto &ghost_particles_iterators =
2060 ghost_particles_cache.ghost_particles_iterators;
2062 for (
auto &recv_particle : ghost_particles_iterators)
2067 recv_particle->read_particle_data_from_memory(recv_data_it);
2069 Assert(recv_particle->particles_in_cell->cell->is_ghost(),
2073 recv_data_it = load_callback(
2076 recv_particle->particle_index_within_cell),
2080 AssertThrow(recv_data_it == recv_data.data() + recv_data.size(),
2082 "The amount of data that was read into new particles "
2083 "does not match the amount of data sent around."));
2087 template <
int dim,
int spacedim>
2090 const std::function<std::size_t()> &size_callb,
2095 size_callback = size_callb;
2096 store_callback = store_callb;
2097 load_callback = load_callb;
2101 template <
int dim,
int spacedim>
2106 for (
const auto &connection : tria_listeners)
2107 connection.disconnect();
2109 tria_listeners.clear();
2111 tria_listeners.push_back(
triangulation->signals.create.connect([&]() {
2112 this->initialize(*(this->triangulation),
2114 this->property_pool->n_properties_per_slot());
2117 this->tria_listeners.push_back(
2118 this->
triangulation->signals.clear.connect([&]() { this->clear(); }));
2124 tria_listeners.push_back(
2126 [&]() { this->post_mesh_change_action(); }));
2127 tria_listeners.push_back(
2128 triangulation->signals.post_distributed_repartition.connect(
2129 [&]() { this->post_mesh_change_action(); }));
2130 tria_listeners.push_back(
2132 [&]() { this->post_mesh_change_action(); }));
2136 tria_listeners.push_back(
triangulation->signals.post_refinement.connect(
2137 [&]() { this->post_mesh_change_action(); }));
2143 template <
int dim,
int spacedim>
2149 const bool distributed_triangulation =
2152 &(*triangulation)) !=
nullptr;
2153 (void)distributed_triangulation;
2156 distributed_triangulation || number_of_locally_owned_particles == 0,
2158 "Mesh refinement in a non-distributed triangulation is not supported "
2159 "by the ParticleHandler class. Either insert particles after mesh "
2160 "creation, or use a distributed triangulation."));
2164 if (number_of_locally_owned_particles == 0)
2165 cells_to_particle_cache.resize(
triangulation->n_active_cells(),
2171 template <
int dim,
int spacedim>
2175 register_data_attach();
2180 template <
int dim,
int spacedim>
2184 register_data_attach();
2189 template <
int dim,
int spacedim>
2193 const auto callback_function =
2197 return this->pack_callback(cell_iterator, cell_status);
2200 tria_attached_data_index =
2202 ->register_data_attach(callback_function,
2208 template <
int dim,
int spacedim>
2212 const bool serialization =
false;
2213 notify_ready_to_unpack(serialization);
2218 template <
int dim,
int spacedim>
2222 const bool serialization =
true;
2223 notify_ready_to_unpack(serialization);
2227 template <
int dim,
int spacedim>
2230 const bool serialization)
2240 register_data_attach();
2245 const auto callback_function =
2249 const boost::iterator_range<std::vector<char>::const_iterator>
2251 this->unpack_callback(cell_iterator, cell_status, range_iterator);
2255 ->notify_ready_to_unpack(tria_attached_data_index, callback_function);
2259 update_cached_numbers();
2265 template <
int dim,
int spacedim>
2271 std::vector<particle_iterator> stored_particles_on_cell;
2280 const unsigned int n_particles = n_particles_in_cell(cell);
2281 stored_particles_on_cell.reserve(n_particles);
2283 for (
unsigned int i = 0; i < n_particles; ++i)
2285 cells_to_particle_cache[cell->active_cell_index()],
2295 for (
const auto &child : cell->child_iterators())
2297 const unsigned int n_particles = n_particles_in_cell(child);
2299 stored_particles_on_cell.reserve(
2300 stored_particles_on_cell.size() + n_particles);
2302 const typename particle_container::iterator &cache =
2303 cells_to_particle_cache[child->active_cell_index()];
2304 for (
unsigned int i = 0; i < n_particles; ++i)
2305 stored_particles_on_cell.push_back(
2316 return pack_particles(stored_particles_on_cell);
2321 template <
int dim,
int spacedim>
2326 const boost::iterator_range<std::vector<char>::const_iterator> &data_range)
2328 if (data_range.begin() == data_range.end())
2331 const auto cell_to_store_particles =
2335 if (data_range.begin() != data_range.end())
2337 const void *
data =
static_cast<const void *
>(&(*data_range.begin()));
2338 const void *end =
static_cast<const void *
>(
2339 &(*data_range.begin()) + (data_range.end() - data_range.begin()));
2343 const void *old_data =
data;
2344 const auto x = insert_particle(
data, cell_to_store_particles);
2348 const void *new_data =
data;
2353 x->serialized_size_in_bytes());
2358 "The particle data could not be deserialized successfully. "
2359 "Check that when deserializing the particles you expect "
2360 "the same number of properties that were serialized."));
2363 auto loaded_particles_on_cell = particles_in_cell(cell_to_store_particles);
2378 for (
auto &particle : loaded_particles_on_cell)
2381 mapping->transform_real_to_unit_cell(cell_to_store_particles,
2382 particle.get_location());
2383 particle.set_reference_location(p_unit);
2392 typename particle_container::iterator &cache =
2393 cells_to_particle_cache[cell_to_store_particles
2394 ->active_cell_index()];
2401 auto particle = loaded_particles_on_cell.begin();
2402 for (
unsigned int i = 0; i < cache->particles.size();)
2404 bool found_new_cell =
false;
2406 for (
const auto &child : cell->child_iterators())
2413 mapping->transform_real_to_unit_cell(
2414 child, particle->get_location());
2416 p_unit, tolerance_inside_cell))
2418 found_new_cell =
true;
2419 particle->set_reference_location(p_unit);
2423 if (child != cell_to_store_particles)
2426 insert_particle(cache->particles[i], child);
2428 cache->particles[i] = cache->particles.back();
2429 cache->particles.pop_back();
2446 if (found_new_cell ==
false)
2455 signals.particle_lost(particle,
2456 particle->get_surrounding_cell());
2457 if (cache->particles[i] !=
2459 property_pool->deregister_particle(cache->particles[i]);
2460 cache->particles[i] = cache->particles.back();
2461 cache->particles.pop_back();
2465 if (cache->particles.empty())
2467 particles.erase(cache);
2468 cache = particles.end();
2480#include "particle_handler.inst"
@ children_will_be_coarsened
std::array< unsigned int, 4 > binary_type
const unsigned int n_components
virtual void vector_value(const Point< dim > &p, Vector< RangeNumberType > &values) const
void add_indices(const ForwardIterator &begin, const ForwardIterator &end)
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)
unsigned int tria_attached_data_index
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)
ObserverPointer< const Mapping< dim, spacedim >, ParticleHandler< dim, spacedim > > mapping
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()
std::enable_if_t< std::is_convertible_v< VectorType *, Function< spacedim > * >==false > set_particle_positions(const VectorType &input_vector, const bool displace_particles=true)
std::vector< char > pack_callback(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const CellStatus status) const
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 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
ObserverPointer< const Triangulation< dim, spacedim >, ParticleHandler< dim, spacedim > > triangulation
particle_iterator_range particles_in_cell(const typename Triangulation< dim, spacedim >::active_cell_iterator &cell)
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
void unpack_callback(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const CellStatus status, const boost::iterator_range< std::vector< char >::const_iterator > &data_range)
virtual ~ParticleHandler()
void copy_from(const ParticleHandler< dim, spacedim > &particle_handler)
types::particle_index get_next_free_particle_index() const
particle_container particles
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
types::particle_index get_id() const
ArrayView< double > get_properties()
numbers::NumberTraits< Number >::real_type norm() const
constexpr numbers::NumberTraits< Number >::real_type norm_square() const
IteratorState::IteratorStates state() const
#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
#define DEAL_II_ASSERT_UNREACHABLE()
std::vector< index_type > data
@ past_the_end
Iterator reached end of container.
@ valid
Iterator points to a valid object.
T sum(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)
unsigned int n_mpi_processes(const MPI_Comm mpi_communicator)
T max(const T &t, const MPI_Comm mpi_communicator)
std::vector< T > all_gather(const MPI_Comm comm, const T &object_to_send)
const types::subdomain_id artificial_subdomain_id
static const unsigned int invalid_unsigned_int
bool is_finite(const double x)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
unsigned int subdomain_id
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation
std::map< unsigned int, std::set<::types::subdomain_id > > * vertices_with_ghost_neighbors
#define DEAL_II_PARTICLE_INDEX_MPI_TYPE
static bool is_inside_unit_cell(const Point< dim > &p)