tadd functionality to list inter-particle contacts - sphere - GPU-based 3D discrete element method algorithm with optional fluid coupling
(HTM) git clone git://src.adamsgaard.dk/sphere
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 83ab042edfff0746b4347f5e56942cfda9f39797
(DIR) parent 7991e3a90cc9ef511a57accea71a4766cec57f0f
(HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
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(-)
---
(DIR) 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 rendered
int fluid = 0;
int device = -1; // -1 run on device with most cores, 0+ run on specified device
+ 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\n"
+ "-c, --contacts\t\tPrint a list of particle-particle contacts\n"
<< 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);
(DIR) diff --git a/src/sphere.cpp b/src/sphere.cpp
t@@ -813,4 +813,17 @@ void DEM::forcechains(const std::string format, const int threedim,
}
}
+// 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
(DIR) 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