15#ifndef dealii_particles_particle_handler_h
16#define dealii_particles_particle_handler_h
37#include <boost/range/iterator_range.hpp>
38#include <boost/serialization/map.hpp>
61 template <
int dim,
int spacedim = dim>
96 const unsigned int n_properties = 0);
111 const unsigned int n_properties = 0);
165 reserve(
const std::size_t n_particles);
393 std::map<unsigned int, IndexSet>
397 &global_bounding_boxes,
398 const std::vector<std::vector<double>> &properties = {},
399 const std::vector<types::particle_index> &ids = {});
431 std::map<unsigned int, IndexSet>
433 const std::vector<Particle<dim, spacedim>> &
particles,
435 &global_bounding_boxes);
480 template <
typename VectorType>
482 std::is_convertible_v<VectorType *, Function<spacedim> *> ==
false>
484 const bool displace_particles =
true);
508 const bool displace_particles =
true);
531 const bool displace_particles =
true);
560 template <
typename VectorType>
563 const bool add_to_output_vector =
false);
581 const bool add_to_output_vector =
false);
697 PropertyPool<dim, spacedim> &
827 template <
class Archive>
829 serialize(Archive &ar,
const unsigned int version);
858 boost::signals2::signal<void(
1037#ifdef DEAL_II_WITH_MPI
1069 &new_cells_for_particles = std::map<
1073 const bool enable_cache =
false);
1089 &particles_to_send);
1161 const boost::iterator_range<std::vector<char>::const_iterator>
1168 typename particle_container::iterator
1175 typename particle_container::iterator
1182 typename particle_container::iterator
1189 typename particle_container::iterator
1198 template <
int dim,
int spacedim>
1207 template <
int dim,
int spacedim>
1218 template <
int dim,
int spacedim>
1227 template <
int dim,
int spacedim>
1236 template <
int dim,
int spacedim>
1245 template <
int dim,
int spacedim>
1256 template <
int dim,
int spacedim>
1265 template <
int dim,
int spacedim>
1274 template <
int dim,
int spacedim>
1281 typename particle_container::iterator begin =
1288 template <
int dim,
int spacedim>
1293 return owned_particles_end;
1298 template <
int dim,
int spacedim>
1303 typename particle_container::iterator begin = owned_particles_end;
1309 template <
int dim,
int spacedim>
1314 typename particle_container::iterator end =
1321 template <
int dim,
int spacedim>
1322 template <
class Archive>
1333 ar &global_number_of_particles &global_max_particles_per_cell
1334 &next_free_particle_index;
1339 template <
int dim,
int spacedim>
1340 template <
typename VectorType>
1341 inline std::enable_if_t<
1342 std::is_convertible_v<VectorType *, Function<spacedim> *> ==
false>
1344 const VectorType &input_vector,
1345 const bool displace_particles)
1348 get_next_free_particle_index() * spacedim);
1349 for (
auto &p : *
this)
1352 const auto id = p.get_id();
1354 if (displace_particles)
1355 for (
unsigned int i = 0; i < spacedim; ++i)
1356 position[i] += input_vector[
id * spacedim + i];
1358 for (
unsigned int i = 0; i < spacedim; ++i)
1359 position[i] = input_vector[
id * spacedim + i];
1361 sort_particles_into_subdomains_and_cells();
1366 template <
int dim,
int spacedim>
1367 template <
typename VectorType>
1370 VectorType &output_vector,
1371 const bool add_to_output_vector)
1374 get_next_free_particle_index() * spacedim);
1375 for (
const auto &p : *
this)
1377 auto point = p.get_location();
1378 const auto id = p.get_id();
1379 if (add_to_output_vector)
1380 for (
unsigned int i = 0; i < spacedim; ++i)
1381 output_vector[
id * spacedim + i] += point[i];
1383 for (
unsigned int i = 0; i < spacedim; ++i)
1384 output_vector[
id * spacedim + i] = point[i];
1386 if (add_to_output_vector)
Abstract base class for mapping classes.
std::list< ParticlesInCell > particle_container
std::function< void *(const particle_iterator &, void *)> store_callback
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
particle_iterator end_ghost() 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
typename ParticleAccessor< dim, spacedim >::particle_container particle_container
const double tolerance_inside_cell
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)
ParticleIterator< dim, spacedim > particle_iterator
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
particle_iterator begin_ghost() const
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)
void serialize(Archive &ar, const unsigned int version)
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)
particle_iterator begin() const
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)
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::function< std::size_t()> size_callback
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
const particle_container::iterator owned_particles_end
void register_store_callback_function()
particle_iterator end() const
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()
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
std::vector< boost::signals2::connection > tria_listeners
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()
std::vector< typename particle_container::iterator > cells_to_particle_cache
void copy_from(const ParticleHandler< dim, spacedim > &particle_handler)
std::function< const void *(const particle_iterator &, const void *)> load_callback
SmartPointer< const Mapping< dim, spacedim >, ParticleHandler< dim, spacedim > > mapping
std::unique_ptr< GridTools::Cache< dim, spacedim > > triangulation_cache
types::particle_index get_next_free_particle_index() const
particle_container particles
IndexSet locally_owned_particle_ids() const
#define DEAL_II_DEPRECATED
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcInternalError()
boost::signals2::signal< void(const typename Particles::ParticleIterator< dim, spacedim > &particle, const typename Triangulation< dim, spacedim >::active_cell_iterator &cell)> particle_lost