This is an example of how to use the netdem library.
#include <filesystem>
#include <fstream>
#include <iostream>
#include <random>
#include <sstream>
#include <string>
using namespace std;
void FrictionTestSphere(int potential_case) {
sh.
a_nm[0] = sqrt(Math::PI);
cout <<
"shape size: " << sh.
GetSize() << endl;
cout << "particle created ... " << endl;
double timestep = 1.0e-4;
for (int i = 0; i < 1001; i++) {
cnt_solver.
Init(&obj_p2, &obj_p1);
if (cnt == nullptr) {
} else {
}
double pos_x = obj_p2.
pos[0];
Vec3d cnt_force{0, 0, 0}, cnt_moment{0, 0, 0};
cnt_force[0] += cnt_entry.cnt_forces.force[0];
cnt_force[1] += cnt_entry.cnt_forces.force[1];
cnt_force[2] += cnt_entry.cnt_forces.force[2];
dir_n[0] += cnt_entry.cnt_forces.force_n[0];
dir_n[1] += cnt_entry.cnt_forces.force_n[1];
dir_n[2] += cnt_entry.cnt_forces.force_n[2];
dir_s[0] += cnt_entry.cnt_forces.force_t[0];
dir_s[1] += cnt_entry.cnt_forces.force_t[1];
dir_s[2] += cnt_entry.cnt_forces.force_t[2];
}
Math::Normalize(&dir_n);
Math::Normalize(&dir_s);
<< cnt_force <<
", " <<
dir_n <<
", " <<
dir_s << endl;
cnt_force[0], cnt_force[1], cnt_force[2],
dir_n[0],
} else {
double pos_x = obj_p2.
pos[0];
cnt_data.push_back({pos_x, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0});
}
}
string root_dir = "local/potential_models/friction_test/";
filesystem::create_directories(root_dir);
switch (potential_case) {
case SolverSDFPP::PotentialType::linear:
SaveDataset(root_dir + "sphere_linear.txt", cnt_data);
break;
case SolverSDFPP::PotentialType::hertz:
SaveDataset(root_dir + "sphere_hertz.txt", cnt_data);
break;
default:
SaveDataset(root_dir + "sphere_hertz.txt", cnt_data);
break;
}
if (cnt != nullptr) {
delete cnt;
cnt = nullptr;
}
}
Contact model that uses linear spring elements to evaluate contact forces and moments.
Definition model_linear_spring.hpp:16
Definition particle.hpp:26
virtual void ClearMoment()
Clear all moments applied to the particle.
Definition particle.cpp:180
virtual void SetRodrigues(double angle, double axis_x, double axis_y, double axis_z)
Sets the orientation of the particle using a Rodrigues rotation vector.
Definition particle.cpp:95
virtual void UpdateMotion(double timestep)
Update the motion of the particle based on the applied forces and moments over a time step.
Definition particle.cpp:245
virtual void SetPosition(double pos_x, double pos_y, double pos_z)
Sets the position of the particle.
Definition particle.cpp:83
virtual void SetVelocity(double v_x, double v_y, double v_z)
Sets the velocity of the particle.
Definition particle.cpp:112
Vec3d pos
The position of the particle.
Definition particle.hpp:103
virtual void ClearForce()
Clear all forces applied to the particle.
Definition particle.cpp:174
virtual void EnableSurfaceNodes()
Enable the use of surface nodes.
Definition shape.cpp:284
virtual double GetSize() const
Return shape size, which is defined as the diameter of equal-volume sphere.
Definition shape.cpp:116
Signed distance field-based contact solver.
Definition solver_sdf_pp.hpp:19
void ResolveUpdate(ContactPP *const cnt, double timestep) override
Updates the contact resolution for a contact point.
Definition solver_sdf_pp.cpp:191
int potential_type
Whether to solve both sides of the collision.
Definition solver_sdf_pp.hpp:31
bool use_equivalent_stiffness
Definition solver_sdf_pp.hpp:38
bool Detect() override
Detects collisions between particles.
Definition solver_sdf_pp.cpp:73
void ResolveInit(ContactPP *const cnt, double timestep) override
Initializes the contact resolution for a contact point.
Definition solver_sdf_pp.cpp:163
void Init(Particle *const p1, Particle *const p2) override
Initializes the collision solver with two particles.
Definition solver_sdf_pp.cpp:18
A class representing a spherical harmonics object.
Definition shape_spherical_harmonics.hpp:24
VecXT< double > a_nm
Definition shape_spherical_harmonics.hpp:27
void UpdateShapeProperties() override
Update the shape properties of the SphericalHarmonics object.
Definition shape_spherical_harmonics.cpp:129
Definition bond_entry.hpp:7
std::vector< T > VecXT
Definition utils_macros.hpp:31
std::array< double, 3 > Vec3d
Definition utils_macros.hpp:18
dir_n
Definition json_serilization.hpp:19
dir_s
Definition json_serilization.hpp:19