NetDEM v1.0
Loading...
Searching...
No Matches
sdf_dem_main.cpp

This is an example of how to use the netdem library.

#include <filesystem>
#include <iostream>
#include <string>
using namespace std;
void SDFDemo(int argc, char **argv);
void SDFError(int argc, char **argv);
void ContactTestSphere(int potential_case, int surface_node_num);
void ContactTestTrimesh(int potential_case, int surface_node_num);
void NutInBolt(int argc, char **argv);
void PackingDemo(int argc, char **argv);
void PackingEllipsoid(int argc, char **argv);
void TriaxialComp(bool need_make_convex, double pressure, string root_dir);
void AngleRepose(bool need_make_convex, double friction, string root_dir);
int main(int argc, char **argv) {
if (argc == 1) {
cout << "please specify the id of the task. \n"
<< "e.g.: netdem_example_sdf_dem i" << endl;
cout << ">> 0: signed distance field demo" << endl;
cout << ">> 1: signed distance field error investigation" << endl;
cout << ">> 10: contact potential test of sphere. option: [potential_case] "
"[surface_node_num]"
<< endl;
cout << ">> 11: contact potential test of trimesh. option: "
"[potential_case] [surface_node_num]"
<< endl;
cout << ">> 90: random packing" << endl;
cout << ">> 91: ellipsoid with parametric shape parameters" << endl;
cout << ">> 92: nut in bolt" << endl;
cout << ">> 93: triaxial compression" << endl;
cout << ">> 94: column collapse" << endl;
return -1;
}
int id = atof(argv[1]);
switch (id) {
case 0:
SDFDemo(argc, argv);
break;
case 1:
SDFError(argc, argv);
break;
case 10:
if (argc == 4) {
int potential_case = atof(argv[2]);
int surface_node_num = atof(argv[3]);
ContactTestSphere(potential_case, surface_node_num);
cout << "potential case: " << potential_case << ", "
<< "node num: " << surface_node_num << endl;
} else {
ContactTestSphere(1, 1000);
}
break;
case 11:
if (argc == 4) {
int potential_case = atof(argv[2]);
int surface_node_num = atof(argv[3]);
ContactTestTrimesh(potential_case, surface_node_num);
cout << "potential case: " << potential_case << ", "
<< "node num: " << surface_node_num << endl;
} else {
ContactTestTrimesh(1, 1000);
}
break;
case 90:
PackingDemo(argc, argv);
break;
case 91:
PackingEllipsoid(argc, argv);
break;
case 92:
NutInBolt(argc, argv);
break;
case 93:
if (argc == 5) {
bool need_make_convex = atof(argv[2]);
double pressure = atof(argv[3]);
string root_dir = string(argv[4]);
filesystem::create_directories(root_dir);
TriaxialComp(need_make_convex, pressure, root_dir);
} else {
filesystem::create_directories("tmp/examples/sdf_contact/triaxial_comp/");
TriaxialComp(false, 1.0e5, "tmp/examples/sdf_contact/triaxial_comp/");
}
break;
case 94:
if (argc == 5) {
bool need_make_convex = atof(argv[2]);
double friction = atof(argv[3]);
string root_dir = string(argv[4]);
filesystem::create_directories(root_dir);
AngleRepose(need_make_convex, friction, root_dir);
} else {
filesystem::create_directories("tmp/examples/sdf_contact/angle_repose/");
AngleRepose(false, 0.3, "tmp/examples/sdf_contact/angle_repose/");
}
break;
default:
break;
}
return 0;
}
int main(int argc, char *argv[])
Definition main.cpp:18