This is an example of how to use the netdem library.
#include <filesystem>
#include <string>
using namespace std;
void HertzContact() {
Plane plane_1(0, 0, -0.45, 0, 0, 1);
Plane plane_2(0, 0, 0.45, 0, 0, -1);
double dt = 1.0e-4;
string root_dir = "tmp/examples/deformable_particle/hertz_contact/";
filesystem::create_directories(root_dir);
double fz = 0;
for (int ti = 0; ti < 100; ti++) {
for (int tj = 0; tj < 50; tj++) {
cnt_solver.
Init(&p, &w_1);
}
}
cnt_solver.
Init(&p, &w_2);
fz = 0;
}
}
}
cout << "contact force z:" << abs(fz) << endl;
char filename[128];
snprintf(filename, 128, "particle_%03d.vtk", ti + 1);
}
}
A class representing a deformable particle simulated using the Finite Element Method (FEM).
Definition deformable_particle.hpp:21
void ClearForce() override
Clears all forces on the particle's mesh.
Definition deformable_particle.cpp:150
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 SaveAsVTK(std::string const &filename) override
Saves the particle as a VTK file.
Definition deformable_particle.cpp:269
void AddForce(int node_id, Vec3d const &f)
Adds a force to a node on the particle's mesh.
Definition deformable_particle.cpp:135
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
Vec3d gravity_coef
The gravitational force acting on the object.
Definition fem_simulator.hpp:33
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
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.
void SetSize(double d) override
Set the size of the TriMesh object.
Definition shape_trimesh.cpp:207
A class representing a wall object in a physics simulation.
Definition wall.hpp:32
Definition bond_entry.hpp:7