Experimental Data into EnSight

In the simulation world, it is quite common to have some type of experimental data which you’d like to compare against your simulation data. Now, if the data is just a table of “location versus value”, you can use EnSight’s built in “Import Query” function to read this 2 column of data into EnSight and graph alongside your simulation. But, what about more complex experimental data? What about a net of data with multiple variables? Perhaps data at a bunch of X,Y,Z locations; each with some amount of variables?   Perhaps some PIV data?…. EnSight can handle that too!

I’ve written a little snippet of code to take an excel comma separated file containing X,Y,Z,Var1,Var2 data, and read that right into EnSight. You can change or adjust the code for more variables, vectors, or even time varying.

You can download the python code and icon file for a UserDefinedTool.

Python code CSV to Point Data

Example Dataset

# ############################################
# Python Script to convert from a comma separated 5 column file (X,Y,Z,Var1,Var2) to
# EnSight Case format
# Assume temperature as Var1
# and strain_rate as Var2
#
# Kevin Colburn
# CEI
# June, 2010
#
# ############################################

select 0d, 1d, 2d, 3d parts

here’s how to select parts based on element type

 

Here is a link to a python file

select_parts_0D_1D_2D.py

from ensight.objs import *

#
#
#
def echo_part_elem_type(p):
    if p.HAS1DELEMENTS:
        print p.DESCRIPTION, " has 1D line elements"
    if p.HAS2DELEMENTS:
        print p.DESCRIPTION, " has 2D surface elements"
    if p.HAS3DELEMENTS:
        print p.DESCRIPTION, " has 3D volume elements"
    #  Ensight 10 only
    #if p.HAS0DELEMENTS:
    #    print p.DESCRIPTION, " has 0D point elements"
    #
    # STRUCTURED MODEL PART
    #
    if p.PARTTYPE == ensight.PART_MODEL:
        if p.NODERANGESTEPI[0] > 0 and p.NODERANGESTEPI[1] > 0 and p.NODERANGESTEPI[2] > 0:
            print "Structured I from ", p.NODERANGESTEPI[0] , " to ", p.NODERANGESTEPI[1], " by step " , p.NODERANGESTEPI[2]
        if p.NODERANGESTEPJ[0] > 0 and p.NODERANGESTEPJ[1] > 0 and p.NODERANGESTEPJ[2] > 0:
            print "Structured J from ", p.NODERANGESTEPJ[0] , " to ", p.NODERANGESTEPJ[1], " by step " , p.NODERANGESTEPJ[2]
        if p.NODERANGESTEPK[0] > 0 and p.NODERANGESTEPK[1] > 0 and p.NODERANGESTEPK[2] > 0:
            print "Structured K from ", p.NODERANGESTEPK[0] , " to ", p.NODERANGESTEPK[1], " by step " , p.NODERANGESTEPK[2]
    print
    return
#
#  Note this methodology will work in ES10
#
for p in core.PARTS:
    if p.ISGROUP == True:
        if p.sources:
            for subp in p.sources:
                echo_part_elem_type(subp)
    else:
        echo_part_elem_type(p)