Need help in reading from a Tecplot file

Tecplot's automation language

Python scripts are supported in the alpha version.

Moderators: steve, jprenaud, straton, Chris Idso, davetaflin, salter

Arabzadeh
Newbie
Posts: 3
Joined: Thu May 17, 2007 5:38 am
Location: canada
Contact:

Need help in reading from a Tecplot file

Postby Arabzadeh » Tue Jul 28, 2009 9:21 am

Hello,

I generated an ASCII output from Tecplot, it contains x,y coordinates and temperature data of my 2D geometry. I need to read the data points from this file in another code written in C & store them in arrays.
(i.e.,x_coordinate[i][j], y_coordinate[i][j] & Temperature[i][j]) but since the tecplot writes in unstructured ascii data, it puts the connectivity information at the end of the file & I don't know how to read the nodes in a right order.Does anyone have any idea?

Many thanks,
Sanaz

scottf
Tecplot Employee
Posts: 114
Joined: Wed Apr 05, 2006 8:58 am
Location: Bellevue, WA
Contact:

Re: Need help in reading from a Tecplot file

Postby scottf » Tue Jul 28, 2009 2:50 pm

It sounds like you're dealing with FE data. And you want to create arrays of your X,Y,Temp variables in the same order as the connectivity, rather than the order of the points. If my understanding is correct you might take a look at writing a Python script (you can also do this via a C or Fortran add-on)

Python code (untested):

Code: Select all

NodeMapRef = TecUtil.DataNodeGetReadableRef(ZoneNumber)
XVarRef = TecUtil.DataValueGetReadableRef(ZoneNumber, XVarNum)
YVarRef = TecUtil.DataValueGetReadableRef(ZoneNumber, YVarNum)
TempVarRef = TecUtil.DataValueGetReadableRef(ZoneNumber, TempVarNum)
ZoneInfo = TecUtil.ZoneGetInfo(ZoneNumber)
NumElements = ZoneInfo[1]
NumCorners = ZoneInfo[2]
for element in range(0, NumElements):
    for corner in range(0, NumCorners):
        index = TecUtil.DataNodeGetByRef(NodeMapRef, element+1, corner+1)
        x = TecUtil.DataValueGetByRef(XVarRef, index)
        y = TecUtil.DataValueGetByRef(YVarRef, index)
        temp = TecUtil.DataValueGetByRef(TempVarRef, index)
        InsertValuesInArray(x,y,temp)

I'll leave writing InsertValuesInArray() up to you. If you want unique nodes, you'll have to track that somehow, perhaps by remembering which 'index' values you've already used.

Hope that helps.

*I haven't tested the code, so your mileage my vary. The concept is there though.
Scott Fowler
Image


Return to “Macros and Python Scripts”

Who is online

Users browsing this forum: No registered users and 0 guests