Reference documentation for deal.II version Git 082d75bebd 2019-10-16 19:44:02 +0200
\(\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 
140  template <int dim, int spacedim = dim>
141  class Particle
142  {
143  public:
148  Particle();
149 
161  Particle(const Point<spacedim> & location,
162  const Point<dim> & reference_location,
163  const types::particle_index id);
164 
172  Particle(const Particle<dim, spacedim> &particle);
173 
190  Particle(const void *& begin_data,
191  PropertyPool *const property_pool = nullptr);
192 
197  Particle(Particle<dim, spacedim> &&particle) noexcept;
198 
203  operator=(const Particle<dim, spacedim> &particle);
204 
209  operator=(Particle<dim, spacedim> &&particle) noexcept;
210 
217  ~Particle();
218 
232  void
233  write_data(void *&data) const;
234 
241  void
242  set_location(const Point<spacedim> &new_location);
243 
249  const Point<spacedim> &
250  get_location() const;
251 
258  void
259  set_reference_location(const Point<dim> &new_reference_location);
260 
264  const Point<dim> &
265  get_reference_location() const;
266 
271  get_id() const;
272 
280  void
281  set_property_pool(PropertyPool &property_pool);
282 
287  bool
288  has_properties() const;
289 
296  void
297  set_properties(const ArrayView<const double> &new_properties);
298 
309  const ArrayView<double>
310  get_properties();
311 
319  get_properties() const;
320 
326  std::size_t
327  serialized_size_in_bytes() const;
328 
333  template <class Archive>
334  void
335  save(Archive &ar, const unsigned int version) const;
336 
341  template <class Archive>
342  void
343  load(Archive &ar, const unsigned int version);
344 
345  BOOST_SERIALIZATION_SPLIT_MEMBER()
346 
347  private:
352 
357 
362 
368 
373  };
374 
375  /* ---------------------- inline and template functions ------------------ */
376 
377  template <int dim, int spacedim>
378  template <class Archive>
379  void
380  Particle<dim, spacedim>::load(Archive &ar, const unsigned int)
381  {
382  unsigned int n_properties = 0;
383 
384  ar &location &reference_location &id &n_properties;
385 
386  if (n_properties > 0)
387  {
388  properties = new double[n_properties];
389  ar &boost::serialization::make_array(properties, n_properties);
390  }
391  }
392 
393  template <int dim, int spacedim>
394  template <class Archive>
395  void
396  Particle<dim, spacedim>::save(Archive &ar, const unsigned int) const
397  {
398  unsigned int n_properties = 0;
399  if ((property_pool != nullptr) &&
400  (properties != PropertyPool::invalid_handle))
401  n_properties = get_properties().size();
402 
403  ar &location &reference_location &id &n_properties;
404 
405  if (n_properties > 0)
406  ar &boost::serialization::make_array(properties, n_properties);
407  }
408 } // namespace Particles
409 
410 DEAL_II_NAMESPACE_CLOSE
411 
412 #endif
PropertyPool::Handle properties
Definition: particle.h:372
Point< spacedim > location
Definition: particle.h:351
types::particle_index id
Definition: particle.h:361
unsigned int particle_index
Definition: particle.h:64
Definition: types.h:31
Point< dim > reference_location
Definition: particle.h:356
PropertyPool * property_pool
Definition: particle.h:367