24 template <
int dim,
int spacedim>
29 template <
int dim,
int spacedim>
31 : property_pool(&global_property_pool)
32 , property_pool_handle(property_pool->register_particle())
37 template <
int dim,
int spacedim>
41 : property_pool(&global_property_pool)
42 , property_pool_handle(property_pool->register_particle())
51 template <
int dim,
int spacedim>
53 : property_pool(particle.property_pool)
54 , property_pool_handle(property_pool->register_particle())
67 std::copy(their_properties.
begin(),
68 their_properties.
end(),
69 my_properties.
begin());
75 template <
int dim,
int spacedim>
79 : property_pool(new_property_pool != nullptr ? new_property_pool :
80 &global_property_pool)
81 , property_pool_handle(property_pool->register_particle())
86 const double *pdata =
reinterpret_cast<const double *
>(id_data);
89 for (
unsigned int i = 0; i < spacedim; ++i)
90 location(i) = *pdata++;
94 for (
unsigned int i = 0; i < dim; ++i)
95 reference_location(i) = *pdata++;
102 const unsigned int size = particle_properties.
size();
103 for (
unsigned int i = 0; i < size; ++i)
104 particle_properties[i] = *pdata++;
107 data =
static_cast<const void *
>(pdata);
112 template <
int dim,
int spacedim>
114 : property_pool(std::move(particle.property_pool))
115 , property_pool_handle(std::move(particle.property_pool_handle))
128 template <
int dim,
int spacedim>
132 if (
this != &particle)
134 Assert(this->property_pool->n_properties_per_slot() ==
140 set_id(particle.
get_id());
147 property_pool->get_properties(property_pool_handle);
149 std::copy(their_properties.
begin(),
150 their_properties.
end(),
151 my_properties.
begin());
160 template <
int dim,
int spacedim>
165 if (
this != &particle)
171 property_pool->deregister_particle(property_pool_handle);
173 property_pool = std::move(particle.property_pool);
174 property_pool_handle = std::move(particle.property_pool_handle);
182 particle.property_pool_handle =
190 template <
int dim,
int spacedim>
197 property_pool->deregister_particle(property_pool_handle);
202 template <
int dim,
int spacedim>
212 property_pool->deregister_particle(property_pool_handle);
217 template <
int dim,
int spacedim>
220 void *data_pointer)
const
226 double *pdata =
reinterpret_cast<double *
>(id_data);
229 for (
unsigned int i = 0; i < spacedim; ++i, ++pdata)
230 *pdata = get_location()[i];
233 for (
unsigned int i = 0; i < dim; ++i, ++pdata)
234 *pdata = get_reference_location()[i];
237 if (has_properties())
240 property_pool->get_properties(property_pool_handle);
241 for (
unsigned int i = 0; i < particle_properties.
size(); ++i, ++pdata)
242 *pdata = particle_properties[i];
245 return static_cast<void *
>(pdata);
250 template <
int dim,
int spacedim>
253 const void *data_pointer)
258 const double *pdata =
reinterpret_cast<const double *
>(id_data);
261 for (
unsigned int i = 0; i < spacedim; ++i)
262 location(i) = *pdata++;
263 set_location(location);
266 for (
unsigned int i = 0; i < dim; ++i)
267 reference_location(i) = *pdata++;
268 set_reference_location(reference_location);
271 if (has_properties())
274 property_pool->get_properties(property_pool_handle);
275 const unsigned int size = particle_properties.
size();
276 for (
unsigned int i = 0; i < size; ++i)
277 particle_properties[i] = *pdata++;
280 return static_cast<const void *
>(pdata);
285 template <
int dim,
int spacedim>
289 std::size_t size =
sizeof(get_id()) +
sizeof(get_location()) +
290 sizeof(get_reference_location());
292 if (has_properties())
295 property_pool->get_properties(property_pool_handle);
296 size +=
sizeof(double) * particle_properties.
size();
303 template <
int dim,
int spacedim>
309 property_pool->get_properties(property_pool_handle);
313 "You are trying to assign properties with an incompatible length. "
314 "The particle has space to store " +
315 std::to_string(property_values.
size()) +
316 " properties, but you are trying to assign " +
317 std::to_string(new_properties.
size()) +
318 " properties. This is not allowed."));
320 if (property_values.
size() > 0)
321 std::copy(new_properties.
begin(),
322 new_properties.
end(),
323 property_values.
begin());
328 template <
int dim,
int spacedim>
332 return property_pool->get_properties(property_pool_handle);
340#include "particle.inst"
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
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 set_id(const types::particle_index &new_id)
void set_location(const Point< spacedim > &new_location)
unsigned int n_properties_per_slot() const
ArrayView< double > get_properties(const Handle handle)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)