15#ifndef dealii_particles_particle_h
16#define dealii_particles_particle_h
26#include <boost/geometry/index/indexable.hpp>
27#include <boost/serialization/array.hpp>
94 template <
int dim,
int spacedim = dim>
427 template <
class Archive>
429 save(Archive &ar,
const unsigned int version)
const;
440 template <
class Archive>
442 load(Archive &ar,
const unsigned int version);
456 template <
class Archive>
458 serialize(Archive &archive,
const unsigned int version);
462 BOOST_SERIALIZATION_SPLIT_MEMBER()
488 template <
int dim,
int spacedim>
489 template <
class Archive>
493 unsigned int n_properties = 0;
498 ar &location &reference_location &
id &n_properties;
500 set_location(location);
501 set_reference_location(reference_location);
504 if (n_properties > 0)
508 properties.
size() == n_properties,
510 "This particle was serialized with " +
511 std::to_string(n_properties) +
512 " properties, but the new property handler provides space for " +
513 std::to_string(properties.
size()) +
514 " properties. Deserializing a particle only works for matching property sizes."));
516 ar &boost::serialization::make_array(properties.
data(), n_properties);
522 template <
int dim,
int spacedim>
523 template <
class Archive>
527 unsigned int n_properties = 0;
528 if ((property_pool !=
nullptr) &&
530 n_properties = get_properties().
size();
533 Point<dim> reference_location = get_reference_location();
536 ar &location &reference_location &
id &n_properties;
538 if (n_properties > 0)
539 ar &boost::serialization::make_array(get_properties().
data(),
545 template <
int dim,
int spacedim>
549 property_pool->
set_location(property_pool_handle, new_loc);
554 template <
int dim,
int spacedim>
558 return property_pool->
get_location(property_pool_handle);
563 template <
int dim,
int spacedim>
567 return property_pool->
get_location(property_pool_handle);
572 template <
int dim,
int spacedim>
581 template <
int dim,
int spacedim>
590 template <
int dim,
int spacedim>
594 return property_pool->
get_id(property_pool_handle);
599 template <
int dim,
int spacedim>
603 property_pool->
set_id(property_pool_handle, new_id);
608 template <
int dim,
int spacedim>
628 const Point<dim> reference_location = get_reference_location();
631 if ( has_properties())
636 std::copy(old_properties.
cbegin(),
637 old_properties.
cend(),
638 new_properties.
begin());
647 property_pool = &new_property_pool;
648 property_pool_handle = new_handle;
651 set_location(location);
652 set_reference_location(reference_location);
658 template <
int dim,
int spacedim>
662 if (has_properties() ==
false)
670 template <
int dim,
int spacedim>
679 Assert((property_pool_handle !=
699 template <
int dim,
int spacedim>
710 const ::Particles::Particle<dim, spacedim> &particle)
const
712 return particle.get_location();
const_iterator cend() const
const_iterator cbegin() const
value_type * data() const noexcept
PropertyPool< dim, spacedim > * property_pool
void set_property_pool(PropertyPool< dim, spacedim > &property_pool)
const Point< dim > & get_reference_location() const
const Point< spacedim > & get_location() const
bool has_properties() const
static PropertyPool< dim, spacedim > global_property_pool
void set_reference_location(const Point< dim > &new_reference_location)
std::size_t serialized_size_in_bytes() const
void save(Archive &ar, const unsigned int version) const
Particle< dim, spacedim > & operator=(const Particle< dim, spacedim > &particle)
void set_properties(const ArrayView< const double > &new_properties)
const void * read_particle_data_from_memory(const void *data)
void * write_particle_data_to_memory(void *data) const
types::particle_index get_id() const
ArrayView< double > get_properties()
PropertyPool< dim, spacedim >::Handle property_pool_handle
void load(Archive &ar, const unsigned int version)
void set_id(const types::particle_index &new_id)
void serialize(Archive &archive, const unsigned int version)
void set_location(const Point< spacedim > &new_location)
const Point< spacedim > & get_location(const Handle handle) const
unsigned int n_properties_per_slot() const
void deregister_particle(Handle &handle)
void set_id(const Handle handle, const types::particle_index &new_id)
types::particle_index get_id(const Handle handle) const
void set_reference_location(const Handle handle, const Point< dim > &new_reference_location)
void set_location(const Handle handle, const Point< spacedim > &new_location)
const Point< dim > & get_reference_location(const Handle handle) const
ArrayView< double, ::MemorySpace::Host > get_properties(const Handle handle)
Handle register_particle()
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
std::vector< index_type > data
std::pair< int, int > LevelInd
result_type operator()(const ::Particles::Particle< dim, spacedim > &particle) const