24 template <
int dim,
int spacedim>
29 , property_pool(nullptr)
35 template <
int dim,
int spacedim>
40 , reference_location(reference_location)
42 , property_pool(nullptr)
48 template <
int dim,
int spacedim>
50 : location(particle.get_location())
51 , reference_location(particle.get_reference_location())
52 , id(particle.get_id())
53 , property_pool(particle.property_pool)
54 , properties((particle.has_properties()) ?
55 property_pool->allocate_properties_array() :
61 property_pool->get_properties(properties);
66 their_properties.
end(),
67 my_properties.
begin());
73 template <
int dim,
int spacedim>
80 const double *pdata =
reinterpret_cast<const double *
>(id_data);
82 for (
unsigned int i = 0; i < spacedim; ++i)
83 location(i) = *pdata++;
85 for (
unsigned int i = 0; i < dim; ++i)
86 reference_location(i) = *pdata++;
88 property_pool = new_property_pool;
89 if (property_pool !=
nullptr)
92 properties = PropertyPool::invalid_handle;
98 property_pool->get_properties(properties);
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 : location(std::move(particle.location))
112 , reference_location(std::move(particle.reference_location))
113 , id(std::move(particle.id))
114 , property_pool(std::move(particle.property_pool))
115 , properties(std::move(particle.properties))
117 particle.
properties = PropertyPool::invalid_handle;
122 template <
int dim,
int spacedim>
126 if (
this != &particle)
135 properties = property_pool->allocate_properties_array();
139 property_pool->get_properties(properties);
142 their_properties.
end(),
143 my_properties.
begin());
146 properties = PropertyPool::invalid_handle;
153 template <
int dim,
int spacedim>
158 if (
this != &particle)
161 reference_location = particle.reference_location;
163 property_pool = particle.property_pool;
164 properties = particle.properties;
165 particle.properties = PropertyPool::invalid_handle;
172 template <
int dim,
int spacedim>
175 if (property_pool !=
nullptr && properties != PropertyPool::invalid_handle)
176 property_pool->deallocate_properties_array(properties);
181 template <
int dim,
int spacedim>
188 double *pdata =
reinterpret_cast<double *
>(id_data);
191 for (
unsigned int i = 0; i < spacedim; ++i, ++pdata)
192 *pdata = location(i);
195 for (
unsigned int i = 0; i < dim; ++i, ++pdata)
196 *pdata = reference_location(i);
199 if (has_properties())
202 property_pool->get_properties(properties);
203 for (
unsigned int i = 0; i < particle_properties.
size(); ++i, ++pdata)
204 *pdata = particle_properties[i];
207 data =
static_cast<void *
>(pdata);
212 template <
int dim,
int spacedim>
217 sizeof(reference_location);
219 if (has_properties())
222 property_pool->get_properties(properties);
223 size +=
sizeof(
double) * particle_properties.
size();
230 template <
int dim,
int spacedim>
239 template <
int dim,
int spacedim>
248 template <
int dim,
int spacedim>
252 reference_location = new_loc;
257 template <
int dim,
int spacedim>
261 return reference_location;
266 template <
int dim,
int spacedim>
275 template <
int dim,
int spacedim>
284 template <
int dim,
int spacedim>
288 property_pool = &new_property_pool;
293 template <
int dim,
int spacedim>
300 if (properties == PropertyPool::invalid_handle)
301 properties = property_pool->allocate_properties_array();
304 property_pool->get_properties(properties);
307 new_properties.
size() == old_properties.
size(),
310 "You are trying to assign properties with an incompatible length. ") +
311 "The particle has space to store " +
313 "and this function tries to assign" +
315 "This is not allowed."));
317 if (old_properties.
size() > 0)
319 new_properties.
end(),
320 old_properties.
begin());
325 template <
int dim,
int spacedim>
331 return property_pool->get_properties(properties);
336 template <
int dim,
int spacedim>
343 if (properties == PropertyPool::invalid_handle)
345 properties = property_pool->allocate_properties_array();
348 property_pool->get_properties(properties);
350 std::fill(my_properties.
begin(), my_properties.
end(), 0.0);
353 return property_pool->get_properties(properties);
358 template <
int dim,
int spacedim>
362 return (property_pool !=
nullptr) &&
363 (properties != PropertyPool::invalid_handle);
371 #include "particle.inst"