Overset Grid enhancement : OVERINT grid.i.triq to EnSight format

For users of OVERSET grids and EnSight, we have written a little conversion routine to convert the “grid.i.triq” file from OVERINT into EnSight Format. This file contains the closed, water tight, triangulated surface representation of the geometry along with 13 variables stored at each of the node points. The python conversion routine reads the binary grid.i.triq file, and creates the appropriate EnSight Case Gold format .geo file, 13 variable files, along with the appropriate case file, and automatically loads the model into EnSight. This conversion routine only has to be run once per dataset, as all subsequent loads into EnSight can simply load in the converted EnSight Case Gold files.

More information on the OVERINT grid.i.triq file can be found here:

http://people.nas.nasa.gov/~wchan/cgt/doc/fomoco.html

You can download the following bundle and place into your UserDefinedTools area (for either EnSight 9 or EnSight 10). You can then restart EnSight, and you should find the icon for converting the grid.i.triq file. Should have any questions, or require further information, please do not hesitate to contact us.

Download grid.i.triq conversion tool

Part and Variable Information

For those who would like to get detailed information about their model, including part composition, elemental makeup, variable information, there is a little python tool to obtain that. Courtesy of Mr. Bill Dunn, this routine sniffs through the model and returns dataset information such as datafiles used, part composition, element counts, variables, total node and element counts.

Download recipe part_var_core_details here

Tool and Script to Plot Probe Values on a Graph

An interesting request came in today: Can I plot the values from my interactive query probe in a graph?

Good question. Currently, you can see the values reported next to the query probe in the viewport, and you can click on “display values” to get a window pop up with the values in tabular form. But, you can’t populate a Query for a Plotter and get a graph of the values.

Python to the rescue again. Through python, you have direct access to a list of those Interactive Probe Queries and their values. With that information, we can utilize Python to populate those values into a Query Register and make a Plotter (or graph) of them.

This small Python macro will create 4 queries actually: one for X coordinate vs Variable; one for Y coordinate vs. Variable, one for Z Coordinate vs. Variable; and one of Distance (from first probe) vs. Variable. The default plot is chosen as “Distance Vs. Variable”. However, the user can easily drag any of the other 3 queries into the plotter (or make their own plotter) in EnSight. Here is what it looks like when I have 6 probe values:

You can see that you have 4 queries generated, and 1 plotter.

Download the following python and setup as a macro perhaps (assign it to a memorable keystroke sequence) and be able to quickly and easily plot the values from your multiple interactive probes…. Voila.

Python Code for Plotting Probes

Another option is a python tool that will do this.

 

query_probe_example

 

 

 

 

 

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

RTZ Range Tool to generate Circumferential Average

Using roughly the same Python tool posted in the previous entry (RTZ Range Tool), I modified this tool to loop through the theta range and report back the distribution in the circumferential sense. This is useful when looking at some type of an average quantity as you traverse in theta, rather than using a line (which only reports back the local non-averaged value). The added benefit of using this small pie slice volume is that you can look at a more average quantity, rather than an unique quantity at a finite single point.

This routine shares about 85% with the above interactive routine, including all of the logic for the creation of the RTZ range selection. This routine has the added “loop” at the end of the routine, were the resulting RTZ range clip is then swept around through 360 degrees and a query of a variable is made.

The Batch version differs from the previous Interactive RTZ Clip tool in the following manner:

  1. It is made for batch operation (settings at the top of the file for input).
  2. It uses a single axial value, and this ends up as a thin clip.
  3. It uses a theta sector (say 5 degrees for example), and loops through the entire 360 deg range.
  4. It queries a variable on this clip part, and builds a Query and Plotter as a result.

The main goal for this tool is to be used in batch, and query a particular variable as a function of theta (over a sector plane).

An example screencast tutorial, dataset, and python routine for this batch python routine can be found at :

http://www.ensight.com/screencasts/RTZ_Range_Batch_Tool/RTZ_Range_Batch_Tool.html

http://www.ensight.com/screencasts/RTZ_Range_Batch_Tool/RTZ_Range_Batch.zip

The same example manifold model is used for this case. A sample output from this routine yields the following type of graph:

The intention for this type of code is to allow the user to query a value on a segment in theta (rather than a single theta value), and report this back as a query and plot. This routine also works in batch mode, with a few user inputs listed at the top of the python routine.

RTZ Range Tool — Interactive

The Box Tool in EnSight works great to Intersect or Select a portion of the domain by providing all three Cartesian X,Y,Z limits. However, when working on cylindrical problems, or problems involving some rotational axis, it would be equally useful to have a tool that works to select a portion of the domain via RTZ limits (radial, theta, axial).

This tool allows you to specify the range in both the radial, theta, and axial extent to select out a “pie slice” of the domain. This works equally well on 3D and 2D parts.

The RTZ Range Tool creates a new part for you, thus allowing you to utilize this RTZ range for analytical or visual analysis.

An example screencast tutorial on using this Tool can be found here:

http://www.ensight.com/screencasts/RTZ_Range_Tool/RTZ_Range_Tool.html

The dataset used, along with the example Python routine for UserDefinedTool implementation can be found at:

http://www.ensight.com/screencasts/RTZ_Range_Tool/RTZ_Range.zip

The example model of a fuel manifold is a common example, where you are interested in particular sectors of the results. When you insert the tool into your UserDefinedTool area, you should then see the following entry in your UserDefinedTool:

When clicked, the tool will appear with the following GUI. The axis of rotation, along with the Min & Max values of Radius, Theta, and Axial location are entered.

The following picture denotes what you can expect for a newly created RTZ Range part (with the Parent as the Fluid Domain):

 

Time and System Info

In the good ole days, users of EnSight could execute the “test: start_timer” and the “test: print_timer” to attempt to retrieve information about the time that it took to perform the operations between those two commands. Well, that may be not really enough information, or information that you can easily use or report. Python to the rescue again, this time courtesy of Randy’s “snapshot” function.

You can now use EnSight’s Python “snapshot” function to store in a dictionary not only timestamp information, but also information about client and server application memory as well as client and server memory load.

In python, you can call:

ensight.message_window.memory_snapshot("Info_t1")

“Info_t1” can be anything that you want. This creates a snapshot of client and server memory, as well timestamp information.

The call :

ensight.query(ensight.SYSINFO)['memory_snapshots']

returns a dictionary of the snapshots, indexed by the name that you gave it (in this case “Info_t1”). If you then print this line, you would get the following information:

{ 'Info_t1': {'server_freeram': 5980388,
             'timestamp': 1310502681.3050001,
             'client_freeram': 5980388,
             'server_totalram': 10485092,
             'client_appram': 247852,
             'client_cores': 8,
             'server_appram': 14288,
             'server_cores': 8,
             'client_totalram': 10485092},
}

So, let’s put this together into something useful:

ensight.message_window.memory_snapshot("Info_t1")
# Do something interesting here.
ensight.message_window.memory_snapshot("Info_t2")
d = ensight.query(ensight.SYSINFO)['memory_snapshots']
print "="*36
print "Client Ram Increase " ,(float(d['Info_t2']['client_appram']) - float(d['Info_t1']['client_appram'])) / 1024.0, " Mb"
print "Server Ram Increase " ,(float(d['Info_t2']['server_appram']) - float(d['Info_t1']['server_appram'])) / 1024.0, " Mb"
print "Time to execute was    " ,float(d['Info_t2']['timestamp']) - float(d['Info_t1']['timestamp']), " sec"

 

Side by Side Animations

As an engineer working with multiple solutions, or comparing multiple variables, it is quite useful to be able to compare images side by side, but also animations side by side. Image comparison side by side is quite easily done with Word, or Powerpoint, or even image viewers. However, the comparison of multiple animations in a side by side layout is not quite so straight forward. Sure, there are probably some fancy, and/or expensive options out there for video editing, but there is a simpler solution —- EnVe from EnSight.

Given two animations of equal length (number of frames), EnVe’s multiple tiled movie format (.mtm) can be utilized to place two animations side by side, and a new single animation created.

Here are two example animations:

Case 1 AVI

Case 2 AVI

These two animations are each 826 pixels in X, and 574 pixels in Y, and each are 30 frames. In this example of side-by-side, both animations should be the same height (but could vary in width). You can also place the animations one on top of the other, in which case you’d want to have the animations the same width, but could vary each heights.

A Simple “Multiple Tiled Movie Format” file (.mtm) contains information about how to arrange these two animations together. Here is what that file looks like:

MTM 1.0
#
# This is a Multi-Tile Movie file.
#

nummovies 2

fullresolution 1652 574

movie
   imageoffset 0 0
   format AVI
   file Case1.avi

movie
   imageoffset 826 0
   format AVI
   file Case2.avi

You can see above that we set the total number of movies, and the total dimensions of the two movies together (1652 x 574). For each movie, you can therefore set the offset (from the lower left corner). Movie #1 will have a zero offset in X and Y, while Movie #2 will be offset by 826 pixels in X.

You can read this .mtm file into EnVideo, and view a live playing of two animation files, or you can read the .mtm file into EnVe, and simply save out a new single animation file which will have both animations playing side by side. This works great to control the comparison of different models, results, or different variables from separate single animations. Given the flexibility of the .mtm file, you can tile many animations together to make a multiple animation comparison easily and without cost.

Please see below a link which has the animation files, mtm file, and the combined movie example.

Multiple Animation Example

Please see the attached PDF file for similar other operations that can be performed using EnVe… Using EnVe to Create a Single Movie from Existing Movies that Play Simultaneously

Aerial Photo Alignment

I’ve been working with River Simulation results recently. The simulation results look good colored by the various variables, but they look 10x better when you use aerial photos overlaid on the simulation. This gives a great perspective and context to the simulation, as well as providing the viewer with a lot more spatial information. It is a great combination of simulation and real map. The crux of this problem is the accurate alignment of the photo with the simulation results. Lucky, most high end/bespoke aerial photos have some type of Global Positioning, or World File information with them. This provides some spatial reference information which can be combined with the simulation space to align the two pieces of information.

texture map alignment

Exact Alignment of Texture map image with geometry using World File information.

In the models and images I looked at this week, the images had “World Files” associated with them. These world files provide the scaling, rotation, and transformation information to map the pixels of the image into 2D space. So, I wrote a small little python tool as an example of being able to accurately align the image with the simulation results using these “World Files”. The python file opens up the image file to figure out its pixel dimensions, and then opens the World File to extract out the scaling & transformation information (I’ve left rotation out of the mix for the moment). With this information, I can then correctly specify the S and T projection vectors as well as the Offset information in the texture map dialog to automatically project the image onto the geometry in the correct 2D space. I also included an option for relative vs. absolute coordinates of the simulation model, so that you can easily account for that difference in the World File.

The Python tool and window are as follows:

 

This provides a nice enhancement to the texture map capability in EnSight, to exactly align the image with the geometry when this information is known (via World File).

If users utilize other conventions for alignment of the Aerial Photo with the geometry, please feel free to contact us, as the power of python programming should allow alternative methods.

To install this python, copy the link below, and place into your ~/.ensight92/extensions/user_defined/Tools/ directory (or subdirectory), and re-launch EnSight.

EnSight UserDefinedTool for Image Alignment