80 likes | 173 Views
CHAPTER 3 Reuse of Commands & Branching. Repeating a Command. *REPEAT, NTOT, VINC1, VINC2, …, VINC11 NTOT : Number of times the preceding command is executed (including the initial execution). Must be 2 or greater. NTOT of 2 causes one repeat (for a total of 2 executions).
E N D
CHAPTER 3 Reuse of Commands & Branching Written by Changhyun, SON
Repeating a Command *REPEAT, NTOT, VINC1, VINC2, …, VINC11 NTOT : Number of times the preceding command is executed (including the initial execution). Must be 2 or greater. NTOT of 2 causes one repeat (for a total of 2 executions). VINC1, VINC2, ..., VINC11 : Value increments applied to first through eleventh data fields of the preceding command E,1,2,3,4 *REPEAT,4,1,10,1,20 Written by Changhyun, SON
Do-loops *DO,Par,IVAL,FVAL,INC . . . . . . *ENDDO Do-loops can be input interactively and can also be nested up to ten levels deeps. *DIM,XX2ANDX3,,10,3 *DO,ROW,1,10,1 *DO,COL,1,3,1 XX2ANDX3(ROW,COL)=ROW**COL *ENDDO *ENDDO Written by Changhyun, SON
IF-THEN-ELSE Constructs *IF, VAL1, Oper, VAL2, Base . . . . . . *ELSEIF, VAL3, Oper, VAL4 . . . . . . *ELSE . . . . . . *ENDIF Oper : LT, LE, EQ, GE, GT Base : THEN, CYCLE, EXIT, STOP, :Label IF-THEN-ELSE constructs can be nested up to 10 levels deep. Written by Changhyun, SON
Loop ControlBase Option IF-THEN-ELSE Construct THEN - Signifies that this is the beginning of an IF-THEN-ELSE construct CYCLE - Used only inside a do-loop; equivalent to a conditional *CYCLE command EXIT - Used only inside a do-loop; equivalent to a conditional *EXIT command STOP - Immediately stop and exit the ANSYS program :Label - Read the next command from the line following this user defined label (8 characters maximum) Written by Changhyun, SON
Abbreviation *ABBR,Abbr,String *ABBR,NNON,/PNUM,NODE,ON *ABBR,NNOFF,/PNUM,NODE,OFF *ABBR,ENON,/PNUM,ELEM,ON *ABBR,ENOFF,/PNUM,ELEM,OFF . . . NNON NPLOT NNOFF Written by Changhyun, SON
Start FORCE PRESSURE PRESSURE > 20 FORCE > 100 FORCE < 50 FORCE PRESSURE 50 < FORCE < 100 PRESSURE < 20 PRESSURE > 50 PRESSURE PRESSURE < 50 WIDTH = 10 LENGTH = 2 WIDTH = 8 LENGTH = 1.2 Exercise Written by Changhyun, SON
Input File :restart *ask,force,’FORCE = ’ *ask,pressure,’PRESSURE = ’ *if,force,le,50,then *if,pressure,le,20,then width=8.0 length=1.2 *endif *elseif,force,le,100 *if,pressure,le,50,then width=10.0 length=2.0 *endif *else *go,:restart *endif Written by Changhyun, SON