16#ifndef dealii_particles_particle_h
17#define dealii_particles_particle_h
27#include <boost/serialization/array.hpp>
95 template <
int dim,
int spacedim = dim>
404 template <
class Archive>
406 save(Archive &ar,
const unsigned int version)
const;
417 template <
class Archive>
419 load(Archive &ar,
const unsigned int version);
433 template <
class Archive>
435 serialize(Archive &archive,
const unsigned int version);
439 BOOST_SERIALIZATION_SPLIT_MEMBER()
465 template <
int dim,
int spacedim>
466 template <
class Archive>
470 unsigned int n_properties = 0;
475 ar &location &reference_location &
id &n_properties;
477 set_location(location);
478 set_reference_location(reference_location);
481 if (n_properties > 0)
485 properties.
size() == n_properties,
487 "This particle was serialized with " +
488 std::to_string(n_properties) +
489 " properties, but the new property handler provides space for " +
490 std::to_string(properties.
size()) +
491 " properties. Deserializing a particle only works for matching property sizes."));
493 ar &boost::serialization::make_array(properties.
data(), n_properties);
499 template <
int dim,
int spacedim>
500 template <
class Archive>
504 unsigned int n_properties = 0;
505 if ((property_pool !=
nullptr) &&
507 n_properties = get_properties().
size();
510 Point<dim> reference_location = get_reference_location();
513 ar &location &reference_location &
id &n_properties;
515 if (n_properties > 0)
516 ar &boost::serialization::make_array(get_properties().data(),
522 template <
int dim,
int spacedim>
526 property_pool->
set_location(property_pool_handle, new_loc);
531 template <
int dim,
int spacedim>
535 return property_pool->
get_location(property_pool_handle);
540 template <
int dim,
int spacedim>
549 template <
int dim,
int spacedim>
558 template <
int dim,
int spacedim>
562 return property_pool->
get_id(property_pool_handle);
567 template <
int dim,
int spacedim>
571 property_pool->
set_id(property_pool_handle, new_id);
576 template <
int dim,
int spacedim>
596 const Point<dim> reference_location = get_reference_location();
599 if ( has_properties())
604 std::copy(old_properties.
cbegin(),
605 old_properties.
cend(),
606 new_properties.
begin());
615 property_pool = &new_property_pool;
616 property_pool_handle = new_handle;
619 set_location(location);
620 set_reference_location(reference_location);
626 template <
int dim,
int spacedim>
630 if (has_properties() ==
false)
638 template <
int dim,
int spacedim>
647 Assert((property_pool_handle !=
671 template <
int dim,
int spacedim>
682 const ::Particles::Particle<dim, spacedim> &particle)
const
684 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)
const ArrayView< double > get_properties()
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
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
ArrayView< double > get_properties(const Handle handle)
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
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::pair< int, int > LevelInd
result_type operator()(const ::Particles::Particle< dim, spacedim > &particle) const