CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Tecplot (https://www.cfd-online.com/Forums/tecplot/)
-   -   timestep extraction for macro (https://www.cfd-online.com/Forums/tecplot/176070-timestep-extraction-macro.html)

manuc August 10, 2016 12:20

timestep extraction for macro
 
Hello

I want to have a time weighted average of certain field. To do that I require the time step information .But for each time step a zone is created.But I am not able to extract the timestep array nor the solution time array of the zones . The timestep is required in place where SOLTIME is calculated but wrong output.

SOLUTIONTIME :gives only the time of current frame but of no use when looped with zones.It still displaces the time of the active GUI.
This part of macro is of interest to me..The whole macro can be seen below after the **** lines
-------------------------------------------------------------------
$!LOOP |DN|

$!ACTIVEFIELDZONES = [|ALOOP|]
$!VARSET |SOLTIME|[|ALOOP|] = [|ALOOP|]|TIME|
$!VarSet |ALOOP| += 1
$!ENDLOOP
$!PAUSE "The soltime array is |SOLTIME| "




$!LOOP |DN|


$!ALTERDATA
EQUATION = "{AVERAGE} = (1-|WEIGHT|)*{AVERAGE} + |WEIGHT|*V|AVEVAR|[|KLOOP|]"
$!VarSet |KLOOP| += 1
$!VarSet |WEIGHT| =(1/(1+|SOLTIME|[|KLOOP|]-|SOLTIME|[|KLOOP|-1]))
$!ENDLOOP

************************************************** ****************************



#!MC 1410
#Macro for finding an average value for an IJ- or IJK-ordered zone.
#------------------------------------------------------------------

#This macro creates a new variable that is set to the AVERAGE of a
#chosen variable. This AVERAGE is calculated for all of the points in the
#lowest ACTIVE zone in your dataset. This macro only works on I-, IJ-,
#and IJK-ordered data.

#This macro will NOT work properly if your zone is Finite Element.

#To use this macro, do the following:

#1. before running the macro, determine which zone you want to find
#the average value for. In Plot Attributes, deactivate all zones lower
#than the one you want to average. For example, if I want to find the average
#Temparature value for zone 3, I would deactivate zones 1 and 2.

#2. Run the macro. Enter the number of the variable you want to
#average. For example, if you want to find the average of variable
##4: Temperature, enter '4'.

#3. If you were not in 2D mode prior to running the macro, you will
#need to switch back to your original frame mode by clicking on the
#appropriate sidebar button after running the macro.

$!GETUSERINPUT |AVEVAR|
INSTRUCTIONS = "Enter the number of the variable to average."
$!GETUSERINPUT |ZONEI|
INSTRUCTIONS = "Enter the number of the ZONE to START averaging."
$!GETUSERINPUT |ZONEL|
INSTRUCTIONS = "Enter the number of the ZONE to STOP averaging."


$!DRAWGRAPHICS FALSE
$!ALTERDATA
EQUATION = "{AVERAGE} = 0"

$!FRAMEMODE = TWOD
$!VarSet |KLOOP| = (|ZONEI|)
$!VarSet |ALOOP| = (|ZONEI|)
$!VarSet |DN| = (|ZONEL|-|ZONEI|+1)
$!VarSet |WEIGHT| =1

$!LOOP |DN|

$!ACTIVEFIELDZONES = [|ALOOP|]
$!VARSET |SOLTIME|[|ALOOP|] = [|ALOOP|]|TIME|
$!VarSet |ALOOP| += 1
$!ENDLOOP
$!PAUSE "The soltime array is |SOLTIME| "




$!LOOP |DN|


$!ALTERDATA
EQUATION = "{AVERAGE} = (1-|WEIGHT|)*{AVERAGE} + |WEIGHT|*V|AVEVAR|[|KLOOP|]"
$!VarSet |KLOOP| += 1
$!VarSet |WEIGHT| =(1/(1+|SOLTIME|[|KLOOP|]-|SOLTIME|[|KLOOP|-1]))
$!ENDLOOP



$!GLOBALSCATTER VAR = |NUMVARS|
$!DRAWGRAPHICS TRUE
#$!PAUSE "The average Value of Variable |AVEVAR| is |MAXS|"


All times are GMT -4. The time now is 01:35.