16 #include <deal.II/particles/particle.h> 18 DEAL_II_NAMESPACE_OPEN
22 template <
int dim,
int spacedim>
28 property_pool(nullptr),
35 template <
int dim,
int spacedim>
41 reference_location (reference_location),
43 property_pool(nullptr),
50 template <
int dim,
int spacedim>
53 location (particle.get_location()),
54 reference_location (particle.get_reference_location()),
55 id (particle.get_id()),
56 property_pool(particle.property_pool),
57 properties ((particle.has_properties()) ? property_pool->allocate_properties_array() :
PropertyPool::invalid_handle)
64 std::copy(their_properties.
begin(), their_properties.
end(), my_properties.
begin());
70 template <
int dim,
int spacedim>
76 const double *pdata =
reinterpret_cast<const double *
> (id_data);
78 for (
unsigned int i = 0; i < spacedim; ++i)
79 location(i) = *pdata++;
81 for (
unsigned int i = 0; i < dim; ++i)
82 reference_location(i) = *pdata++;
84 property_pool = new_property_pool;
85 if (property_pool !=
nullptr)
93 const ArrayView<double> particle_properties = property_pool->get_properties(properties);
94 const unsigned int size = particle_properties.
size();
95 for (
unsigned int i = 0; i < size; ++i)
96 particle_properties[i] = *pdata++;
99 data =
static_cast<const void *
> (pdata);
104 template <
int dim,
int spacedim>
107 location (std::move(particle.location)),
108 reference_location(std::move(particle.reference_location)),
109 id (std::move(particle.id)),
110 property_pool(std::move(particle.property_pool)),
111 properties(std::move(particle.properties))
118 template <
int dim,
int spacedim>
122 if (
this != &particle)
133 const ArrayView<double> my_properties = property_pool->get_properties(properties);
135 std::copy(their_properties.
begin(), their_properties.
end(), my_properties.
begin());
145 template <
int dim,
int spacedim>
149 if (
this != &particle)
151 location = particle.location;
152 reference_location = particle.reference_location;
154 property_pool = particle.property_pool;
155 properties = particle.properties;
163 template <
int dim,
int spacedim>
167 property_pool->deallocate_properties_array(properties);
172 template <
int dim,
int spacedim>
179 double *pdata =
reinterpret_cast<double *
> (id_data);
182 for (
unsigned int i = 0; i < spacedim; ++i,++pdata)
183 *pdata = location(i);
186 for (
unsigned int i = 0; i < dim; ++i,++pdata)
187 *pdata = reference_location(i);
190 if (has_properties())
192 const ArrayView<double> particle_properties = property_pool->get_properties(properties);
193 for (
unsigned int i = 0; i < particle_properties.
size(); ++i,++pdata)
194 *pdata = particle_properties[i];
197 data =
static_cast<void *
> (pdata);
202 template <
int dim,
int spacedim>
208 +
sizeof(reference_location);
210 if (has_properties())
212 const ArrayView<double> particle_properties = property_pool->get_properties(properties);
213 size +=
sizeof(double) * particle_properties.
size();
220 template <
int dim,
int spacedim>
229 template <
int dim,
int spacedim>
238 template <
int dim,
int spacedim>
242 reference_location = new_loc;
247 template <
int dim,
int spacedim>
251 return reference_location;
256 template <
int dim,
int spacedim>
265 template <
int dim,
int spacedim>
269 property_pool = &new_property_pool;
274 template <
int dim,
int spacedim>
279 properties = property_pool->allocate_properties_array();
281 const ArrayView<double> old_properties = property_pool->get_properties(properties);
284 ExcMessage(std::string(
"You are trying to assign properties with an incompatible length. ")
287 +
"This is not allowed."));
289 if (old_properties.
size() > 0)
290 std::copy(new_properties.
begin(), new_properties.
end(), old_properties.
begin());
295 template <
int dim,
int spacedim>
299 Assert(property_pool !=
nullptr,
302 return property_pool->get_properties(properties);
307 template <
int dim,
int spacedim>
311 Assert(property_pool !=
nullptr,
314 return property_pool->get_properties(properties);
319 template <
int dim,
int spacedim>
323 return (property_pool !=
nullptr)
328 DEAL_II_NAMESPACE_CLOSE
330 DEAL_II_NAMESPACE_OPEN
332 #include "particle.inst" 334 DEAL_II_NAMESPACE_CLOSE
PropertyPool::Handle properties
Point< spacedim > location
void set_property_pool(PropertyPool &property_pool)
Particle< dim, spacedim > & operator=(const Particle< dim, spacedim > &particle)
ArrayView< double > get_properties(const Handle handle)
void write_data(void *&data) const
unsigned int particle_index
types::particle_index get_id() const
void set_properties(const ArrayView< const double > &new_properties)
const Point< spacedim > & get_location() const
const ArrayView< double > get_properties()
void set_reference_location(const Point< dim > &new_reference_location)
std::string to_string(const number value, const unsigned int digits=numbers::invalid_unsigned_int)
std::size_t serialized_size_in_bytes() const
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
static const Handle invalid_handle
const Point< dim > & get_reference_location() const
Point< dim > reference_location
bool has_properties() const
void set_location(const Point< spacedim > &new_location)
PropertyPool * property_pool
Handle allocate_properties_array()
static ::ExceptionBase & ExcInternalError()