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\}}\)
Public Member Functions | Private Attributes | List of all members
Particles::Particle< dim, spacedim > Class Template Reference

#include <deal.II/particles/particle.h>

Inheritance diagram for Particles::Particle< dim, spacedim >:
[legend]

Public Member Functions

 Particle ()
 
 Particle (const Point< spacedim > &location, const Point< dim > &reference_location, const types::particle_index id)
 
 Particle (const Particle< dim, spacedim > &particle)
 
 Particle (const void *&begin_data, PropertyPool *const property_pool=nullptr)
 
 Particle (Particle< dim, spacedim > &&particle) noexcept
 
Particle< dim, spacedim > & operator= (const Particle< dim, spacedim > &particle)
 
Particle< dim, spacedim > & operator= (Particle< dim, spacedim > &&particle) noexcept
 
 ~Particle ()
 
void write_data (void *&data) const
 
void set_location (const Point< spacedim > &new_location)
 
const Point< spacedim > & get_location () const
 
void set_reference_location (const Point< dim > &new_reference_location)
 
const Point< dim > & get_reference_location () const
 
types::particle_index get_id () const
 
void set_id (const types::particle_index &new_id)
 
void set_property_pool (PropertyPool &property_pool)
 
bool has_properties () const
 
void set_properties (const ArrayView< const double > &new_properties)
 
const ArrayView< doubleget_properties ()
 
const ArrayView< const doubleget_properties () const
 
std::size_t serialized_size_in_bytes () const
 
template<class Archive >
void save (Archive &ar, const unsigned int version) const
 
template<class Archive >
void load (Archive &ar, const unsigned int version)
 
template<class Archive >
void serialize (Archive &archive, const unsigned int version)
 

Private Attributes

Point< spacedim > location
 
Point< dim > reference_location
 
types::particle_index id
 
PropertyPoolproperty_pool
 
PropertyPool::Handle properties
 

Detailed Description

template<int dim, int spacedim = dim>
class Particles::Particle< dim, spacedim >

A class that represents a particle in a domain that is meshed by a triangulation of some kind. The data this class stores is the position of the particle in the overall space, the position of the particle in the reference coordinate system of the cell it is currently in, an ID number that is unique among all particles, and a variable number of "properties".

The "properties" attached to each object of this class are stored by a PropertyPool object. These properties are stored as an array of double variables that can be accessed via an ArrayView object. For example, if one wanted to equip each particle with a "temperature" and "chemical composition" property that is advected along with the particle (and may change from time step to time step based on some differential equation, for example), then one would allocate two properties per particle in the PropertyPool object.

In practice, however, one often wants to associate properties with particles that are not just independent numbers as in the situation above. An example would be if one wanted to track the stress or strain that a particle is subjected to – a tensor-valued quantity. In these cases, one would interpret these scalar properties as the components of the stress or strain. In other words, one would first tell the PropertyPool to allocate as many properties per particle as there are components in the tensor one wants to track, and then write small conversion functions that take the ArrayView of scalar properties returned by the get_properties() function and convert it to a tensor of the appropriate type. This can then be evaluated and evolved in each time step. A second conversion function would convert back from a tensor to an ArrayView object to store the updated data back in the particle via the set_properties() function.

There are of course cases where the properties one cares about are not real (or, in computers, floating point) numbers but rather categorical: For example, one may want to mark some particles as "red", "blue", or "green". The property might then either be represented as an integer, or as an element of an enum. In these cases, one would need to come up with a way to represent these sorts of categorical fields in terms of floating point numbers. For example, one could map "red" to the floating point number 1.0, "blue" to 2.0, and "green" to 3.0. The conversion functions to translate between these two representations should then not be very difficult to write either.

Author
Rene Gassmoeller, 2017

Definition at line 146 of file particle.h.

Constructor & Destructor Documentation

◆ Particle() [1/5]

template<int dim, int spacedim>
Particles::Particle< dim, spacedim >::Particle

Empty constructor for Particle, creates a particle at the origin.

Definition at line 25 of file particle.cc.

◆ Particle() [2/5]

template<int dim, int spacedim>
Particles::Particle< dim, spacedim >::Particle ( const Point< spacedim > &  location,
const Point< dim > &  reference_location,
const types::particle_index  id 
)

Constructor for Particle, creates a particle with the specified ID at the specified location. Note that there is no check for duplicate particle IDs so the user must make sure the IDs are unique over all processes.

Parameters
[in]locationInitial location of particle.
[in]reference_locationInitial location of the particle in the coordinate system of the reference cell.
[in]idGlobally unique ID number of particle.

Definition at line 36 of file particle.cc.

◆ Particle() [3/5]

template<int dim, int spacedim>
Particles::Particle< dim, spacedim >::Particle ( const Particle< dim, spacedim > &  particle)

Copy-Constructor for Particle, creates a particle with exactly the state of the input argument. Note that since each particle has a handle for a certain piece of the property memory, and is responsible for registering and freeing this memory in the property pool this constructor registers a new chunk, and copies the properties.

Definition at line 49 of file particle.cc.

◆ Particle() [4/5]

template<int dim, int spacedim>
Particles::Particle< dim, spacedim >::Particle ( const void *&  begin_data,
PropertyPool *const  property_pool = nullptr 
)

Constructor for Particle, creates a particle from a data vector. This constructor is usually called after serializing a particle by calling the write_data() function.

Parameters
[in,out]begin_dataA pointer to a memory location from which to read the information that completely describes a particle. This class then de-serializes its data from this memory location and advance the pointer accordingly.
[in,out]property_poolAn optional pointer to a property pool that is used to manage the property data used by this particle. Note that if a non-null pointer is handed over this constructor assumes begin_data contains serialized data of the same length and type that is allocated by property_pool.

Definition at line 74 of file particle.cc.

◆ Particle() [5/5]

template<int dim, int spacedim>
Particles::Particle< dim, spacedim >::Particle ( Particle< dim, spacedim > &&  particle)
noexcept

Move constructor for Particle, creates a particle from an existing one by stealing its state.

Definition at line 110 of file particle.cc.

◆ ~Particle()

template<int dim, int spacedim>
Particles::Particle< dim, spacedim >::~Particle

Destructor. Releases the property handle if it is valid, and therefore frees that memory space for other particles. (Note: the memory is managed by the property pool, and the pool is responsible for what happens to the memory.

Definition at line 173 of file particle.cc.

Member Function Documentation

◆ operator=() [1/2]

template<int dim, int spacedim>
Particle< dim, spacedim > & Particles::Particle< dim, spacedim >::operator= ( const Particle< dim, spacedim > &  particle)

Copy assignment operator.

Definition at line 124 of file particle.cc.

◆ operator=() [2/2]

template<int dim, int spacedim>
Particle< dim, spacedim > & Particles::Particle< dim, spacedim >::operator= ( Particle< dim, spacedim > &&  particle)
noexcept

Move assignment operator.

Definition at line 156 of file particle.cc.

◆ write_data()

template<int dim, int spacedim>
void Particles::Particle< dim, spacedim >::write_data ( void *&  data) const

Write particle data into a data array. The array is expected to be large enough to take the data, and the void pointer should point to the first entry of the array to which the data should be written. This function is meant for serializing all particle properties and later de-serializing the properties by calling the appropriate constructor Particle(void *&data, PropertyPool *property_pool = nullptr);

Parameters
[in,out]dataThe memory location to write particle data into. This pointer points to the begin of the memory, in which the data will be written and it will be advanced by the serialized size of this particle.

Definition at line 183 of file particle.cc.

◆ set_location()

template<int dim, int spacedim>
void Particles::Particle< dim, spacedim >::set_location ( const Point< spacedim > &  new_location)

Set the location of this particle. Note that this does not check whether this is a valid location in the simulation domain.

Parameters
[in]new_locationThe new location for this particle.

Definition at line 232 of file particle.cc.

◆ get_location()

template<int dim, int spacedim>
const Point< spacedim > & Particles::Particle< dim, spacedim >::get_location

Get the location of this particle.

Returns
The location of this particle.

Definition at line 241 of file particle.cc.

◆ set_reference_location()

template<int dim, int spacedim>
void Particles::Particle< dim, spacedim >::set_reference_location ( const Point< dim > &  new_reference_location)

Set the reference location of this particle.

Parameters
[in]new_reference_locationThe new reference location for this particle.

Definition at line 250 of file particle.cc.

◆ get_reference_location()

template<int dim, int spacedim>
const Point< dim > & Particles::Particle< dim, spacedim >::get_reference_location

Return the reference location of this particle in its current cell.

Definition at line 259 of file particle.cc.

◆ get_id()

template<int dim, int spacedim>
types::particle_index Particles::Particle< dim, spacedim >::get_id

Return the ID number of this particle.

Definition at line 268 of file particle.cc.

◆ set_id()

template<int dim, int spacedim>
void Particles::Particle< dim, spacedim >::set_id ( const types::particle_index new_id)

Set the ID number of this particle.

Parameters
[in]new_idThe new ID number for this particle.

Definition at line 277 of file particle.cc.

◆ set_property_pool()

template<int dim, int spacedim>
void Particles::Particle< dim, spacedim >::set_property_pool ( PropertyPool property_pool)

Tell the particle where to store its properties (even if it does not own properties). Usually this is only done once per particle, but since the particle does not know about the properties, we want to do it not at construction time. Another use for this function is after particle transfer to a new process.

Definition at line 286 of file particle.cc.

◆ has_properties()

template<int dim, int spacedim>
bool Particles::Particle< dim, spacedim >::has_properties

Return whether this particle has a valid property pool and a valid handle to properties.

Definition at line 360 of file particle.cc.

◆ set_properties()

template<int dim, int spacedim>
void Particles::Particle< dim, spacedim >::set_properties ( const ArrayView< const double > &  new_properties)

Set the properties of this particle.

Parameters
[in]new_propertiesAn ArrayView containing the new properties for this particle.

Definition at line 295 of file particle.cc.

◆ get_properties() [1/2]

template<int dim, int spacedim>
const ArrayView< double > Particles::Particle< dim, spacedim >::get_properties

Get write-access to properties of this particle. If the particle has no properties yet, but has access to a PropertyPool object it will allocate properties to allow writing into them. If it has no properties and has no access to a PropertyPool this function will throw an exception.

Returns
An ArrayView of the properties of this particle.

Definition at line 327 of file particle.cc.

◆ get_properties() [2/2]

template<int dim, int spacedim = dim>
const ArrayView<const double> Particles::Particle< dim, spacedim >::get_properties ( ) const

Get read-access to properties of this particle. If the particle has no properties this function throws an exception.

Returns
An ArrayView of the properties of this particle.

◆ serialized_size_in_bytes()

template<int dim, int spacedim>
std::size_t Particles::Particle< dim, spacedim >::serialized_size_in_bytes

Return the size in bytes this particle occupies if all of its data is serialized (i.e. the number of bytes that is written by the write_data function of this class).

Definition at line 214 of file particle.cc.

◆ save()

template<int dim, int spacedim>
template<class Archive >
void Particles::Particle< dim, spacedim >::save ( Archive &  ar,
const unsigned int  version 
) const

Write the data of this object to a stream for the purpose of serialization.

Definition at line 421 of file particle.h.

◆ load()

template<int dim, int spacedim>
template<class Archive >
void Particles::Particle< dim, spacedim >::load ( Archive &  ar,
const unsigned int  version 
)

Read the data of this object from a stream for the purpose of serialization.

Definition at line 405 of file particle.h.

◆ serialize()

template<int dim, int spacedim = dim>
template<class Archive >
void Particles::Particle< dim, spacedim >::serialize ( Archive &  archive,
const unsigned int  version 
)

Write and read the data of this object from a stream for the purpose of serialization.

Member Data Documentation

◆ location

template<int dim, int spacedim = dim>
Point<spacedim> Particles::Particle< dim, spacedim >::location
private

Current particle location.

Definition at line 376 of file particle.h.

◆ reference_location

template<int dim, int spacedim = dim>
Point<dim> Particles::Particle< dim, spacedim >::reference_location
private

Current particle location in the reference cell.

Definition at line 381 of file particle.h.

◆ id

template<int dim, int spacedim = dim>
types::particle_index Particles::Particle< dim, spacedim >::id
private

Globally unique ID of particle.

Definition at line 386 of file particle.h.

◆ property_pool

template<int dim, int spacedim = dim>
PropertyPool* Particles::Particle< dim, spacedim >::property_pool
private

A pointer to the property pool. Necessary to translate from the handle to the actual memory locations.

Definition at line 392 of file particle.h.

◆ properties

template<int dim, int spacedim = dim>
PropertyPool::Handle Particles::Particle< dim, spacedim >::properties
private

A handle to all particle properties

Definition at line 397 of file particle.h.


The documentation for this class was generated from the following files: