38 1 X ,II_STOK, CAND_B ,CAND_E ,ITASK,
39 2 NBRIC ,ITAB , BUFBRIC ,NCAND,
59#include "implicit_f.inc"
76 INTEGER CAND_B(NCAND),CAND_E(NCAND), NCAND, NIN,
77 . ITASK, NBRIC, ITAB(*),
78 . BUFBRIC(NBRIC), IXS(NIXS,*), II_STOK
83 INTEGER NB_NCN,NB_NCN1,NB_ECN,I,J,K,L,DIR,NB_NC,NB_EC,
84 . N1,N2,N3,N4,NN,NE,NCAND_PROV,J_STOK,II,JJ,TT,
85 . NSNF, NSNL, TANGENT(12),
86 . prov_b(2*mvsiz), prov_e(2*mvsiz), last_ne,
87 . voxbnd(2*mvsiz,0:1,1:3)
90 . dx,dy,dz,xs,ys,zs,xx,sx,sy,sz,s2,
91 . xmin, xmax,ymin,
ymax,zmin, zmax, tz, gapsmx, gapl,
92 . d1x,d1y,d1z,d2x,d2y,d2z,dd1,dd2,d2,a2,gs, point(3),point2(3),d_1,d_2,d_3,
95 INTEGER IX,IY,IZ,NEXT,M(8),
96 . IX1,IY1,IZ1,IX2,IY2,IZ2,IBUG,IBUG2,I_LOC,
97 . BIX1(NBRIC),BIY1(NBRIC),BIZ1(NBRIC),
98 . bix2(nbric),biy2(nbric),biz2(nbric),
99 . first_add, prev_add, lchain_add, i_stok , idb_id
101 INTEGER,
DIMENSION(1) :: SHELL_ADD
103 INTEGER :: NC, I_STOK_BAK, IPA,IPB
105 . xminb,yminb,zminb,xmaxb,ymaxb,zmaxb,
107 . aaa, basisconst2,ns,
108 . power(8), cutcoor,cutcoor2,cut(2),
109 . pow(2), old_cutcoor, old_cutshell, cutnode(2)
113 LOGICAL,
DIMENSION(NBRIC) :: COUNT
115 LOGICAL :: BOOL(NIRECT_L)
116 INTEGER NBCUT, NBCUT2,DEJA, ISONSHELL, ISONSH3N
117 INTEGER :: COUNTER, NEDGE, NFACE, NODES8(8), COUNTER_BRICK(NBRIC)
119 INTEGER :: iN(2), iN1a, iN2a, iN1b, iN2b , iN3, iN4
120 INTEGER :: POS, IAD, IADE, IB ,IBG , NBF, NBL
121 INTEGER :: I_12bits, nbits, npqts, pqts(4), SOM, SECTION
122 INTEGER :: I_bits(12), MAX_ADD, IMIN_LOC, IMAX_LOC
124 my_real :: aeradiag, debugtab(24*ncand,3)
125 LOGICAL db_FLAG, TAGnode(8), debug_outp
127 CHARACTER*12 :: sectype
128 CHARACTER*12 ::filename
131 CHARACTER(LEN=1) filenum
134 . min_ix_loc, min_iy_loc, min_iz_loc, !indice voxel
min used
135 . max_ix_loc, max_iy_loc, max_iz_loc
139 my_real,
dimension(:),
allocatable :: POWB
141 INTEGER :: A(5), IE, N_CUT_EDGE
143 INTEGER :: TAG_INDEX(NBRIC), I8(8,NBRIC),IFLG_DB
144 my_real :: r8(8,nbric), denom,
norm, tolcrit,tol
149 a(1:5)=((/1,2,3,4,1/))
179 nbf = 1+itask*
nb/nthread
180 nbl = (itask+1)*
nb/nthread
207 if(itask==0.AND.debug_outp)
then
209 print *,
"================================="
210 print *,
"==== BRICK INTERSECTIONS ====="
211 print *,
"================================="
215 nbf = 1+itask*
nb/nthread
216 nbl = (itask+1)*
nb/nthread
221 ALLOCATE(basisconst(
ncande,4))
256 if(itask==0 .AND. debug_outp)print *,
""
270 nbf = 1+itask*
ncande/nthread
271 nbl = (itask+1)*
ncande/nthread
275 m(3:4)=irect_l(3:4,ne)
285 ptz(i,1)=fourth*sum( irect_l( 05:08,ne) )
286 ptz(i,2)=fourth*sum( irect_l( 09:12,ne) )
287 ptz(i,3)=fourth*sum( irect_l( 13:16,ne) )
290 ptz(i,1)=irect_l(08,ne)
291 ptz(i,2)=irect_l(12,ne)
292 ptz(i,3)=irect_l(16,ne)
299 pta(i,1:3,tt) = irect_l((/4,8,12/)+ipa,ne)
300 vza(i,1:3,tt) = irect_l((/4,8,12/)+ipa,ne)-ptz(i,1:3)
301 vzb(i,1:3,tt) = irect_l((/4,8,12/)+ipb,ne)-ptz(i,1:3)
302 vne(i,1:3,tt) = vza(i,(/2,3,1/),tt)*vzb(i,(/3,1,2/),tt) -
303 . vza(i,(/3,1,2/),tt)*vzb(i,(/2,3,1/),tt)
305 norm = vne(i,1,tt)*vne(i,1,tt)+vne(i,2,tt)*vne(i,2,tt)+vne(i,3,tt)*vne(i,3,tt)
308 vne(i,1,tt) = vne(i,1,tt) /
norm
309 vne(i,2,tt) = vne(i,2,tt) /
norm
310 vne(i,3,tt) = vne(i,3,tt) /
norm
312 basisconst(i,tt) = sum(ptz(i,1:3)*vne(i,1:3,tt))
325 if(itask==0 .AND. debug_outp)
then
326 print *,
" Calcul des Intersections sur Proc=", itask+1
330 nbf = 1+itask*
ncandb/nthread
331 nbl = (itask+1)*
ncandb/nthread
347 print *,
"idb_ID====="
348 print *,
"CAND_E =", cand_e(
iadf(i):
iadl(i))
370 power(1:8)=(/(sum(vne(iade,1:3,tt) * x(1:3,ixs(ii,ibg)))- basisconst(iade,tt),ii=2,9)/)
381 print *,
"J=", j, itab(in(1:2))
382 write(*,fmt=
'(A,4I20)')
"shell N1-N2-N3 :",int(irect_l(01:04,ie))
383 write(*,fmt=
'(A,3F20.12)') " shell n1 :
",IRECT_L( (/05,09,13/),IE)
384 write(*,FMT='(A,3F20.12)') " shell n2 :
",IRECT_L( (/06,10,14/),IE)
385 write(*,FMT='(A,3F20.12)') " shell n3 :
",IRECT_L( (/07,11,15/),IE)
386 write(*,FMT='(A,2F40.20)')" pow(1:2)=
", POW(1:2)
389 !(2 intersection points : if edge is on the plane)
390 if (ixs(11,brick_list(nin,i)%id)==idb_ID )then
391 print *, "idb_id=====
"
392 write(*,FMT='(A,4I20)') "shell n1-n2-n3-n4 :
",INT(IRECT_L(01:04,IE))
396 print *, "pow1,pow2
", POW(1:2)
398.AND.
!if (ixs(11,brick_list(nin,i)%id)==5882 J==12)then
399 ! print *, "5882=====
"
400 ! write(*,FMT='(A,4I20)') "shell n1-n2-n3-n4 :
",INT(IRECT_L(01:04,IE))
401 ! print *, "ie =
", IE
402 ! print *, "tt =
", TT
404 ! print *, "pow1,pow2
", POW(1:2)
408 TOL = (ONE+EM04)*TOLCRIT*diag22(I) !EM04 in ISONSH3N
409 ! POWER is in mm corresponds to the shifted distance of the intercept (ordonnee a lorigine) it must be normalized
410.AND.
IF((ABS(POW(1))<=TOL)(ABS(POW(2))<=TOL))THEN !edge is on the shell then no intersection with the face
412 !print *, "tangent=1
",ixs(11,brick_list(nin,i)%id)
415 IF(DEJA==2)CYCLE !hypothesis: 2 intersections max. Warning possible dpedency of elem numbering
416.AND..OR..AND.
IF( ((POW(1)<-TOL)(POW(2)>TOL)) ((POW(1)>TOL)(POW(2)<-TOL)) )THEN !intersection with current shell
417 ON1(1:3) = X(1:3,iN(1))
418 N1N2(1:3)= EDGE_LIST(NIN,K)%VECTOR(1:3)
419 DENOM = SUM( vNE(IADE,1:3,TT) * N1N2(1:3) )
420 IF(ABS(DENOM)>EM12)THEN
421 CUTCOOR = ( BasisCONST(IADE,TT) - SUM( vNE(IADE,1:3,TT) * ON1(1:3) ) ) / DENOM !N.N1 change all 3 cycles (possible optimization, cf definition of iedge)
423 !in this case edge is intersected with a plane which is quasi tangent. possibly infinite solutions. We choose cutcoor=0.5, error related to this description is neglictible
428.AND.
IF((CUTCOOR<=ONE+TOL)(CUTCOOR>=-TOL))THEN !check if intersection point is one on the shell
429 CUTCOOR = MIN(ONE-EM06,CUTCOOR)
430 CUTCOOR = MAX(EM06 ,CUTCOOR)
431 POINT(1:3)=ON1(1:3) + CUTCOOR * N1N2(1:3)
433 print *, " cutcoor =
", CUTCOOR
438.AND.
ELSEIF((ABS(POW(1))<=TOL)(ABS(POW(2))<=TOL))THEN !edge is on the shell then no intersection with the face
439 !DON'T CUT EDGE WHICH IS LAYING ON THE CUT PLANE. ITS ADJACENT EDGES WILL BE CUT.
440 ! specific case : edge is on the structural face
441.OR..OR..OR.
!IF(J==1 J==5 J==8 J==12)THEN
442 ! ON1(1:3) = X(1:3,iN(1))
443 ! N1N2(1:3)= EDGE_LIST(NIN,K)%VECTOR(1:3)
444 ! CUTCOOR = ONE-EM06 !intserection on edge nodes1,5,8 ou 12 (necessary case to get a corresponding topology without risking to loose the lagrangian surface while it moves)
449 !-!ON1(1:3) = X(1:3,iN(1))
450 !-!N1N2(1:3)= EDGE_LIST(NIN,K)%VECTOR(1:3)
452 !-!POINT(1:3) = ON1(1:3) + CUTCOOR * N1N2(1:3)
456 ELSEIF (ABS(POW(1))<=TOL)THEN !intersection with summit #1
457 !SET CUTCOOR = EM06 TO HAVE A EPSILON CUT SURFACE. OTHERWISE CRITERIA FOR AMBIGUS COMBINATION WILL GET A DIVISION BY 0 (double penta check in i22subvol)
458.OR..OR..OR.
!IF(J==1 J==5 J==8 J==12)THEN
459 ON1(1:3) = X(1:3,iN(1))
460 N1N2(1:3)= EDGE_LIST(NIN,K)%VECTOR(1:3)
461 CUTCOOR = EM06 !intserection on edge nodes 1,5,8 ou 12 (necessary case to get a corresponding topology without risking to loose the lagrangian surface while it moves)
462 POINT(1:3) = ON1(1:3) + ZERO * N1N2(1:3)
468! IF(TAGnode(iEDGE(1,J))==.FALSE.)THEN
469! POINT(1:3)=X(1:3,iN(1))
471! TAGnode(iEDGE(1,J))=.TRUE.
476 ELSEIF (ABS(POW(2))<=TOL)THEN !intersection with summit #2
477 !SET CUTCOOR = ONE-EM06 TO HAVE A EPSILON CUT SURFACE. OTHERWISE CRITERIA FOR AMBIGUS COMBINATION WILL GET A DIVISION BY 0 (double penta check in i22subvol)
478.OR..OR..OR.
!IF(J==1 J==5 J==8 J==12)THEN
479 ON1(1:3) = X(1:3,iN(1))
480 N1N2(1:3)= EDGE_LIST(NIN,K)%VECTOR(1:3)
481 CUTCOOR = ONE-EM06 !intserection with edge nodes 1,5,8 ou 12 (necessary case to get a corresponding topology without risking to loose the lagrangian surface while it moves)
482 POINT(1:3) = ON1(1:3) + ONE * N1N2(1:3)
488! IF(TAGnode(iEDGE(2,J))==.FALSE.)THEN
489! POINT(1:3)=X(1:3,iN(2))
491! TAGnode(iEDGE(2,J))=.TRUE.
496 ELSE !2 nodes of the edges are on the same side of the intersection plane
501 if (ixs(11,brick_list(nin,i)%id)==idb_ID )then
502 print *, "cutcoor=
", cutcoor
508 IF(NBCUT==-1) NBCUT =ISONSH3N( ptZ(IADE,1:3),ptA(IADE,1:3,TT),vZA(IADE,1:3,TT),vZB(IADE,1:3,TT),POINT(1:3) ,IFLG_DB) ! verifie si POINT(:) appartient au triangle
509 IF(NBCUT2==-1)NBCUT2=ISONSH3N( ptZ(IADE,1:3),ptA(IADE,1:3,TT),vZA(IADE,1:3,TT),vZB(IADE,1:3,TT),POINT2(1:3),IFLG_DB) ! verifie si POINT(:) appartient au triangle
511 if (ixs(11,brick_list(nin,i)%id)==idb_ID )then
512 print *, "nbcut, nbcut2=
", NBCUT,NBCUT2
515 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
516 !If intersection with infinite plane, we calculate coordinates on the edge : COOR = N1+ t N1N2
517 ! if t is not within [0,1] we are not on the segment but on the open entity (N1N2)\[N1N2]
518 IF(NBCUT>0) THEN !if we detect intersection on current shell
519 IF(DEJA==0)THEN !edge is not yet cut : first intersection detected
520 !print *, "nouveau point
", CUTCOOR
522 EDGE_LIST(NIN,K)%CUTCOOR(1) = CUTCOOR ! storage
523 EDGE_LIST(NIN,K)%CUTSHELL(1) = IE
524 ELSEIF (DEJA==1)THEN ! already cut => 2nd intersection
525 OLD_CUTCOOR = EDGE_LIST(NIN,K)%CUTCOOR(1) ! first store, the ordering the 2 intersections
526 OLD_CUTSHELL = EDGE_LIST(NIN,K)%CUTSHELL(1)
527 IF (ABS(CUTCOOR-OLD_CUTCOOR)>EM6) THEN
529 IF(CUTCOOR>OLD_CUTCOOR)THEN
530 EDGE_LIST(NIN,K)%CUTCOOR(1) = OLD_CUTCOOR
531 EDGE_LIST(NIN,K)%CUTCOOR(2) = CUTCOOR
532 EDGE_LIST(NIN,K)%CUTSHELL(1) = OLD_CUTSHELL
533 EDGE_LIST(NIN,K)%CUTSHELL(2) = IE
534 !print *, "second points point
",OLD_CUTCOOR,CUTCOOR
535 ELSEIF(CUTCOOR<OLD_CUTCOOR)THEN
536 EDGE_LIST(NIN,K)%CUTCOOR(1) = CUTCOOR
537 EDGE_LIST(NIN,K)%CUTCOOR(2) = OLD_CUTCOOR
538 EDGE_LIST(NIN,K)%CUTSHELL(1) = IE
539 EDGE_LIST(NIN,K)%CUTSHELL(2) = OLD_CUTSHELL
540 !print *, "second points point
",CUTCOOR,OLD_CUTCOOR
542 !print *, "point
", CUTCOOR
543 NBCUT=1 ! le point est le meme, inutile de l'enregistrer.
546 ELSEIF(DEJA==2)THEN ! already 2 intersections, no more expected (hypothesis)
547.AND.
if(itask==0 debug_outp)then
548.or.
if(ibug22_intersect==-1 ibug22_intersect==ixs(11,brick_list(nin,i)%id))then
549 print *, "three intersection
"
554 EDGE_LIST(NIN,K)%NBCUT = NBCUT
555 EDGE_LIST(NIN,K)%LEN = SQRT(N1N2(1)*N1N2(1)+N1N2(2)*N1N2(2)+N1N2(3)*N1N2(3))
558.AND.
IF(NBCUT2>0 DEJA==0)THEN !if already intersected
560 EDGE_LIST(NIN,K)%CUTCOOR(1)=ZERO ! storage
561 EDGE_LIST(NIN,K)%CUTCOOR(2)=ONE ! storage
562.AND.
if(itask==0 debug_outp)then
563.or.
if(ibug22_intersect==-1 ibug22_intersect==ixs(11,brick_list(nin,i)%id))then
564 print *, "edge fully on intersection plane
",J
567 EDGE_LIST(NIN,K)%CUTSHELL(1) = IE
568 EDGE_LIST(NIN,K)%CUTSHELL(2) = IE
569 EDGE_LIST(NIN,K)%NBCUT = 2
572 END DO !next J=1,12 // next edge
573 END DO !next TT=1,NbSubTriangles // next sub triangles
574 END DO !next IAD=IADF(I),IADL(I)
576 if (ixs(11,brick_list(nin,i)%id)==idb_ID )print *, "tangent 1-12=
", TANGENT(1:12)
579 IF(TANGENT(J)==1)THEN
581 NBCUT = EDGE_LIST(NIN,K)%NBCUT
583 ! EDGE_LIST(NIN,K)%CUTSHELL(1) = 0
584 ! EDGE_LIST(NIN,K)%CUTSHELL(2) = 0
585 ! EDGE_LIST(NIN,K)%NBCUT = 0
586 ! EDGE_LIST(NIN,K)%CUTCOOR(1) = 0
587 ! EDGE_LIST(NIN,K)%CUTCOOR(2) = 0
588 !ELSEIF(NBCUT==1)THEN
590 ! +-------------+ +-------------+
593 ! | o-----------------1----o dble -> O O
596 ! +-|-----------+ +-O-----------+
599 ! face1 cuts edge within tolerance, intersection point must be doubled to get PENTA HEXA, otherwise, max(secID) = HEXA
601 !cleaning if cutcoor = EM06 ou CUTCOOR = ONE-EM06 (CASE : lagrangian face == euler face => HEXA cutting)
603 CUTCOOR = EDGE_LIST(NIN,K)%CUTCOOR(1)
604.OR.
IF(CUTCOOR==EM06 CUTCOOR==ONE-EM06)THEN
605 EDGE_LIST(NIN,K)%CUTSHELL(1) = EDGE_LIST(NIN,K)%CUTSHELL(2)
606 EDGE_LIST(NIN,K)%NBCUT = MAX(0,EDGE_LIST(NIN,K)%NBCUT-1)
607 EDGE_LIST(NIN,K)%CUTCOOR(1) = EDGE_LIST(NIN,K)%CUTCOOR(2)
608 NBCUT = EDGE_LIST(NIN,K)%NBCUT
610 EDGE_LIST(NIN,K)%CUTSHELL(2) = 0
611 EDGE_LIST(NIN,K)%CUTCOOR(2) = ZERO
616 NBCUT = EDGE_LIST(NIN,K)%NBCUT
617 CUTCOOR = EDGE_LIST(NIN,K)%CUTCOOR(1)
618.AND..AND.
IF(NBCUT==1 CUTCOOR>EM06 CUTCOOR<ONE-EM06)THEN
619 EDGE_LIST(NIN,K)%CUTSHELL(2) = EDGE_LIST(NIN,K)%CUTSHELL(1)
620 EDGE_LIST(NIN,K)%NBCUT = 2
621 EDGE_LIST(NIN,K)%CUTCOOR(2) = EDGE_LIST(NIN,K)%CUTCOOR(1)
628 END DO !next I=NBF,NBL
635 CALL MY_BARRIER !wait for all nodes to be computed
637.AND.
if(ITASK==0 IBUG22_OUTP_IntPoint==1)THEN
640 print *, " ===== intersection_nodes.txt
"
643 filename(1:12) = "cut_nod0.txt
"
644 write(filename(8:8),'(i1.1)')ISPMD+1
646 open( unit=IPA, file = filename(1:12) )
652.or..or.
if(ibug22_intersect==ixs(11,brick_list(nin,i)%id) ibug22_intersect==-1 IBUG22_OUTP_IntPoint == 1)then
653 write (unit=IPA,fmt='(A,I10)') "cell
id =
", ixs(11,brick_list(nin,i)%id)
654 write (* ,fmt='(A,I10)') "cell
id =
", ixs(11,brick_list(nin,i)%id)
658 NBCUT = EDGE_LIST(NIN,IAD)%NBCUT
659 CUT(1:2) = EDGE_LIST(NIN,IAD)%CUTCOOR(1:2)
660 iN(1:2) = EDGE_LIST(NIN,IAD)%NODE(1:2)
661 N1N2(1:3) = EDGE_LIST(NIN,IAD)%VECTOR(1:3)
662 ON1(1:3) = X(1:3,iN(1))
664 !intersection coordinates
665 POINT(1:3)= ON1(1:3) + CUT(K) * N1N2(1:3)
666 ! EDGE_LIST(NIN,IAD)%CUTPOINT(1:3) = POINT(1:3)
668.or..or.
if(ibug22_intersect==ixs(11,brick_list(nin,i)%id) ibug22_intersect==-1 IBUG22_OUTP_IntPoint == 1)then
670 . fmt='(A12,F20.14,A1,F20.14,A1,F20.14,A13)')"*createnode
",POINT(1) ," ", POINT(2)," ",POINT(3)," 0 0 0
"
672 . fmt='(A12,F20.14,A1,F20.14,A1,F20.14,A13)')"*createnode
",POINT(1) ," ", POINT(2)," ",POINT(3)," 0 0 0
"
679 if(SUM(ABS(point(1:3)-debugTab(L,1:3)))<EM06)
685 debugTab(som,1:3) =point(1:3)
688 END DO ! (DO K=1,NBCUT <=> NBCUT>0)
699! print *, " |
WRITE : script
"
700! print *, " |-------------------------------|
"
701! print *, SOM , "nodes written
"
703! print *, debugTAB(L,1:3)
716 print *, " | edges |
"
717 print *, " |-------------------------------|
"
718 print *, 12*NB , " edges(12*nbric)
"
719 DO I=1, NB ! 1,NB fractionne sur les differents threads
720.and.
if(ibug22_intersect/=-1 ibug22_intersect/=ixs(11,brick_list(nin,i)%id))cycle
721 print *, " ** cell **
", IXS(11,BRICK_LIST(NIN,I)%ID)
724 IF( EDGE_LIST(NIN,K)%NBCUT==0)THEN
725 WRITE(*,FMT='(A10,I10,A1,I12,I12,A8)') " edge
",K,":
",
726 . ITAB(EDGE_LIST(NIN,K)%NODE(1)),
727 . ITAB(EDGE_LIST(NIN,K)%NODE(2))," "
728 ELSEIF( EDGE_LIST(NIN,K)%NBCUT==1)THEN
729 WRITE(*,FMT='(A10,I10,A1,I12,I12,A8,1F30.16)') " edge
",K,":
",
730 . ITAB(EDGE_LIST(NIN,K)%NODE(1)),
731 . ITAB(EDGE_LIST(NIN,K)%NODE(2))," cutted :
" ,EDGE_LIST(NIN,K)%CUTCOOR(1)
733 WRITE(*,FMT='(A10,I10,A1,I12,I12,A8,2F30.16)') " edge
",K,":
",
734 . ITAB(EDGE_LIST(NIN,K)%NODE(1)),
735 . ITAB(EDGE_LIST(NIN,K)%NODE(2))," 2cutted :
" ,EDGE_LIST(NIN,K)%CUTCOOR(1:2)
749 DEALLOCATE(BasisCONST)
750 DEALLOCATE(NbSubTriangles)