PeTar
N-body code for collisional gravitational systems
ParticleBase Class Reference

Basic particle class. More...

#include <particle_base.hpp>

Inheritance diagram for ParticleBase:
[legend]

Public Member Functions

void setBinaryPairID (const PS::S64 _id)
 save pair id in binary_state with shift bit size of BINARY_STATE_ID_SHIFT More...
 
void setBinaryInterruptState (const BinaryInterruptState _state)
 save binary interrupt state in the first BINARY_STATE_ID_SHIFT bit in binary_state More...
 
BinaryInterruptState getBinaryInterruptState () const
 get binary interrupt state from binary_state More...
 
PS::S64 getBinaryPairID () const
 get pair ID from binary_state More...
 
 ParticleBase ()
 defaulted constructor More...
 
template<class Tp >
 ParticleBase (const Tp &p)
 
 ParticleBase (const PS::F64 _mass, const PS::F64vec &_pos, const PS::F64vec &_vel)
 constructor More...
 
 ParticleBase (const PS::F64 _mass, const PS::F64vec &_pos, const PS::F64vec &_vel, const PS::S64 _binary_state)
 constructor More...
 
void writeAscii (FILE *fp) const
 write class data with ASCII format More...
 
void readAscii (FILE *fp)
 read class data with ASCII format More...
 
void writeBinary (FILE *fp) const
 write class data with BINARY format More...
 
void readBinary (FILE *fp)
 read class data with BINARY format More...
 
void print (std::ostream &fout) const
 for print debugging More...
 
void printColumn (std::ostream &_fout, const int _width=20) const
 print data of class members using column style More...
 
template<class Tpcm >
void printColumnWithOffset (Tpcm &_pcm, std::ostream &_fout, const int _width=20) const
 print data of class members with pos and vel offset using column style More...
 
template<class Tp >
void DataCopy (const Tp &din)
 Copy from another ParticleBase. More...
 
PS::F64 getMass ()
 Get mass (required for ARC::chain) More...
 
PS::F64 * getPos ()
 Get position (required for ARC::chain) More...
 
PS::F64 * getVel ()
 Get velocity (required for ARC::chain) More...
 
void setPos (const PS::F64 x, const PS::F64 y, const PS::F64 z)
 Set position (required for ARC::chain) More...
 
void setPos (const PS::F64vec &_pos)
 Set position (used in soft part) More...
 
void setVel (const PS::F64 vx, const PS::F64 vy, const PS::F64 vz)
 Set velocity (required for ARC::chain) More...
 
void setVel (const PS::F64vec &_vel)
 Set velocity. More...
 
void setMass (const PS::F64 m)
 Set mass (required for ARC::chain) More...
 

Static Public Member Functions

static void printColumnTitle (std::ostream &_fout, const int _width=20)
 print titles of class members using column style More...
 
static int printTitleWithMeaning (std::ostream &_fout, const int _counter=0, const int _offset=0)
 print column title with meaning (each line for one column) More...
 

Public Attributes

PS::F64 mass
 
PS::F64vec pos
 
PS::F64vec vel
 
PS::S64 binary_state
 

Detailed Description

Basic particle class.

Constructor & Destructor Documentation

◆ ParticleBase() [1/4]

ParticleBase::ParticleBase ( )
inline

defaulted constructor

◆ ParticleBase() [2/4]

template<class Tp >
ParticleBase::ParticleBase ( const Tp &  p)
inline
Here is the call graph for this function:

◆ ParticleBase() [3/4]

ParticleBase::ParticleBase ( const PS::F64  _mass,
const PS::F64vec &  _pos,
const PS::F64vec &  _vel 
)
inline

constructor

Here is the call graph for this function:

◆ ParticleBase() [4/4]

ParticleBase::ParticleBase ( const PS::F64  _mass,
const PS::F64vec &  _pos,
const PS::F64vec &  _vel,
const PS::S64  _binary_state 
)
inline

constructor

Member Function Documentation

◆ DataCopy()

template<class Tp >
void ParticleBase::DataCopy ( const Tp &  din)
inline

Copy from another ParticleBase.

This is used for data transfer between nodes and between soft and hard parts

Parameters
[in]dindata need to be copied
Here is the caller graph for this function:

◆ getBinaryInterruptState()

BinaryInterruptState ParticleBase::getBinaryInterruptState ( ) const
inline

get binary interrupt state from binary_state

◆ getBinaryPairID()

PS::S64 ParticleBase::getBinaryPairID ( ) const
inline

get pair ID from binary_state

◆ getMass()

PS::F64 ParticleBase::getMass ( )
inline

Get mass (required for ARC::chain)

Returns
mass

◆ getPos()

PS::F64* ParticleBase::getPos ( )
inline

Get position (required for ARC::chain)

Returns
position vector (PS::F64[3])

◆ getVel()

PS::F64* ParticleBase::getVel ( )
inline

Get velocity (required for ARC::chain)

Returns
velocity vector (PS::F64[3])

◆ print()

void ParticleBase::print ( std::ostream &  fout) const
inline

for print debugging

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printColumn()

void ParticleBase::printColumn ( std::ostream &  _fout,
const int  _width = 20 
) const
inline

print data of class members using column style

print data of class members in one line for column style. Notice no newline is printed at the end

Parameters
[out]_foutstd::ostream output object
[in]_widthprint width (defaulted 20)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printColumnTitle()

static void ParticleBase::printColumnTitle ( std::ostream &  _fout,
const int  _width = 20 
)
inlinestatic

print titles of class members using column style

print titles of class members in one line for column style

Parameters
[out]_foutstd::ostream output object
[in]_widthprint width (defaulted 20)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printColumnWithOffset()

template<class Tpcm >
void ParticleBase::printColumnWithOffset ( Tpcm &  _pcm,
std::ostream &  _fout,
const int  _width = 20 
) const
inline

print data of class members with pos and vel offset using column style

print data of class members in one line for column style. Notice no newline is printed at the end

Parameters
[in]_pcmparticle data with position and velocity offset that are added when print data
[out]_foutstd::ostream output object
[in]_widthprint width (defaulted 20)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printTitleWithMeaning()

static int ParticleBase::printTitleWithMeaning ( std::ostream &  _fout,
const int  _counter = 0,
const int  _offset = 0 
)
inlinestatic

print column title with meaning (each line for one column)

Parameters
[out]_foutstd::ostream output object
[in]_counteroffset of the number counter for each line to indicate the column index (defaulted 0)
[in]_offsetthe printing whitespace offset for each line (defaulted 0)
Returns
: the total counter of columns
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readAscii()

void ParticleBase::readAscii ( FILE *  fp)
inline

read class data with ASCII format

Parameters
[in]_finfile IO for read
Here is the caller graph for this function:

◆ readBinary()

void ParticleBase::readBinary ( FILE *  fp)
inline

read class data with BINARY format

Parameters
[in]_finfile IO for read
Here is the caller graph for this function:

◆ setBinaryInterruptState()

void ParticleBase::setBinaryInterruptState ( const BinaryInterruptState  _state)
inline

save binary interrupt state in the first BINARY_STATE_ID_SHIFT bit in binary_state

◆ setBinaryPairID()

void ParticleBase::setBinaryPairID ( const PS::S64  _id)
inline

save pair id in binary_state with shift bit size of BINARY_STATE_ID_SHIFT

◆ setMass()

void ParticleBase::setMass ( const PS::F64  m)
inline

Set mass (required for ARC::chain)

NAN check will be done

Parameters
[in]mparticle mass

◆ setPos() [1/2]

void ParticleBase::setPos ( const PS::F64  x,
const PS::F64  y,
const PS::F64  z 
)
inline

Set position (required for ARC::chain)

NAN check will be done

Parameters
[in]xparticle position in x axis
[in]yparticle position in y axis
[in]zparticle position in z axis

◆ setPos() [2/2]

void ParticleBase::setPos ( const PS::F64vec &  _pos)
inline

Set position (used in soft part)

◆ setVel() [1/2]

void ParticleBase::setVel ( const PS::F64  vx,
const PS::F64  vy,
const PS::F64  vz 
)
inline

Set velocity (required for ARC::chain)

NAN check will be done

Parameters
[in]vxparticle velocity in x axis
[in]vyparticle velocity in y axis
[in]vzparticle velocity in z axis

◆ setVel() [2/2]

void ParticleBase::setVel ( const PS::F64vec &  _vel)
inline

Set velocity.

◆ writeAscii()

void ParticleBase::writeAscii ( FILE *  fp) const
inline

write class data with ASCII format

Parameters
[in]_foutfile IO for write
Here is the caller graph for this function:

◆ writeBinary()

void ParticleBase::writeBinary ( FILE *  fp) const
inline

write class data with BINARY format

Parameters
[in]_foutfile IO for write
Here is the caller graph for this function:

Member Data Documentation

◆ binary_state

PS::S64 ParticleBase::binary_state

◆ mass

PS::F64 ParticleBase::mass

◆ pos

PS::F64vec ParticleBase::pos

◆ vel

PS::F64vec ParticleBase::vel

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