Commit be084099 authored by Bruno Chareyre's avatar Bruno Chareyre Committed by Anton Gladky

Critical bugfix for periodic boundaries.

parent 253fbafd
From c7c8e6f62d452c81a31415f05a12587a6cc8c452 Mon Sep 17 00:00:00 2001
From: bchareyre <bruno.chareyre@grenoble-inp.fr>
Date: Fri, 14 Apr 2017 12:04:32 +0200
Subject: [PATCH] Critical bugfix for collision detection in periodic boundary
conditions. Bounds lists were left partially unordered, then some
interactions were never detected (my toughest yade debugging until now).
---
pkg/common/InsertionSortCollider.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/pkg/common/InsertionSortCollider.cpp b/pkg/common/InsertionSortCollider.cpp
index dc5d7ac..163a4f4 100644
--- a/pkg/common/InsertionSortCollider.cpp
+++ b/pkg/common/InsertionSortCollider.cpp
@@ -410,8 +410,10 @@ Real InsertionSortCollider::cellWrapRel(const Real x, const Real x0, const Real
void InsertionSortCollider::insertionSortPeri(VecBounds& v, InteractionContainer* interactions, Scene*, bool doCollide){
assert(periodic);
long &loIdx=v.loIdx; const long &size=v.size;
- for(long _i=0; _i<size; _i++){
- const long i=v.norm(_i);
+ /* We have to visit each bound at least once (first condition), but this is not enough. The correct ordering in the begining of the list needs a second pass to connect begin and end consistently (the second condition). Strictly the second condition should include "+ (v.norm(j+1)==loIdx ? v.cellDim : 0)" but it is ok as is since the shift is added inside the loop. */
+ long _i=0;
+ for(; (_i<size) || (v[v.norm(_i)].coord < v[v.norm(_i-1)].coord); _i++){
+ const long i=v.norm(_i);//FIXME: useless, and many others can probably be removed
const long i_1=v.norm(i-1);
//switch period of (i) if the coord is below the lower edge cooridnate-wise and just above the split
if(i==loIdx && v[i].coord<0){ v[i].period-=1; v[i].coord+=v.cellDim; loIdx=v.norm(loIdx+1); }
01_remove_google_analytics.patch
08_fix_gui.patch
09_fix_periodic_boundaries.patch
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment