Merging Multiple Time Periods of a Converge Result into One

Are you a ConvergeCFD user with EnSight?

Do you have a Single Dataset, but multiple time periods which you translated to Case Format? Ie you export results from Time T = 0 to T1 in one operation, then later exported from Time T2 to Time T3, and then again exported reults from Time T4 to T5?

If so, then currently you have multiple different time ‘sets’ or ‘periods’, which can’t easily read into a single session of EnSight (other than using Multiple Cases, but that is not what Cases are meant for).

Would you then like to be able to operate on this solution as though it were one complete time period from T = 0 to T5? Well, I think we have a little tool for you. This tool should provide you back with a single coherent time period (From T = 0 to T = T5) as a single case.

This little python tool takes a look at all of the .case files in your current directory, and gathers up a list of all of the files that are referenced, constants written, and time values. In then creates a internal global list of all of that infomation, and sorts it in ascending time order. It then renames all of the associated files so that they fall into a single progression in time order, and generates a NEW case file, referencing the global total time, global total constants, and the newly renamed set of variable and geometry files. The routine takes only a second to run (renames are quick), and you should be able to load up the NEW case file into EnSight.

As renaming files is perhaps a dangerous thing, the routine also writes an “undo” file as well. You can run the “undo”, and you will get back to your original set of files (if you need to for some reason).

As with any routine, there are some assumptions, limitations, and caveats. They shouldn’t be too restrictive, but here they are, so you have a better idea about what the routine is expecting:

a. All of the case files are in the same directory (the routine doesn’t go rooting around in sub directories looking for .case files to merge).

b. All the .case files in the current directory are meant to be “merged” into one. If there are some which aren’t meant to be merged, just move them temporarily to somewhere else.

c. When you exported the results (using post_convert), you ALWAYS exported the same variables. No exceptions allowed, no if’s, but’s, no coconuts. (EnSight can’t deal with some variables existing at some times, and not others…. rules are rules).

d. The time values can overlap, and be of varying delta T. The routine should handle that okay.

e. The routine assumes you have measured data (default for converge post_convert us).

f. Due to internal coding assumptions/methods, this routine is for CONVERGE users only. If you have results from OpenFOAM, or Fluent, CFx, or other solvers, please contact CEI (support@ceisoftware.com) separately. We have some prototypes for other solvers.

To run the routine, simply download the python file, and place it into the directory you want to merge Converge .case files together. Then, type :

cpython31 merge_time_case.py

After running, should you need to undo, there will be a new python file created in your directory, and that can be run via:

cpython31 merge_time_UNDO.py

This works for MAC/Linux/Win. Use a cmd shell in Windows to run the python routine.

As always, please contact if you have questions, comments, requests. We’d love to hear from you, and work with you to provide you with the best post processing experience.

-Kevin

Download Link for file:

merge_time_case

Once downloaded, simply unzip the file to find the python .py routine.

Fluent Particle Data with Multiple Injections

Currently (up to at least Fluent 15), when you attempt to export multiple injections from Fluent to the EnSight format, each injection is written as its own set of Measured Data files **SEPARATELY**, with separate .encas files written.

The result is that if you were to attempt to load any of the separate .encas files into EnSight, you would only see particles from a single injection. You could perhaps load in the multiple .encas files as multiple cases, but this would perhaps multiply the amount of memory used, result in lots of extra parts, and is not a suggested method (although it might work for you).

Fluent are aware of this issue, and have been requested to correctly export multiple injections to a single set of Measured Data files. Their schedule for that improvement is currently unknown.

However, in the meantime, there is a potential work around for this. With a short python script, one can merge the various injections into a single set of measured data files, so that you can visualize all of the injections in a single case. In addition to merging the injections, the routine also creates one additional variable called “inj_id” for the injection ID. Thus, you can still analyze, interrogate, visualize separate injections within EnSight, even though it is contained within a single Measured Data Part.

The ptyhon routine does require a very minor edit, based on your particular dataset, variable export, and timesteps.

A short video tutorial on using this python utility (including the basic editing for your dataset) is provided below.

Tutorial Video on Handling Multiple Injection Particle Data from Fluent

Click here to Download the Python Utility

Releasing Streamlines from Centroids of Elements

imgoutA request came in the other day to release streamlines from the centroids of all of the 2D elements of the selected parts. Now, EnSight, the default seed locations are from the nodes of the parts, not the centroids. However, this user would like to release from the centroids of the parts selected.

Python to rescue. We can utilize the Calculator Capability in EnSight to compute the X,Y,Z coordinates of the selected parts, and use the “NodeToElem” to convert those three scalar variable field values to be at the centroids of each element. With Elemental Values at the centroids of the parts, we use the FlatFile export with the “CELLID” parameter and ascii format to write out the elements of selected part(s) and their elemental variables to a text file. We can then just reformat this text file into a qualified “Particle Emitter File”. Voila. Within the standard streamline creation of EnSight, we can use a “Particle Emitter File” as the seed locations for the Streamlines, and therefore generate streamlines from the centroids of all elements in the selected part(s).

See below a short little Python Code to do this operation, as well as an image of what such a release would look like.

Python Utility to create Particle Emitter File from Centroids of Parts Selected

Element Metrics and Histogram Tool

elemetric_histogramAs part of the core capability of EnSight to not only visualize, but analyze the domain and solution results, we have implemented the Element Metrics routines from Sandia Verdict Library (http://cubit.sandia.gov/public/documents/Verde_UG-2.5B.pdf). There are approximately 30 different element metrics that this routine will calculate for you, depending upon the grid types used. Again, we have implemented this function as a general purpose calculator function, as well wrap this fundamental capability with a Python-based macro to add further ease of use and end-user functionality. This macro is called “EleMetric_Histogram”, and performs the following on the selected parts in EnSight:

1. Determines the element types selected, and only calculates EleMetric quantities which apply.
2. Creates separate scalar variables for each Metric computed. Users can color by any of these variables, or further query where maximum or minimum values occur.
3. Determines a Histogram Distribution through the domain, and reports this to a text file (EleMetric_Histogram.txt) in the directory where your case is. This file is simple ascii, and can be inspected with any text editor.
4. An EnSight Query is generated for each Metric Histogram, so that you can visually graph the distribution of that Metric for the domain.

elemetrics_guiDouble clicking on this utility will launch the following short GUI for some basic user controls:
The first option allows the user to utilize the current selected parts only, or to calculate the variables for ALL parts in the model.
The histogram options provide the ability to control the number of bins for the histogram function, as well as where to write this information (text file and/or EnSight query registers).
The typical output to the text file should provide a nice overview of the variables computed, as well as quantification of the variable distribution in the domain.

The “EleMetric_Histogram.txt” file list all of the variables computed. If the minimum and maximum are the same, we simply report that. Else, the distribution is given as well:

txt_file_grab

In EnSight, the user now has access to the variable information computed, and can clip the domain (perhaps a crinkly clip would be best), and color the domain by the metric of interest:

image_quality1_lrg

 

The following link can be used to download the user defined tool for “EleMetric_Histogram”

Download here for elemetric_histogram

Current version is 4.0, dated 23-Oct-2014, updated by Marina Galvagni.

Kevin Colburn, CEI

 

Prepare cube tool for a skybox

Here is a very short script that prepares the cube tool to make a skybox. Just change the numbers in the first 2 lines and go. Then create the skybox manually.

skbox_size=1000
skbox_center=[0,0,0]
ensight.tools.box(“ON”)
ensight.view_transf.function(“box”)
ensight.view_transf.box_length(skbox_size,skbox_size,skbox_size)
ensight.view_transf.box_origin(-skbox_size/2+skbox_center[0],-skbox_size/2+skbox_center[1],-skbox_size/2+skbox_center[2])
ensight.view.highlight_parts(“OFF”)
ensight.tools.box(“OFF”)

Moving car animation

This script assists in creating an animation with frame mode. It makes the car appear to move and wheel spin at a rate that matches the car’s speed. It can do constant speed as well as constant acceleration and deceleration.

First create 3 frames (ground and background, front wheels, rear wheels) and assign them to the parts. Then adjust the settings at the beginning of the script. The car will stay stationary while the ground moves in the opposite direction to give the appearance of motion.

Download: drive_car.py

Transient animation update palette range

Problem statement: EnSight has an option for setting the variable palette range to what is visible in a given viewport or to selected parts. However there is no option to update to these ranges automatically when time changes.

Value proposition: These are two scripts for updating the palette range automatically. One script adds a time callback, but this is only called when changing solution time in the GUI. It is not called for transient flipbooks, keyframes, or when saving a solution time animation. So the other script uses EnVe to save a solution time animation. Neither script works with flipbook or keyframe.

Script 1: Time callback update palette range

This works by remembering the selected parts when the script is run and using their min/max range. If the variable used to color the first part (of the selected parts) is changed then the new variable will update instead of the old one. You can add multiple independent callbacks by running the script again (each run creates a new instance of the class). The user should not need to edit the script, just select parts and run. There is some output in the python tab.

Download: time_callback_update_palette_range.zip

Script 2: Transient update palette

A very basic script that creates a single transient movie. All the settings are near the beginning of the script. Only a few lines of code update the palette range, and these could easily be changed to perform different actions every time step. So this is also a template for saving any transient animation with changes each time step.

Download: transient_update_palette.zip

Calculate percent volume/area/length

For users who want to calculate the % or fraction of a part which has variable values within a certain range. This is fairly easy to do manually in EnSight but requires some knowledge and can give false answers if parent parts have mixed dimensions. This routine automates the steps:

  1. create an isovolume
  2. calculate the volume, area, or length of the isovolume and parent part(s)
  3. divide the isovolume by parent to get fraction (x100 for %)

In addition to automating, the script also checks for the existence of mixed element dimensions in the selected parts. If there is more than one dimensionality (1D, 2D, 3D) of elements then the script aborts. If only one type exists then the script chooses the correct calculator function for that dimension and names the constant variables accordingly.

The options are set by 3 variables at the beginning of the script. Just variable, isovolume by high/low/band, and the iso values. Multiple values can be specified to create multiple isos.

This is really just the bare beginnings and there is certainly a lot more that can be done. GUI, error reporting, creating annotations, more options, command language, extension class.

After you have run this script you will have a Vol_percent_1 variable which represents the isovolume fraction % of total.  Now select the isovolume part and double click on the Tools icon at the top, and go into the Analyze folder and run the Part Constant Query tool. Choose the Vol_percent_1 constant variable.  Now you have a nice plot from sweeping the max isovolume from min to max.

Vol_vs_var

 

Download script: percent_area.zip

Logo annotation helper

Problem statement: Most EnSight graphics and annotations will resize automatically with the graphics window or output image size, however, the logo annotation does not. Also, the location of the logo is fixed by the bottom-left corner, which means it won’t stay fixed in the upper-right corner when the resolution changes.

Value proposition: This tools makes it easy to set the logo size, aspect ratio, and location in ways useful for image and animation output.

The current state of this python is a script with a simple GUI. It is unfinished but in a usable state and lacking documentation. The GUI options are a bit long and confusing at first.

Download the script: logo_helper.zip

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. **