Reference documentation for deal.II version 9.0.0
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 at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_particles_particle_h
17 #define dealii_particles_particle_h
18 
19 #include <deal.II/particles/property_pool.h>
20 
21 #include <deal.II/base/point.h>
22 #include <deal.II/base/types.h>
23 #include <deal.II/base/array_view.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  typedef unsigned long long int particle_index;
44 
45 #ifdef DEAL_II_WITH_MPI
46 
50 # define PARTICLE_INDEX_MPI_TYPE MPI_UNSIGNED_LONG_LONG
51 #endif
52 #else
53 
64  typedef unsigned int particle_index;
65 
66 #ifdef DEAL_II_WITH_MPI
67 
71 # define PARTICLE_INDEX_MPI_TYPE MPI_UNSIGNED
72 #endif
73 #endif
74 }
75 
80 namespace Particles
81 {
82  namespace internal
83  {
87  typedef std::pair<int, int> LevelInd;
88  }
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 = nullptr);
152 
157  Particle (Particle<dim,spacedim> &&particle) noexcept;
158 
163 
168 
175  ~Particle ();
176 
190  void
191  write_data(void *&data) const;
192 
199  void
200  set_location (const Point<spacedim> &new_location);
201 
207  const Point<spacedim> &
208  get_location () const;
209 
216  void
217  set_reference_location (const Point<dim> &new_reference_location);
218 
222  const Point<dim> &
223  get_reference_location () const;
224 
229  get_id () const;
230 
238  void
240 
245  bool
246  has_properties () const;
247 
254  void
255  set_properties (const ArrayView<const double> &new_properties);
256 
262  const ArrayView<double>
263  get_properties ();
264 
271  get_properties () const;
272 
278  std::size_t
279  serialized_size_in_bytes() const;
280 
285  template <class Archive>
286  void save (Archive &ar, const unsigned int version) const;
287 
292  template <class Archive>
293  void load (Archive &ar, const unsigned int version);
294 
295  BOOST_SERIALIZATION_SPLIT_MEMBER()
296 
297  private:
302 
307 
312 
318 
323  };
324 
325  /* -------------------------- inline and template functions ---------------------- */
326 
327  template <int dim, int spacedim>
328  template <class Archive>
329  void Particle<dim,spacedim>::load (Archive &ar, const unsigned int)
330  {
331  unsigned int n_properties = 0;
332 
333  ar &location
334  & reference_location
335  & id
336  & n_properties;
337 
338  if (n_properties > 0)
339  {
340  properties = new double[n_properties];
341  ar &boost::serialization::make_array(properties, n_properties);
342  }
343  }
344 
345  template <int dim, int spacedim>
346  template <class Archive>
347  void Particle<dim,spacedim>::save (Archive &ar, const unsigned int) const
348  {
349  unsigned int n_properties = 0;
350  if ((property_pool != nullptr) && (properties != PropertyPool::invalid_handle))
351  n_properties = get_properties().size();
352 
353  ar &location
354  & reference_location
355  & id
356  & n_properties;
357 
358  if (n_properties > 0)
359  ar &boost::serialization::make_array(properties, n_properties);
360 
361  }
362 }
363 
364 DEAL_II_NAMESPACE_CLOSE
365 
366 #endif
367 
PropertyPool::Handle properties
Definition: particle.h:322
Point< spacedim > location
Definition: particle.h:301
void set_property_pool(PropertyPool &property_pool)
Definition: particle.cc:267
Particle< dim, spacedim > & operator=(const Particle< dim, spacedim > &particle)
Definition: particle.cc:120
void write_data(void *&data) const
Definition: particle.cc:174
unsigned int particle_index
Definition: particle.h:64
types::particle_index get_id() const
Definition: particle.cc:258
void set_properties(const ArrayView< const double > &new_properties)
Definition: particle.cc:276
types::particle_index id
Definition: particle.h:311
const Point< spacedim > & get_location() const
Definition: particle.cc:231
const ArrayView< double > get_properties()
Definition: particle.cc:309
void set_reference_location(const Point< dim > &new_reference_location)
Definition: particle.cc:240
std::size_t serialized_size_in_bytes() const
Definition: particle.cc:204
void save(Archive &ar, const unsigned int version) const
Definition: particle.h:347
void load(Archive &ar, const unsigned int version)
Definition: particle.h:329
Definition: types.h:30
static const Handle invalid_handle
Definition: property_pool.h:54
const Point< dim > & get_reference_location() const
Definition: particle.cc:249
Point< dim > reference_location
Definition: particle.h:306
bool has_properties() const
Definition: particle.cc:321
void set_location(const Point< spacedim > &new_location)
Definition: particle.cc:222
PropertyPool * property_pool
Definition: particle.h:317