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 
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
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
array_view.h
Particles::Particle::id
types::particle_index id
Definition: particle.h:386
Particles::Particle::get_id
types::particle_index get_id() const
Definition: particle.cc:268
types.h
Particles::Particle::get_location
const Point< spacedim > & get_location() const
Definition: particle.cc:241
ArrayView
Definition: array_view.h:77
Particles::Particle::~Particle
~Particle()
Definition: particle.cc:173
Particles::PropertyPool
Definition: property_pool.h:43
Particles
Definition: data_out.h:27
Particles::Particle::set_properties
void set_properties(const ArrayView< const double > &new_properties)
Definition: particle.cc:295
Particles::Particle::serialized_size_in_bytes
std::size_t serialized_size_in_bytes() const
Definition: particle.cc:214
Particles::Particle::set_reference_location
void set_reference_location(const Point< dim > &new_reference_location)
Definition: particle.cc:250
Particles::Particle::set_location
void set_location(const Point< spacedim > &new_location)
Definition: particle.cc:232
Particles::Particle::set_property_pool
void set_property_pool(PropertyPool &property_pool)
Definition: particle.cc:286
Particles::PropertyPool::invalid_handle
static const Handle invalid_handle
Definition: property_pool.h:56
Particles::Particle
Definition: particle.h:146
Particles::Particle::get_reference_location
const Point< dim > & get_reference_location() const
Definition: particle.cc:259
double
Particles::Particle::properties
PropertyPool::Handle properties
Definition: particle.h:397
Particles::Particle::set_id
void set_id(const types::particle_index &new_id)
Definition: particle.cc:277
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
property_pool.h
types::particle_index
unsigned int particle_index
Definition: particle.h:69
Particles::Particle::operator=
Particle< dim, spacedim > & operator=(const Particle< dim, spacedim > &particle)
Definition: particle.cc:124
Particles::Particle::write_data
void write_data(void *&data) const
Definition: particle.cc:183
types
Definition: types.h:31
unsigned int
Particles::Particle::load
void load(Archive &ar, const unsigned int version)
Definition: particle.h:405
Particles::internal::LevelInd
std::pair< int, int > LevelInd
Definition: particle.h:92
Particles::Particle::location
Point< spacedim > location
Definition: particle.h:376
Point< spacedim >
Particles::Particle::serialize
void serialize(Archive &archive, const unsigned int version)
config.h
Particles::Particle::has_properties
bool has_properties() const
Definition: particle.cc:360
internal
Definition: aligned_vector.h:369
Particles::Particle::save
void save(Archive &ar, const unsigned int version) const
Definition: particle.h:421
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
Particles::Particle::property_pool
PropertyPool * property_pool
Definition: particle.h:392
Particles::Particle::reference_location
Point< dim > reference_location
Definition: particle.h:381
Particles::Particle::get_properties
const ArrayView< double > get_properties()
Definition: particle.cc:327
int
Particles::Particle::Particle
Particle()
Definition: particle.cc:25
point.h