Page 326 - The Combined Finite-Discrete Element Method
P. 326
NBS CONTACT DETECTION ALGORITHM IN 3D 309
.........continued from previous listing.............
/* assign all contactors to z-cells */
for(ielem=0;ielem<nelem;ielem++)
{ if(d1erad[ielem]>R0)
{ i1cnz[ielem]=i1cfz[i1eccz[ielem]];
i1cfz[i1eccz[ielem]]=ielem;
}}
Listing 10.28 All elements are put onto simply connected z-lists, and all lists are marked new.
.........continued from previous listing.............
/* scan all loaded z cells */
for(ielem=0;ielem<nelem;ielem++)
{ iz=i1eccz[ielem];
if(i1cfz[iz]<nelem)
{ i1heaz[0]=i1cfz[iz];
i1heaz[1]=i1cfz[iz-1];
if(i1heaz[1]>nelem)i1heaz[1]=i1heaz[1]-nelemd;
i1cfz[iz]=i1cfz[iz]+nelemd;
Listing 10.29 All z-lists are searched for a new list, which is then marked as an old list by
increasing the first element in the list by nelemd=2*nelem.
.........continued from previous listing.............
/* load elements from cells iz & iz-1 onto y cells */
for(ihz=0;ihz<2;ihz++)
{ ielemz=i1heaz[ihz];
while(ielemz>=0)
{ i1cny[ielemz]=i2cfy[ihz][(i1eccy[ielemz])];
i2cfy[ihz][(i1eccy[ielemz])]=ielemz;
ielemz=i1cnz[ielemz];
}}
Listing 10.30 Elements from a new z-list are loaded onto y-lists.
sets of y-lists are used: the first set i2cfy[0] contains all lists for discrete elements from the
central layer iz; the second set i2cfy[1] contains all y-lists containing all discrete elements
from the layer iz-1.
All y-lists are, at this stage, considered to be ‘new y-lists’. Some of these y-lists are
empty, thus a search for non-empty y-lists is performed, as shown in Listing 10.31. This
is done by considering all discrete elements from iz-list, i.e. all discrete elements from the
central layer of cells. First, a discrete element is therefore the head of this list i1heaz[0],
which in Listing 10.29 was set to i1heaz[0]=i1cfz[iz]. Once a ‘new’ iy-list is found, row
iy is called the central row, and the y-list corresponding to it is marked as ‘old’ by setting
i2cfy[0][iy]=i2cfy[0][iy]+nelemd. The head of the y-list representing the central row is
stored as i1heay[0], while the heads of y-lists representing neighbouring rows are stored
as i1heay[1], i1heay[2], i1heay[3] and i1heay[4].
All discrete elements from the central row iy are loaded onto x-lists, as shown
in Listing 10.32. This is done by looping over discrete elements from the y-lists

