MFEM v4.9.0
Finite element discretization library
Loading...
Searching...
No Matches
mfem::Particle Class Reference

Container for data associated with a single particle. More...

#include <particleset.hpp>

Collaboration diagram for mfem::Particle:
[legend]

Public Member Functions

 Particle (int dim, const Array< int > &field_vdims, int num_tags)
 Construct a Particle instance.
 
 Particle (const Particle &)=default
 
Particleoperator= (const Particle &)=default
 
 Particle (Particle &&)=default
 
Particleoperator= (Particle &&)=default
 
 ~Particle ()=default
 
int GetDim () const
 Get the spatial dimension of this particle.
 
int GetNFields () const
 Get the number of fields associated with this particle.
 
int GetFieldVDim (int f) const
 Get the vector dimension of field f .
 
int GetNTags () const
 Get the number of tags associated with this particle.
 
VectorCoords ()
 Get reference to particle coordinates Vector.
 
const VectorCoords () const
 Get const reference to particle coordinates Vector.
 
real_tFieldValue (int f, int c=0)
 Get reference to field f , component c value.
 
const real_tFieldValue (int f, int c=0) const
 Get const reference to field f , component c value.
 
VectorField (int f)
 Get reference to field f Vector.
 
const VectorField (int f) const
 Get const reference to field f Vector.
 
int & Tag (int t)
 Get reference to tag t .
 
const int & Tag (int t) const
 Get const reference to tag t .
 
void SetTagRef (int t, int *tag_data)
 Set tag t to reference external data.
 
void SetFieldRef (int f, real_t *field_data)
 Set field f to reference external data.
 
bool operator== (const Particle &rhs) const
 Particle equality operator.
 
bool operator!= (const Particle &rhs) const
 Particle inequality operator.
 
void Print (std::ostream &os=mfem::out) const
 Print all particle data to os.
 

Protected Attributes

Vector coords
 Spatial coordinates.
 
std::vector< Vectorfields
 A std::vector of Vector where each Vector holds data for a given field (e.g., mass, momentum or velocity) associated with the particle.
 
std::vector< Array< int > > tags
 A std::vector of Array<int> where each Array<int> holds data for a given tag.
 

Detailed Description

Container for data associated with a single particle.

Note
This class mainly serves as a convenience interface to individual particle data from ParticleSet. We recommend seeing ParticleSet first.

As described in ParticleSet documentation, each particle has a position (coords), arbitrary number of scalar or vector real_t data (fields), and arbitrary number of integers (tags) associated with it.

fields can thus hold data such as mass, momentum, and velocity, while tags can hold integer data such as particle type, color, etc.

Each particle also has a unique global ID, but that is managed by the ParticleSet class and not stored in this Particle class. Simiarly, the names of the fields and tags, typically useful for output purposes, are managed by the ParticleSet class.

For clarity, we will use the particles below to illustrate the data layout for coords, fields, and tags

Particle_0: coords = (x0, y0),
fields = {'mass'=m0, 'vel' = (vx0, vy0)},
tags = {'type'=t0, 'color'=color0}
Particle_1: coords = (x1, y1),
fields = {'mass'=m1, 'vel' = (vx1, vy1)},
tags = {'type'=t1, 'color'=color1}
Particle_2: coords = (x2, y2),
fields = {'mass'=m2, 'vel' = (vx2, vy2)},
tags = {'type'=t2, 'color'=color2}
std::vector< Array< int > > tags
A std::vector of Array<int> where each Array<int> holds data for a given tag.
std::vector< Vector > fields
A std::vector of Vector where each Vector holds data for a given field (e.g., mass,...
Vector coords
Spatial coordinates.

Definition at line 59 of file particleset.hpp.

Constructor & Destructor Documentation

◆ Particle() [1/3]

mfem::Particle::Particle ( int dim,
const Array< int > & field_vdims,
int num_tags )

Construct a Particle instance.

Parameters
[in]dimSpatial dimension (size of coords).
[in]field_vdimsVector dimensions of particle fields.
[in]num_tagsNumber of integer tags.

Definition at line 40 of file particleset.cpp.

◆ Particle() [2/3]

mfem::Particle::Particle ( const Particle & )
default

◆ Particle() [3/3]

mfem::Particle::Particle ( Particle && )
default

◆ ~Particle()

mfem::Particle::~Particle ( )
default

Member Function Documentation

◆ Coords() [1/2]

Vector & mfem::Particle::Coords ( )
inline

Get reference to particle coordinates Vector.

Definition at line 115 of file particleset.hpp.

◆ Coords() [2/2]

const Vector & mfem::Particle::Coords ( ) const
inline

Get const reference to particle coordinates Vector.

Definition at line 118 of file particleset.hpp.

◆ Field() [1/2]

Vector & mfem::Particle::Field ( int f)
inline

Get reference to field f Vector.

Definition at line 141 of file particleset.hpp.

◆ Field() [2/2]

const Vector & mfem::Particle::Field ( int f) const
inline

Get const reference to field f Vector.

Definition at line 149 of file particleset.hpp.

◆ FieldValue() [1/2]

real_t & mfem::Particle::FieldValue ( int f,
int c = 0 )
inline

Get reference to field f , component c value.

Definition at line 121 of file particleset.hpp.

◆ FieldValue() [2/2]

const real_t & mfem::Particle::FieldValue ( int f,
int c = 0 ) const
inline

Get const reference to field f , component c value.

Definition at line 131 of file particleset.hpp.

◆ GetDim()

int mfem::Particle::GetDim ( ) const
inline

Get the spatial dimension of this particle.

Definition at line 103 of file particleset.hpp.

◆ GetFieldVDim()

int mfem::Particle::GetFieldVDim ( int f) const
inline

Get the vector dimension of field f .

Definition at line 109 of file particleset.hpp.

◆ GetNFields()

int mfem::Particle::GetNFields ( ) const
inline

Get the number of fields associated with this particle.

Definition at line 106 of file particleset.hpp.

◆ GetNTags()

int mfem::Particle::GetNTags ( ) const
inline

Get the number of tags associated with this particle.

Definition at line 112 of file particleset.hpp.

◆ operator!=()

bool mfem::Particle::operator!= ( const Particle & rhs) const
inline

Particle inequality operator.

Definition at line 182 of file particleset.hpp.

◆ operator=() [1/2]

Particle & mfem::Particle::operator= ( const Particle & )
default

◆ operator=() [2/2]

Particle & mfem::Particle::operator= ( Particle && )
default

◆ operator==()

bool mfem::Particle::operator== ( const Particle & rhs) const

Particle equality operator.

Definition at line 76 of file particleset.cpp.

◆ Print()

void mfem::Particle::Print ( std::ostream & os = mfem::out) const

Print all particle data to os.

Definition at line 125 of file particleset.cpp.

◆ SetFieldRef()

void mfem::Particle::SetFieldRef ( int f,
real_t * field_data )

Set field f to reference external data.

Definition at line 67 of file particleset.cpp.

◆ SetTagRef()

void mfem::Particle::SetTagRef ( int t,
int * tag_data )

Set tag t to reference external data.

Definition at line 60 of file particleset.cpp.

◆ Tag() [1/2]

int & mfem::Particle::Tag ( int t)
inline

Get reference to tag t .

Definition at line 157 of file particleset.hpp.

◆ Tag() [2/2]

const int & mfem::Particle::Tag ( int t) const
inline

Get const reference to tag t .

Definition at line 165 of file particleset.hpp.

Member Data Documentation

◆ coords

Vector mfem::Particle::coords
protected

Spatial coordinates.

For the sample_particle_data, coords would hold (x_i, y_i) for each particle i.

Definition at line 67 of file particleset.hpp.

◆ fields

std::vector<Vector> mfem::Particle::fields
protected

A std::vector of Vector where each Vector holds data for a given field (e.g., mass, momentum or velocity) associated with the particle.

For the sample_particle_data, fields would be fields[0]=(m_i), fields[1]=(vx_i,vy_i) for each particle i.

Definition at line 75 of file particleset.hpp.

◆ tags

std::vector<Array<int> > mfem::Particle::tags
protected

A std::vector of Array<int> where each Array<int> holds data for a given tag.

For the sample_particle_data, tags would be tags[0]=(type_i), tags[1]=(color_i) for each particle i.

Note
An Array of length 1 is used for EACH tag, strictly for its owning/non-owning semantics (see Array<T>::MakeRef).

Definition at line 86 of file particleset.hpp.


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