TrueGrid logo

A Mesh Generator and Pre-Processor for
FEA and CFD Analysis

Command File for If Statement Hole Example

c Define Parameters
para
del .5 c element size
r 3 c hole of radius
xc 16 c x coordinates of hole center
yc 7 c y coordinates of hole center

x1 0
x2 [%xc-%r*.707]
x3 [%xc+%r*.707]
x4 20
y1 0
y2 [%yc-%r*.707]
y3 [%yc-%r*.707]
y4 10
;

c Hole Beyond Top
if ((%yc+%r+%del).gt.%y4)then
 para
  r [%y4-%yc-%del]
  x2 [%xc-%r*.707]
  x3 [%xc+%r*.707]
  y2 [%yc-%r*.707]
  y3 [%yc+%r*.707];

c Hole Beyond Bottom
 elseif ((%yc-%del-%r).lt.%y1)then
  para
   r [%yc-%y1-%del]
   x2 [%xc-%r*.707]
   x3 [%xc+%r*.707]
   y2 [%yc-%r*.707]
   y3 [%yc+%r*.707];
endif

para
i1 1
i2 [nint(%i1+(%x2-%x1)/%del)]
i3 [nint(%i2+(%x3-%x2)/%del)]
i4 [nint(%i3+(%x4-%x3)/%del)]
j1 1
j2 [nint(%j1+(%y2-%y1)/%del)]
j3 [nint(%j2+(%y3-%y2)/%del)]
j4 [nint(%j3+(%y4-%y3)/%del)];

sd 1 cy %xc %yc 0 0 0 1 %r

block
%i1 %i2 %i3 %i4;
%j1 %j2 %j3 %j4;
-1;
%x1 %x2 %x3 %x4;
%y1 %y2 %y3 %y4;
0
dei 2 3;2 3;-1;
sfi -2 -3;-2 -3;-1;sd 1
res 1 1 1 1 4 1 j 1
res 4 1 1 4 4 1 j 1
relaxi 1 4;1 4;-1; 10 0 1
mate 1 
endpart  
merge