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

Main model class to handle demo two-particle test implementation. Goal is to show that it is easy to specialize the DEMModel class for different scenarios. More...

Inheritance diagram for twoparticle_demo::Model:
Collaboration diagram for twoparticle_demo::Model:

Public Member Functions

 Model (inp::Input *deck)
 Constructor.
 
void run (inp::Input *deck) override
 Runs simulation by executing steps such as init(), integrate(), and close().
 
void integrate () override
 Perform time step integration.
 
void twoParticleTest ()
 Handles postprocessing for two-particle test.
 
void twoParticleTestPenetrationDist ()
 Computes penetration distance of top particle into bottom particle.
 
void twoParticleTestMaxShearStress ()
 Computes maximum shear stress and its location in particle.
 
- 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 restart (inp::Input *deck)
 Restarts the simulation from previous state.
 
virtual void init ()
 Initialize remaining data members.
 
virtual void close ()
 Closure operations.
 
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 computeForces ()
 Computes peridynamic forces and contact forces.
 
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.
 

Data Fields

double d_penDist = 0.
 Penetration distance of top particle into bottom particle.
 
double d_contactAreaRadius = 0.
 Contact area radius.
 
double d_maxDist = 0.
 Maximum vertical distance of top particle in initial configuration.
 
double d_maxStress = 0.
 Maximum stress.
 
double d_maxStressLocRef = 0.
 Maximum stress location in reference configuration.
 
double d_maxStressLocCur = 0.
 Maximum stress location in current configuration.
 
double d_maxY = 0.
 Current maximum vertical distance of top particle.
 
double d_contactAreaRadiusIdeal = 0.
 Ideal contact area radius from Hertz theory.
 
double d_maxStressIdeal = 0.
 Ideal maximum stress.
 
double d_maxStressLocRefIdeal = 0.
 Ideal maximum stress location location in reference configuration.
 
- 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 handle demo two-particle test implementation. Goal is to show that it is easy to specialize the DEMModel class for different scenarios.

Definition at line 55 of file main.cpp.

Constructor & Destructor Documentation

◆ Model()

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

Constructor.

Parameters
deckInput deck

Definition at line 64 of file main.cpp.

64 : model::DEMModel(deck, "twoparticle_demo::Model") {
65
66 if (d_ppFile.is_open())
68
69 std::string filename =
70 d_outputDeck_p->d_path + "pp_" + d_outputDeck_p->d_tagPPFile + ".csv";
71 d_ppFile = std::ofstream(filename, std::ios_base::out);
72 d_ppFile << "t, delta, cont_area_r, s_loc, s_val, max_dist, "
73 "cont_area_r_ideal, s_loc_ideal, s_val_ideal" << std::flush;
74 }
A class for discrete element particle simulation with peridynamic model
Definition demModel.h:32
virtual void close()
Closure operations.
Definition demModel.cpp:104
std::ofstream d_ppFile
File stream to output information.
Definition modelData.h:546
std::shared_ptr< inp::OutputDeck > d_outputDeck_p
Output deck.
Definition modelData.h:558

References model::ModelData::d_outputDeck_p, and model::ModelData::d_ppFile.

Member Function Documentation

◆ integrate()

void twoparticle_demo::Model::integrate ( )
inlineoverridevirtual

Perform time step integration.

Reimplemented from model::DEMModel.

Definition at line 132 of file main.cpp.

132 {
133 // perform output at the beginning
134 if (d_n == 0 && d_outputDeck_p->d_performOut) {
135 log(fmt::format("{}: Output step = {}, time = {:.6f} \n", d_name, d_n, d_time),
136 2);
137 output();
138 }
139
140 // apply initial condition
141 if (d_n == 0) applyInitialCondition();
142
143 // apply loading
146
147 for (size_t i = d_n; i < d_modelDeck_p->d_Nt; i++) {
148
149 log(fmt::format("{}: Time step: {}, time: {:8.6f}, steps completed = {}%\n",
150 d_name,
151 i,
152 d_time,
153 float(i) * 100. / d_modelDeck_p->d_Nt),
154 2, d_n % d_infoN == 0, 3);
155
156 // NOTE: If there is need for different time-stepping scheme, one can
157 // define another function similar to these two below
158 auto t1 = steady_clock::now();
160 double integrate_time =
161 util::methods::timeDiff(t1, steady_clock::now());
162
163 log(fmt::format(" Integration time (ms) = {}\n", integrate_time),
164 2, d_n % d_infoN == 0, 3);
165
166 if (d_pDeck_p->d_testName == "two_particle") {
167 // NOTE: The purpose of this app 'twop' is to show that if we have
168 // specific post-processing requirement from the outcome of
169 // simulation -- eg in two-particle test, we may be interested in the
170 // maximum of y-coordinate of top particle to measure the damping
171 // effect or the maximum shear stress -- we wrap the base DEMModel
172 // class as we did here and add a specific post-processing function
173 // like 'ppTwoParticleTest()'.
175 }
176
177 // handle general output
178 if ((d_n % d_outputDeck_p->d_dtOut == 0) &&
179 (d_n >= d_outputDeck_p->d_dtOut) && d_outputDeck_p->d_performOut) {
180 output();
181 }
182
183 // check for stop (we may want to terminate the simulation early if the
184 // results are garbage, or if some other criteria is met)
185 // NOTE: this too can be specific to particular application
186 checkStop();
187 } // loop over time steps
188 }
virtual void computeExternalForces()
Computes external/boundary condition forces.
Definition demModel.cpp:791
virtual void output()
Output the snapshot of data at current time step.
virtual void applyInitialCondition()
Applies initial condition.
virtual void computeExternalDisplacementBC()
Applies displacement boundary conditions.
Definition demModel.cpp:814
virtual void integrateStep()
Performs one time step.
Definition demModel.cpp:342
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
virtual void checkStop()
Checks if simulation should be stopped due to abnormal state of system.
std::string d_name
Name of the model for logging purposes (useful if other classes are built on top of this class)
Definition demModel.h:42
size_t d_infoN
Print log step interval.
Definition modelData.h:540
std::shared_ptr< inp::ModelDeck > d_modelDeck_p
Model deck.
Definition modelData.h:552
size_t d_n
Current time step.
Definition modelData.h:531
double d_time
Current time.
Definition modelData.h:534
std::shared_ptr< inp::ParticleDeck > d_pDeck_p
Particle deck.
Definition modelData.h:561
void twoParticleTest()
Handles postprocessing for two-particle test.
Definition main.cpp:193
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

References model::DEMModel::applyInitialCondition(), model::DEMModel::checkStop(), model::DEMModel::computeExternalDisplacementBC(), model::DEMModel::computeExternalForces(), model::ModelData::d_infoN, model::ModelData::d_modelDeck_p, model::ModelData::d_n, model::DEMModel::d_name, model::ModelData::d_outputDeck_p, model::ModelData::d_pDeck_p, model::ModelData::d_time, model::DEMModel::integrateStep(), model::DEMModel::log(), model::DEMModel::output(), util::methods::timeDiff(), and twoParticleTest().

Referenced by run().

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

◆ run()

void twoparticle_demo::Model::run ( inp::Input deck)
inlineoverridevirtual

Runs simulation by executing steps such as init(), integrate(), and close().

Parameters
deckInput deck

Reimplemented from model::DEMModel.

Definition at line 81 of file main.cpp.

81 {
82
83 log(d_name + ": Running TwoParticle_Demo app \n");
84
85 // initialize data
86 init();
87
88 // check if init() successfully created quadrature data which we need for postprocessing
89 {
90 size_t totalQuadPoints = 0;
91 for (auto &p: d_particlesListTypeAll) {
92 const auto &particle_mesh_p = p->d_rp_p->getMeshP();
93
94 // get Quadrature
95 fe::BaseElem *elem;
96 if (particle_mesh_p->getElementType() == util::vtk_type_line)
97 elem = new fe::LineElem(d_modelDeck_p->d_quadOrder);
98 else if (particle_mesh_p->getElementType() == util::vtk_type_triangle)
99 elem = new fe::TriElem(d_modelDeck_p->d_quadOrder);
100 else if (particle_mesh_p->getElementType() == util::vtk_type_quad)
101 elem = new fe::QuadElem(d_modelDeck_p->d_quadOrder);
102 else if (particle_mesh_p->getElementType() == util::vtk_type_tetra)
103 elem = new fe::TetElem(d_modelDeck_p->d_quadOrder);
104 else {
105 std::cerr << fmt::format("Error: Can not compute strain/stress as the element "
106 "type = {} is not yet supported in this routine.\n", particle_mesh_p->getElementType());
107 exit(EXIT_FAILURE);
108 }
109
110 totalQuadPoints += particle_mesh_p->getNumElements() *
111 elem->getNumQuadPoints();
112 }
113
114 if (d_xQuadCur.size() != totalQuadPoints
115 or d_strain.size() != totalQuadPoints
116 or d_stress.size() != totalQuadPoints) {
117 std::cerr << "Error: DEMModel::init() did not initialize quadrature data.\n";
118 exit(EXIT_FAILURE);
119 }
120 }
121
122 // integrate in time
123 integrate();
124
125 // close
126 close();
127 }
A base class which provides methods to map points to/from reference element and to compute quadrature...
Definition baseElem.h:84
size_t getNumQuadPoints()
Get number of quadrature points in the data.
Definition baseElem.h:111
A class for mapping and quadrature related operations for linear 2-node line element.
Definition lineElem.h:49
A class for mapping and quadrature related operations for bi-linear quadrangle element.
Definition quadElem.h:64
A class for mapping and quadrature related operations for linear tetrahedron element.
Definition tetElem.h:141
A class for mapping and quadrature related operations for linear triangle element.
Definition triElem.h:91
virtual void init()
Initialize remaining data members.
Definition demModel.cpp:109
std::vector< particle::BaseParticle * > d_particlesListTypeAll
List of particles + walls.
Definition modelData.h:592
std::vector< util::SymMatrix3 > d_stress
Stress in elements (values at quadrature points)
Definition modelData.h:737
std::vector< util::Point > d_xQuadCur
Current position of quadrature points.
Definition modelData.h:731
std::vector< util::SymMatrix3 > d_strain
Strain in elements (values at quadrature points)
Definition modelData.h:734
void integrate() override
Perform time step integration.
Definition main.cpp:132
static const int vtk_type_triangle
Integer flag for triangle element.
static const int vtk_type_quad
Integer flag for quad element.
static const int vtk_type_tetra
Integer flag for tetrahedron element.
static const int vtk_type_line
Integer flag for line element.

References model::DEMModel::close(), model::ModelData::d_modelDeck_p, model::DEMModel::d_name, model::ModelData::d_particlesListTypeAll, model::ModelData::d_strain, model::ModelData::d_stress, model::ModelData::d_xQuadCur, fe::BaseElem::getNumQuadPoints(), model::DEMModel::init(), integrate(), model::DEMModel::log(), util::vtk_type_line, util::vtk_type_quad, util::vtk_type_tetra, and util::vtk_type_triangle.

Referenced by main().

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

◆ twoParticleTest()

void twoparticle_demo::Model::twoParticleTest ( )
inline

Handles postprocessing for two-particle test.

Definition at line 193 of file main.cpp.

193 {
194
195 bool continue_dt = false;
196 auto check_dt = d_outputDeck_p->d_dtTestOut;
197 if ((d_n % check_dt == 0) && (d_n >= check_dt))
198 continue_dt = true;
199
200 if (!continue_dt)
201 return;
202
203 // compute QoIs
206
207 // log
208 d_ppFile << d_time << ", " << -d_penDist << ", " << d_contactAreaRadius
209 << ", " << d_maxStressLocRef << ", " << d_maxStress << ", "
210 << d_maxDist << ", " << d_contactAreaRadiusIdeal << ", "
212 << std::endl;
213 }
double d_maxStressIdeal
Ideal maximum stress.
Definition main.cpp:368
void twoParticleTestPenetrationDist()
Computes penetration distance of top particle into bottom particle.
Definition main.cpp:218
double d_maxStressLocRefIdeal
Ideal maximum stress location location in reference configuration.
Definition main.cpp:371
double d_contactAreaRadiusIdeal
Ideal contact area radius from Hertz theory.
Definition main.cpp:365
double d_maxStress
Maximum stress.
Definition main.cpp:353
double d_maxDist
Maximum vertical distance of top particle in initial configuration.
Definition main.cpp:350
double d_contactAreaRadius
Contact area radius.
Definition main.cpp:347
double d_penDist
Penetration distance of top particle into bottom particle.
Definition main.cpp:344
double d_maxStressLocRef
Maximum stress location in reference configuration.
Definition main.cpp:356
void twoParticleTestMaxShearStress()
Computes maximum shear stress and its location in particle.
Definition main.cpp:281

References d_contactAreaRadius, d_contactAreaRadiusIdeal, d_maxDist, d_maxStress, d_maxStressIdeal, d_maxStressLocRef, d_maxStressLocRefIdeal, model::ModelData::d_n, model::ModelData::d_outputDeck_p, d_penDist, model::ModelData::d_ppFile, model::ModelData::d_time, twoParticleTestMaxShearStress(), and twoParticleTestPenetrationDist().

Referenced by integrate().

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

◆ twoParticleTestMaxShearStress()

void twoparticle_demo::Model::twoParticleTestMaxShearStress ( )
inline

Computes maximum shear stress and its location in particle.

Definition at line 281 of file main.cpp.

281 {
282
283 // compute maximum shear stress and where it occurs
284 double max_stress_t = 0.;
285 auto max_stress_loc_cur_t = util::Point();
286 auto max_stress_loc_ref_t = util::Point();
287
288 // if particle mat data is not computed, compute them
289 if (d_particlesMatDataList.empty()) {
290 for (auto &p: d_particlesListTypeAll) {
291 d_particlesMatDataList.push_back(p->getMaterial()->computeMaterialProperties(
292 p->getMeshP()->getDimension()));
293 }
294 }
295
296 // compute stress and strain
297 for (auto &p: d_particlesListTypeAll) {
298
299 const auto particle_mesh_p = p->getMeshP();
300
301 fe::getCurrentQuadPoints(particle_mesh_p.get(), d_xRef, d_u, d_xQuadCur,
302 p->d_globStart,
303 p->d_globQuadStart,
304 d_modelDeck_p->d_quadOrder);
305
306 auto p_z_id = p->d_zoneId;
307 auto isPlaneStrain = d_pDeck_p->d_particleZones[p_z_id].d_matDeck.d_isPlaneStrain;
308 fe::getStrainStress(particle_mesh_p.get(), d_xRef, d_u,
309 isPlaneStrain,
311 p->d_globStart,
312 p->d_globQuadStart,
313 d_particlesMatDataList[p->getId()].d_nu,
314 d_particlesMatDataList[p->getId()].d_lambda,
315 d_particlesMatDataList[p->getId()].d_mu,
316 true,
317 d_modelDeck_p->d_quadOrder);
318
319 double p_max_stress = 0.;
320 auto p_max_stress_loc_cur = util::Point();
321 auto p_max_stress_loc_ref = util::Point();
322 fe::getMaxShearStressAndLoc(p->getMeshP().get(), d_xRef, d_u, d_stress,
323 p_max_stress,
324 p_max_stress_loc_ref,
325 p_max_stress_loc_cur,
326 p->d_globStart, p->d_globQuadStart, d_modelDeck_p->d_quadOrder);
327
328 if (util::isGreater(p_max_stress, max_stress_t)) {
329 max_stress_t = p_max_stress;
330 auto p_center_node_id = p->d_globStart + p->d_rp_p->getCenterNodeId();
331 max_stress_loc_ref_t = p_max_stress_loc_ref - d_xRef[p_center_node_id];
332 max_stress_loc_cur_t = p_max_stress_loc_cur - d_x[p_center_node_id];
333 }
334 }
335
336 d_maxStress = max_stress_t;
337 d_maxStressLocRef = max_stress_loc_ref_t.length();
338 d_maxStressLocCur = max_stress_loc_cur_t.length();
339 }
std::vector< util::Point > d_xRef
reference positions of the nodes
Definition modelData.h:630
std::vector< util::Point > d_u
Displacement of the nodes.
Definition modelData.h:636
std::vector< util::Point > d_x
Current positions of the nodes.
Definition modelData.h:633
std::vector< inp::MatData > d_particlesMatDataList
List of particle material data. Only populated if needed for calculation of stress or other quantitie...
Definition modelData.h:604
double d_maxStressLocCur
Maximum stress location in current configuration.
Definition main.cpp:359
void getMaxShearStressAndLoc(const fe::Mesh *mesh_p, const std::vector< util::Point > &xRef, const std::vector< util::Point > &u, const std::vector< util::SymMatrix3 > &stress, double &maxShearStress, util::Point &maxShearStressLocRef, util::Point &maxShearStressLocCur, size_t iNodeStart=0, size_t iStrainStart=0, size_t quadOrder=1)
Get location where maximum of specified component of stress occurs in this particle.
Definition meshUtil.cpp:429
void getStrainStress(const fe::Mesh *mesh_p, const std::vector< util::Point > &xRef, const std::vector< util::Point > &u, bool isPlaneStrain, std::vector< util::SymMatrix3 > &strain, std::vector< util::SymMatrix3 > &stress, size_t iNodeStart=0, size_t iStrainStart=0, double nu=0., double lambda=0., double mu=0., bool computeStress=false, size_t quadOrder=1)
Strain and stress at quadrature points in the mesh.
Definition meshUtil.cpp:280
void getCurrentQuadPoints(const fe::Mesh *mesh_p, const std::vector< util::Point > &xRef, const std::vector< util::Point > &u, std::vector< util::Point > &xQuadCur, size_t iNodeStart=0, size_t iQuadStart=0, size_t quadOrder=1)
Get current location of quadrature points of elements in the mesh. This function expects mesh has ele...
Definition meshUtil.cpp:176
bool isGreater(const double &a, const double &b)
Returns true if a > b.
Definition function.cpp:15
A structure to represent 3d vectors.
Definition point.h:30

References d_maxStress, d_maxStressLocCur, d_maxStressLocRef, model::ModelData::d_modelDeck_p, model::ModelData::d_particlesListTypeAll, model::ModelData::d_particlesMatDataList, model::ModelData::d_pDeck_p, model::ModelData::d_strain, model::ModelData::d_stress, model::ModelData::d_u, model::ModelData::d_x, model::ModelData::d_xQuadCur, model::ModelData::d_xRef, fe::getCurrentQuadPoints(), fe::getMaxShearStressAndLoc(), fe::getStrainStress(), and util::isGreater().

Referenced by twoParticleTest().

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

◆ twoParticleTestPenetrationDist()

void twoparticle_demo::Model::twoParticleTestPenetrationDist ( )
inline

Computes penetration distance of top particle into bottom particle.

Definition at line 218 of file main.cpp.

218 {
219
220 // get alias for particles
221 const auto &p0 = this->d_particlesListTypeAll[0];
222 const auto &p1 = this->d_particlesListTypeAll[1];
223
224 // get penetration distance
225 const auto &xc0 = p0->getXCenter();
226 const auto &xc1 = p1->getXCenter();
227 const double &r = p0->d_geom_p->boundingRadius();
228
229 const auto &contact = d_cDeck_p->getContact(p0->d_zoneId, p1->d_zoneId);
230 double r_e = r + contact.d_contactR;
231
232 d_penDist = xc1.dist(xc0) - r_e - r;
233 if (util::isLess(d_penDist, 0.))
235 std::sqrt(std::pow(r_e, 2.) - std::pow(r_e + d_penDist, 2.));
236 else if (util::isGreater(d_penDist, 0.)) {
237 d_penDist = 0.;
239 }
240
241 // get max distance of second particle (i.e. the y-coord of center + radius)
242 d_maxDist = xc1.d_y + p1->d_geom_p->boundingRadius();
243
244 // compute maximum y coordinate of particle 2
245 double max_y_loc = p1->getXLocal(0).d_y;
246 for (size_t i = 0; i < p1->getNumNodes(); i++)
247 if (util::isLess(max_y_loc, p1->getXLocal(i).d_y))
248 max_y_loc = p1->getXLocal(i).d_y;
249
250 if (util::isLess(d_maxY, max_y_loc))
251 d_maxY = max_y_loc;
252
253 log(fmt::format("max y: {} \n", d_maxY), 2, d_n % d_infoN == 0, 3);
254
255 // compute ideal values
256 static int contact_pp_ideal = -1;
257 if (contact_pp_ideal == -1) {
258 double mass = p1->getDensity() * M_PI * std::pow(r, 2.);
259
260 const auto &mat_data =
261 p1->getMaterial()->computeMaterialProperties(d_modelDeck_p->d_dim);
262
263 d_contactAreaRadiusIdeal = 3. * mass * std::abs(d_pDeck_p->d_gravity[1]) *
264 2. * r * (1. - std::pow(mat_data.d_nu, 2.)) /
265 (4. * mat_data.d_E);
267
269
271 0.93 * mass * std::abs(d_pDeck_p->d_gravity[1]) /
273
274 contact_pp_ideal = 0;
275 }
276 }
std::shared_ptr< inp::ContactDeck > d_cDeck_p
Contact deck.
Definition modelData.h:564
double d_maxY
Current maximum vertical distance of top particle.
Definition main.cpp:362
bool isLess(const double &a, const double &b)
Returns true if a < b.
Definition function.cpp:20

References model::ModelData::d_cDeck_p, d_contactAreaRadius, d_contactAreaRadiusIdeal, model::ModelData::d_infoN, d_maxDist, d_maxStressIdeal, d_maxStressLocRefIdeal, d_maxY, model::ModelData::d_modelDeck_p, model::ModelData::d_n, model::ModelData::d_particlesListTypeAll, model::ModelData::d_pDeck_p, d_penDist, util::isGreater(), util::isLess(), and model::DEMModel::log().

Referenced by twoParticleTest().

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

Field Documentation

◆ d_contactAreaRadius

double twoparticle_demo::Model::d_contactAreaRadius = 0.

Contact area radius.

Definition at line 347 of file main.cpp.

Referenced by twoParticleTest(), and twoParticleTestPenetrationDist().

◆ d_contactAreaRadiusIdeal

double twoparticle_demo::Model::d_contactAreaRadiusIdeal = 0.

Ideal contact area radius from Hertz theory.

Definition at line 365 of file main.cpp.

Referenced by twoParticleTest(), and twoParticleTestPenetrationDist().

◆ d_maxDist

double twoparticle_demo::Model::d_maxDist = 0.

Maximum vertical distance of top particle in initial configuration.

Definition at line 350 of file main.cpp.

Referenced by twoParticleTest(), and twoParticleTestPenetrationDist().

◆ d_maxStress

double twoparticle_demo::Model::d_maxStress = 0.

Maximum stress.

Definition at line 353 of file main.cpp.

Referenced by twoParticleTest(), and twoParticleTestMaxShearStress().

◆ d_maxStressIdeal

double twoparticle_demo::Model::d_maxStressIdeal = 0.

Ideal maximum stress.

Definition at line 368 of file main.cpp.

Referenced by twoParticleTest(), and twoParticleTestPenetrationDist().

◆ d_maxStressLocCur

double twoparticle_demo::Model::d_maxStressLocCur = 0.

Maximum stress location in current configuration.

Definition at line 359 of file main.cpp.

Referenced by twoParticleTestMaxShearStress().

◆ d_maxStressLocRef

double twoparticle_demo::Model::d_maxStressLocRef = 0.

Maximum stress location in reference configuration.

Definition at line 356 of file main.cpp.

Referenced by twoParticleTest(), and twoParticleTestMaxShearStress().

◆ d_maxStressLocRefIdeal

double twoparticle_demo::Model::d_maxStressLocRefIdeal = 0.

Ideal maximum stress location location in reference configuration.

Definition at line 371 of file main.cpp.

Referenced by twoParticleTest(), and twoParticleTestPenetrationDist().

◆ d_maxY

double twoparticle_demo::Model::d_maxY = 0.

Current maximum vertical distance of top particle.

Definition at line 362 of file main.cpp.

Referenced by twoParticleTestPenetrationDist().

◆ d_penDist

double twoparticle_demo::Model::d_penDist = 0.

Penetration distance of top particle into bottom particle.

Definition at line 344 of file main.cpp.

Referenced by twoParticleTest(), and twoParticleTestPenetrationDist().


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