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

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

#include <filesystem>
#include <iostream>
#include <string>
using namespace std;
void ContactTestSphere(int potential_case, int surface_node_num);
void ContactTestTrimesh(int potential_case, int surface_node_num);
void EnergyTest(int potential_case, int shape_case, double timestep);
void CurvatureEffectTest(int potential_case, int surface_node_num);
void SizeEffectTest(int potential_case, int surface_node_num, double size);
void FrictionTestSphere(int potential_case);
void FrictionTestTrimesh(int potential_case);
void RandomPacking(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);
void Rockfall(int potential_case, double kn, int surface_node_num,
string root_dir);
void TriaxialCompSphereSDF(double kn_coef, double friction, double pressure,
string root_dir);
void TriaxialCompSphereGeom(double kn_coef, double friction, double pressure,
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_potential_models i" << endl;
cout << ">> 00: contact potential test of sphere. option: [potential_case] "
"[surface_node_num]"
<< endl;
cout << ">> 01: contact potential test of trimesh. option: "
"[potential_case] [surface_node_num]"
<< endl;
cout << ">> 02: evergy evolution test. option: [potential_case] "
"[shape_case] [timestep]"
<< endl;
cout << ">> 03: friction test of sphere. option: [potential_case]" << endl;
cout << ">> 04: friction test of trimesh. option: [potential_case]" << endl;
cout << ">> 05: contact test for curvature effect. option: "
"[potential_case] [surface_node_num]"
<< endl;
cout << ">> 80: random packing" << endl;
cout << ">> 91: triaxial compression" << endl;
cout << ">> 92: angle of repose" << endl;
cout << ">> 93: rock fall test" << endl;
cout << ">> 96: triaxial compression of sphere based on sh" << endl;
cout << ">> 97: triaxial compression of sphere in conventional" << endl;
return -1;
}
int id = atof(argv[1]);
switch (id) {
case 0:
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);
cout << "potential case: " << 1 << ", "
<< "node num: " << 1000 << endl;
}
break;
case 1:
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);
cout << "potential case: " << 1 << ", "
<< "node num: " << 1000 << endl;
}
break;
case 2:
if (argc == 5) {
int potential_case = atof(argv[2]);
int shape_case = atof(argv[3]);
double timestep = atof(argv[4]);
cout << "potential case: " << potential_case << ", "
<< "shape case: " << shape_case << ", "
<< "timestep: " << timestep << endl;
EnergyTest(potential_case, shape_case, timestep);
} else {
cout << "potential case: " << 1 << ", "
<< "shape case: " << 1 << ", "
<< "timestep: " << 1.0e-4 << endl;
EnergyTest(1, 1, 1.0e-4);
}
break;
case 3:
if (argc == 3) {
int potential_case = atof(argv[2]);
FrictionTestSphere(potential_case);
cout << "potential case: " << potential_case << endl;
} else {
FrictionTestSphere(1);
cout << "potential case: " << 1 << endl;
}
break;
case 4:
if (argc == 3) {
int potential_case = atof(argv[2]);
FrictionTestTrimesh(potential_case);
cout << "potential case: " << potential_case << endl;
} else {
FrictionTestTrimesh(1);
cout << "potential case: " << 1 << endl;
}
break;
case 5:
if (argc == 4) {
int potential_case = atof(argv[2]);
int surface_node_num = atof(argv[3]);
CurvatureEffectTest(potential_case, surface_node_num);
cout << "potential case: " << potential_case << ", "
<< "node num: " << surface_node_num << endl;
} else {
CurvatureEffectTest(1, 1000);
cout << "potential case: " << 1 << ", "
<< "node num: " << 1000 << endl;
}
break;
case 6:
if (argc == 5) {
int potential_case = atof(argv[2]);
int surface_node_num = atof(argv[3]);
double size = atof(argv[4]);
SizeEffectTest(potential_case, surface_node_num, size);
cout << "potential case: " << potential_case << ", "
<< "node num: " << surface_node_num << ", "
<< "size: " << size << endl;
} else {
SizeEffectTest(0, 1000, 1.0);
cout << "potential case: " << 1 << ", "
<< "node num: " << 1000 << ", "
<< "size: " << 1.0 << endl;
}
break;
case 80:
RandomPacking(argc, argv);
break;
case 91:
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("local/potential_models/triaxial_comp/");
TriaxialComp(false, 1.0e5, "local/potential_models/triaxial_comp/");
}
break;
case 92:
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("local/potential_models/angle_repose/");
AngleRepose(false, 0.3, "local/potential_models/angle_repose/");
}
break;
case 93:
if (argc == 6) {
double potential_case = atof(argv[2]);
double kn = atof(argv[3]);
double surface_node_num = atof(argv[4]);
string root_dir = string(argv[5]);
filesystem::create_directories(root_dir);
Rockfall(potential_case, kn, surface_node_num, root_dir);
} else {
string root_dir = "local/potential_models/rockfall/tmp/";
filesystem::create_directories(root_dir);
Rockfall(0, 1.0e5, 1000, root_dir);
}
break;
case 96:
if (argc < 5) {
double kn_coef = 1.0;
double friction = 0.3;
double pressure = 2.0e5;
string root_dir = "local/potential_models/triaxial_comp_sh/";
cout << "default case: " << endl;
cout << " kn_coef: " << kn_coef << ", "
<< " friction: " << friction << ", "
<< " pressure: " << pressure << endl
<< " root_dir: " << root_dir << endl;
filesystem::create_directories(root_dir);
TriaxialCompSphereSDF(kn_coef, friction, pressure, root_dir);
} else {
double kn_coef = atof(argv[2]);
double friction = atof(argv[3]);
double pressure = atof(argv[4]);
string root_dir = string(argv[5]);
cout << "specified case: " << endl;
cout << " kn_coef: " << kn_coef << ", "
<< " friction: " << friction << ", "
<< " pressure: " << pressure << endl
<< " root_dir: " << root_dir << endl;
filesystem::create_directories(root_dir);
TriaxialCompSphereSDF(kn_coef, friction, pressure, root_dir);
}
break;
case 97:
if (argc < 5) {
double kn_coef = 1.0;
double friction = 0.3;
double pressure = 2.0e5;
string root_dir = "local/potential_models/triaxial_comp_sh/";
cout << "default case: " << endl;
cout << " kn_coef: " << kn_coef << ", "
<< " friction: " << friction << ", "
<< " pressure: " << pressure << endl
<< " root_dir: " << root_dir << endl;
filesystem::create_directories(root_dir);
TriaxialCompSphereGeom(kn_coef, friction, pressure, root_dir);
} else {
double kn_coef = atof(argv[2]);
double friction = atof(argv[3]);
double pressure = atof(argv[4]);
string root_dir = string(argv[5]);
cout << "specified case: " << endl;
cout << " kn_coef: " << kn_coef << ", "
<< " friction: " << friction << ", "
<< " pressure: " << pressure << endl
<< " root_dir: " << root_dir << endl;
filesystem::create_directories(root_dir);
TriaxialCompSphereGeom(kn_coef, friction, pressure, root_dir);
}
break;
default:
break;
}
return 0;
}
int main(int argc, char *argv[])
Definition main.cpp:18