Multiple Variable Constraints (Venn Diagram)

EnSight’s capability to utilize multiple variables at once is very powerful. Coloring by multiple variables at once on the same part can be very powerful visual aspect to understanding the relationship of various variables at once. One variant of this is to allow the user to specify multiple variables as set of constraints so that the user can visualize a portion of the domain which has been restricted by multiple variables. For example, I would like see the portion of the domain which has Temperature between 290 and 310, and Density between 0.9 and 1.05, and a Velocity from 10 to 15…. and so forth. Basically, the user would like to build a Venn Diagram of the common constraints from multiple variables at once.

Well, enter in Python + EnSight again. Here, we utilize EnSight’s ability to create an IsoVolume (a region constrained by a range of a single variable), along with the ability in Python to loop through this constrain N times, as well as present the user with a new little GUI to specify the constraints. In this short example, I have coded up to 6 constraining variables at once. Each variable gets constrained as an IsoVolume, with the subsequent constraint using the previous IsoVolume as its parent. Voila.

Capitalizing on some of the benefits of EnSight’s dependancy tree structure, you can adjust any of the constraint variables or ranges after the fact, and the whole Venn Diagram Region is automatically updated. Each IsoVolume is now also labeled with the initial variable and range used to create it, so the user can go back through and understand the different constraints.

Here is what the tool in place looks like:

You can download the Python Tool and install it into your UserDefinedTool area:

Download Python Multiple Constraint Tool

Please provide comments back for issue you find, additional capability you’d like, or adjusts which would make this more useful for your implementation.

 

Projected or Frontal Area Calculation

 

 

 

In EnSight, you can easily obtain the area of a set of elements with the EleSize function. You can even get the area in a particular Direction by multiplying it by the Normal and extracting out the component.

However, one particularly useful functionality is to get the “projected” area of a set of elements, or “frontal area”. In this method, overlapping faces do not contribute to the frontal area, and need to be accounted for. I’ve been asked on a few occasions to make something like this work.

This technique modifies the background in EnSight to black, the target elements to white, and uses EnVe to count up the number of white pixels. The routine then does this with an element of fixed/known area, and then it approximates the projected area of the target elements.


Attached is an example Python routine. Please open it up and read through it. There are few User Requirements and caveats at the top of the routine that you should be aware of. It is an approximation using pixel count. In my example model with a prescribed known target size, and my frontal area error is less than 0.01%. This value will differ depending upon the complexity of the geometry and the pixel-to-geometry accuracy at ~8000×8000 resolution.

With slight modification, this routine can be used in batch (add in the model load and part selection).

Click here to download frontal_area Python Script

 

Direct Access to Variable information

Want a quick look at the variables in your model? Want to figure out minimums and maximums in a few steps? Through the use of Python in EnSight, you can get direct access to items such as what variable names are available (to check to see what the dataset has, or figure out if your potential new names conflict with any already there). You can also get quick access to items like min and max (for the model). This is particularly handy with regards to Vectors, where you can direct return of all components and magnitude.

# Obtain variable min and max info
varname = "Momentum"

print "========================="
a = ensight.query(ensight.VARIABLE_OBJECTS)
var_list = a[2]
for i in range(len(var_list)):
    name_now = var_list[i]
    if name_now == varname:
        print "Found ",varname
        var_id = i
        print "Var_Id = ",var_id
        type_flag = a[1][var_id + 1]
        print "Type_flag = ",type_flag
        ensight.variables.activate(varname)
        b = ensight.query(ensight.VARIABLE_INFORMATION,var_id)
        if type_flag == 0:
            min_val = b[2][0]
            max_val = b[2][1]
            print "Min_val = ",min_val
            print "Max_val = ",max_val
        if type_flag == 1:
            minx = b[2][0]
            maxx = b[2][1]
            miny = b[2][2]
            maxy = b[2][3]
            minz = b[2][4]
            maxz = b[2][5]
            minmag = b[2][6]
            maxmag = b[2][7]
            print "Minvals = ",minx,miny,minz
            print "Maxvals = ",maxx,maxy,maxz
            print "Mag     = ",minmag,maxmag