This is an example of how to use the netdem library.
#include <filesystem>
#include <iostream>
#include <unordered_map>
using namespace std;
void GolfBallImpact() {
string result_dir = "tmp/examples/deformable_particle/golf_ball/";
filesystem::create_directories(result_dir);
Plane plane(-0.1, 0, 0, 1, 0, 0);
double dem_timestep = 1.0e-7;
p.
SaveAsVTK(result_dir +
"p_tetmesh_000.vtk");
for (int ti = 0; ti < 400; ti++) {
for (int j = 0; j < 50; j++) {
}
}
char filename[128];
snprintf(filename, 128, "p_tetmesh_%03d.vtk", ti + 1);
snprintf(filename, 128, "p_trimesh_%03d.vtk", ti + 1);
}
}
A class representing a deformable particle simulated using the Finite Element Method (FEM).
Definition deformable_particle.hpp:21
void SetVelocity(double v_x, double v_y, double v_z) override
Sets the velocity of the particle.
Definition deformable_particle.cpp:114
void SetPosition(double x, double y, double z) override
Sets the position of the particle.
Definition deformable_particle.cpp:82
void ClearForce() override
Clears all forces on the particle's mesh.
Definition deformable_particle.cpp:150
void ApplyContactForce(ContactPP const *cnt) override
Applies a contact force to the particle.
Definition deformable_particle.cpp:158
void UpdateMotion(double dt) override
Updates the motion of the particle.
Definition deformable_particle.cpp:183
void SetShape(Shape *s) override
Sets the shape of the particle.
Definition deformable_particle.cpp:21
void SetDensity(double dens) override
Sets the density of the particle.
Definition deformable_particle.cpp:71
int mesh_res
The resolution of the tetrahedral mesh.
Definition deformable_particle.hpp:33
void SaveAsVTK(std::string const &filename) override
Saves the particle as a VTK file.
Definition deformable_particle.cpp:269
void SaveSurfaceAsVTK(std::string const &filename)
Saves the surface of the particle as a VTK file.
Definition deformable_particle.cpp:228
FEMSimulator fem_simulator
The FEM simulator object used to simulate the particle.
Definition deformable_particle.hpp:30
double timestep
The time step used in the simulation.
Definition fem_simulator.hpp:36
double neo_k
The bulk modulus of the material being simulated.
Definition fem_simulator.hpp:21
double damp_coef
The damping coefficient used in the simulation.
Definition fem_simulator.hpp:30
double neo_mu
The shear modulus of the material being simulated.
Definition fem_simulator.hpp:24
Contact model that uses linear spring elements to evaluate contact forces and moments.
Definition model_linear_spring.hpp:16
A class for representing a plane with a center point and normal vector.
Definition shape_plane.hpp:22
A class used to solve collisions between a particle and a wall using a signed distance field.
Definition solver_sdf_pw.hpp:18
bool Detect() override
Detects if there is a collision between the particle and the wall.
Definition solver_sdf_pw.cpp:71
void ResolveInit(ContactPW *const cnt, double timestep) override
Resolves the collision based on the initial contact information and timestep.
Definition solver_sdf_pw.cpp:171
void Init(Particle *const p, Wall *const w) override
Initializes the SolverSDFPW instance with the given particles and walls.
Definition solver_sdf_pw.cpp:16
int potential_type
Whether to solve both sides of the collision.
Definition solver_sdf_pw.hpp:30
bool solve_two_sides
Definition solver_sdf_pw.hpp:33
A class representing a sphere.
Definition shape_sphere.hpp:17
STLModel GetSTLModel(int num_nodes=200) override
Generate an STL model for the Sphere object.
Definition shape_sphere.cpp:97
A class representing a triangular mesh in 3D space.
Definition shape_trimesh.hpp:23
void InitFromSTL(std::string const &file)
Initialize the TriMesh object from an STL file.
A class representing a wall object in a physics simulation.
Definition wall.hpp:32
Definition bond_entry.hpp:7