SPHinXsys  alpha version
Classes | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
SPH::BaseParticles Class Reference

Particles with essential (geometric and kinematic) data. There are three types of particles, all particles of a same type are saved with continuous memory segments. The first type is real particles whose states are updated by particle dynamics. One is buffer particles whose state are not updated by particle dynamics. Buffer particles are saved behind real particles. The global value of total_real_particles_ separate the real and buffer particles. They may be switched from real particles or switch to real particles. As the memory for both particles are continuous, such switch is achieved at the memory boundary sequentially. The basic idea is swap the data of the last real particle with the one will be switched particle, and then switch this swapped last particle as buffer particle by decrease the total_real_particles_ by one. Switch from buffer particle to real particle is easy. One just need to assign expect state to the first buffer particle and increase total_real_particles_ by one. The other is ghost particles whose states are updated according to boundary condition if their indices are included in the neighbor particle list. The ghost particles are saved behind the buffer particles. The global value of real_particles_bound_ separate the sum of real and buffer particles with ghost particles. The global value of total_ghost_particles_ indicates the total number of ghost particles in use. It will be initialized to zero before a time step. In SPHinXsys, the variables registered in general particle data (ParticleData) belong to a hierarchy of two layers. The first is for the global basic physical states to describe the physical process. These variables are defined within the classes of particles. The second is for the local, dynamics-method-related variables, which are defined in specific methods, and are only used by the relevant methods. There is a rule of single registration, that is, a variable is only allowed to be registered with a name once by the function registerAVariable. The usage of the second- and third-layer variables is accessed by getVariableByName. Such a rule requires careful design of the code. More...

#include <base_particles.h>

Inherited by SPH::FluidParticles, SPH::ObserverParticles, and SPH::SolidParticles.

Classes

struct  addAParticleDataValue
 
struct  copyAParticleDataValue
 
struct  resizeParticleData
 

Public Member Functions

 BaseParticles (SPHBody &sph_body, BaseMaterial *base_material)
 
template<typename VariableType >
void registerVariable (StdLargeVec< VariableType > &variable_addrs, const std::string &variable_name, VariableType initial_value=VariableType(0))
 
template<typename VariableType , class InitializationFunction >
void registerVariable (StdLargeVec< VariableType > &variable_addrs, const std::string &variable_name, const InitializationFunction &initialization)
 
template<typename VariableType >
StdLargeVec< VariableType > * getVariableByName (const std::string &variable_name)
 
template<typename VariableType >
void addVariableNameToList (ParticleVariableList &variable_name_list, const std::string &variable_name)
 
template<typename VariableType >
void addVariableToWrite (const std::string &variable_name)
 
template<class DerivedVariableMethod >
void addDerivedVariableToWrite ()
 
template<typename VariableType >
void addVariableToRestart (const std::string &variable_name)
 
template<typename VariableType >
void addVariableToReload (const std::string &variable_name)
 
template<typename VariableType >
void registerSortableVariable (const std::string &variable_name)
 
SPHBodygetSPHBody ()
 
virtual void initializeOtherVariables ()
 
void addBufferParticles (size_t buffer_size)
 
void copyFromAnotherParticle (size_t this_index, size_t another_index)
 
void updateFromAnotherParticle (size_t this_index, size_t another_index)
 
size_t insertAGhostParticle (size_t index_i)
 
void switchToBufferParticle (size_t index_i)
 
template<typename OutStreamType >
void writeParticlesToVtk (OutStreamType &output_stream)
 
void writeParticlesToPltFile (std::ofstream &output_file)
 
virtual void writeSurfaceParticlesToVtuFile (std::ostream &output_file, BodySurface &surface_particles)
 
void resizeXmlDocForParticles (XmlEngine &xml_engine)
 
void writeParticlesToXmlForRestart (std::string &filefullpath)
 
void readParticleFromXmlForRestart (std::string &filefullpath)
 
XmlEnginegetReloadXmlEngine ()
 
void writeToXmlForReloadParticle (std::string &filefullpath)
 
void readFromXmlForReloadParticle (std::string &filefullpath)
 
virtual BaseParticlesThisObjectPtr ()
 
virtual Vecd getKernelGradient (size_t index_i, size_t index_j, Real dW_ij, Vecd &e_ij)
 
virtual Vecd ParticleTotalAcceleration (size_t index_i)
 
virtual Real ParticleVolume (size_t index_i)
 
virtual Real ParticleMass (size_t index_i)
 
template<typename StreamType >
void writeParticlesToVtk (StreamType &output_stream)
 

Public Attributes

StdLargeVec< Vecd > pos_
 
StdLargeVec< Vecd > vel_
 
StdLargeVec< Vecd > acc_
 
StdLargeVec< Vecd > acc_prior_
 
StdLargeVec< Real > Vol_
 
StdLargeVec< Real > rho_
 
StdLargeVec< Real > mass_
 
Real rho0_
 
Real sigma0_
 
Real speed_max_
 
Real signal_speed_max_
 
size_t total_real_particles_
 
size_t real_particles_bound_
 
size_t total_ghost_particles_
 
ParticleData all_particle_data_
 
ParticleDataMap all_variable_maps_
 
StdVec< ParticleDynamics< void > * > derived_variables_
 
ParticleVariableList variables_to_write_
 
StdLargeVec< size_tunsorted_id_
 
StdLargeVec< size_tsorted_id_
 
StdLargeVec< size_tsequence_
 
ParticleData sortable_data_
 
ParticleDataMap sortable_variable_maps_
 

Protected Member Functions

void addAParticleEntry ()
 
virtual void writePltFileHeader (std::ofstream &output_file)
 
virtual void writePltFileParticleData (std::ofstream &output_file, size_t index_i)
 

Protected Attributes

SPHBodysph_body_
 
std::string body_name_
 
XmlEngine restart_xml_engine_
 
XmlEngine reload_xml_engine_
 
ParticleVariableList variables_to_restart_
 
ParticleVariableList variables_to_reload_
 
DataAssembleOperation< resizeParticleDataresize_particle_data_
 
DataAssembleOperation< addAParticleDataValueadd_a_particle_value_
 
DataAssembleOperation< copyAParticleDataValuecopy_a_particle_value_
 

Detailed Description

Particles with essential (geometric and kinematic) data. There are three types of particles, all particles of a same type are saved with continuous memory segments. The first type is real particles whose states are updated by particle dynamics. One is buffer particles whose state are not updated by particle dynamics. Buffer particles are saved behind real particles. The global value of total_real_particles_ separate the real and buffer particles. They may be switched from real particles or switch to real particles. As the memory for both particles are continuous, such switch is achieved at the memory boundary sequentially. The basic idea is swap the data of the last real particle with the one will be switched particle, and then switch this swapped last particle as buffer particle by decrease the total_real_particles_ by one. Switch from buffer particle to real particle is easy. One just need to assign expect state to the first buffer particle and increase total_real_particles_ by one. The other is ghost particles whose states are updated according to boundary condition if their indices are included in the neighbor particle list. The ghost particles are saved behind the buffer particles. The global value of real_particles_bound_ separate the sum of real and buffer particles with ghost particles. The global value of total_ghost_particles_ indicates the total number of ghost particles in use. It will be initialized to zero before a time step. In SPHinXsys, the variables registered in general particle data (ParticleData) belong to a hierarchy of two layers. The first is for the global basic physical states to describe the physical process. These variables are defined within the classes of particles. The second is for the local, dynamics-method-related variables, which are defined in specific methods, and are only used by the relevant methods. There is a rule of single registration, that is, a variable is only allowed to be registered with a name once by the function registerAVariable. The usage of the second- and third-layer variables is accessed by getVariableByName. Such a rule requires careful design of the code.

Member Function Documentation

◆ addDerivedVariableToWrite()

template<class DerivedVariableMethod >
void SPH::BaseParticles::addDerivedVariableToWrite ( )

add a derived variable into the list for state output

◆ addVariableNameToList()

template<typename VariableType >
void SPH::BaseParticles::addVariableNameToList ( ParticleVariableList variable_name_list,
const std::string &  variable_name 
)

add a variable into a particle variable name list

◆ addVariableToReload()

template<typename VariableType >
void SPH::BaseParticles::addVariableToReload ( const std::string &  variable_name)

add a variable into the list for particle reload

◆ addVariableToRestart()

template<typename VariableType >
void SPH::BaseParticles::addVariableToRestart ( const std::string &  variable_name)

add a variable into the list for restart

◆ addVariableToWrite()

template<typename VariableType >
void SPH::BaseParticles::addVariableToWrite ( const std::string &  variable_name)

add a variable into the list for state output

◆ getKernelGradient()

virtual Vecd SPH::BaseParticles::getKernelGradient ( size_t  index_i,
size_t  index_j,
Real  dW_ij,
Vecd &  e_ij 
)
inlinevirtual

Get the kernel gradient in weak form.

Reimplemented in SPH::ElectroPhysiologyReducedParticles, and SPH::SolidParticles.

◆ getVariableByName()

template<typename VariableType >
StdLargeVec< VariableType > * SPH::BaseParticles::getVariableByName ( const std::string &  variable_name)

get a registered variable from particles by its name. return by pointer so that return nullptr if fail.

◆ initializeOtherVariables()

void SPH::BaseParticles::initializeOtherVariables ( )
virtual

◆ insertAGhostParticle()

size_t SPH::BaseParticles::insertAGhostParticle ( size_t  index_i)

For a ghost particle, its sorted id is that of corresponding real particle.
For a ghost particle, its sorted id is that of corresponding real particle.

◆ registerSortableVariable()

template<typename VariableType >
void SPH::BaseParticles::registerSortableVariable ( const std::string &  variable_name)

register an already defined variable as sortable

◆ registerVariable() [1/2]

template<typename VariableType >
void SPH::BaseParticles::registerVariable ( StdLargeVec< VariableType > &  variable_addrs,
const std::string &  variable_name,
VariableType  initial_value = VariableType(0) 
)

register a variable defined in a class (can be non-particle class)

◆ registerVariable() [2/2]

template<typename VariableType , class InitializationFunction >
void SPH::BaseParticles::registerVariable ( StdLargeVec< VariableType > &  variable_addrs,
const std::string &  variable_name,
const InitializationFunction &  initialization 
)

register a variable from a initialization function

◆ writeParticlesToPltFile()

void SPH::BaseParticles::writeParticlesToPltFile ( std::ofstream &  output_file)

Write particle data in PLT format for Tecplot.

◆ writeParticlesToVtk()

template<typename OutStreamType >
void SPH::BaseParticles::writeParticlesToVtk ( OutStreamType &  output_stream)

Write particle data in Vtk format for Paraview.

◆ writeSurfaceParticlesToVtuFile()

void SPH::BaseParticles::writeSurfaceParticlesToVtuFile ( std::ostream &  output_file,
BodySurface surface_particles 
)
virtual

Write only surface particle data in VTU format for Paraview. TODO: this should be generalized for body part by particles

Member Data Documentation

◆ acc_

StdLargeVec<Vecd> SPH::BaseParticles::acc_

total acceleration including inner pressure- or stress-induced acceleration and other accelerations

◆ acc_prior_

StdLargeVec<Vecd> SPH::BaseParticles::acc_prior_

other, such as gravity and viscous, accelerations

◆ mass_

StdLargeVec<Real> SPH::BaseParticles::mass_

particle massive measure, also referred to mass per-unit thickness of surface particle and mass per-unit cross-section area of linear particle

◆ pos_

StdLargeVec<Vecd> SPH::BaseParticles::pos_

particle position

◆ real_particles_bound_

size_t SPH::BaseParticles::real_particles_bound_

Maximum possible number of real particles. Also the start index of ghost particles.

◆ rho0_

Real SPH::BaseParticles::rho0_

reference density

◆ rho_

StdLargeVec<Real> SPH::BaseParticles::rho_

particle density

◆ sequence_

StdLargeVec<size_t> SPH::BaseParticles::sequence_

the sequence referred for sorting.

◆ sigma0_

Real SPH::BaseParticles::sigma0_

reference number density.

◆ signal_speed_max_

Real SPH::BaseParticles::signal_speed_max_

Maximum signal speed.

◆ sorted_id_

StdLargeVec<size_t> SPH::BaseParticles::sorted_id_

the sorted particle ids of particles from unsorted ids.

◆ speed_max_

Real SPH::BaseParticles::speed_max_

Maximum particle speed.

◆ sph_body_

SPHBody* SPH::BaseParticles::sph_body_
protected

The body in which the particles belongs to.

◆ unsorted_id_

StdLargeVec<size_t> SPH::BaseParticles::unsorted_id_

the ids assigned just after particle generated.

◆ vel_

StdLargeVec<Vecd> SPH::BaseParticles::vel_

particle velocity

◆ Vol_

StdLargeVec<Real> SPH::BaseParticles::Vol_

particle volumetric measure, also referred to area of surface particle and length of linear particle


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