Page 316 - The Combined Finite-Discrete Element Method
P. 316

POTENTIAL CONTACT FORCE IN 3D      299

            .............continued from previous listing..............
                /* distances of C-points from S edges */
            niners=0; ninerc=0;
            for(i=0;i<nspoin;i++)
            { inext=i+1;
             if(inext>=nspoin)inext=0;
             for(j=0;j<3;j++)
             { jnext=j+1;
              if(jnext>2)jnext=0;
              dcs[j][i]=(uc[jnext]-uc[j])*(vs[i]-vc[j])-
                   (vc[jnext]-vc[j])*(us[i]-uc[j]);
              dsc[i][j]=(us[inext]-us[i])*(vc[j]-vs[i])-
                   (vs[inext]-vs[i])*(uc[j]-us[i]);
              if(dsc[i][j]>=R0)
              { innerc[j]=innerc[j]+1;
               if(innerc[j]==nspoin)ninerc=ninerc+1;
              }
              if(dcs[j][i]>=R0)
              { inners[i]=inners[i]+1;
               if(inners[i]==3)niners=niners+1;
            }} }
               .............continued in the next listing...........

           Listing 10.12 Distance dcs[j][i] from the edges of a C-triangle to S-points (nodes of S-polygon);
           and distance dsc[i][j] from the edges of an S-polygon to C-points (edges of C-triangle).


             The intersection between the C-triangle and S-polygon is called a B-polygon. A B-
           polygon is the area through which the current target sub-tetrahedron is interacting with
           the current surface of the current contactor tetrahedron. The nodes of the B-polygon
           polygon are called B-points.
             Three sceanarios are possible:

           • C-triangle is inside the S-polygon, as shown in Listing 10.13.
           • S-polygon is inside the C-triangle (Listing 10.14).
           • General case of polygon-triangle intersection (Listing 10.15).
             A general case of polygon-triangle intersection is illustrated in Figure 10.2, where both
           S and B points are shown. In the example shown in the figure, S-points form a triangle.


            .............continued from previous listing..............
               /* distances of C-points from S edges */
             /* B-points */
            if(ninerc==3) /* triangle inside polygon  */
            { nbpoin=3;
             for(i=0;i<nbpoin;i++)
             { ub[i]=uc[i]; vb[i]=vc[i];
            }}
            ...........continued in the next listing...........
                 Listing 10.13  Calculation of B-points when the C-triangle is inside an S-polygon.
   311   312   313   314   315   316   317   318   319   320   321