23 template <
int dim,
int spacedim>
28 template <
int dim,
int spacedim>
30 : property_pool(&global_property_pool)
31 , property_pool_handle(property_pool->register_particle())
36 template <
int dim,
int spacedim>
40 : property_pool(&global_property_pool)
41 , property_pool_handle(property_pool->register_particle())
50 template <
int dim,
int spacedim>
52 : property_pool(particle.property_pool)
53 , property_pool_handle(property_pool->register_particle())
66 std::copy(their_properties.
begin(),
67 their_properties.
end(),
68 my_properties.
begin());
74 template <
int dim,
int spacedim>
78 : property_pool(new_property_pool != nullptr ? new_property_pool :
79 &global_property_pool)
80 , property_pool_handle(property_pool->register_particle())
85 const double *pdata =
reinterpret_cast<const double *
>(id_data);
88 for (
unsigned int i = 0; i < spacedim; ++i)
89 location[i] = *pdata++;
93 for (
unsigned int i = 0; i < dim; ++i)
94 reference_location[i] = *pdata++;
101 const unsigned int size = particle_properties.
size();
102 for (
unsigned int i = 0; i <
size; ++i)
103 particle_properties[i] = *pdata++;
106 data =
static_cast<const void *
>(pdata);
111 template <
int dim,
int spacedim>
113 : property_pool(std::move(particle.property_pool))
114 , property_pool_handle(std::move(particle.property_pool_handle))
127 template <
int dim,
int spacedim>
131 if (
this != &particle)
133 Assert(this->property_pool->n_properties_per_slot() ==
139 set_id(particle.
get_id());
146 property_pool->get_properties(property_pool_handle);
148 std::copy(their_properties.
begin(),
149 their_properties.
end(),
150 my_properties.
begin());
159 template <
int dim,
int spacedim>
164 if (
this != &particle)
170 property_pool->deregister_particle(property_pool_handle);
172 property_pool = std::move(particle.property_pool);
173 property_pool_handle = std::move(particle.property_pool_handle);
181 particle.property_pool_handle =
189 template <
int dim,
int spacedim>
201 template <
int dim,
int spacedim>
211 property_pool->deregister_particle(property_pool_handle);
216 template <
int dim,
int spacedim>
219 void *data_pointer)
const
225 double *pdata =
reinterpret_cast<double *
>(id_data);
228 for (
unsigned int i = 0; i < spacedim; ++i, ++pdata)
229 *pdata = get_location()[i];
232 for (
unsigned int i = 0; i < dim; ++i, ++pdata)
233 *pdata = get_reference_location()[i];
236 if (has_properties())
239 property_pool->get_properties(property_pool_handle);
240 for (
unsigned int i = 0; i < particle_properties.
size(); ++i, ++pdata)
241 *pdata = particle_properties[i];
244 return static_cast<void *
>(pdata);
249 template <
int dim,
int spacedim>
252 const void *data_pointer)
257 const double *pdata =
reinterpret_cast<const double *
>(id_data);
260 for (
unsigned int i = 0; i < spacedim; ++i)
261 location[i] = *pdata++;
262 set_location(location);
265 for (
unsigned int i = 0; i < dim; ++i)
266 reference_location[i] = *pdata++;
267 set_reference_location(reference_location);
270 if (has_properties())
273 property_pool->get_properties(property_pool_handle);
274 const unsigned int size = particle_properties.
size();
275 for (
unsigned int i = 0; i <
size; ++i)
276 particle_properties[i] = *pdata++;
279 return static_cast<const void *
>(pdata);
284 template <
int dim,
int spacedim>
288 std::size_t
size =
sizeof(get_id()) +
289 sizeof(
double) * spacedim +
290 sizeof(double) * dim;
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)
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 set_id(const types::particle_index &new_id)
void set_location(const Point< spacedim > &new_location)
unsigned int n_properties_per_slot() const
void deregister_particle(Handle &handle)
ArrayView< double, ::MemorySpace::Host > 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)
std::vector< index_type > data