Page 315 - The Combined Finite-Discrete Element Method
P. 315
298 ALGORITHM IMPLEMENTATION
.............continued from previous listing..............
/* u,v coordinates of S-points and C-points */
nspoin=0;
for(i=0;i<3;i++)
{ for(j=0;j<2;j++)
{ inext=i+1;
if(inext>2)inext=0;
if(j==0)inext=3;
if(((dct[i]>R0)&&(dct[inext]<R0))||
((dct[i]<R0)&&(dct[inext]>R0)))
{ factor=ABS(dct[i]-dct[inext]);
if(factor>EPSILON)
{ factor=ABS(dct[i]/factor);
us[nspoin]=factor*ut[inext]+(R1-factor)*ut[i];
vs[nspoin]=factor*vt[inext]+(R1-factor)*vt[i];
inners[nspoin]=0;
nspoin=nspoin+1;
} }}}
if((nspoin<3)||(nspoin>4))continue;
.............. continued in the next listing...........
Listing 10.10 Distances and local coordinates of the nodes of the target sub-tetrahedron.
.............continued from previous listing..............
/* u,v coordinates of S-points and C-points */
/* check ordering of S-points */
if(((us[1]-us[0])*(vs[2]-vs[0])-(vs[1]-vs[0])*(us[2]-us[0]))<R0)
{ i=0;
j=nspoin-1;
while(i<j)
{ k=inners[i]; inners[i]=inners[j]; inners[j]=k;
tmp=us[i]; us[i]=us[j]; us[j]=tmp;
tmp=vs[i]; vs[i]=vs[j]; vs[j]=tmp;
i++; j--;
}}
for(i=0;i<3;i++)
{ V3DDot(uc[i],xc[i],yc[i],zc[i],xe[0],ye[0],ze[0]);
V3DDot(vc[i],xc[i],yc[i],zc[i],xe[1],ye[1],ze[1]);
innerc[i]=0;
}
.............continued in the next listing...........
Listing 10.11 Ordering of S-points and calculation of C-points.