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

class for collecting and calculating the energy and angular momemtum of the system More...

#include <energy.hpp>

Public Member Functions

 EnergyAndMomemtum ()
 
void clear ()
 
void print (std::ostream &_fout=std::cout, const PS::S32 _width=16)
 print title and values in one lines More...
 
void printColumnTitle (std::ofstream &_fout, const PS::S32 _width=16) const
 print titles of class members using column style More...
 
void printColumn (std::ofstream &_fout, const PS::S32 _width=16) const
 print data of class members using column style More...
 
void writeAscii (FILE *_fout)
 
void writeBinary (FILE *_fout)
 
template<class Tptcl >
void calc (const Tptcl *_particles, const PS::S32 _n_particle, const bool _init_flag=false, const PS::F64vec *_pos_offset=NULL, const PS::F64vec *_vel_offset=NULL)
 calculate the system kinetic and potential energy of particles More...
 
template<class Tptcl >
void calc (const Tptcl *_particles, const PS::S32 *_particle_index, const PS::S32 _n_particle, const bool _init_flag=false)
 calculate the system kinetic and potential energy of particles More...
 
void getSumMultiNodes (const bool _init_flag=false)
 get summation of kinetic, potential energy and angular momemtum of all MPI processes More...
 
void saveEnergyError ()
 save current energy error More...
 
PS::F64 getEnergyError () const
 get energy error More...
 
PS::F64 getMomentumError () const
 get angular momemtum (value) error More...
 

Public Attributes

PS::F64 error_cum_pre
 
PS::F64 ekin
 
PS::F64 epot
 
PS::F64 etot_ref
 
PS::F64 error_Lt_cum_pre
 
PS::F64 Lt
 
PS::F64vec L
 
PS::F64vec L_ref
 

Detailed Description

class for collecting and calculating the energy and angular momemtum of the system

Constructor & Destructor Documentation

◆ EnergyAndMomemtum()

EnergyAndMomemtum::EnergyAndMomemtum ( )
inline
Here is the call graph for this function:

Member Function Documentation

◆ calc() [1/2]

template<class Tptcl >
void EnergyAndMomemtum::calc ( const Tptcl *  _particles,
const PS::S32 *  _particle_index,
const PS::S32  _n_particle,
const bool  _init_flag = false 
)
inline

calculate the system kinetic and potential energy of particles

Using particle index array to select particles

Parameters
[in]_particlesparticle array
[in]_particle_indexindex array to select particles
[in]_n_particlenumber of particles
[in]_init_flagif true, set etot, etot_sd and L reference

◆ calc() [2/2]

template<class Tptcl >
void EnergyAndMomemtum::calc ( const Tptcl *  _particles,
const PS::S32  _n_particle,
const bool  _init_flag = false,
const PS::F64vec *  _pos_offset = NULL,
const PS::F64vec *  _vel_offset = NULL 
)
inline

calculate the system kinetic and potential energy of particles

Parameters
[in]_particlesparticle array
[in]_n_particlenumber of particles
[in]_init_flagif true, set etot, etot_sd and L reference
[in]_vel_offsetvelocity shift to calculate kinetic energy, if not given, assume it is zero

◆ clear()

void EnergyAndMomemtum::clear ( )
inline
Here is the caller graph for this function:

◆ getEnergyError()

PS::F64 EnergyAndMomemtum::getEnergyError ( ) const
inline

get energy error

Here is the caller graph for this function:

◆ getMomentumError()

PS::F64 EnergyAndMomemtum::getMomentumError ( ) const
inline

get angular momemtum (value) error

Here is the caller graph for this function:

◆ getSumMultiNodes()

void EnergyAndMomemtum::getSumMultiNodes ( const bool  _init_flag = false)
inline

get summation of kinetic, potential energy and angular momemtum of all MPI processes

Parameters
[in]_init_flagif true, set etot, etot_sd and L reference

◆ print()

void EnergyAndMomemtum::print ( std::ostream &  _fout = std::cout,
const PS::S32  _width = 16 
)
inline

print title and values in one lines

print titles and values in one lines

Parameters
[out]_foutstd::ostream output object
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printColumn()

void EnergyAndMomemtum::printColumn ( std::ofstream &  _fout,
const PS::S32  _width = 16 
) 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 16)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printColumnTitle()

void EnergyAndMomemtum::printColumnTitle ( std::ofstream &  _fout,
const PS::S32  _width = 16 
) const
inline

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 16)
Here is the caller graph for this function:

◆ saveEnergyError()

void EnergyAndMomemtum::saveEnergyError ( )
inline

save current energy error

Here is the call graph for this function:

◆ writeAscii()

void EnergyAndMomemtum::writeAscii ( FILE *  _fout)
inline

◆ writeBinary()

void EnergyAndMomemtum::writeBinary ( FILE *  _fout)
inline

Member Data Documentation

◆ ekin

PS::F64 EnergyAndMomemtum::ekin

◆ epot

PS::F64 EnergyAndMomemtum::epot

◆ error_cum_pre

PS::F64 EnergyAndMomemtum::error_cum_pre

◆ error_Lt_cum_pre

PS::F64 EnergyAndMomemtum::error_Lt_cum_pre

◆ etot_ref

PS::F64 EnergyAndMomemtum::etot_ref

◆ L

PS::F64vec EnergyAndMomemtum::L

◆ L_ref

PS::F64vec EnergyAndMomemtum::L_ref

◆ Lt

PS::F64 EnergyAndMomemtum::Lt

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