tfix contact detection logic - granular - granular dynamics simulation (HTM) git clone git://src.adamsgaard.dk/granular (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit c4ee0c13dd0ce42de531eba07cc3d85b67859c87 (DIR) parent 357d8ccfa35d782b9a4997a588cad20ab7f7eab5 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Thu, 22 Apr 2021 22:10:09 +0200 fix contact detection logic Diffstat: M grain.c | 1 + M simulation.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) --- (DIR) diff --git a/grain.c b/grain.c t@@ -374,6 +374,7 @@ grain_register_contact(struct grain *g, size_t i, size_t j, g->contacts[ic].centerdist[d] = centerdist[d]; g->contacts[ic].tandisp[d] = 0.0; } + return; } } } (DIR) diff --git a/simulation.c b/simulation.c t@@ -130,7 +130,7 @@ sim_check_add_contact(struct simulation *sim, size_t i, size_t j) double overlap, centerdist[3]; int d; - if (i >= j) + if (i >= j || !sim->grains[i].enabled || !sim->grains[j].enabled) return; for (d = 0; d < 3; d++) t@@ -139,8 +139,8 @@ sim_check_add_contact(struct simulation *sim, size_t i, size_t j) overlap = 0.5*(sim->grains[i].diameter + sim->grains[j].diameter) - euclidean_norm(centerdist, 3); - if (sim->grains[i].enabled) - grain_register_contact(&sim->grains[i], j, i, centerdist, overlap); + if (overlap > 0.0) + grain_register_contact(&sim->grains[i], i, j, centerdist, overlap); } void