Skip to main content
. 2022 Jul 6;15(14):4733. doi: 10.3390/ma15144733
Algorithm 2 Compactness algorithm
fork in [0, Kmax−1]
  for j in [0, Jmax−1]
    for i in [0, Imax−1]
      xboundary = max (x|x is the x coordinate of points on the particles at M [i−1,j,k])
      yboundary = max (y|y is the y coordinate of points on the particles at M [i,jn,k],
           where jn in [jnneighbor, j+nneighbor])
      zboundary = max (z|z is the z coordinate of points on the particles at M [i,jn,kn],
           where jn in [jnneighbor, j+nneighbor] and kn in [knneighbor, k+nneighbor]
   Assume:
     Plane Px parallel to the yz-plane intersects the x-axis at xboundary.
     Plane Py parallel to the xz-plane intersects the y-axis at yboundary.
     Plane Pz parallel to the xy-plane intersects the z-axis at zboundary.
       dx = distance between M [i,j,k] and Px
       dy = distance between M [i,j,k] and Py
       dz = distance between M [i,j,k] and Pz
        while max (dx, dy, dz) ⩾ ρ
          if dx = max (dx, dy, dz)
            subtract dx/3 from the x coordinate of M [i,j,k]
          else if dy = max (dx, dy, dz)
            subtract dy/3 from the y coordinate of M [i,j,k]
          else dz = max (dx, dy, dz)
            subtract dz/3 from the z coordinate of M [i,j,k]
          Recalculate dx,dy,dz
          if loop has executed more than 1000 times:
          Report exception and quit