tadd functionality to list inter-particle contacts - sphere - GPU-based 3D disc… | |
git clone git://src.adamsgaard.dk/sphere | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 83ab042edfff0746b4347f5e56942cfda9f39797 | |
parent 7991e3a90cc9ef511a57accea71a4766cec57f0f | |
Author: Anders Damsgaard <[email protected]> | |
Date: Tue, 30 Sep 2014 14:51:32 +0200 | |
add functionality to list inter-particle contacts | |
Diffstat: | |
M src/main.cpp | 12 ++++++++++++ | |
M src/sphere.cpp | 13 +++++++++++++ | |
M src/sphere.h | 5 ++++- | |
3 files changed, 29 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/src/main.cpp b/src/main.cpp | |
t@@ -38,6 +38,7 @@ int main(const int argc, const char *argv[]) | |
float lower_cutoff = 0.0f;// lower cutoff, particles below won't be render… | |
int fluid = 0; | |
int device = -1; // -1 run on device with most cores, 0+ run on specified … | |
+ int print_contacts = 0; | |
// Process input parameters | |
int i; | |
t@@ -66,6 +67,7 @@ int main(const int argc, const char *argv[]) | |
"\tnormal, pres, vel, angvel, xdisp, angpos\n" | |
"\t'normal' is the default mode\n" | |
"\tif -l is appended, don't render particles with value below\… | |
+ "-c, --contacts\t\tPrint a list of particle-particle contacts\… | |
<< std::endl; | |
return 0; // Exit with success | |
} | |
t@@ -106,6 +108,9 @@ int main(const int argc, const char *argv[]) | |
else if (argvi == "-f" || argvi == "--fluid") | |
fluid = 1; | |
+ else if (argvi == "-c" || argvi == "--contacts") | |
+ print_contacts = 1; | |
+ | |
else if (argvi == "-d") { | |
device = atoi(argv[i+1]); | |
if (device < -1) { | |
t@@ -169,6 +174,10 @@ int main(const int argc, const char *argv[]) | |
// Create DEM class, read data from input binary, check values, | |
// init cuda, transfer const mem | |
DEM dem(argvi, verbose, checkVals, dry, 1, 1, fluid, device); | |
+ | |
+ if (print_contacts == 1) | |
+ dem.printContacts(); | |
+ | |
// Render image if requested | |
if (render == 1) | |
dem.render(method, max_val, lower_cutoff); | |
t@@ -182,6 +191,9 @@ int main(const int argc, const char *argv[]) | |
// Do not transfer to const. mem after the first file | |
DEM dem(argvi, verbose, checkVals, dry, 1, 0, fluid, device); | |
+ if (print_contacts == 1) | |
+ dem.printContacts(); | |
+ | |
// Render image if requested | |
if (render == 1) | |
dem.render(method, max_val, lower_cutoff); | |
diff --git a/src/sphere.cpp b/src/sphere.cpp | |
t@@ -813,4 +813,17 @@ void DEM::forcechains(const std::string format, const int… | |
} | |
} | |
+// Loop over all particles, find intersections. Print particle indexes, | |
+// overlap distance and normal force | |
+void DEM::printContacts() | |
+{ | |
+ std::vector< std::vector<unsigned int> > ij; | |
+ std::vector< Float > delta_n_ij; | |
+ findOverlaps(ij, delta_n_ij); | |
+ | |
+ for (unsigned int n=0; n<ij.size(); ++n) | |
+ std::cout << ij[n][0] << '\t' << ij[n][1] << '\t' << delta_n_ij[n] | |
+ << std::endl; | |
+} | |
+ | |
// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 | |
diff --git a/src/sphere.h b/src/sphere.h | |
t@@ -357,7 +357,10 @@ class DEM { | |
const double lower_cutoff = 0.0, | |
const double upper_cutoff = 1.0e9); | |
- | |
+ // Print all particle-particle contacts to stdout | |
+ void printContacts(); | |
+ | |
+ | |
///// Porous flow functions | |
// Print fluid arrays to file stream |