CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Tecplot (http://www.cfd-online.com/Forums/tecplot/)
-   -   Tecplot Macro - conditional - array variable (http://www.cfd-online.com/Forums/tecplot/66764-tecplot-macro-conditional-array-variable.html)

pchidamb July 23, 2009 13:45

Tecplot Macro - conditional - array variable
 
Hi

I am using Tecplot 10. I am able to use conditional Tecplot macros for scalar variables.
Ex:
#!MC 1000
$!Macrofunction Name = "CheckControl"
$!Varset |A| =2
$!Varset |B| =1
$!If |B| != 0
$!ALTERDATA
EQUATION = '{CC} = ATAN({AA}/{BB})'
$!Else
$!ALTERDATA
EQUATION = '{CC} = ATAN({AA})'
$!Endif
$!Endmacrofunction
$!Runmacrofunction "CheckControl"

I also want to use conditional Tecplot macros for array variables.
For example, I want to scan the array {BB} and evaluate the array {CC}.
Will you please let me know the syntax in Tecplot?

Thanks
Praba

wsfowler July 28, 2009 19:02

You should be able to use $!GETFIELDVALUE to get values from a particular zone/variable. Something like this:

$!LOOP |NUMPOINTS|
$!GETFIELDVALUE |VALUE|
ZONE = 1
VAR = 1
INDEX = (|LOOP|)
#Do something with |VALUE|
$!ENDLOOP

You'll need to know, or calculate |NUMPOINTS|.

pchidamb July 29, 2009 09:48

Tecplot Macro - conditional - array variable
 
Thank you Scott!
My macro works!
#!MC 1000
#$!VarSet |MFBD| = 'C:\Program Files\TEC100'
$!Macrofunction Name = "Equation1"
$!VarSet |NumPoints| = (|MaxI|*|MaxJ|*|MaxK|)
$!VarSet |VarFp| = 42 #Fp
$!VarSet |ConstantF| = 1.2776E+06
$!VarSet |ANR| = 3.0E+11
$!LOOP |NumPoints|
$!GetFieldValue |Value|
Zone = 1
Var = |VarFp|
Index = |LOOP|
#
$!If |Value| > |ConstantF|
$!ALTERDATA
EQUATION = '{DELTA} = |ANR|/(2 * PI * SQRT(|Value|*|Value| - |ConstantF|*|ConstantF|))'
$!Else
$!ALTERDATA
EQUATION = '{DELTA} = 1000'
$!Endif
$!ENDLOOP
#
#Cleanup
#
$!RemoveVar |NumPoints|
$!RemoveVar |VarFp|
$!RemoveVar |ConstantF|
$!RemoveVar |ANR|
$!RemoveVar |Value|
$!Endmacrofunction
$!Runmacrofunction "Equation1"


All times are GMT -4. The time now is 14:55.