15#ifndef dealii_particles_particle_h
16#define dealii_particles_particle_h
26#include <boost/serialization/array.hpp>
92 template <
int dim,
int spacedim = dim>
425 template <
class Archive>
427 save(Archive &ar,
const unsigned int version)
const;
438 template <
class Archive>
440 load(Archive &ar,
const unsigned int version);
454 template <
class Archive>
456 serialize(Archive &archive,
const unsigned int version);
460 BOOST_SERIALIZATION_SPLIT_MEMBER()
486 template <
int dim,
int spacedim>
487 template <
class Archive>
491 unsigned int n_properties = 0;
496 ar &location &reference_location &
id &n_properties;
498 set_location(location);
499 set_reference_location(reference_location);
502 if (n_properties > 0)
506 properties.
size() == n_properties,
508 "This particle was serialized with " +
509 std::to_string(n_properties) +
510 " properties, but the new property handler provides space for " +
511 std::to_string(properties.
size()) +
512 " properties. Deserializing a particle only works for matching property sizes."));
514 ar &boost::serialization::make_array(properties.
data(), n_properties);
520 template <
int dim,
int spacedim>
521 template <
class Archive>
525 unsigned int n_properties = 0;
526 if ((property_pool !=
nullptr) &&
528 n_properties = get_properties().
size();
531 Point<dim> reference_location = get_reference_location();
534 ar &location &reference_location &
id &n_properties;
536 if (n_properties > 0)
537 ar &boost::serialization::make_array(get_properties().
data(),
543 template <
int dim,
int spacedim>
547 property_pool->
set_location(property_pool_handle, new_loc);
552 template <
int dim,
int spacedim>
556 return property_pool->
get_location(property_pool_handle);
561 template <
int dim,
int spacedim>
565 return property_pool->
get_location(property_pool_handle);
570 template <
int dim,
int spacedim>
579 template <
int dim,
int spacedim>
588 template <
int dim,
int spacedim>
592 return property_pool->
get_id(property_pool_handle);
597 template <
int dim,
int spacedim>
601 property_pool->
set_id(property_pool_handle, new_id);
606 template <
int dim,
int spacedim>
626 const Point<dim> reference_location = get_reference_location();
629 if ( has_properties())
634 std::copy(old_properties.
cbegin(),
635 old_properties.
cend(),
636 new_properties.
begin());
645 property_pool = &new_property_pool;
646 property_pool_handle = new_handle;
649 set_location(location);
650 set_reference_location(reference_location);
656 template <
int dim,
int spacedim>
660 if (has_properties() ==
false)
668 template <
int dim,
int spacedim>
677 Assert((property_pool_handle !=
701 template <
int dim,
int spacedim>
712 const ::Particles::Particle<dim, spacedim> &particle)
const
714 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