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

A Finite Element Method (FEM) simulator used for simulating the deformation of objects. More...

#include <fem_simulator.hpp>

Public Member Functions

 FEMSimulator ()
 Constructs a new FEMSimulator object.
 
void SetMesh (TetMesh const &tetmesh)
 Sets the tetrahedral mesh used in the simulation.
 
void Init ()
 Initializes the FEM simulator object for this object.
 
void SetBCNodalVelocity (int nid, double vx, double vy, double vz, bool use_prescribed_vx, bool use_prescribed_vy, bool use_prescribed_vz)
 Sets the prescribed velocity for a certain node on the boundary of the object.
 
void AddBCFacetForce (int bc_fid, double fx, double fy, double fz)
 Adds a force to a facet on the surface of the object.
 
void SetNodalVels (double v_x, double v_y, double v_z)
 Sets the nodal velocities for all nodes on the boundary of the object.
 
void ClearBoundaryCondition ()
 Clears all boundary conditions from the object.
 
void Solve (double dt)
 Solves for the motion and deformation of the object at each time step.
 
VecXT< Vec3dGetNodalPositions (VecXT< int > nids)
 Gets the positions of a set of nodes in the tetrahedral mesh.
 
VecXT< Vec3dGetNodalDisps (VecXT< int > nids)
 Gets the displacements of a set of nodes in the tetrahedral mesh.
 
VecXT< Vec3dGetNodalVels (VecXT< int > nids)
 Gets the velocities of a set of nodes in the tetrahedral mesh.
 
void SaveAsVTK (std::string const &file_name)
 Saves the object as a VTK file.
 

Public Attributes

double neo_k {6.94e5}
 The bulk modulus of the material being simulated.
 
double neo_mu {5.21e5}
 The shear modulus of the material being simulated.
 
double density {500.0}
 The density of the material being simulated.
 
double damp_coef {0.7}
 The damping coefficient used in the simulation.
 
Vec3d gravity_coef {0.0, 0.0, 0.0}
 The gravitational force acting on the object.
 
double timestep {1.0e-4}
 The time step used in the simulation.
 
VecXT< Vec3dnodes
 The nodal positions of the tetrahedral mesh.
 
VecXT< Vec4ielements
 The elements of the tetrahedral mesh.
 
VecXT< Vec3dnodes_ref
 The reference nodal positions of the tetrahedral mesh.
 
VecXT< Vec3ibound_facets
 The facets of the object that define its bounding surface.
 
VecXT< int > bound_nodes
 The IDs of the nodes on the bounding surface.
 
VecXT< double > elemental_vol
 The volume of each element in the tetrahedral mesh.
 
VecXT< VecNT< double, 6 > > elemental_stress
 The stress values of each element in the tetrahedral mesh.
 
VecXT< double > nodal_vols
 The volume of each node in the tetrahedral mesh.
 
VecXT< Vec3dnodal_vels
 The velocity of each node in the tetrahedral mesh.
 
VecXT< Vec3dbc_facet_forces
 The forces applied to each facet on the boundary of the object.
 
VecXT< VecNT< double, 6 > > bc_nodal_vels
 The prescribed velocities for each node on the boundary of the object.
 

Protected Member Functions

void Advance (double dt)
 Advances the object by one time step.
 
void InitInitialCondition ()
 Initializes the initial condition for the FEM simulator.
 
double GetElementVolume (Vec3d const &v0, Vec3d const &v1, Vec3d const &v2, Vec3d const &v3)
 Calculates the volume of a tetrahedral element.
 
Mat3d GetDeformationGradient (Vec3d const &v0_new, Vec3d const &v1_new, Vec3d const &v2_new, Vec3d const &v3_new, Vec3d const &v0_ref, Vec3d const &v1_ref, Vec3d const &v2_ref, Vec3d const &v3_ref)
 Calculates the deformation gradient of a tetrahedral element.
 
Mat3d GetCauchyStress (Mat3d const &def_grad)
 Calculates the Cauchy stress tensor for a given deformation gradient.
 
MatNd< 4, 3 > GetInternalForces (Mat3d const &cauchy_stress, Vec3d const &v0, Vec3d const &v1, Vec3d const &v2, Vec3d const &v3)
 Calculates the internal forces acting on each node of a tetrahedral element.
 

Protected Attributes

VecXT< Vec3dnodal_forces_int
 < The internal forces acting on each node.
 
VecXT< Vec3dnodal_forces_ext
 The average nodal velocities used in the simulation.
 
VecXT< Vec3dnodal_vels_ave
 

Detailed Description

A Finite Element Method (FEM) simulator used for simulating the deformation of objects.

This class contains all the necessary data and functions to simulate the motion and deformation of an object using FEM. It includes a tetrahedral mesh, elemental stress values, nodal velocities, and boundary conditions. Functions are provided to initialize the simulation, set boundary conditions, and solve for the motion and deformation of the object at each time step.

Constructor & Destructor Documentation

◆ FEMSimulator()

FEMSimulator::FEMSimulator ( )

Constructs a new FEMSimulator object.

Member Function Documentation

◆ AddBCFacetForce()

void FEMSimulator::AddBCFacetForce ( int bc_fid,
double fx,
double fy,
double fz )

Adds a force to a facet on the surface of the object.

This function adds a force to a specified facet on the surface of the object. The force is applied only at the nodes of the facet.

Parameters
bc_fidThe ID of the facet to add the force to.
fxThe X component of the force to apply.
fyThe Y component of the force to apply.
fzThe Z component of the force to apply.

◆ Advance()

void FEMSimulator::Advance ( double dt)
protected

Advances the object by one time step.

This function advances the object by one time step. It calculates the internal and external forces acting on each node, applies any prescribed boundary conditions, and then updates the positions and velocities of each node based on these forces using an explicit Euler method.

Parameters
dtThe time step to use for the simulation.

◆ ClearBoundaryCondition()

void FEMSimulator::ClearBoundaryCondition ( )

Clears all boundary conditions from the object.

This function clears all boundary conditions from the object by setting all values in bc_nodal_vels and bc_facet_forces to zero.

◆ GetCauchyStress()

Mat3d FEMSimulator::GetCauchyStress ( Mat3d const & def_grad)
protected

Calculates the Cauchy stress tensor for a given deformation gradient.

This function calculates the Cauchy stress tensor for a given deformation gradient using the neo-Hookean model of hyperelasticity.

Parameters
def_gradThe deformation gradient of an element in the mesh.
Returns
The Cauchy stress tensor as a Mat3d object.

◆ GetDeformationGradient()

Mat3d FEMSimulator::GetDeformationGradient ( Vec3d const & v0_new,
Vec3d const & v1_new,
Vec3d const & v2_new,
Vec3d const & v3_new,
Vec3d const & v0_ref,
Vec3d const & v1_ref,
Vec3d const & v2_ref,
Vec3d const & v3_ref )
protected

Calculates the deformation gradient of a tetrahedral element.

This function calculates the deformation gradient of a tetrahedral element specified by its four new vertices and their corresponding reference vertices.

Parameters
v0_newThe new position of the first vertex of the tetrahedron.
v1_newThe new position of the second vertex of the tetrahedron.
v2_newThe new position of the third vertex of the tetrahedron.
v3_newThe new position of the fourth vertex of the tetrahedron.
v0_refThe reference position of the first vertex of the tetrahedron.
v1_refThe reference position of the second vertex of the tetrahedron.
v2_refThe reference position of the third vertex of the tetrahedron.
v3_refThe reference position of the fourth vertex of the tetrahedron.
Returns
The deformation gradient of the tetrahedron as a Mat3d object.

◆ GetElementVolume()

double FEMSimulator::GetElementVolume ( Vec3d const & v0,
Vec3d const & v1,
Vec3d const & v2,
Vec3d const & v3 )
protected

Calculates the volume of a tetrahedral element.

This function calculates the volume of a tetrahedral element specified by its four vertices.

Parameters
v0The first vertex of the tetrahedron.
v1The second vertex of the tetrahedron.
v2The third vertex of the tetrahedron.
v3The fourth vertex of the tetrahedron.
Returns
The volume of the tetrahedron.

◆ GetInternalForces()

MatNd< 4, 3 > FEMSimulator::GetInternalForces ( Mat3d const & cauchy_stress,
Vec3d const & v0,
Vec3d const & v1,
Vec3d const & v2,
Vec3d const & v3 )
protected

Calculates the internal forces acting on each node of a tetrahedral element.

This function calculates the internal forces acting on each node of a tetrahedral element using the Cauchy stress tensor and the deformation gradient of the element.

Parameters
cauchy_stressThe Cauchy stress tensor of the element.
v0,v1,v2,v3The vertices of the tetrahedron.
Returns
The internal forces acting on each node as a MatNd<4, 3> object.

◆ GetNodalDisps()

VecXT< Vec3d > FEMSimulator::GetNodalDisps ( VecXT< int > nids)

Gets the displacements of a set of nodes in the tetrahedral mesh.

This function returns the displacements of a set of nodes in the tetrahedral mesh specified by their IDs. The displacements are calculated as the difference between the current and reference positions of each node, and are returned as a VecXT<Vec3d> object containing a vector of Vec3d objects representing the displacement of each node.

Parameters
nidsA vector of node IDs to get the displacements of.
Returns
A VecXT<Vec3d> object containing the displacements of the specified nodes.

◆ GetNodalPositions()

VecXT< Vec3d > FEMSimulator::GetNodalPositions ( VecXT< int > nids)

Gets the positions of a set of nodes in the tetrahedral mesh.

This function returns the positions of a set of nodes in the tetrahedral mesh specified by their IDs. The positions are returned as a VecXT<Vec3d> object containing a vector of Vec3d objects representing the position of each node.

Parameters
nidsA vector of node IDs to get the positions of.
Returns
A VecXT<Vec3d> object containing the positions of the specified nodes.

◆ GetNodalVels()

VecXT< Vec3d > FEMSimulator::GetNodalVels ( VecXT< int > nids)

Gets the velocities of a set of nodes in the tetrahedral mesh.

This function returns the velocities of a set of nodes in the tetrahedral mesh specified by their IDs. The velocities are returned as a VecXT<Vec3d> object containing a vector of Vec3d objects representing the velocity of each node.

Parameters
nidsA vector of node IDs to get the velocities of.
Returns
A VecXT<Vec3d> object containing the velocities of the specified nodes.

◆ Init()

void FEMSimulator::Init ( )

Initializes the FEM simulator object for this object.

This function initializes the FEM simulator object for this object by setting up the nodal forces and velocities, elemental volumes and stresses, and boundary conditions for the simulation.

◆ InitInitialCondition()

void FEMSimulator::InitInitialCondition ( )
protected

Initializes the initial condition for the FEM simulator.

This function initializes the initial condition for the FEM simulator by setting up the nodal volumes and velocities that will be used in the simulation.

◆ SaveAsVTK()

void FEMSimulator::SaveAsVTK ( std::string const & file_name)

Saves the object as a VTK file.

This function saves the object, including its tetrahedral mesh and nodal properties, to a VTK file.

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

◆ SetBCNodalVelocity()

void FEMSimulator::SetBCNodalVelocity ( int nid,
double vx,
double vy,
double vz,
bool use_prescribed_vx,
bool use_prescribed_vy,
bool use_prescribed_vz )

Sets the prescribed velocity for a certain node on the boundary of the object.

This function sets the prescribed velocity for a certain node on the boundary of the object, specifying the velocity components in each dimension and whether or not to use velocity as a prescribed value in that dimension.

Parameters
nidThe ID of the node to set the velocity for.
vxThe X component of the prescribed velocity.
vyThe Y component of the prescribed velocity.
vzThe Z component of the prescribed velocity.
use_prescribed_vxWhether or not to use the X-component of the velocity as a prescribed value.
use_prescribed_vyWhether or not to use the Y-component of the velocity as a prescribed value.
use_prescribed_vzWhether or not to use the Z-component of the velocity as a prescribed value.

◆ SetMesh()

void FEMSimulator::SetMesh ( TetMesh const & tetmesh)

Sets the tetrahedral mesh used in the simulation.

This function sets the tetrahedral mesh used in the simulation by copying its nodes and elements into the nodes and elements member variables of this object.

Parameters
tetmeshA reference to the TetMesh object representing the tetrahedral mesh.

◆ SetNodalVels()

void FEMSimulator::SetNodalVels ( double v_x,
double v_y,
double v_z )

Sets the nodal velocities for all nodes on the boundary of the object.

This function sets the nodal velocities for all nodes on the boundary of the object, specifying the velocity components in each dimension.

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

◆ Solve()

void FEMSimulator::Solve ( double dt)

Solves for the motion and deformation of the object at each time step.

This function solves for the motion and deformation of the object at each time step using FEM. It first calculates the internal and external forces acting on each node, applies any prescribed boundary conditions, and then updates the positions and velocities of each node based on these forces using an explicit Euler method.

Parameters
dtThe time step to use for the simulation.

Member Data Documentation

◆ bc_facet_forces

VecXT<Vec3d> netdem::FEMSimulator::bc_facet_forces

The forces applied to each facet on the boundary of the object.

◆ bc_nodal_vels

VecXT<VecNT<double, 6> > netdem::FEMSimulator::bc_nodal_vels

The prescribed velocities for each node on the boundary of the object.

◆ bound_facets

VecXT<Vec3i> netdem::FEMSimulator::bound_facets

The facets of the object that define its bounding surface.

◆ bound_nodes

VecXT<int> netdem::FEMSimulator::bound_nodes

The IDs of the nodes on the bounding surface.

◆ damp_coef

double netdem::FEMSimulator::damp_coef {0.7}

The damping coefficient used in the simulation.

Examples
81_golf_ball_impact.cpp.

◆ density

double netdem::FEMSimulator::density {500.0}

The density of the material being simulated.

◆ elemental_stress

VecXT<VecNT<double, 6> > netdem::FEMSimulator::elemental_stress

The stress values of each element in the tetrahedral mesh.

◆ elemental_vol

VecXT<double> netdem::FEMSimulator::elemental_vol

The volume of each element in the tetrahedral mesh.

◆ elements

VecXT<Vec4i> netdem::FEMSimulator::elements

The elements of the tetrahedral mesh.

◆ gravity_coef

Vec3d netdem::FEMSimulator::gravity_coef {0.0, 0.0, 0.0}

The gravitational force acting on the object.

Examples
00_hertz_contact.cpp.

◆ neo_k

double netdem::FEMSimulator::neo_k {6.94e5}

The bulk modulus of the material being simulated.

Examples
81_golf_ball_impact.cpp.

◆ neo_mu

double netdem::FEMSimulator::neo_mu {5.21e5}

The shear modulus of the material being simulated.

Examples
81_golf_ball_impact.cpp.

◆ nodal_forces_ext

VecXT<Vec3d> netdem::FEMSimulator::nodal_forces_ext
protected

The average nodal velocities used in the simulation.

◆ nodal_forces_int

VecXT<Vec3d> netdem::FEMSimulator::nodal_forces_int
protected

< The internal forces acting on each node.

The external forces acting on each node.

◆ nodal_vels

VecXT<Vec3d> netdem::FEMSimulator::nodal_vels

The velocity of each node in the tetrahedral mesh.

◆ nodal_vels_ave

VecXT<Vec3d> netdem::FEMSimulator::nodal_vels_ave
protected

◆ nodal_vols

VecXT<double> netdem::FEMSimulator::nodal_vols

The volume of each node in the tetrahedral mesh.

◆ nodes

VecXT<Vec3d> netdem::FEMSimulator::nodes

The nodal positions of the tetrahedral mesh.

◆ nodes_ref

VecXT<Vec3d> netdem::FEMSimulator::nodes_ref

The reference nodal positions of the tetrahedral mesh.

◆ timestep

double netdem::FEMSimulator::timestep {1.0e-4}

The time step used in the simulation.

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

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