NetDEM v1.0
Loading...
Searching...
No Matches
netdem::DeformableParticle Class Reference

A class representing a deformable particle simulated using the Finite Element Method (FEM). More...

#include <deformable_particle.hpp>

Inheritance diagram for netdem::DeformableParticle:
netdem::Particle

Public Member Functions

 DeformableParticle ()
 Constructs a new DeformableParticle object.
 
ParticleClone () 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 STLModelGetSTLModelInternal ()
 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.
 
NeighPofPLinkToParticle (Particle *const q)
 Create a new neighbor tuple between this particle and the given particle q, and return the newly created tuple.
 
NeighWofPLinkToWall (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

TriMeshtrimesh {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.
 
Shapeshape {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.
 
NeighPofPBuildContactRefPP (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.
 
NeighWofPBuildContactRefPW (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< NeighPofPlinked_particle_list
 List of linked particles used for narrow-phase contact detection with particles.
 
VecXT< NeighWofPlinked_wall_list
 List of linked walls used for narrow-phase contact detection with walls.
 
VecXT< NeighPofPcontact_pp_ref_table
 Lookup table used to reconstruct reference of contact history with particles.
 
VecXT< NeighWofPcontact_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.
 

Detailed Description

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.

Examples
00_hertz_contact.cpp, and 81_golf_ball_impact.cpp.

Constructor & Destructor Documentation

◆ DeformableParticle()

netdem::DeformableParticle::DeformableParticle ( )

Constructs a new DeformableParticle object.

◆ ~DeformableParticle()

netdem::DeformableParticle::~DeformableParticle ( )
override

Destroys the DeformableParticle object and frees any memory used by it.

Member Function Documentation

◆ AddForce()

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.

Parameters
node_idThe ID of the node to add the force to.
fThe force vector to add to the node.
Examples
00_hertz_contact.cpp.

◆ ApplyContactForce() [1/2]

void netdem::DeformableParticle::ApplyContactForce ( ContactPP const * cnt)
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.

Parameters
cntA pointer to the ContactPP object representing the contact.

Reimplemented from netdem::Particle.

Examples
81_golf_ball_impact.cpp.

◆ ApplyContactForce() [2/2]

void netdem::DeformableParticle::ApplyContactForce ( ContactPW const * cnt)
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.

Parameters
cntA pointer to the ContactPW object representing the contact.

Reimplemented from netdem::Particle.

◆ ClearForce()

void netdem::DeformableParticle::ClearForce ( )
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.

Examples
00_hertz_contact.cpp, and 81_golf_ball_impact.cpp.

◆ Clone()

Particle * netdem::DeformableParticle::Clone ( ) const
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.

Returns
A pointer to the new DeformableParticle object.

Reimplemented from netdem::Particle.

◆ GetVelocity()

Vec3d netdem::DeformableParticle::GetVelocity ( Vec3d const & pos)
overridevirtual

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.

Parameters
posThe position vector to get the velocity at.
Returns
The velocity vector at the specified position.

Reimplemented from netdem::Particle.

◆ InitFEMMesh()

void netdem::DeformableParticle::InitFEMMesh ( )

Initialized the mesh for FEM analysis.

◆ SaveAsVTK()

void netdem::DeformableParticle::SaveAsVTK ( std::string const & filename)
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.

Parameters
filenameThe name of the file to save the data in.

Reimplemented from netdem::Particle.

Examples
00_hertz_contact.cpp, and 81_golf_ball_impact.cpp.

◆ SaveSurfaceAsVTK()

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.

Parameters
filenameThe name of the file to save the data in.
Examples
81_golf_ball_impact.cpp.

◆ SetDensity()

void netdem::DeformableParticle::SetDensity ( double dens)
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.

Parameters
densThe density value to set.

Reimplemented from netdem::Particle.

Examples
81_golf_ball_impact.cpp.

◆ SetPosition()

void netdem::DeformableParticle::SetPosition ( double x,
double y,
double z )
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.

Parameters
xThe X coordinate of the new position.
yThe Y coordinate of the new position.
zThe Z coordinate of the new position.

Reimplemented from netdem::Particle.

Examples
81_golf_ball_impact.cpp.

◆ SetQuaternion()

void netdem::DeformableParticle::SetQuaternion ( double q_0,
double q_1,
double q_2,
double q_3 )
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.

Parameters
q_0The scalar component of the quaternion.
q_1The X-component of the quaternion.
q_2The Y-component of the quaternion.
q_3The Z-component of the quaternion.

Reimplemented from netdem::Particle.

◆ SetRodrigues()

void netdem::DeformableParticle::SetRodrigues ( double angle,
double axis_x,
double axis_y,
double axis_z )
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.

Parameters
angleThe angle of rotation in radians.
axis_xThe X component of the rotation axis.
axis_yThe Y component of the rotation axis.
axis_zThe Z component of the rotation axis.

Reimplemented from netdem::Particle.

◆ SetShape()

void netdem::DeformableParticle::SetShape ( Shape * s)
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.

Parameters
sA pointer to the Shape object to use for setting the particle's shape.

Reimplemented from netdem::Particle.

Examples
00_hertz_contact.cpp, and 81_golf_ball_impact.cpp.

◆ SetVelocity()

void netdem::DeformableParticle::SetVelocity ( double v_x,
double v_y,
double v_z )
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.

Parameters
v_xThe X component of the new velocity vector.
v_yThe Y component of the new velocity vector.
v_zThe Z component of the new velocity vector.

Reimplemented from netdem::Particle.

Examples
81_golf_ball_impact.cpp.

◆ UpdateBound()

void netdem::DeformableParticle::UpdateBound ( )
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.

◆ UpdateBoundFast()

void netdem::DeformableParticle::UpdateBoundFast ( )
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.

◆ UpdateMotion()

void netdem::DeformableParticle::UpdateMotion ( double dt)
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.

Parameters
dtThe time step to use for the update.

Reimplemented from netdem::Particle.

Examples
00_hertz_contact.cpp, and 81_golf_ball_impact.cpp.

◆ UpdateShape()

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.

Member Data Documentation

◆ fem_simulator

FEMSimulator netdem::DeformableParticle::fem_simulator

The FEM simulator object used to simulate the particle.

Examples
00_hertz_contact.cpp, and 81_golf_ball_impact.cpp.

◆ mesh_res

int netdem::DeformableParticle::mesh_res {20}

The resolution of the tetrahedral mesh.

Examples
81_golf_ball_impact.cpp.

◆ tetmesh

TetMesh netdem::DeformableParticle::tetmesh

The tetrahedral mesh used for the simulation.

◆ trimesh

TriMesh* netdem::DeformableParticle::trimesh {nullptr}

Pointer to the triangular mesh shape of the particle.


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