Reference documentation for deal.II version Git a0b41b6d0f 2020-02-26 20:08:13 -0600
\(\newcommand{\vcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\vcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
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/config.h>
20 
21 #include <deal.II/base/array_view.h>
22 #include <deal.II/base/point.h>
23 #include <deal.II/base/types.h>
24 
25 #include <deal.II/particles/property_pool.h>
26 
27 DEAL_II_NAMESPACE_OPEN
28 
29 namespace types
30 {
31  /* Type definitions */
32 
33 #ifdef DEAL_II_WITH_64BIT_INDICES
34 
45  using particle_index = unsigned long long int;
46 
47 # ifdef DEAL_II_WITH_MPI
48 
52 # define DEAL_II_PARTICLE_INDEX_MPI_TYPE MPI_UNSIGNED_LONG_LONG
53 # endif
54 #else
55 
66  using particle_index = unsigned int;
67 
68 # ifdef DEAL_II_WITH_MPI
69 
73 # define DEAL_II_PARTICLE_INDEX_MPI_TYPE MPI_UNSIGNED
74 # endif
75 #endif
76 } // namespace types
77 
82 namespace Particles
83 {
84  namespace internal
85  {
89  using LevelInd = std::pair<int, int>;
90  } // namespace internal
91 
142  template <int dim, int spacedim = dim>
143  class Particle
144  {
145  public:
150  Particle();
151 
163  Particle(const Point<spacedim> & location,
164  const Point<dim> & reference_location,
165  const types::particle_index id);
166 
174  Particle(const Particle<dim, spacedim> &particle);
175 
192  Particle(const void *& begin_data,
193  PropertyPool *const property_pool = nullptr);
194 
199  Particle(Particle<dim, spacedim> &&particle) noexcept;
200 
205  operator=(const Particle<dim, spacedim> &particle);
206 
211  operator=(Particle<dim, spacedim> &&particle) noexcept;
212 
219  ~Particle();
220 
234  void
235  write_data(void *&data) const;
236 
243  void
244  set_location(const Point<spacedim> &new_location);
245 
251  const Point<spacedim> &
252  get_location() const;
253 
260  void
261  set_reference_location(const Point<dim> &new_reference_location);
262 
266  const Point<dim> &
267  get_reference_location() const;
268 
273  get_id() const;
274 
280  void
281  set_id(const types::particle_index &new_id);
282 
290  void
291  set_property_pool(PropertyPool &property_pool);
292 
297  bool
298  has_properties() const;
299 
306  void
307  set_properties(const ArrayView<const double> &new_properties);
308 
319  const ArrayView<double>
320  get_properties();
321 
329  get_properties() const;
330 
336  std::size_t
337  serialized_size_in_bytes() const;
338 
343  template <class Archive>
344  void
345  save(Archive &ar, const unsigned int version) const;
346 
351  template <class Archive>
352  void
353  load(Archive &ar, const unsigned int version);
354 
355  BOOST_SERIALIZATION_SPLIT_MEMBER()
356 
357  private:
362 
367 
372 
378 
383  };
384 
385  /* ---------------------- inline and template functions ------------------ */
386 
387  template <int dim, int spacedim>
388  template <class Archive>
389  void
390  Particle<dim, spacedim>::load(Archive &ar, const unsigned int)
391  {
392  unsigned int n_properties = 0;
393 
394  ar &location &reference_location &id &n_properties;
395 
396  if (n_properties > 0)
397  {
398  properties = new double[n_properties];
399  ar &boost::serialization::make_array(properties, n_properties);
400  }
401  }
402 
403  template <int dim, int spacedim>
404  template <class Archive>
405  void
406  Particle<dim, spacedim>::save(Archive &ar, const unsigned int) const
407  {
408  unsigned int n_properties = 0;
409  if ((property_pool != nullptr) &&
410  (properties != PropertyPool::invalid_handle))
411  n_properties = get_properties().size();
412 
413  ar &location &reference_location &id &n_properties;
414 
415  if (n_properties > 0)
416  ar &boost::serialization::make_array(properties, n_properties);
417  }
418 } // namespace Particles
419 
420 DEAL_II_NAMESPACE_CLOSE
421 
422 #endif
PropertyPool::Handle properties
Definition: particle.h:382
Point< spacedim > location
Definition: particle.h:361
types::particle_index id
Definition: particle.h:371
unsigned int particle_index
Definition: particle.h:66
Definition: types.h:31
Point< dim > reference_location
Definition: particle.h:366
PropertyPool * property_pool
Definition: particle.h:377