NetDEM v1.0
|
A class representing a deformable particle simulated using the Finite Element Method (FEM). More...
#include <deformable_particle.hpp>
Public Member Functions | |
DeformableParticle () | |
Constructs a new DeformableParticle object. | |
Particle * | Clone () const override |
Creates a new instance of this object. | |
void | SetShape (Shape *s) override |
Sets the shape of the particle. | |
void | InitFEMMesh () |
Initialized the mesh for FEM analysis. | |
void | SetDensity (double dens) override |
Sets the density of the particle. | |
void | SetPosition (double x, double y, double z) override |
Sets the position of the particle. | |
void | SetRodrigues (double angle, double axis_x, double axis_y, double axis_z) override |
Sets the angle and axis of rotation for the particle. | |
void | SetQuaternion (double q_0, double q_1, double q_2, double q_3) override |
Sets the orientation of the particle using a quaternion. | |
void | SetVelocity (double v_x, double v_y, double v_z) override |
Sets the velocity of the particle. | |
Vec3d | GetVelocity (Vec3d const &pos) override |
Gets the velocity of the particle at a given position. | |
void | AddForce (int node_id, Vec3d const &f) |
Adds a force to a node on the particle's mesh. | |
void | ClearForce () override |
Clears all forces on the particle's mesh. | |
void | ApplyContactForce (ContactPP const *cnt) override |
Applies a contact force to the particle. | |
void | ApplyContactForce (ContactPW const *cnt) override |
Applies a contact force between a particle and a wall. | |
void | UpdateMotion (double dt) override |
Updates the motion of the particle. | |
void | UpdateShape () |
Updates the shape of the particle. | |
void | UpdateBoundFast () override |
Updates the bounding box of the particle. | |
void | UpdateBound () override |
Updates the bounding box of the particle. | |
void | SaveSurfaceAsVTK (std::string const &filename) |
Saves the surface of the particle as a VTK file. | |
void | SaveAsVTK (std::string const &filename) override |
Saves the particle as a VTK file. | |
~DeformableParticle () override | |
Destroys the DeformableParticle object and frees any memory used by it. | |
Public Member Functions inherited from netdem::Particle | |
Particle () | |
Default constructor for the Particle class. | |
Particle (Shape *const shape) | |
Constructor for the Particle class which specifies the shape of the particle. | |
virtual void | Init () |
Initializes the particle by setting default values for all properties. | |
virtual double | GetDensity () const |
Gets the density of the particle. | |
virtual void | SetMargin (double m) |
Sets the margin of the particle. | |
virtual double | GetMargin () const |
Gets the margin of the particle. | |
virtual void | SetForce (double fx, double fy, double fz) |
Sets the force acting on the particle. | |
virtual void | SetMoment (double mx, double my, double mz) |
Sets the moment acting on the particle. | |
virtual void | SetSpin (double spin_x, double spin_y, double spin_z) |
Sets the angular velocity (spin) of the particle. | |
virtual void | SetDynamicProperty (std::string const &key, double value) |
Set the value of a dynamic property identified by the given key. | |
virtual double | GetDynamicProperty (std::string const &key) |
Get the value of a dynamic property identified by the given key. | |
virtual void | AddForce (const Vec3d &force) |
Add a force to the particle. | |
virtual void | AddMoment (const Vec3d &moment) |
Add a moment (torque) to the particle. | |
virtual void | AddForceAtomic (const Vec3d &f) |
Add a force to the particle atomically. | |
virtual void | AddMomentAtomic (const Vec3d &m) |
Add a moment (torque) to the particle atomically. | |
virtual void | ClearMoment () |
Clear all moments applied to the particle. | |
virtual void | UpdateContactForce () |
Update the contact forces applied to the particle. | |
void | ClearLinkedCells () |
Clear the linked cells of the particle. | |
void | ClearLinkedDomains () |
Clear the linked domains of the particle. | |
void | ClearLinkedNeighs () |
Clear the linked neighbors of the particle. | |
void | BuildContactRefTable () |
Build a look-up table for contacts between particles. | |
void | ClearContactRefTable () |
Clear the look-up table for contacts between particles. | |
void | UpdateLinkedDomains (DomainManager *const dm) |
Update the linked domains of the particle based on the given domain manager. | |
void | UpdateLinkedCells (CellManager *const cm) |
Update the linked cells of the particle based on the given cell manager. | |
void | UpdateLinkedNeighs (Domain *const domain) |
Update the linked neighbors of the particle based on the given domain. | |
VecXT< ContactPP * > | GetContactPPs () |
Get a vector of pointers to all contact points between particles. | |
VecXT< ContactPW * > | GetContactPWs () |
Get a vector of pointers to all contact points between particles and walls. | |
VecXT< std::pair< Domain *, int > > const & | GetLinkedDomains () |
Gets a vector of pointers to the domains that may be potentially overlapped this wall. | |
VecXT< std::pair< Cell *, int > > const & | GetLinkedCells () |
Gets a vector of pointers to the cells that may be potentially overlapped this wall. | |
VecXT< NeighPofP > const & | GetLinkedParticles () |
Gets a vector of pointers to the particles that may be potentially overlapped this wall. | |
VecXT< NeighWofP > const & | GetLinkedWalls () |
Gets a vector of pointers to the walls that may be potentially overlapped this wall. | |
NeighPofP *const | GetLinkedParticle (int lookup_id) |
Gets the neigh obj by look-up id. | |
NeighWofP *const | GetLinkedWall (int lookup_id) |
Gets the neigh obj by look-up id. | |
virtual void | UpdateSTLModel () |
Update the geometry of the particle's STL model. | |
virtual STLModel | GetSTLModel (int num_nodes=200) |
Get a copy of the particle's STL model as an object of type STLModel . | |
virtual STLModel * | GetSTLModelInternal () |
Get a copy of the particle's STL model as an object of type STLModel . | |
virtual void | Print () const |
Print information about the particle to the console. | |
virtual | ~Particle () |
Destroy the particle object and free any resources it might be holding. | |
NeighPofP * | LinkToParticle (Particle *const q) |
Create a new neighbor tuple between this particle and the given particle q , and return the newly created tuple. | |
NeighWofP * | LinkToWall (Wall *const w) |
Create a new neighbor tuple between this particle and the given wall w , and return the newly created tuple. | |
int | LinkToCell (Cell *const cell) |
Create a link between this particle and the given cell and return the look up id. | |
int | LinkToDomain (Domain *const domain) |
Create a link between this particle and the given domain and return the look up id. | |
int | FindLinkedParticle (Particle *const q) |
Find the index of the neighbor tuple belonging to this particle that is linked to the given particle q . | |
int | FindLinkedWall (Wall *const w) |
Find the index of the neighbor tuple belonging to this particle that is linked to the given wall w . | |
Public Attributes | |
TriMesh * | trimesh {nullptr} |
Pointer to the triangular mesh shape of the particle. | |
TetMesh | tetmesh |
The tetrahedral mesh used for the simulation. | |
FEMSimulator | fem_simulator |
The FEM simulator object used to simulate the particle. | |
int | mesh_res {20} |
The resolution of the tetrahedral mesh. | |
Public Attributes inherited from netdem::Particle | |
int | id {0} |
The ID of the particle. | |
Shape * | shape {nullptr} |
The shape of the particle. | |
Vec3d | bound_min {0, 0, 0} |
The minimum bounds of the particle's shape. | |
Vec3d | bound_max {0, 0, 0} |
The maximum bounds of the particle's shape. | |
double | margin {0} |
The margin of the particle's shape. | |
Vec3d | bound_disp {0, 0, 0} |
The displacement of the particle's bounds for the linked list. | |
int | material_type {0} |
The material type of the particle. | |
double | mass {0.0} |
The mass of the particle. | |
Vec3d | moi_principal {0, 0, 0} |
The principal moment of inertia of the particle. | |
double | damp_viscous {0} |
The viscous damping coefficient of the particle. | |
double | damp_numerical {0} |
The numerical damping coefficient of the particle. | |
Vec3d | pos {0, 0, 0} |
The position of the particle. | |
Vec4d | quaternion {1, 0, 0, 0} |
The quaternion of the particle. | |
Vec3d | vel {0, 0, 0} |
The velocity of the particle. | |
Vec3d | spin {0, 0, 0} |
The spin of the particle. | |
Vec3d | vel_m0p5 {0, 0, 0} |
The square root velocity of the particle for half-step integration. | |
Vec3d | spin_principal {0, 0, 0} |
The principal spin axis of the particle. | |
Vec3d | force {0, 0, 0} |
The force acting on the particle. | |
Vec3d | moment {0, 0, 0} |
The moment acting on the particle. | |
MiniMap< std::string, double > | dynamic_properties |
Map of dynamic properties of the particle. | |
bool | enable_bound_aabb {false} |
Flag indicating whether bounding sphere should be used to approximate axis-aligned bounding box (AABB). | |
bool | need_update_linked_list {true} |
Flag indicating whether linked-list algorithm should be used for broad-phase contact detection. | |
bool | need_update_stl_model {false} |
Flag indicating whether STl model intersection-based contact detection and resolution is needed. | |
Additional Inherited Members | |
Protected Member Functions inherited from netdem::Particle | |
void | RemoveLinkedCell (int lookup_id) |
Reomve a linked cell by look-up id. | |
void | RemoveLinkedDomain (int lookup_id) |
Reomve a linked domain by look-up id. | |
void | RemoveLinkedParticle (int lookup_id) |
Reomve a linked neighbor by look-up id. | |
void | RemoveLinkedWall (int lookup_id) |
Reomve a linked neighbor by look-up id. | |
void | RemoveContactRefPP (int lookup_id) |
Reomve a p-p contact by look-up id. | |
void | RemoveContactRefPW (int lookup_id) |
Reomve a p-w contact by look-up id. | |
NeighPofP *const | GetLinkedContactRefPP (int lookup_id) |
Gets the neigh obj by look-up id. | |
NeighWofP *const | GetLinkedContactRefPW (int lookup_id) |
Gets the neigh obj by look-up id. | |
NeighPofP * | BuildContactRefPP (Particle *const q, ContactPP *const cnt) |
Create a new contact lookup table entry for the given pair of particles q and cnt , and return the newly created entry. | |
NeighWofP * | BuildContactRefPW (Wall *const w, ContactPW *const cnt) |
Create a new contact lookup table entry for the given wall w and contact point cnt , and return the newly created entry. | |
int | FindContactRefPP (Particle *const q) |
Find the index of the contact lookup table entry belonging to this particle that references the given particle q . | |
int | FindContactRefPW (Wall *const w) |
Find the index of the contact lookup table entry belonging to this particle that references the given wall w . | |
Protected Attributes inherited from netdem::Particle | |
double | density {2650} |
The density of the particle. Please use SetDensity to change its value. | |
VecXT< std::pair< Cell *, int > > | linked_cell_list |
List of linked cells used for broad-phase contact detection. | |
VecXT< NeighPofP > | linked_particle_list |
List of linked particles used for narrow-phase contact detection with particles. | |
VecXT< NeighWofP > | linked_wall_list |
List of linked walls used for narrow-phase contact detection with walls. | |
VecXT< NeighPofP > | contact_pp_ref_table |
Lookup table used to reconstruct reference of contact history with particles. | |
VecXT< NeighWofP > | contact_pw_ref_table |
Lookup table used to reconstruct reference of contact history with walls. | |
bool | is_on_edge {false} |
Flag indicating whether particle is on domain edge. | |
bool | need_send_out {false} |
Flag indicating whether data needs to be sent out to linked domains. | |
VecXT< std::pair< Domain *, int > > | linked_domain_list |
List of linked domains that overlap with the particle. | |
STLModel | stl_model |
STLModel object used for intersection-based contact detection and resolution. | |
A class representing a deformable particle simulated using the Finite Element Method (FEM).
This class inherits from the Particle
class and includes additional functionality for simulating deformable particles using FEM. It contains a triangular mesh shape and a tetrahedral mesh used for the simulation, as well as functions to update the motion and shape of the particle, apply contact forces, and save data in VTK format.
netdem::DeformableParticle::DeformableParticle | ( | ) |
Constructs a new DeformableParticle
object.
|
override |
Destroys the DeformableParticle
object and frees any memory used by it.
void netdem::DeformableParticle::AddForce | ( | int | node_id, |
Vec3d const & | f ) |
Adds a force to a node on the particle's mesh.
This function adds a force to a specific node on the particle's tetrahedral mesh.
node_id | The ID of the node to add the force to. |
f | The force vector to add to the node. |
|
overridevirtual |
Applies a contact force to the particle.
This function applies a contact force between two particles using a point-particle contact model. It overrides the ApplyContactForce
method from the Particle
class.
cnt | A pointer to the ContactPP object representing the contact. |
Reimplemented from netdem::Particle.
|
overridevirtual |
Applies a contact force between a particle and a wall.
This function applies a contact force between a particle and a wall using a point-wall contact model. It overrides the ApplyContactForce
method from the Particle
class.
cnt | A pointer to the ContactPW object representing the contact. |
Reimplemented from netdem::Particle.
|
overridevirtual |
Clears all forces on the particle's mesh.
This function clears all forces applied to the nodes on this particle's tetrahedral mesh. It overrides the ClearForce
method from the Particle
class.
Reimplemented from netdem::Particle.
|
overridevirtual |
Creates a new instance of this object.
This function returns a new DeformableParticle
object that is a copy of the current object. It overrides the Clone
method from the Particle
class.
DeformableParticle
object. Reimplemented from netdem::Particle.
Gets the velocity of the particle at a given position.
This function returns the velocity of the particle at a given position in space. It overrides the GetVelocity
method from the Particle
class.
pos | The position vector to get the velocity at. |
Reimplemented from netdem::Particle.
void netdem::DeformableParticle::InitFEMMesh | ( | ) |
Initialized the mesh for FEM analysis.
|
overridevirtual |
Saves the particle as a VTK file.
This function saves the particle, including its tetrahedral mesh, to a VTK file. It overrides the SaveAsVTK
method from the Particle
class.
filename | The name of the file to save the data in. |
Reimplemented from netdem::Particle.
void netdem::DeformableParticle::SaveSurfaceAsVTK | ( | std::string const & | filename | ) |
Saves the surface of the particle as a VTK file.
This function saves the surface of the particle's triangular mesh shape to a VTK file.
filename | The name of the file to save the data in. |
|
overridevirtual |
Sets the density of the particle.
This function sets the density of the particle and updates its mass accordingly. It overrides the SetDensity
method from the Particle
class.
dens | The density value to set. |
Reimplemented from netdem::Particle.
|
overridevirtual |
Sets the position of the particle.
This function sets the position of the particle to a given point in 3D space. It overrides the SetPosition
method from the Particle
class.
x | The X coordinate of the new position. |
y | The Y coordinate of the new position. |
z | The Z coordinate of the new position. |
Reimplemented from netdem::Particle.
|
overridevirtual |
Sets the orientation of the particle using a quaternion.
This function sets the orientation of the particle using a quaternion representation. It overrides the SetQuaternion
method from the Particle
class.
q_0 | The scalar component of the quaternion. |
q_1 | The X-component of the quaternion. |
q_2 | The Y-component of the quaternion. |
q_3 | The Z-component of the quaternion. |
Reimplemented from netdem::Particle.
|
overridevirtual |
Sets the angle and axis of rotation for the particle.
This function sets the angle and axis of rotation for the particle using Rodrigues' formula. It overrides the SetRodrigues
method from the Particle
class.
angle | The angle of rotation in radians. |
axis_x | The X component of the rotation axis. |
axis_y | The Y component of the rotation axis. |
axis_z | The Z component of the rotation axis. |
Reimplemented from netdem::Particle.
|
overridevirtual |
Sets the shape of the particle.
This function sets the shape of the particle to a given Shape
object by generating a tetrahedral mesh from the object's triangular mesh. It overrides the SetShape
method from the Particle
class.
s | A pointer to the Shape object to use for setting the particle's shape. |
Reimplemented from netdem::Particle.
|
overridevirtual |
Sets the velocity of the particle.
This function sets the velocity of the particle to a given vector in 3D space. It overrides the SetVelocity
method from the Particle
class.
v_x | The X component of the new velocity vector. |
v_y | The Y component of the new velocity vector. |
v_z | The Z component of the new velocity vector. |
Reimplemented from netdem::Particle.
|
overridevirtual |
Updates the bounding box of the particle.
This function updates the bounding box of the particle's tetrahedral mesh based on its current configuration. It overrides the UpdateBound
method from the Particle
class.
Reimplemented from netdem::Particle.
|
overridevirtual |
Updates the bounding box of the particle.
This function updates the bounding box of the particle's tetrahedral mesh based on its current configuration. It overrides the UpdateBound
method from the Particle
class.
Reimplemented from netdem::Particle.
|
overridevirtual |
Updates the motion of the particle.
This function updates the motion of the particle using the FEM simulator object. It overrides the UpdateMotion
method from the Particle
class.
dt | The time step to use for the update. |
Reimplemented from netdem::Particle.
void netdem::DeformableParticle::UpdateShape | ( | ) |
Updates the shape of the particle.
This function updates the shape of the particle's tetrahedral mesh based on the current state of the triangular mesh shape. It is called automatically by UpdateMotion
.
FEMSimulator netdem::DeformableParticle::fem_simulator |
The FEM simulator object used to simulate the particle.
int netdem::DeformableParticle::mesh_res {20} |
The resolution of the tetrahedral mesh.
TetMesh netdem::DeformableParticle::tetmesh |
The tetrahedral mesh used for the simulation.
TriMesh* netdem::DeformableParticle::trimesh {nullptr} |
Pointer to the triangular mesh shape of the particle.