title filter by Trent Eggleston
c
c Requires the file 'mkhole' to be in
c the same directory where TrueGrid is run.
c

para

c USER SPECIFIABLE PARAMETERS
   width   3                             c approximate width of a single cell
   blkang  5                             c angle of rotation between wafers
   nofblk  4                             c number of holes per wafer
   xang    1                             c angle of rotation of cylindrical hole
   yang    1                             c secondary angle of rotation of hole
   density 1                             c mesh density parameter
   extra   1                             c extra nodes around each hole

c THE NEXT PARAMETERS ARE INTERNAL
   ascl    [%blkang/%width]
   xcent   [0.5*%width]
   ycent   [0.5*%nofblk*%width]
   zcent   [0.5*%nofblk*%width]
   iblk    1
   nofsrf  4
   i       1;

c MAKE THE MESH
block 
c I-LIST
      1 [1+%density] [1+2*%density+%extra] [1+3*%density+%extra];
c J-LIST
      1 [1+%density           ] [1+2*%density+  %extra]
        [1+3*%density+  %extra] [1+4*%density+2*%extra]
        [1+5*%density+2*%extra] [1+6*%density+3*%extra]
        [1+7*%density+3*%extra] [1+8*%density+4*%extra]
    c add another line here for more holes
        [1+(2*%nofblk+1)*%density+%nofblk*%extra];
c K-LIST
      1 [1+(2*%nofblk+1)*%density+%nofblk*%extra];
c X-LIST
      0 [         %width/4] [         3*%width/4] [  %width];
c Y-LIST
      0 [         %width/4] [         3*%width/4]
        [  %width+%width/4] [  %width+3*%width/4]
        [2*%width+%width/4] [2*%width+3*%width/4]
        [3*%width+%width/4] [3*%width+3*%width/4]
    c add another line here for more holes
        [%nofblk*%width];
c Z-LIST
      0 [%nofblk*%width];

c CYLINDRICAL OUTER BOUNDARY, and CAP ENDS
sd 1 cyli %xcent %ycent %zcent 1 0 0 [0.5*%nofblk*%width*sqrt(2)]
sd 2 plan 0 0 0 1 0 0
sd 3 plan %width 0 0 1 0 0

c MAKE THE HOLES
dei 2 3; 2 3 0 4 5 0 6 7 0 8 9;;

c MAKE SURE NODES ARE EVENLY SPACE AROUND THE CYLINDER
c SO THAT WAFERS WILL MERGE PROPERLY
res 1 1 1 1 1 2 k 1
res 4 1 1 4 1 2 k 1
res 4 [%nofblk*2+2] 1 4 [%nofblk*2+2] 2 k 1
res 1 [%nofblk*2+2] 1 1 [%nofblk*2+2] 2 k 1
res 1 1 1 1 [%nofblk*2+2] 1 j 1
res 1 1 2 1 [%nofblk*2+2] 2 j 1
res 4 1 2 4 [%nofblk*2+2] 2 j 1
res 4 1 1 4 [%nofblk*2+2] 1 j 1

c PROJECT TO THE OUTER SURFACES
sfi ;-1 [-(2*%nofblk+2)];-1 -2;sd 1
sfi -1;;;sd 2
sfi -4;;;sd 3

c RELAX TO INSURE SMOOTHNESS OF ENDS OF WAFER AS WELL AS SYMMETRY
relaxi -1 0 -4;;;200 0 1

c TWIST THE MESH
y=(y-%ycent)*cos((x-%xcent)*%ascl)-(z-%zcent)*sin((x-%xcent)*%ascl)+%ycent
z=(y-%ycent)*sin((x-%xcent)*%ascl)+(z-%zcent)*cos((x-%xcent)*%ascl)+%zcent

c MAKE THE HOLES
INCLUDE mkhole
para i 2;
INCLUDE mkhole
para i 3;
INCLUDE mkhole
para i 4;
INCLUDE mkhole

c DUPLICATE THE PARTS
lct 3
    mx [%width] 
      v 0 [-%ycent] [-%zcent] 
      rx [90+%blkang] 
      v 0 %ycent %zcent;
    mx [2*%width] 
      v 0 [-%ycent] [-%zcent] 
      rx [2*%blkang] 
      v 0 %ycent %zcent;
    mx [3*%width] 
      v 0 [-%ycent] [-%zcent] 
      rx [90+3*%blkang] 
      v 0 %ycent %zcent;

lrep 0 1 2 3;

endpart merge

c MERGE THE REDUNDANT NODES BETWEEN WAFERS
stp 0.1
