Texture mapping tool

This code enables a very simple and handy way of texture mapping. The code can handle pre-selected (multiple) parts or the user can select a single part within the script GUI. Additionally the mapping direction and the texture image must be chosen. Now click “Create” and the code will automatically grab the dimension of all selected parts and map the texture over the whole part surface. The GUI remains open so the user can rotate the plane tool for adjusting the texture.

http://pythonexchange.com/?attachment_id=816

Continue reading

STAR-CCM+ Particle Track File Conversion into EnSight 10

** Updated 01-May-2014: Users of EnSight 10.1 will have version2.3 of this tool automatically installed in the UserDefinedTools — > File Import/Export section. **

Users of STAR-CCM+ who are also using the lagrangian or discrete element modeling capability, there is a new translation utility from CEI to convert the STAR-CCM+ based particle track file into EnSight’s Measured Data format, to visualize and analyze within EnSight.

This translation routine takes an existing EnSight Case Format files (the continuous domain) exported from STAR-CCM+, along with the STAR-CCM+ based Particle Track files (.trk). The routine converts the .trk file contents onto a single timeline, creates the appropriate EnSight Measured Data files (in a “trk_mea_files” directory), and modifies the EnSight Case file to include the appropriate references for the Measured Data Files. Once loaded, the user can visualize, analyze, and communicate the information contained within both the lagrangian/discrete phase along with the continuous phase.

To utilize this new translation routine, please follow the instructions below:

1. Download the .zip file containing the new translator. Unzip. To make this available to all users on your installation, place the “ccm_trk_ensext” directory into your installation Tools sub directory as follows:

$CEI_HOME/ensight100/site_preferences/extensions/user_defined/Tools

(Please ensure that you have proper write privileges to place this directory here).

Now start up EnSight as follows (example assumes you are running EnSight 10.0)

ensight100 -no_prefs

OR

for personal use, install into your local Tools directory as described in the How To Manual (in HOW TO PRODUCE CUSTOMIZED ACCESS TO TOOLS & FEATURES)

Local directory – python files for your own personal use

Linux: ~/.ensight100/extensions/user_defined/Tools

Mac: ~/Library/Application Support/EnSight100/extensions/user_defined/Tools Windows

Vista, Windows 7: C:\Users\username\.ensight100\extensions\user_defined\Tools

Windows XP: %HOMEDRIVE%%HOMEPATH%\(username)\.ensight100\extensions\user_defined\Tools

To find out your %HOMEDRIVE%%HOMEPATH% do Help>Online Support, click the System Into tab, and look at the Prefs Dir. This is where EnSight looks for user defined tools.

If you don’t see your tool, try

ensight100 -no_prefs

Download version 2.3 of STAR-CCM+ Track File Conversion Tool Here

2. Start EnSight 10. You should notice a new tool under the “UserDefinedTools — > File Import/Export” denoting STAR-CCM+ .trk file translation:

3. Ensure that you have exported the continuous domain from STAR-CCM+ into EnSight format.

4. Double click the “STAR-CCM+ .trk import” tool from the UserDefinedTools area.

4a. Specify the EnSight Case format “.case” file. (Exported from STAR-CCM+)

4b. Specify the STAR-CCM+ Particle/Discrete Element file (.trk)

4c. Specify the number of timesteps to re-sample the particle track information into.

4d. Specify Time option for conversion of the Particles. The Default of “Max Trace” will resample all of the particles based on the min and max time of all the particles.  If you choose “User Specified”, then please specify the minimum and maximum times in section 4e (below). Use this option if you have rogue particles which may “hang around” for long periods of time, or you want to specifically control the time period over which the particles are converted.

4e. If you choose the “User Specified” Time option, then provide the minimum and maximum time.

4f. Toggle to keep particles at their last known location if the time is greater than defined for that particle. Particularly useful to “stick” particle where they exit the domain.

5. Click on the “Convert” button to convert the STAR-CCM+ based Track File into EnSight Measured data.

You will see a progress bar indicating the progress through the process of reading, re-sampling, and writing out the new EnSight Measured data. Two new items are written in the same directory : “trk_mea_files” directory containing the EnSight format Measured Data, and a modified .case file “<original_name>_particles.case”

Once complete, you will get a “Done” Dialog, after which the new case file will be automatically loaded in. You can now change the visible aspects of the Measured Data via the “Node Display” icon :

Since the Translation routine writes new Measured Data files, subsequent loading of this case with Measured data, the user can simply specify to load the “_particles.case” file directly, without the need to re-translate the Particle Track information each time.

Should you have any questions, please do not hesitate to contact CEI (support@ceisoftware.com) with questions, comments, praise.

Example Dataset:

An example STAR-CCM+ based dataset containing Particle track information can be downloaded here.

 

Video Tutorial:

To further assist your use of STAR-CCM+ Particles in EnSight, please consult this video tutorial here:

http://www.ceisoftware.com/wp-content/uploads/screencasts/star_ccm_plus_trackfiles/star_ccm_plus_trackfiles.html

 

 

Users of STAR-CD v3.x and v4.x:

Note: This routine mentioned here is meant to work for the specific “STAR-CCM+” based track file format, which is different to that of STAR-CD (v3.x and v4.x) particle track routines. If you are trying to convert “STAR-CD” based particle track files, please see our existing “f33toparticle” conversion routine.

http://ceisoftware.zendesk.com/entries/23238017-STAR-CD-Droplet-Lagrangian-Particles-to-EnSight-

http://video.ceisoftware.com/media/starcd_trackfile

Revision History

** Version 2.3:  Updated 01-May-2014 for mint & maxt calculation, as well as sorting trks based on time prior to re-sampling/interpolation. **

Gamma Uniformity Index

The Gamma Uniformity Index is a measure of flow uniformity on a clip plan.

It is the normalized RMS of the difference between the local velocity and the spatial mean of the velocity integrated over the area of the clip plane.  See the attached equation.

Gamma Uniformity Equation

Equation for Gamma Uniformity

Attached is a demonstration of EnSight Python for calculating the Gamma Uniformity Index. This is only intended as a prototype demonstration script for calculating this variable.

Directions for use: make a clip plane in your flow. Select the clip plane part.  If your velocity variable is different than ‘VELOCITY’ then you will have to edit this .py file to the correct variable name. Now run this script. You will have several intermediate variables calculated, but the gamma uniformity index is a constant named gam_uniform.

gamma_uniformity_index.py

 

Transient STL File Conversion

Do you have a series of STL files which represent moving geometry? If this geometric motion is simple (constant rotation, or translation), you can utilize the “Rigid Body Motion” capability already in EnSight. However, what if the motion is complex, or if the STL surfaces change from timestep to timestep? The native STL file reader in EnSight expects steady state STL file information (either a single STL file, or multiple STL files via .xct; but still only for a single timestep).

A short Python routine can be used here to actually help out. This python routine takes a series of STL files, and assumes that they are part of a transient sequence, with one STL file per timestep. The Python routine converts the STL information into EnSight Case Gold format files, with multiple .geo files, allowing you to view your STL information in a transient nature. This routine can be further modified and customized to suit your needs, file conventions, or time information (since no time information is explicitly available within the .stl file).

Please feel free to contact CEI, or the author of the routine (kevin@ceisoftware.com) for further customization or questions.

To download this example Python utility, please click on the link below, and place into your User Defined Tools area.

Click here to download Multiple Transient STL Conversion Tool

Current Version : 1.0 (11-January-2013)

Current Limitations/Assumptions:

a. A series of ASCII stl files all with ‘.stl’ extension
b. Will convert and assume ALL “*.stl” files in the directory are to be converted.
c. All STL files have the same number of parts (but can change triangles from timestep to timestep)
d. Since there is no Time information with STL, will force Time 0 = 0.0 seconds, Time 1 = 1.0 seconds, etc
If user needs other time information, just change the time values in the .case file
e. STL files are all triangles (no quads)

Help Documentation can be found here : https://sites.google.com/a/ensight.com/user_defined_tools/transient_stl_translation

Measure Distance & Size

EnSight has no really handy capability to measure the size of a selected part or the distance between two points although all necessary information is existig. I was asked several times for a simple click solution. Well, here it comes. Attached are two Python codes zipped to a complete directory. Both scripts include a dynamical GUI which enables a very handy usage.

The size measurement tool:

Start the routine and just select one ore more parts from the part list or directly from the graphical area – that’s all. The GUI of the code will update immediately so you will get the desired information without more steps.

 

 

 

 

 

 

 

 

The distance measurement tool:

Start the routine and choose the measurement mode. Now just click on the first surface point. The GUI will update at once and asks you to select the second surface point. Once again the GUI will update and tell you the distance betwee the two points. Both points are connected with the line tool now. You can continue picking surface points as long as the GUI is active. If you are finished, just quit the GUI and the line tool will disappear.

 

 

 

 

 

 

 

 

Both routines are included in a complete user defined tool directory. Download the file, unzip it and copy the whole directory to this path (If the path does not exist you’ll have to create it):

$HOMEDRIVE/$HOMEPATH/.ensight100/extensions/user_defined

 

Please contact me at david@ceisoftware.com if you have any problems.

david

CEI_GMBH_TOOLS

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

 

 

 

 

 

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