Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
particle.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2017 - 2019 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_particles_particle_h
17 #define dealii_particles_particle_h
18 
19 #include <deal.II/base/array_view.h>
20 #include <deal.II/base/point.h>
21 #include <deal.II/base/types.h>
22 
23 #include <deal.II/particles/property_pool.h>
24 
25 DEAL_II_NAMESPACE_OPEN
26 
27 namespace types
28 {
29  /* Type definitions */
30 
31 #ifdef DEAL_II_WITH_64BIT_INDICES
32 
43  using particle_index = unsigned long long int;
44 
45 # ifdef DEAL_II_WITH_MPI
46 
50 # define DEAL_II_PARTICLE_INDEX_MPI_TYPE MPI_UNSIGNED_LONG_LONG
51 # endif
52 #else
53 
64  using particle_index = unsigned int;
65 
66 # ifdef DEAL_II_WITH_MPI
67 
71 # define DEAL_II_PARTICLE_INDEX_MPI_TYPE MPI_UNSIGNED
72 # endif
73 #endif
74 } // namespace types
75 
80 namespace Particles
81 {
82  namespace internal
83  {
87  using LevelInd = std::pair<int, int>;
88  } // namespace internal
89 
100  template <int dim, int spacedim = dim>
101  class Particle
102  {
103  public:
108  Particle();
109 
123  const types::particle_index id);
124 
132  Particle(const Particle<dim, spacedim> &particle);
133 
150  Particle(const void *& begin_data,
151  PropertyPool *const property_pool = nullptr);
152 
157  Particle(Particle<dim, spacedim> &&particle) noexcept;
158 
163  operator=(const Particle<dim, spacedim> &particle);
164 
169  operator=(Particle<dim, spacedim> &&particle) noexcept;
170 
177  ~Particle();
178 
192  void
193  write_data(void *&data) const;
194 
201  void
202  set_location(const Point<spacedim> &new_location);
203 
209  const Point<spacedim> &
210  get_location() const;
211 
218  void
219  set_reference_location(const Point<dim> &new_reference_location);
220 
224  const Point<dim> &
225  get_reference_location() const;
226 
231  get_id() const;
232 
240  void
242 
247  bool
248  has_properties() const;
249 
256  void
257  set_properties(const ArrayView<const double> &new_properties);
258 
269  const ArrayView<double>
270  get_properties();
271 
279  get_properties() const;
280 
286  std::size_t
287  serialized_size_in_bytes() const;
288 
293  template <class Archive>
294  void
295  save(Archive &ar, const unsigned int version) const;
296 
301  template <class Archive>
302  void
303  load(Archive &ar, const unsigned int version);
304 
305  BOOST_SERIALIZATION_SPLIT_MEMBER()
306 
307  private:
312 
317 
322 
328 
333  };
334 
335  /* ---------------------- inline and template functions ------------------ */
336 
337  template <int dim, int spacedim>
338  template <class Archive>
339  void
340  Particle<dim, spacedim>::load(Archive &ar, const unsigned int)
341  {
342  unsigned int n_properties = 0;
343 
344  ar &location &reference_location &id &n_properties;
345 
346  if (n_properties > 0)
347  {
348  properties = new double[n_properties];
349  ar &boost::serialization::make_array(properties, n_properties);
350  }
351  }
352 
353  template <int dim, int spacedim>
354  template <class Archive>
355  void
356  Particle<dim, spacedim>::save(Archive &ar, const unsigned int) const
357  {
358  unsigned int n_properties = 0;
359  if ((property_pool != nullptr) &&
360  (properties != PropertyPool::invalid_handle))
361  n_properties = get_properties().size();
362 
363  ar &location &reference_location &id &n_properties;
364 
365  if (n_properties > 0)
366  ar &boost::serialization::make_array(properties, n_properties);
367  }
368 } // namespace Particles
369 
370 DEAL_II_NAMESPACE_CLOSE
371 
372 #endif
PropertyPool::Handle properties
Definition: particle.h:332
Point< spacedim > location
Definition: particle.h:311
void set_property_pool(PropertyPool &property_pool)
Definition: particle.cc:275
Particle< dim, spacedim > & operator=(const Particle< dim, spacedim > &particle)
Definition: particle.cc:122
void write_data(void *&data) const
Definition: particle.cc:181
types::particle_index get_id() const
Definition: particle.cc:266
void set_properties(const ArrayView< const double > &new_properties)
Definition: particle.cc:284
types::particle_index id
Definition: particle.h:321
const Point< spacedim > & get_location() const
Definition: particle.cc:239
const ArrayView< double > get_properties()
Definition: particle.cc:327
void set_reference_location(const Point< dim > &new_reference_location)
Definition: particle.cc:248
std::size_t serialized_size_in_bytes() const
Definition: particle.cc:212
void save(Archive &ar, const unsigned int version) const
Definition: particle.h:356
unsigned int particle_index
Definition: particle.h:64
void load(Archive &ar, const unsigned int version)
Definition: particle.h:340
Definition: types.h:31
static const Handle invalid_handle
Definition: property_pool.h:54
const Point< dim > & get_reference_location() const
Definition: particle.cc:257
Point< dim > reference_location
Definition: particle.h:316
bool has_properties() const
Definition: particle.cc:349
void set_location(const Point< spacedim > &new_location)
Definition: particle.cc:230
PropertyPool * property_pool
Definition: particle.h:327