Merging multiple time periods of a CFx simulation into one

During the calculation of a CFx simulation, the solver can stop and restart. When this happens, the user can only export one dataset in Case Gold format for each one of the restarts, making it impossible to load the solution in EnSight as a single transient dataset. In this scenario, some operations such as the calculation of the temporal average, or the creation of plots vs. time over all the timeline, will not be possible.

If this is the problem you are facing, then you can use this User Defined Tool presented in this article to concatenate the datasets from the restarts into a single transient Case Gold dataset. The Tool will take care of distinguishing between changing or static connectivity, and will check the sequence of timesteps to create a unique timeset with increasing timesteps.

Shown below is the structure of the directories with the data that you need to have to run this UDT. Note that there is no constraint on the directory names – only on their structure

Transient data

Data1

Data2

…..

DataN

In this example, Data1 will contain the dataset for the first restart, Data2 will contain the dataset for the second restart, and so on.

Download the attached file, un-zip it and place the files into your local UDT directory (which by default is in $CEI_HOME/ensight101/site_preferences/extensions/user_defined/Tools). Open EnSight a first time with the “-no_prefs” option to initially load this tool, and then restart EnSight  normally. Now, you will find the tool among the User Defined Tools.

Double-click on the tool lo launch it. It will pop-up a window asking for the first .case file. Select it and give “Ok”.

The script creates an additional ZData directory under the Transient_Data directory. In this new ZData you will find the new concatenated dataset. Note that the script makes a copy of the original files, doesn’t move/delete them. This means that you can end up using a lot of disk space, if your initial dataset is large.

Please feel free to contact us if you have any question or problem in using this Tool

Marina

CFX_join

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

Converting Plot3D variables to dimensional variables

PLOT3D variables in EnSight are non-dimensional.  They are non-dimensionalized in a somewhat arcane calculation.  The density is scaled by the freestream density, the momentum is scaled by the product of the  freestream density and the speed of sound, and the Energy is scaled by the product of the freestream density and the speed of sound squared.

For those who don’t want to go through this calculation of dimensioned variables manually and want access to the engineering variables in consistent, user-selected units at a user-selected altitude from a PLOT3D calculation, this script calculates the extended plot3d variables in either SI or English units. This script uses the non-dimensional Plot3D Energy, Density, and Momentum variables in its calculation. This script is assumes Earth atmospheric data. So, it is not valid for calculations on Mars, nor is it valid for calculations in water.

If ‘Energy’, ‘Density’ and ‘Momentum’ all exist then the script will prompt the user for unit type (SI or English) and the altitude and then use a lookup table to find the corresponding variables in consistent units.  The code will then calculate a Density_true, Momentum_true, and Energy_true variables (which have consistent units for the user input)  and use those to calculate the extended CFD variables.

Click below to download the zipped EnSight Python Script

extended_cfd_with_units4.py

Exporting variable values on a grid

This was made for a specific customer request. It exports variable values that lay on a specified grid of points over an X-Y plane. It saves these values for all time steps. Download: probe_values_XY_export.zip

flow2d_probes

The default settings work with the flow2d data and save to a .csv file.

This was also my first venture with PyQt. These lines of code pop up a confirm file overwrite window if the target save file already exists:

q = PyQt4.QtGui.QMessageBox()
q.setWindowTitle(“File already exists”)
q.setText(“The file “+filename+” already exists.\nDo you want to overwrite the existing file?”)
q.setIcon(PyQt4.QtGui.QMessageBox.Warning)
q.addButton(“Cancel”,PyQt4.QtGui.QMessageBox.RejectRole)
q.addButton(“Overwrite”,PyQt4.QtGui.QMessageBox.YesRole)
ret = q.exec_()

I didn’t make my own class to do it, but QMessageBox is already a class so I don’t see why my own class would be better for a simple case like this. The setWindowTitle method doesn’t seem to work for me though (the window has no title). Making it a function would have been cleaner but this was just a quick script.

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

In-Cylinder Tools

In-Cylinder Engine (ICE) simulations often contain specialized requirements for analysis. EnSight’s Python tool capability allows users to develop their own custom operations to fulfill the requirements of the analysis. I have written an initial set of tools here called “In-Cylinder Tools”, which can be installed as UserDefinedTools in EnSight 10

In this set of tools, we have the following:

1. Calculate Swirl. This routine takes the currently selected parent part(s) (typically the fluid domain of the cylinder), and calculates Swirl Velocity based about the Z axis. Using the parent part, it also calculates an Constant Variable which is the Spatial Mean of Swirl, so that you could easily create a plot vs. time for the average swirl.

 

 

 

2. Calculate Tumble. This routine takes the currently selected parent part(s) (typically the fluid domain of the cylinder), and calculates a tumble velocity, using the current average height of the parent part. The routine automatically works through time to determine this tumble velocity using the new center reference point at each timestep, and creates a graph of tumble vs time.

 

 

 

3. Crank Angle Conversion tool. This converts an EnSight .case file which has been setup with Analysis_Time specified as degrees crank angle, and converts this to Analysis_Time in seconds (user provides RPM). This allows EnSight to compute Pathlines correctly, as all of the constituent variables have consistent units.

4. Spray.out reader. For users of Converge, this tool will read in the Spray.out file information into a series of queries that you can then automatically plot. This reader will also read other Converge .out files which confirm to the save format.

 

 

 

 

 

5. Particle Distribution Function. This routine operates on the Measured Data within EnSight, to determine a mass-based distribution of any measured data variable (like radius or temperature) within the time domain. Please refer to this previous Python Exchange article for further information on the intended uses and application of this routine. Previous article.

 

 

 

Please download these tools from the link below. Unzip the file, and place the directory into your .ensight100/extensions/user_defined/Tools/ directory, and restart EnSight. You should then see a new tool folder in your UserDefinedTools area with the above tools.

Should you require any assistance with the tools or modification of them to suit your particular needs, please do not hesitate to contact CEI.

Click here to download In_Cylinder_Tools

 

Particle Distribution Analysis

As a follow on to the Probability Density/Distribution Function for the continuous phase domain (link here), I have created a close cousin of this routine which works on Discrete Particles to determine a Particle Distribution of the Discrete Phase.

This routine was written with the intended use for Spray Distribution in an In-Cylinder model, and built according to the typical variables and techniques used for this modeling scheme. It is common to determine and understand what the distribution of the particular spray is within the domain over time (mass distribution vs. radius).  This routine asks the user for a variable to base the Distribution on (in this case droplet radius). The routine breaks this value down into N number of “bins” (in this case 20). For each bin, the routine calculates the total mass of the spray in that bin, and reports back out a distribution. The routine then walks the transient domain to collect this information over time, and generate extracted information vs. time.

In order to base the total in each bin on Mass, the user must prescribe three items : a) the droplet radius, b) the droplet density, and c) the number of droplet per parcel. In this instance, the actual Discrete/Particle data in EnSight represents one parcel of spray (all with the same physical properties).  Therefore, the mass is represented as (number_drop_parcel)*(particle_density)*(4/3*pi*r^3).

The GUI input for this routine is similar to the previous PDF macro for the continuous phase, with the addition of variable prescription needed for the mass calculation.

Based on this range, it then divides the volume into N number of IsoVolumes (number of bins) based on this variable range. The routine then determines the mass of the spray which is contained within each of these variable constrained ranges. The result is placed into a query register and automatically plotted on the screen.

The Tool presents the user with the simple Window to select the variable, and number of bins (or bars) for the distribution function, along with the three items needed to calculate the mass of the spray (radius, density, parcel count)

 

After executing, you will then get a graph of distribution of the variable within the parent part(s) selected.

The values on the graph should always sum to the total mass of spray in the domain.

Note: As users increase the number of bars( or bins) for the graph, the shape of the curve will increase in resolution, although values on the Y-axis of the graph will adjust.

This Tool can be downloaded from the link below. Please unzip the file and place both the Python Script and Icon PNG file into your UserDefinedTools area and restart EnSight. You should see a “PDF Particle Graph” icon available in your UDT area, and you can double click to execute.

 

 Video Tutorial:

Please view this video tutorial for a detailed walk through of using this tool for Spray Analysis.

Screencast Tutorial

Download:
Please use the following link to download the UserDefinedTool:

Click here to download Particle Distribution Tool

 

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

LIGGGHTS and STL Transient Conversion Routine

liggghtsDo you have LIGGGHTS data that you’d like to visualize, analyze, or communicate? Do you have similar DEM (Discrete Element Model) type of data? EnSight can used easily to analyze, visualize, and communicate the results from a LIGGGHTS solution. In this particular situation, the user has both LIGGGHTS dataset for each timestep, along with STL data for each timestep which represents the moving geometry. This python routine converts both the LIGGGHTS data file as well as the STL data into EnSight format, allowing you to visualize both the moving geometry and particles at the same time, but also utilize the analysis capabilities within EnSight to quantify the discrete particle solution for such things as mass, center of gravity, particles & mass within a particular geometric region, amount of particles leaving the domain vs. time, etc.

Please visit this site for the up-to-date help and version information regarding this Conversion Routine:

https://sites.google.com/a/ensight.com/user_defined_tools/liggghts-translation

The current release of this tool (version 1.6; 04-Dec-2012) can be downloaded with the following link. Simply place both files into your User Defined Tools directory, re-launch EnSight and start to visualize, analyze, and communicate your LIGGGHTS data within EnSight.

Click here to Download new version 1.6 of LIGGGHTS Conversion Tool