| tfix contact detection logic - granular - granular dynamics simulation | |
| git clone git://src.adamsgaard.dk/granular | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| commit c4ee0c13dd0ce42de531eba07cc3d85b67859c87 | |
| parent 357d8ccfa35d782b9a4997a588cad20ab7f7eab5 | |
| Author: Anders Damsgaard <[email protected]> | |
| 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(-) | |
| --- | |
| 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] = center… | |
| g->contacts[ic].tandisp[d] = 0.0; | |
| } | |
| + return; | |
| } | |
| } | |
| } | |
| diff --git a/simulation.c b/simulation.c | |
| t@@ -130,7 +130,7 @@ sim_check_add_contact(struct simulation *sim, size_t i, si… | |
| 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, si… | |
| 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, over… | |
| + if (overlap > 0.0) | |
| + grain_register_contact(&sim->grains[i], i, j, centerdist, over… | |
| } | |
| void |