Reference documentation for deal.II version Git 10f3285 2019-01-18 22:14:04 -0700
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
particle.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2017 - 2018 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, PropertyPool *const = nullptr);
151 
156  Particle(Particle<dim, spacedim> &&particle) noexcept;
157 
162  operator=(const Particle<dim, spacedim> &particle);
163 
168  operator=(Particle<dim, spacedim> &&particle) noexcept;
169 
176  ~Particle();
177 
191  void
192  write_data(void *&data) const;
193 
200  void
201  set_location(const Point<spacedim> &new_location);
202 
208  const Point<spacedim> &
209  get_location() const;
210 
217  void
218  set_reference_location(const Point<dim> &new_reference_location);
219 
223  const Point<dim> &
224  get_reference_location() const;
225 
230  get_id() const;
231 
239  void
241 
246  bool
247  has_properties() const;
248 
255  void
256  set_properties(const ArrayView<const double> &new_properties);
257 
263  const ArrayView<double>
264  get_properties();
265 
272  get_properties() const;
273 
279  std::size_t
280  serialized_size_in_bytes() const;
281 
286  template <class Archive>
287  void
288  save(Archive &ar, const unsigned int version) const;
289 
294  template <class Archive>
295  void
296  load(Archive &ar, const unsigned int version);
297 
298  BOOST_SERIALIZATION_SPLIT_MEMBER()
299 
300  private:
305 
310 
315 
321 
326  };
327 
328  /* ---------------------- inline and template functions ------------------ */
329 
330  template <int dim, int spacedim>
331  template <class Archive>
332  void
333  Particle<dim, spacedim>::load(Archive &ar, const unsigned int)
334  {
335  unsigned int n_properties = 0;
336 
337  ar &location &reference_location &id &n_properties;
338 
339  if (n_properties > 0)
340  {
341  properties = new double[n_properties];
342  ar &boost::serialization::make_array(properties, n_properties);
343  }
344  }
345 
346  template <int dim, int spacedim>
347  template <class Archive>
348  void
349  Particle<dim, spacedim>::save(Archive &ar, const unsigned int) const
350  {
351  unsigned int n_properties = 0;
352  if ((property_pool != nullptr) &&
353  (properties != PropertyPool::invalid_handle))
354  n_properties = get_properties().size();
355 
356  ar &location &reference_location &id &n_properties;
357 
358  if (n_properties > 0)
359  ar &boost::serialization::make_array(properties, n_properties);
360  }
361 } // namespace Particles
362 
363 DEAL_II_NAMESPACE_CLOSE
364 
365 #endif
PropertyPool::Handle properties
Definition: particle.h:325
Point< spacedim > location
Definition: particle.h:304
void set_property_pool(PropertyPool &property_pool)
Definition: particle.cc:275
Particle< dim, spacedim > & operator=(const Particle< dim, spacedim > &particle)
Definition: particle.cc:122
types::particle_index get_id() const
Definition: particle.cc:266
std::size_t serialized_size_in_bytes() const
Definition: particle.cc:212
void write_data(void *&data) const
Definition: particle.cc:181
void set_properties(const ArrayView< const double > &new_properties)
Definition: particle.cc:284
types::particle_index id
Definition: particle.h:314
const ArrayView< double > get_properties()
Definition: particle.cc:325
void set_reference_location(const Point< dim > &new_reference_location)
Definition: particle.cc:248
void save(Archive &ar, const unsigned int version) const
Definition: particle.h:349
unsigned int particle_index
Definition: particle.h:64
void load(Archive &ar, const unsigned int version)
Definition: particle.h:333
Definition: types.h:31
static const Handle invalid_handle
Definition: property_pool.h:54
Point< dim > reference_location
Definition: particle.h:309
const Point< spacedim > & get_location() const
Definition: particle.cc:239
const Point< dim > & get_reference_location() const
Definition: particle.cc:257
void set_location(const Point< spacedim > &new_location)
Definition: particle.cc:230
bool has_properties() const
Definition: particle.cc:336
PropertyPool * property_pool
Definition: particle.h:320