Reference documentation for deal.II version Git 6177fad8a5 2019-03-23 23:27:20 +0100
\(\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 
121  Particle(const Point<spacedim> & location,
122  const Point<dim> & reference_location,
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
240  set_property_pool(PropertyPool &property_pool);
241 
246  bool
247  has_properties() const;
248 
255  void
256  set_properties(const ArrayView<const double> &new_properties);
257 
268  const ArrayView<double>
269  get_properties();
270 
278  get_properties() const;
279 
285  std::size_t
286  serialized_size_in_bytes() const;
287 
292  template <class Archive>
293  void
294  save(Archive &ar, const unsigned int version) const;
295 
300  template <class Archive>
301  void
302  load(Archive &ar, const unsigned int version);
303 
304  BOOST_SERIALIZATION_SPLIT_MEMBER()
305 
306  private:
311 
316 
321 
327 
332  };
333 
334  /* ---------------------- inline and template functions ------------------ */
335 
336  template <int dim, int spacedim>
337  template <class Archive>
338  void
339  Particle<dim, spacedim>::load(Archive &ar, const unsigned int)
340  {
341  unsigned int n_properties = 0;
342 
343  ar &location &reference_location &id &n_properties;
344 
345  if (n_properties > 0)
346  {
347  properties = new double[n_properties];
348  ar &boost::serialization::make_array(properties, n_properties);
349  }
350  }
351 
352  template <int dim, int spacedim>
353  template <class Archive>
354  void
355  Particle<dim, spacedim>::save(Archive &ar, const unsigned int) const
356  {
357  unsigned int n_properties = 0;
358  if ((property_pool != nullptr) &&
359  (properties != PropertyPool::invalid_handle))
360  n_properties = get_properties().size();
361 
362  ar &location &reference_location &id &n_properties;
363 
364  if (n_properties > 0)
365  ar &boost::serialization::make_array(properties, n_properties);
366  }
367 } // namespace Particles
368 
369 DEAL_II_NAMESPACE_CLOSE
370 
371 #endif
PropertyPool::Handle properties
Definition: particle.h:331
Point< spacedim > location
Definition: particle.h:310
types::particle_index id
Definition: particle.h:320
unsigned int particle_index
Definition: particle.h:64
Definition: types.h:31
Point< dim > reference_location
Definition: particle.h:315
PropertyPool * property_pool
Definition: particle.h:326