tadd debug information for total slider force balance - slidergrid - grid of el… | |
git clone git://src.adamsgaard.dk/slidergrid | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 75d805810911e239896f6865ab9af0dc10b2f2ed | |
parent f592a85d991ec58487fb39ba92a7eb3f32b39f75 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Tue, 22 Mar 2016 11:28:12 -0700 | |
add debug information for total slider force balance | |
Diffstat: | |
M slidergrid/debug.h | 4 ++++ | |
M slidergrid/main.c | 17 ++++++++++++++++- | |
M test.c | 10 ++++++++++ | |
3 files changed, 30 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/slidergrid/debug.h b/slidergrid/debug.h | |
t@@ -5,4 +5,8 @@ | |
// slider-bond initialization function | |
//#define DEBUG_FIND_AND_BOND_TO_NEIGHBORS | |
+// if defined, verbose information to stdout will be shown before the slider | |
+// integration | |
+#define DEBUG_SLIDER_FORCE_TORQUE_AND_NEIGHBORS | |
+ | |
#endif | |
diff --git a/slidergrid/main.c b/slidergrid/main.c | |
t@@ -41,7 +41,7 @@ void print_status(simulation sim) | |
int main(int argc, char** argv) | |
{ | |
- int i; | |
+ int i, j; | |
// default values of command-line flags | |
int verbose = 0; | |
t@@ -137,6 +137,21 @@ int main(int argc, char** argv) | |
sim.N, | |
sim.iteration); | |
+#ifdef DEBUG_SLIDER_FORCE_TORQUE_AND_NEIGHBORS | |
+ printf("Slider %d: F = %f %f %f, T = %f %f %f, neighbors = ", | |
+ i, | |
+ sim.sliders[i].force.x, | |
+ sim.sliders[i].force.y, | |
+ sim.sliders[i].force.z, | |
+ sim.sliders[i].torque.x, | |
+ sim.sliders[i].torque.y, | |
+ sim.sliders[i].torque.z); | |
+ for (j=0; j<MAX_NEIGHBORS; j++) | |
+ if (sim.sliders[i].neighbors[j] >= 0) | |
+ printf("%d ", sim.sliders[i].neighbors[j]); | |
+ puts(""); | |
+#endif | |
+ | |
// update slider kinematics | |
update_kinematics(sim.sliders[i], sim.dt, sim.iteration); | |
} | |
diff --git a/test.c b/test.c | |
t@@ -2,6 +2,8 @@ | |
#include "slidergrid/grid.h" | |
#include "slidergrid/slider.h" | |
+#include <stdio.h> | |
+ | |
// test a regular, 2d, orthogonal grid of sliders | |
simulation setup_simulation() | |
{ | |
t@@ -33,5 +35,13 @@ simulation setup_simulation() | |
sim.time_end = 1.0; | |
sim.file_interval = 0.1; | |
+ if (write_simulation_output(&sim, ".")) { | |
+ fprintf(stderr, "\nFatal error: Could not write one or more " | |
+ "output files.\n"); | |
+ } | |
+ | |
+ | |
+ | |
+ | |
return sim; | |
} |