16 #include <deal.II/particles/particle.h>
18 DEAL_II_NAMESPACE_OPEN
22 template <
int dim,
int spacedim>
25 , reference_location()
27 , property_pool(nullptr)
33 template <
int dim,
int spacedim>
38 , reference_location(reference_location)
40 , property_pool(nullptr)
46 template <
int dim,
int spacedim>
48 : location(particle.get_location())
49 , reference_location(particle.get_reference_location())
50 , id(particle.get_id())
51 , property_pool(particle.property_pool)
52 , properties((particle.has_properties()) ?
53 property_pool->allocate_properties_array() :
63 std::copy(their_properties.
begin(),
64 their_properties.
end(),
65 my_properties.
begin());
71 template <
int dim,
int spacedim>
76 static_cast<const types::particle_index *>(data);
78 const double *pdata = reinterpret_cast<const double *>(id_data);
80 for (
unsigned int i = 0; i < spacedim; ++i)
81 location(i) = *pdata++;
83 for (
unsigned int i = 0; i < dim; ++i)
84 reference_location(i) = *pdata++;
86 property_pool = new_property_pool;
87 if (property_pool !=
nullptr)
96 property_pool->get_properties(properties);
97 const unsigned int size = particle_properties.
size();
98 for (
unsigned int i = 0; i < size; ++i)
99 particle_properties[i] = *pdata++;
102 data = static_cast<const void *>(pdata);
107 template <
int dim,
int spacedim>
109 : location(std::move(particle.location))
110 , reference_location(std::move(particle.reference_location))
111 , id(std::move(particle.id))
112 , property_pool(std::move(particle.property_pool))
113 , properties(std::move(particle.properties))
120 template <
int dim,
int spacedim>
124 if (
this != &particle)
137 property_pool->get_properties(properties);
139 std::copy(their_properties.
begin(),
140 their_properties.
end(),
141 my_properties.
begin());
151 template <
int dim,
int spacedim>
156 if (
this != &particle)
158 location = particle.location;
159 reference_location = particle.reference_location;
161 property_pool = particle.property_pool;
162 properties = particle.properties;
170 template <
int dim,
int spacedim>
174 property_pool->deallocate_properties_array(properties);
179 template <
int dim,
int spacedim>
186 double *pdata = reinterpret_cast<double *>(id_data);
189 for (
unsigned int i = 0; i < spacedim; ++i, ++pdata)
190 *pdata = location(i);
193 for (
unsigned int i = 0; i < dim; ++i, ++pdata)
194 *pdata = reference_location(i);
197 if (has_properties())
200 property_pool->get_properties(properties);
201 for (
unsigned int i = 0; i < particle_properties.
size(); ++i, ++pdata)
202 *pdata = particle_properties[i];
205 data = static_cast<void *>(pdata);
210 template <
int dim,
int spacedim>
215 sizeof(reference_location);
217 if (has_properties())
220 property_pool->get_properties(properties);
221 size +=
sizeof(double) * particle_properties.
size();
228 template <
int dim,
int spacedim>
237 template <
int dim,
int spacedim>
246 template <
int dim,
int spacedim>
250 reference_location = new_loc;
255 template <
int dim,
int spacedim>
259 return reference_location;
264 template <
int dim,
int spacedim>
273 template <
int dim,
int spacedim>
277 property_pool = &new_property_pool;
282 template <
int dim,
int spacedim>
290 properties = property_pool->allocate_properties_array();
293 property_pool->get_properties(properties);
296 new_properties.
size() == old_properties.
size(),
299 "You are trying to assign properties with an incompatible length. ") +
300 "The particle has space to store " +
302 "and this function tries to assign" +
304 "This is not allowed."));
306 if (old_properties.
size() > 0)
307 std::copy(new_properties.
begin(),
308 new_properties.
end(),
309 old_properties.
begin());
314 template <
int dim,
int spacedim>
320 return property_pool->get_properties(properties);
325 template <
int dim,
int spacedim>
334 properties = property_pool->allocate_properties_array();
337 property_pool->get_properties(properties);
339 std::fill(my_properties.
begin(), my_properties.
end(), 0.0);
342 return property_pool->get_properties(properties);
347 template <
int dim,
int spacedim>
351 return (property_pool !=
nullptr) &&
356 DEAL_II_NAMESPACE_CLOSE
358 DEAL_II_NAMESPACE_OPEN
360 #include "particle.inst"
362 DEAL_II_NAMESPACE_CLOSE