NetDEM v1.0
|
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< Vec3d > | GetNodalPositions (VecXT< int > nids) |
Gets the positions of a set of nodes in the tetrahedral mesh. | |
VecXT< Vec3d > | GetNodalDisps (VecXT< int > nids) |
Gets the displacements of a set of nodes in the tetrahedral mesh. | |
VecXT< Vec3d > | GetNodalVels (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< Vec3d > | nodes |
The nodal positions of the tetrahedral mesh. | |
VecXT< Vec4i > | elements |
The elements of the tetrahedral mesh. | |
VecXT< Vec3d > | nodes_ref |
The reference nodal positions of the tetrahedral mesh. | |
VecXT< Vec3i > | bound_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< Vec3d > | nodal_vels |
The velocity of each node in the tetrahedral mesh. | |
VecXT< Vec3d > | bc_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< Vec3d > | nodal_forces_int |
< The internal forces acting on each node. | |
VecXT< Vec3d > | nodal_forces_ext |
The average nodal velocities used in the simulation. | |
VecXT< Vec3d > | nodal_vels_ave |
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.
FEMSimulator::FEMSimulator | ( | ) |
Constructs a new FEMSimulator
object.
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.
bc_fid | The ID of the facet to add the force to. |
fx | The X component of the force to apply. |
fy | The Y component of the force to apply. |
fz | The Z component of the force to apply. |
|
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.
dt | The time step to use for the simulation. |
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.
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.
def_grad | The deformation gradient of an element in the mesh. |
Mat3d
object.
|
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.
v0_new | The new position of the first vertex of the tetrahedron. |
v1_new | The new position of the second vertex of the tetrahedron. |
v2_new | The new position of the third vertex of the tetrahedron. |
v3_new | The new position of the fourth vertex of the tetrahedron. |
v0_ref | The reference position of the first vertex of the tetrahedron. |
v1_ref | The reference position of the second vertex of the tetrahedron. |
v2_ref | The reference position of the third vertex of the tetrahedron. |
v3_ref | The reference position of the fourth vertex of the tetrahedron. |
Mat3d
object.
|
protected |
Calculates the volume of a tetrahedral element.
This function calculates the volume of a tetrahedral element specified by its four vertices.
v0 | The first vertex of the tetrahedron. |
v1 | The second vertex of the tetrahedron. |
v2 | The third vertex of the tetrahedron. |
v3 | The fourth vertex of the tetrahedron. |
|
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.
cauchy_stress | The Cauchy stress tensor of the element. |
v0,v1,v2,v3 | The vertices of the tetrahedron. |
MatNd<4, 3>
object. 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.
nids | A vector of node IDs to get the displacements of. |
VecXT<Vec3d>
object containing the displacements of the specified nodes. 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.
nids | A vector of node IDs to get the positions of. |
VecXT<Vec3d>
object containing the positions of the specified nodes. 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.
nids | A vector of node IDs to get the velocities of. |
VecXT<Vec3d>
object containing the velocities of the specified nodes. 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.
|
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.
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.
file_name | The name of the file to save the data in. |
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.
nid | The ID of the node to set the velocity for. |
vx | The X component of the prescribed velocity. |
vy | The Y component of the prescribed velocity. |
vz | The Z component of the prescribed velocity. |
use_prescribed_vx | Whether or not to use the X-component of the velocity as a prescribed value. |
use_prescribed_vy | Whether or not to use the Y-component of the velocity as a prescribed value. |
use_prescribed_vz | Whether or not to use the Z-component of the velocity as a prescribed value. |
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.
tetmesh | A reference to the TetMesh object representing the tetrahedral mesh. |
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.
v_x | The X component of the nodal velocity. |
v_y | The Y component of the nodal velocity. |
v_z | The Z component of the nodal velocity. |
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.
dt | The time step to use for the simulation. |
The forces applied to each facet on the boundary of the object.
The prescribed velocities for each node on the boundary of the object.
The facets of the object that define its bounding surface.
VecXT<int> netdem::FEMSimulator::bound_nodes |
The IDs of the nodes on the bounding surface.
double netdem::FEMSimulator::damp_coef {0.7} |
The damping coefficient used in the simulation.
double netdem::FEMSimulator::density {500.0} |
The density of the material being simulated.
The stress values of each element in the tetrahedral mesh.
VecXT<double> netdem::FEMSimulator::elemental_vol |
The volume of each element in the tetrahedral mesh.
Vec3d netdem::FEMSimulator::gravity_coef {0.0, 0.0, 0.0} |
The gravitational force acting on the object.
double netdem::FEMSimulator::neo_k {6.94e5} |
The bulk modulus of the material being simulated.
double netdem::FEMSimulator::neo_mu {5.21e5} |
The shear modulus of the material being simulated.
The average nodal velocities used in the simulation.
< The internal forces acting on each node.
The external forces acting on each node.
VecXT<double> netdem::FEMSimulator::nodal_vols |
The volume of each node in the tetrahedral mesh.
double netdem::FEMSimulator::timestep {1.0e-4} |
The time step used in the simulation.