21 template <
int dim,
int spacedim>
26 template <
int dim,
int spacedim>
28 : property_pool(&global_property_pool)
29 , property_pool_handle(property_pool->register_particle())
34 template <
int dim,
int spacedim>
38 : property_pool(&global_property_pool)
39 , property_pool_handle(property_pool->register_particle())
48 template <
int dim,
int spacedim>
50 : property_pool(particle.property_pool)
51 , property_pool_handle(property_pool->register_particle())
64 std::copy(their_properties.
begin(),
65 their_properties.
end(),
66 my_properties.
begin());
72 template <
int dim,
int spacedim>
76 : property_pool(new_property_pool != nullptr ? new_property_pool :
77 &global_property_pool)
78 , property_pool_handle(property_pool->register_particle())
83 const double *pdata =
reinterpret_cast<const double *
>(id_data);
86 for (
unsigned int i = 0; i < spacedim; ++i)
87 location[i] = *pdata++;
91 for (
unsigned int i = 0; i < dim; ++i)
92 reference_location[i] = *pdata++;
99 const unsigned int size = particle_properties.
size();
100 for (
unsigned int i = 0; i <
size; ++i)
101 particle_properties[i] = *pdata++;
104 data =
static_cast<const void *
>(pdata);
109 template <
int dim,
int spacedim>
111 : property_pool(std::move(particle.property_pool))
112 , property_pool_handle(std::move(particle.property_pool_handle))
125 template <
int dim,
int spacedim>
129 if (
this != &particle)
131 Assert(this->property_pool->n_properties_per_slot() ==
137 set_id(particle.
get_id());
144 property_pool->get_properties(property_pool_handle);
146 std::copy(their_properties.
begin(),
147 their_properties.
end(),
148 my_properties.
begin());
157 template <
int dim,
int spacedim>
162 if (
this != &particle)
168 property_pool->deregister_particle(property_pool_handle);
170 property_pool = std::move(particle.property_pool);
171 property_pool_handle = std::move(particle.property_pool_handle);
179 particle.property_pool_handle =
187 template <
int dim,
int spacedim>
199 template <
int dim,
int spacedim>
209 property_pool->deregister_particle(property_pool_handle);
214 template <
int dim,
int spacedim>
217 void *data_pointer)
const
223 double *pdata =
reinterpret_cast<double *
>(id_data);
226 for (
unsigned int i = 0; i < spacedim; ++i, ++pdata)
227 *pdata = get_location()[i];
230 for (
unsigned int i = 0; i < dim; ++i, ++pdata)
231 *pdata = get_reference_location()[i];
234 if (has_properties())
237 property_pool->get_properties(property_pool_handle);
238 for (
unsigned int i = 0; i < particle_properties.
size(); ++i, ++pdata)
239 *pdata = particle_properties[i];
242 return static_cast<void *
>(pdata);
247 template <
int dim,
int spacedim>
250 const void *data_pointer)
255 const double *pdata =
reinterpret_cast<const double *
>(id_data);
258 for (
unsigned int i = 0; i < spacedim; ++i)
259 location[i] = *pdata++;
260 set_location(location);
263 for (
unsigned int i = 0; i < dim; ++i)
264 reference_location[i] = *pdata++;
265 set_reference_location(reference_location);
268 if (has_properties())
271 property_pool->get_properties(property_pool_handle);
272 const unsigned int size = particle_properties.
size();
273 for (
unsigned int i = 0; i <
size; ++i)
274 particle_properties[i] = *pdata++;
277 return static_cast<const void *
>(pdata);
282 template <
int dim,
int spacedim>
286 std::size_t
size =
sizeof(get_id()) +
287 sizeof(
double) * spacedim +
288 sizeof(double) * dim;
290 if (has_properties())
293 property_pool->get_properties(property_pool_handle);
294 size +=
sizeof(double) * particle_properties.
size();
301 template <
int dim,
int spacedim>
307 property_pool->get_properties(property_pool_handle);
311 "You are trying to assign properties with an incompatible length. "
312 "The particle has space to store " +
313 std::to_string(property_values.
size()) +
314 " properties, but you are trying to assign " +
315 std::to_string(new_properties.
size()) +
316 " properties. This is not allowed."));
318 if (property_values.
size() > 0)
319 std::copy(new_properties.
begin(),
320 new_properties.
end(),
321 property_values.
begin());
326 template <
int dim,
int spacedim>
330 return property_pool->get_properties(property_pool_handle);
334#include "particles/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