PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
peridynamics::Model Class Reference

Main model class to simulate peridynamics deformation of single particle. More...

Inheritance diagram for peridynamics::Model:
Collaboration diagram for peridynamics::Model:

Public Member Functions

 Model (inp::Input *deck)
 Constructor.
 
void computeForces () override
 Compute forces.
 
- Public Member Functions inherited from model::DEMModel
 DEMModel (inp::Input *deck, std::string modelName="DEMModel")
 Constructor.
 
void log (std::ostringstream &oss, int priority=0, bool check_condition=true, int override_priority=-1, bool screen_out=false)
 Prints message if any of these two conditions are true.
 
void log (const std::string &str, int priority=0, bool check_condition=true, int override_priority=-1, bool screen_out=false)
 Prints message if any of these two conditions are true.
 
virtual void run (inp::Input *deck)
 Main driver to simulate.
 
virtual void restart (inp::Input *deck)
 Restarts the simulation from previous state.
 
virtual void init ()
 Initialize remaining data members.
 
virtual void close ()
 Closure operations.
 
virtual void integrate ()
 Perform time integration.
 
virtual void integrateStep ()
 Performs one time step.
 
virtual void integrateCD ()
 Perform time integration using central-difference scheme.
 
virtual void integrateVerlet ()
 Perform time integration using velocity verlet scheme.
 
virtual void computePeridynamicForces ()
 Computes peridynamic forces.
 
virtual void computeExternalForces ()
 Computes external/boundary condition forces.
 
virtual void computeExternalDisplacementBC ()
 Applies displacement boundary conditions.
 
virtual void computeContactForces ()
 Computes contact forces.
 
virtual void applyInitialCondition ()
 Applies initial condition.
 
virtual void createParticles ()
 Creates particles in a given container.
 
virtual void createParticlesFromFile (size_t z, std::shared_ptr< particle::RefParticle > ref_p)
 Creates particles in a Hexagonal arrangement.
 
virtual void createParticleUsingParticleZoneGeomObject (size_t z, std::shared_ptr< particle::RefParticle > ref_p)
 Creates particles in a given container.
 
virtual void createGeometryAtSite (const double &particle_radius, const double &particle_orient, const util::Point &site, const std::vector< double > &rep_geom_params, const std::shared_ptr< util::geometry::GeomObject > &rep_geom_p, std::shared_ptr< util::geometry::GeomObject > &p_geom)
 Creates geometrical object for a particle given particle radius, orientation, and site location.
 
virtual void updateGeometryObjectsPostInit ()
 Update varioud geometry objects associated with container, particles, and reference particles.
 
virtual void updateContactNeighborlist ()
 Update neighborlist for contact.
 
virtual void updatePeridynamicNeighborlist ()
 Update neighborlist for peridynamics force.
 
virtual void updateNeighborlistCombine ()
 Update neighborlist for contact and peridynamics force.
 
virtual void setupContact ()
 Creates particles in a given container.
 
virtual void setupQuadratureData ()
 Sets up quadrature data.
 
virtual bool updateContactNeighborSearchParameters ()
 Update contact neighbor search parameters.
 
virtual void output ()
 Output the snapshot of data at current time step.
 
std::string ppTwoParticleTest ()
 Function that handles post-processing for two particle collision test and returns maximum vertical displacement of particle.
 
std::string ppCompressiveTest ()
 Function that handles post-processing for compressive test of particulate media by rigid wall and returns wall penetration and reaction force on wall.
 
virtual void checkStop ()
 Checks if simulation should be stopped due to abnormal state of system.
 
- Public Member Functions inherited from model::ModelData
 ModelData (inp::Input *deck)
 Constructor.
 
const particle::BaseParticlegetParticleFromAllList (size_t i) const
 Get pointer to base particle.
 
particle::BaseParticle *& getParticleFromAllList (size_t i)
 Get pointer to base particle.
 
const particle::BaseParticlegetParticleFromParticleList (size_t i) const
 Get pointer to particle (excluding wall)
 
particle::BaseParticle *& getParticleFromParticleList (size_t i)
 
const particle::BaseParticlegetParticleFromWallList (size_t i) const
 Get pointer to wall.
 
particle::BaseParticle *& getParticleFromWallList (size_t i)
 
double getDensity (size_t i)
 Get density of particle.
 
double getHorizon (size_t i)
 Get horizon of particle.
 
size_t & getPtId (size_t i)
 Get particle id given the location in particle list.
 
const size_t & getPtId (size_t i) const
 Get particle id given the location in particle list.
 
void setPtId (size_t i, const size_t &id)
 Set particle id given the location in particle list.
 
double getKeyData (std::string key, bool issue_err=false)
 Get data for a key.
 
void appendKeyData (std::string key, double data, bool issue_err=false)
 Append value to data associated with key.
 
void setKeyData (std::string key, double data, bool issue_err=false)
 Set value to data associated with key.
 
util::PointgetXRef (size_t i)
 Get reference coordinate of the node.
 
const util::PointgetXRef (size_t i) const
 Get reference coordinate of the node.
 
void setXRef (size_t i, const util::Point &x)
 Set reference coordinate of the node.
 
void addXRef (size_t i, const util::Point &x)
 Add reference coordinate of the node.
 
void setXRef (size_t i, int dof, double x)
 Set specific reference coordinate of the node.
 
void addXRef (size_t i, int dof, double x)
 Add specific reference coordinate of the node.
 
util::PointgetX (size_t i)
 Get current coordinate of the node.
 
const util::PointgetX (size_t i) const
 Get current coordinate of the node.
 
void setX (size_t i, const util::Point &x)
 Set current coordinate of the node.
 
void addX (size_t i, const util::Point &x)
 Add current coordinate of the node.
 
void setX (size_t i, int dof, double x)
 Set specific current coordinate of the node.
 
void addX (size_t i, int dof, double x)
 Add to specific current coordinate of the node.
 
util::PointgetU (size_t i)
 Get displacement of the node.
 
const util::PointgetU (size_t i) const
 Get displacement of the node.
 
void setU (size_t i, const util::Point &u)
 Set displacement of the node.
 
void addU (size_t i, const util::Point &u)
 Add to displacement of the node.
 
void setU (size_t i, int dof, double u)
 Set displacement of the node.
 
void addU (size_t i, int dof, double u)
 Add to displacement of the node.
 
util::PointgetV (size_t i)
 Get velocity of the node.
 
const util::PointgetV (size_t i) const
 Get velocity of the node.
 
void setV (size_t i, const util::Point &v)
 Set velocity of the node.
 
void addV (size_t i, const util::Point &v)
 Add to velocity of the node.
 
void setV (size_t i, int dof, double v)
 Set velocity of the node.
 
void addV (size_t i, int dof, double v)
 Add to velocity of the node.
 
util::PointgetF (size_t i)
 Get force of the node.
 
const util::PointgetF (size_t i) const
 Get force of the node.
 
void setF (size_t i, const util::Point &f)
 Set force of the node.
 
void addF (size_t i, const util::Point &f)
 Add to force of the node.
 
void setF (size_t i, int dof, double f)
 Set force of the node.
 
void addF (size_t i, int dof, double f)
 Add to force of the node.
 
double & getVol (size_t i)
 Get volume of the node.
 
const double & getVol (size_t i) const
 Get volume of the node.
 
void setVol (size_t i, const double &vol)
 Set volume of the node.
 
void addVol (size_t i, const double &vol)
 Add to volume of the node.
 
uint8_t & getFix (size_t i)
 Get fixity of the node.
 
const uint8_t & getFix (size_t i) const
 Get fixity of the node.
 
void setFix (size_t i, const unsigned int &dof, const bool &flag)
 Set fixity of the node.
 
double & getMx (size_t i)
 Get weighted-volume (mx) of the node.
 
const double & getMx (size_t i) const
 Get weighted-volume (mx) of the node.
 
void setMx (size_t i, const double &mx)
 Set weighted-volume (mx) of the node.
 
void addMx (size_t i, const double &mx)
 Add to weighted-volume (mx) of the node.
 
double & getThetax (size_t i)
 Get volumetric deformation (thetax) of the node.
 
const double & getThetax (size_t i) const
 Get volumetric deformation (thetax) of the node.
 
void setThetax (size_t i, const double &thetax)
 Set volumetric deformation (thetax) of the node.
 
void addThetax (size_t i, const double &thetax)
 Add to volumetric deformation (thetax) of the node.
 

Additional Inherited Members

- Data Fields inherited from model::DEMModel
std::string d_name
 Name of the model for logging purposes (useful if other classes are built on top of this class)
 
- Data Fields inherited from model::ModelData
size_t d_n
 Current time step.
 
double d_time
 Current time.
 
double d_currentDt
 Current timestep.
 
size_t d_infoN
 Print log step interval.
 
std::map< std::string, double > d_dbgData
 Debug data.
 
std::ofstream d_ppFile
 File stream to output information.
 
inp::Inputd_input_p
 Pointer to Input object.
 
std::shared_ptr< inp::ModelDeckd_modelDeck_p
 Model deck.
 
std::shared_ptr< inp::RestartDeckd_restartDeck_p
 Restart deck.
 
std::shared_ptr< inp::OutputDeckd_outputDeck_p
 Output deck.
 
std::shared_ptr< inp::ParticleDeckd_pDeck_p
 Particle deck.
 
std::shared_ptr< inp::ContactDeckd_cDeck_p
 Contact deck.
 
bool d_stop
 flag to stop the simulation midway
 
double d_hMax
 Minimum mesh over all particles and walls.
 
double d_hMin
 Maximum mesh over all particles and walls.
 
double d_maxContactR
 Maximum contact radius between over pairs of particles and walls.
 
size_t d_contNeighUpdateInterval
 Neighborlist update interval.
 
size_t d_contNeighTimestepCounter
 Contact neighborlist time step counter.
 
double d_contNeighSearchRadius
 Neighborlist contact search radius (multiple of d_maxContactR). This variable will be updated during simulation based on maximum velocity.
 
std::vector< std::shared_ptr< particle::RefParticle > > d_referenceParticles
 Pointer to reference particle.
 
std::vector< particle::BaseParticle * > d_particlesListTypeAll
 List of particles + walls.
 
std::vector< particle::BaseParticle * > d_particlesListTypeParticle
 List of particles.
 
std::vector< particle::BaseParticle * > d_particlesListTypeWall
 List of walls.
 
std::vector< inp::MatDatad_particlesMatDataList
 List of particle material data. Only populated if needed for calculation of stress or other quantities.
 
std::vector< double > d_maxVelocityParticlesListTypeAll
 Maximum velocity among all nodes in the particle for each particle.
 
double d_maxVelocity
 Maximum velocity among all nodes.
 
std::vector< std::vector< size_t > > d_zInfo
 Zone information of particles. For zone 0, d_zInfo[0] = [n1, n2] where n1 is the index at which the particle in this zone starts in d_particlesListTypeAll and n2 is the index + 1, where index is at which the particle in this zone ends.
 
std::unique_ptr< loading::ParticleULoadingd_uLoading_p
 Pointer to displacement Loading object.
 
std::unique_ptr< loading::ParticleFLoadingd_fLoading_p
 Pointer to force Loading object.
 
std::unique_ptr< geometry::Fractured_fracture_p
 Fracture state of bonds.
 
std::unique_ptr< NSearchd_nsearch_p
 Pointer to nsearch.
 
std::vector< util::Pointd_xRef
 reference positions of the nodes
 
std::vector< util::Pointd_x
 Current positions of the nodes.
 
std::vector< util::Pointd_u
 Displacement of the nodes.
 
std::vector< util::Pointd_v
 Velocity of the nodes.
 
std::vector< double > d_vMag
 Magnitude of velocity of the nodes.
 
std::vector< util::Pointd_f
 Total force on the nodes.
 
std::vector< double > d_vol
 Nodal volumes.
 
std::vector< size_t > d_ptId
 Global node to particle id (walls are assigned id after last particle id)
 
std::vector< std::vector< size_t > > d_neighC
 Neighbor data for contact forces.
 
std::vector< std::vector< size_t > > d_neighPd
 Neighbor data for peridynamic forces.
 
std::vector< std::vector< float > > d_neighPdSqdDist
 Square distance neighbor data for peridynamic forces.
 
std::vector< std::vector< std::vector< size_t > > > d_neighWallNodes
 Neighbor data for contact between particle and walls.
 
std::vector< std::vector< std::vector< double > > > d_neighWallNodesDistance
 Neighbor data (distance) for contact between particle and walls.
 
std::vector< std::vector< size_t > > d_neighWallNodesCondensed
 Neighbor data for contact between particle and walls condensed into single vector for each particle.
 
std::vector< uint8_t > d_fix
 Vector of fixity mask of each node.
 
std::vector< uint8_t > d_forceFixity
 Vector of fixity mask of each node for force.
 
std::vector< double > d_thetaX
 Dilation.
 
std::vector< double > d_mX
 Weighted volume.
 
std::vector< size_t > d_fPdCompNodes
 List of global nodes on which force (peridynamic/internal) is to be computed.
 
std::vector< size_t > d_fContCompNodes
 List of global nodes on which force (contact) is to be computed.
 
std::vector< float > d_Z
 Damage at nodes.
 
std::vector< float > d_e
 Energy of the nodes.
 
std::vector< float > d_w
 Work done on each of the nodes.
 
std::vector< float > d_phi
 Damage function \( \phi \) at the nodes.
 
std::vector< float > d_eF
 Fracture energy of the nodes.
 
std::vector< float > d_eFB
 Bond-based fracture energy of the nodes.
 
std::vector< util::Pointd_xQuadCur
 Current position of quadrature points.
 
std::vector< util::SymMatrix3d_strain
 Strain in elements (values at quadrature points)
 
std::vector< util::SymMatrix3d_stress
 Stress in elements (values at quadrature points)
 
float d_te
 Total internal energy.
 
float d_tw
 Total work done.
 
float d_tk
 Total kinetic energy.
 
float d_teF
 Total fracture energy.
 
float d_teFB
 Total bond-based fracture energy.
 

Detailed Description

Main model class to simulate peridynamics deformation of single particle.

Definition at line 55 of file main.cpp.

Constructor & Destructor Documentation

◆ Model()

peridynamics::Model::Model ( inp::Input deck)
inlineexplicit

Constructor.

Parameters
deckInput deck

Definition at line 64 of file main.cpp.

64: model::DEMModel(deck, "peridynamics::Model") {}
A class for discrete element particle simulation with peridynamic model
Definition demModel.h:32

Member Function Documentation

◆ computeForces()

void peridynamics::Model::computeForces ( )
inlineoverridevirtual

Compute forces.

Reimplemented from model::DEMModel.

Definition at line 69 of file main.cpp.

69 {
70
71 bool dbg_condition = d_n % d_infoN == 0;
72
73 log(" Compute forces \n", 2, dbg_condition, 3);
74
75 // reset force
76 auto t1 = steady_clock::now();
77 tf::Executor executor(util::parallel::getNThreads());
78 tf::Taskflow taskflow;
79
80 taskflow.for_each_index(
81 (std::size_t) 0, d_x.size(), (std::size_t) 1,
82 [this](std::size_t i) { this->d_f[i] = util::Point(); }
83 ); // for_each
84
85 executor.run(taskflow).get();
86 auto force_reset_time = util::methods::timeDiff(t1, steady_clock::now());
87
88 // compute peridynamic forces
89 t1 = steady_clock::now();
91 auto pd_time = util::methods::timeDiff(t1, steady_clock::now());
92 appendKeyData("pd_compute_time", pd_time);
93 appendKeyData("avg_peridynamics_force_time", pd_time/d_infoN);
94
95 // Compute external forces
96 t1 = steady_clock::now();
98 auto extf_time = util::methods::timeDiff(t1, steady_clock::now());
99 appendKeyData("extf_compute_time", extf_time);
100 appendKeyData("avg_extf_compute_time", extf_time/d_infoN);
101
102 // output avg time info
103 if (dbg_condition) {
104 log(fmt::format(" Avg time (ms): \n"
105 " {:48s} = {:8d}\n"
106 " {:48s} = {:8d}\n",
107 "peridynamics force", size_t(getKeyData("avg_peridynamics_force_time")),
108 "external force", size_t(getKeyData("avg_extf_compute_time")/d_infoN)),
109 2, dbg_condition, 3);
110
111 appendKeyData("avg_peridynamics_force_time", 0.);
112 appendKeyData("avg_extf_compute_time", 0.);
113 }
114
115 log(fmt::format(" {:50s} = {:8d} \n",
116 "Force reset time (ms)",
117 size_t(force_reset_time)
118 ),
119 2, dbg_condition, 3);
120
121 log(fmt::format(" {:50s} = {:8d} \n",
122 "External force time (ms)",
123 size_t(extf_time)
124 ),
125 2, dbg_condition, 3);
126
127 log(fmt::format(" {:50s} = {:8d} \n",
128 "Peridynamics force time (ms)",
129 size_t(pd_time)
130 ),
131 2, dbg_condition, 3);
132 }
virtual void computeExternalForces()
Computes external/boundary condition forces.
Definition demModel.cpp:791
virtual void computePeridynamicForces()
Computes peridynamic forces.
Definition demModel.cpp:602
void log(std::ostringstream &oss, int priority=0, bool check_condition=true, int override_priority=-1, bool screen_out=false)
Prints message if any of these two conditions are true.
Definition demModel.cpp:53
double getKeyData(std::string key, bool issue_err=false)
Get data for a key.
Definition modelData.h:145
size_t d_infoN
Print log step interval.
Definition modelData.h:540
size_t d_n
Current time step.
Definition modelData.h:531
std::vector< util::Point > d_x
Current positions of the nodes.
Definition modelData.h:633
void appendKeyData(std::string key, double data, bool issue_err=false)
Append value to data associated with key.
Definition modelData.h:154
float timeDiff(std::chrono::steady_clock::time_point begin, std::chrono::steady_clock::time_point end, std::string unit="microseconds")
Returns difference between two times.
Definition methods.h:304
unsigned int getNThreads()
Get number of threads to be used by taskflow.

References model::ModelData::appendKeyData(), model::DEMModel::computeExternalForces(), model::DEMModel::computePeridynamicForces(), model::ModelData::d_infoN, model::ModelData::d_n, model::ModelData::d_x, model::ModelData::getKeyData(), util::parallel::getNThreads(), model::DEMModel::log(), and util::methods::timeDiff().

Here is the call graph for this function:

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