16#ifndef dealii_particles_particle_handler_h
17#define dealii_particles_particle_handler_h
39#include <boost/range/iterator_range.hpp>
40#include <boost/serialization/map.hpp>
60 template <
int dim,
int spacedim = dim>
89 const unsigned int n_properties = 0);
104 const unsigned int n_properties = 0);
394 std::map<unsigned int, IndexSet>
398 & global_bounding_boxes,
399 const std::vector<std::vector<double>> & properties = {},
400 const std::vector<types::particle_index> &ids = {});
432 std::map<unsigned int, IndexSet>
434 const std::vector<Particle<dim, spacedim>> &
particles,
436 &global_bounding_boxes);
481 template <
class VectorType>
482 typename std::enable_if<
483 std::is_convertible<VectorType *, Function<spacedim> *>::value ==
486 const bool displace_particles =
true);
510 const bool displace_particles =
true);
533 const bool displace_particles =
true);
562 template <
class VectorType>
565 const bool add_to_output_vector =
false);
583 const bool add_to_output_vector =
false);
704 PropertyPool<dim, spacedim> &
764 template <
class Archive>
766 serialize(Archive &ar,
const unsigned int version);
795 boost::signals2::signal<void(
836 std::multimap<internal::LevelInd, Particle<dim, spacedim>>
particles;
924#ifdef DEAL_II_WITH_MPI
963 &new_cells_for_particles = std::map<
967 const bool enable_cache =
false);
991 &received_particles);
1022 const boost::iterator_range<std::vector<char>::const_iterator>
1031 template <
int dim,
int spacedim>
1040 template <
int dim,
int spacedim>
1049 template <
int dim,
int spacedim>
1058 template <
int dim,
int spacedim>
1067 template <
int dim,
int spacedim>
1076 template <
int dim,
int spacedim>
1085 template <
int dim,
int spacedim>
1094 template <
int dim,
int spacedim>
1103 template <
int dim,
int spacedim>
1104 template <
class Archive>
1113 &global_number_of_particles &global_max_particles_per_cell
1114 & next_free_particle_index;
1119 template <
int dim,
int spacedim>
1120 template <
class VectorType>
1121 inline typename std::enable_if<
1122 std::is_convertible<VectorType *, Function<spacedim> *>::value ==
1125 const VectorType &input_vector,
1126 const bool displace_particles)
1129 get_next_free_particle_index() * spacedim);
1130 for (
auto &p : *
this)
1132 auto new_point(displace_particles ? p.get_location() :
1134 const auto id = p.get_id();
1135 for (
unsigned int i = 0; i < spacedim; ++i)
1136 new_point[i] += input_vector[
id * spacedim + i];
1137 p.set_location(new_point);
1139 sort_particles_into_subdomains_and_cells();
1144 template <
int dim,
int spacedim>
1145 template <
class VectorType>
1148 VectorType &output_vector,
1149 const bool add_to_output_vector)
1152 get_next_free_particle_index() * spacedim);
1153 for (
const auto &p : *
this)
1155 auto point = p.get_location();
1156 const auto id = p.get_id();
1157 if (add_to_output_vector)
1158 for (
unsigned int i = 0; i < spacedim; ++i)
1159 output_vector[
id * spacedim + i] +=
point[i];
1161 for (
unsigned int i = 0; i < spacedim; ++i)
1162 output_vector[
id * spacedim + i] =
point[i];
1164 if (add_to_output_vector)
1172 template <
int dim,
int spacedim>
1176 return this->locally_owned_particle_ids();
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)
types::particle_index n_global_particles() const
std::multimap< internal::LevelInd, Particle< dim, spacedim > > particles
particle_iterator end_ghost() const
unsigned int global_max_particles_per_cell
internal::GhostParticlePartitioner< dim, spacedim > ghost_particles_cache
IndexSet locally_relevant_ids() const
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)
void update_cached_numbers()
boost::iterator_range< particle_iterator > particle_iterator_range
std::multimap< internal::LevelInd, Particle< dim, spacedim > > ghost_particles
ParticleIterator< dim, spacedim > particle_iterator
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
particle_iterator begin() const
void send_recv_particles_properties_and_location(const std::map< types::subdomain_id, std::vector< particle_iterator > > &particles_to_send, std::multimap< internal::LevelInd, Particle< dim, spacedim > > &received_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 register_load_callback_function(const bool serialization)
virtual ~ParticleHandler() override=default
std::function< std::size_t()> size_callback
std::vector< char > store_particles(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const typename Triangulation< dim, spacedim >::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 register_store_callback_function()
particle_iterator end() const
void remove_particle(const particle_iterator &particle)
types::particle_index n_locally_owned_particles() const
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)
void load_particles(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)
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()
types::particle_index n_global_max_particles_per_cell() const
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
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
void send_recv_particles(const std::map< types::subdomain_id, std::vector< particle_iterator > > &particles_to_send, std::multimap< internal::LevelInd, Particle< dim, spacedim > > &received_particles, 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)
IndexSet locally_owned_particle_ids() const
#define DEAL_II_DEPRECATED
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define AssertDimension(dim1, dim2)
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
std::pair< int, int > LevelInd
boost::signals2::signal< void(const typename Particles::ParticleIterator< dim, spacedim > &particle, const typename Triangulation< dim, spacedim >::active_cell_iterator &cell)> particle_lost