Reference documentation for deal.II version 9.2.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
particle.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2017 - 2020 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 
22 #include <deal.II/base/point.h>
23 #include <deal.II/base/types.h>
24 
26 
27 #include <cstdint>
28 
30 
31 namespace types
32 {
33  /* Type definitions */
34 
35 #ifdef DEAL_II_WITH_64BIT_INDICES
36 
47  using particle_index = uint64_t;
48 
49 # ifdef DEAL_II_WITH_MPI
50 
54 # define DEAL_II_PARTICLE_INDEX_MPI_TYPE MPI_UINT64_T
55 # endif
56 
57 #else
58 
69  using particle_index = unsigned int;
70 
71 # ifdef DEAL_II_WITH_MPI
72 
76 # define DEAL_II_PARTICLE_INDEX_MPI_TYPE MPI_UNSIGNED
77 # endif
78 #endif
79 } // namespace types
80 
85 namespace Particles
86 {
87  namespace internal
88  {
92  using LevelInd = std::pair<int, int>;
93  } // namespace internal
94 
145  template <int dim, int spacedim = dim>
146  class Particle
147  {
148  public:
153  Particle();
154 
166  Particle(const Point<spacedim> & location,
167  const Point<dim> & reference_location,
168  const types::particle_index id);
169 
177  Particle(const Particle<dim, spacedim> &particle);
178 
195  Particle(const void *& begin_data,
196  PropertyPool *const property_pool = nullptr);
197 
202  Particle(Particle<dim, spacedim> &&particle) noexcept;
203 
208  operator=(const Particle<dim, spacedim> &particle);
209 
214  operator=(Particle<dim, spacedim> &&particle) noexcept;
215 
222  ~Particle();
223 
237  void
238  write_data(void *&data) const;
239 
246  void
247  set_location(const Point<spacedim> &new_location);
248 
254  const Point<spacedim> &
255  get_location() const;
256 
263  void
264  set_reference_location(const Point<dim> &new_reference_location);
265 
269  const Point<dim> &
270  get_reference_location() const;
271 
276  get_id() const;
277 
283  void
284  set_id(const types::particle_index &new_id);
285 
293  void
294  set_property_pool(PropertyPool &property_pool);
295 
300  bool
301  has_properties() const;
302 
309  void
310  set_properties(const ArrayView<const double> &new_properties);
311 
322  const ArrayView<double>
323  get_properties();
324 
332  get_properties() const;
333 
339  std::size_t
340  serialized_size_in_bytes() const;
341 
346  template <class Archive>
347  void
348  save(Archive &ar, const unsigned int version) const;
349 
354  template <class Archive>
355  void
356  load(Archive &ar, const unsigned int version);
357 
358 #ifdef DOXYGEN
359 
363  template <class Archive>
364  void
365  serialize(Archive &archive, const unsigned int version);
366 #else
367  // This macro defines the serialize() method that is compatible with
368  // the templated save() and load() method that have been implemented.
369  BOOST_SERIALIZATION_SPLIT_MEMBER()
370 #endif
371 
372  private:
377 
382 
387 
393 
398  };
399 
400  /* ---------------------- inline and template functions ------------------ */
401 
402  template <int dim, int spacedim>
403  template <class Archive>
404  void
405  Particle<dim, spacedim>::load(Archive &ar, const unsigned int)
406  {
407  unsigned int n_properties = 0;
408 
409  ar &location &reference_location &id &n_properties;
410 
411  if (n_properties > 0)
412  {
413  properties = new double[n_properties];
414  ar &boost::serialization::make_array(properties, n_properties);
415  }
416  }
417 
418  template <int dim, int spacedim>
419  template <class Archive>
420  void
421  Particle<dim, spacedim>::save(Archive &ar, const unsigned int) const
422  {
423  unsigned int n_properties = 0;
424  if ((property_pool != nullptr) &&
425  (properties != PropertyPool::invalid_handle))
426  n_properties = get_properties().size();
427 
428  ar &location &reference_location &id &n_properties;
429 
430  if (n_properties > 0)
431  ar &boost::serialization::make_array(properties, n_properties);
432  }
433 } // namespace Particles
434 
436 
437 #endif
PropertyPool::Handle properties
Definition: particle.h:397
Point< spacedim > location
Definition: particle.h:376
types::particle_index id
Definition: particle.h:386
std::pair< int, int > LevelInd
Definition: particle.h:92
unsigned int particle_index
Definition: particle.h:69
void write_data(const std::vector< Patch< dim, spacedim >> &patches, unsigned int n_data_sets, const bool double_precision, StreamType &out)
Definition: types.h:31
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
Point< dim > reference_location
Definition: particle.h:381
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
PropertyPool * property_pool
Definition: particle.h:392