tadd debugging information for bond deformation - slidergrid - grid of elastic … | |
git clone git://src.adamsgaard.dk/slidergrid | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 3246bf804bdc996d1bd737dbeb3acadad09fae2d | |
parent f42ed36e0b3fd01a46ca70e29a11c5ded205f809 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Tue, 12 Apr 2016 15:03:53 -0700 | |
add debugging information for bond deformation | |
Diffstat: | |
M Makefile | 2 +- | |
M slidergrid/debug.h | 9 ++++++--- | |
M slidergrid/slider.c | 53 +++++++++++++++++++++++++----… | |
M tests/elasticity/normal.c | 1 + | |
M tests/elasticity/shear.c | 9 +++++---- | |
5 files changed, 57 insertions(+), 17 deletions(-) | |
--- | |
diff --git a/Makefile b/Makefile | |
t@@ -10,7 +10,7 @@ ESSENTIALOBJS=$(SRCFOLDER)/main.o \ | |
$(SRCFOLDER)/simulation.o | |
BIN=example | |
-default: example tests run-example | |
+default: example tests | |
run-example: $(BIN) | |
./$(BIN) | |
diff --git a/slidergrid/debug.h b/slidergrid/debug.h | |
t@@ -5,16 +5,19 @@ | |
// slider-bond initialization function | |
//#define DEBUG_FIND_AND_BOND_TO_NEIGHBORS | |
+// if defined, show information on the resolved inter-slider bond deformation | |
+#define DEBUG_BOND_DEFORMATION | |
+ | |
// if defined, verbose information to stdout will be shown about the individua… | |
// components of the sum of forces | |
-//#define DEBUG_SLIDER_FORCE_COMPONENTS | |
+#define DEBUG_SLIDER_FORCE_COMPONENTS | |
// if defined, verbose information to stdout will be shown before the slider | |
// integration | |
-//#define DEBUG_SLIDER_FORCE_TORQUE_AND_NEIGHBORS | |
+#define DEBUG_SLIDER_FORCE_TORQUE_AND_NEIGHBORS | |
// if defined, verbose information to stdout will be shown after the slider | |
// integration | |
-//#define DEBUG_SLIDER_KINEMATICS | |
+#define DEBUG_SLIDER_KINEMATICS | |
#endif | |
diff --git a/slidergrid/slider.c b/slidergrid/slider.c | |
t@@ -238,7 +238,7 @@ void bond_normal_deformation(slider* s1, const slider s2, | |
s1->neighbor_relative_tangential_displacement[idx_neighbor] = | |
tangential_displacement; | |
else | |
- s1->neighbor_relative_distance_displacement[idx_neighbor] = | |
+ s1->neighbor_relative_tangential_displacement[idx_neighbor] = | |
add_float3( | |
s1->neighbor_relative_tangential_displacement[idx_neighbor… | |
dtangential_displacement); | |
t@@ -332,18 +332,36 @@ void bond_shear_kelvin_voigt(slider* s1, const slider s2, | |
s1->neighbor_relative_tangential_velocity[idx_neighbor]); | |
// bond-parallel Kelvin-Voigt force, counteracts tension and compression | |
- const Float3 f_t = multiply_scalar_float3(-1.0, | |
+ const Float3 f_t = multiply_scalar_float3( 1.0, // TODO: test sign | |
add_float3(f_t_elastic, f_t_viscous)); | |
- // add bond-parallel Kelvin-Voigt force to sum of forces on slider | |
+ // add bond-shear Kelvin-Voigt force to sum of forces on slider | |
s1->force = add_float3(s1->force, f_t); | |
+ const Float3 torque = multiply_scalar_float3( -1.0, | |
+ cross_float3( | |
+ multiply_float3_scalar( | |
+ s1->neighbor_distance[idx_neighbor], 0.5), | |
+ f_t)); | |
+ | |
+ // add bond-shear Kelvin-Voigt force to sum of torques on slider | |
+ //s1->torque = add_float3(s1->torque, f_t); | |
+ /*s1->torque = add_float3(s1->torque, | |
+ multiply_scalar_float3( -1.0, | |
+ cross_float3( | |
+ multiply_float3_scalar(s1->neighbor_distance[idx_neighbor]… | |
+ , // midpoint distance between sliders | |
+ f_t)));*/ | |
+ | |
#ifdef DEBUG_SLIDER_FORCE_COMPONENTS | |
- printf("slider_interaction KV-shear: f_t = %f %f %f, " | |
+ printf("slider_interaction KV-shear: f_t = %f %f %f, torque = %f %f %f, " | |
"f_t_elastic = %f %f %f, f_t_viscous = %f %f %f\n", | |
f_t.x, | |
f_t.y, | |
f_t.z, | |
+ torque.x, | |
+ torque.y, | |
+ torque.z, | |
f_t_elastic.x, | |
f_t_elastic.y, | |
f_t_elastic.z, | |
t@@ -358,7 +376,7 @@ void bond_shear_kelvin_voigt(slider* s1, const slider s2, | |
void slider_interaction(slider* s1, const slider s2, const int idx_neighbor) | |
{ | |
bond_parallel_kelvin_voigt(s1, s2, idx_neighbor); | |
- bond_shear_kelvin_voigt(s1, s2, idx_neighbor); | |
+ //bond_shear_kelvin_voigt(s1, s2, idx_neighbor); | |
} | |
t@@ -387,12 +405,29 @@ void slider_neighbor_interaction( | |
s, sliders[s->neighbors[idx_neighbor]], | |
idx_neighbor, iteration, dt); | |
- /*printf("- %d: rel_disp = %f %f %f\n", | |
- idx_neighbor, | |
+#ifdef DEBUG_BOND_DEFORMATION | |
+ int j; | |
+ for (j=0; j<MAX_NEIGHBORS; j++) | |
+ printf("%p = %d:\n" | |
+ "\trel_dist_disp = %f %f %f\n" | |
+ "\trel_dist_vel = %f %f %f\n" | |
+ "\trel_tan_disp = %f %f %f\n" | |
+ "\trel_tan_vel = %f %f %f\n", | |
+ s, idx_neighbor, | |
s->neighbor_relative_distance_displacement[idx_neighbor].x, | |
s->neighbor_relative_distance_displacement[idx_neighbor].y, | |
- s->neighbor_relative_distance_displacement[idx_neighbor].z | |
- );*/ | |
+ s->neighbor_relative_distance_displacement[idx_neighbor].z, | |
+ s->neighbor_relative_distance_velocity[idx_neighbor].x, | |
+ s->neighbor_relative_distance_velocity[idx_neighbor].y, | |
+ s->neighbor_relative_distance_velocity[idx_neighbor].z, | |
+ s->neighbor_relative_tangential_displacement[idx_neighbor]… | |
+ s->neighbor_relative_tangential_displacement[idx_neighbor]… | |
+ s->neighbor_relative_tangential_displacement[idx_neighbor]… | |
+ s->neighbor_relative_tangential_velocity[idx_neighbor].x, | |
+ s->neighbor_relative_tangential_velocity[idx_neighbor].y, | |
+ s->neighbor_relative_tangential_velocity[idx_neighbor].z | |
+ ); | |
+#endif | |
slider_interaction( | |
s, sliders[s->neighbors[idx_neighbor]], idx_neighbor); | |
diff --git a/tests/elasticity/normal.c b/tests/elasticity/normal.c | |
t@@ -33,6 +33,7 @@ simulation setup_simulation() | |
sim.sliders[i].moment_of_inertia = 1.0e3; | |
sim.sliders[i].bond_parallel_kv_stiffness = 1.0e5; | |
//sim.sliders[i].bond_parallel_kv_viscosity = 1.0e2; | |
+ sim.sliders[i].bond_shear_kv_stiffness = 1.0e5; | |
} | |
sim.sliders[0].vel.x = 0.01; | |
diff --git a/tests/elasticity/shear.c b/tests/elasticity/shear.c | |
t@@ -33,16 +33,17 @@ simulation setup_simulation() | |
sim.sliders[i].moment_of_inertia = 1.0e3; | |
sim.sliders[i].bond_parallel_kv_stiffness = 1.0e5; | |
//sim.sliders[i].bond_parallel_kv_viscosity = 1.0e2; | |
+ sim.sliders[i].bond_shear_kv_stiffness = 1.0e5; | |
} | |
sim.sliders[0].vel.y = 0.01; | |
// set temporal parameters | |
- sim.time = 0.0; | |
- //sim.time_end = 1000.0; | |
+ //sim.time_end = 100.0; | |
//sim.file_interval = 1.0; | |
- sim.time_end = 100.0; | |
- sim.file_interval = 0.1; | |
+ sim.time_end = 1.0; | |
+ sim.file_interval = 1.0e-3; | |
+ sim.time = 0.0; | |
return sim; | |
} |