Advanced

The following topics are included in this section:

Rules for Inheriting Constant per Part Variables


Note:  Constants per part, that are in model files and exist with the same value in all parent parts of a created part - are inherited by said created parts. If the value differs, the constant per part will become undefined in the created part. However, computed constants per part are not automatically inherited by created parts (even if the values are the same), and become undefined in the created parts. If a value for the computed constant per part is desired in the created part(s), one should include the created part as one of the parent parts for the computed constant per part.


Example: If part 1 of a model has the constant per part variable rpm (of value 60), and an isovolume (which becomes part 2) is created with part 1 as the parent, part 2 will inherit the rpm constant per part and its value of 60.

However, if part 1 is used as the parent of the computation of constant per part volume (which results in a value of 135.4), and an isovolume (which becomes part 2) is created with part 1 as the parent, volume in part 2 will be undefined. It will not be inherited. One could, however, then go and add part 2 to the list of parent parts for the volume constant per part - and update the variable. This would result in part 2 having volume computed on its elements(and it would be something less than or equal to 135.4).

Plug in Variables

EnSight has the ability to display and create custom plug in variables. These variables appear in the various variable lists when variables they depend on are present. A plug in variable is linked to a command or python file which is executed when the user activates the variable. In short, a plug in variable appears and behaves to the user exactly like any other variable.

Plug in variables are defined in a text file named ensight_user_def_vars.dat. This file contains the name of the plug in variable along with a list of variables needed to compute it as well as the name of an EnSight command or python file to execute on activation. If the variables that a plug in variable needs are present, the plug in variable will be added to the variable lists. Any time a new variable is created the plug in variables are re-examined and added to the variable lists if the new variable satisfies the presentation of a plug in variable.

On activation a plug in variable will execute a command file. The command file (or python file) must create the new variable named the same as the plug in variable definition. If the plug in variable has been defined to be dependent on variables using multiple spellings the python file that creates the variable must check on the variable spellings during the variable creation.

To enable plug in variables, the ensight_user_def_vars.dat file must be located in a subdirectory called "variables" and can be defined in the site-wide preference file or in the local preference file location. The site preferences location is $CEI/ensight242/site_preferences/ while the local location is %HOMEDRIVE%%HOMEPATH%\(username)\.ensight242\ for Windows, ~/.ensight242/ for Linux, or ~/Library/Application Support/EnSight242/ on the Mac.

All files for the plug in variables must be in the same variables subdirectory (or folder if you prefer). This includes not only the ensight_user_def_vars.dat file but also any command or Python file needed to compute the variables.

User Defined variables ensight_user_def_vars.dat file format description

EnSight Variable Extension File
Version 1.0
#
################################################################
# The first two lines of this file are shown above. They MUST always exist
#     A ‘#’ on the first column is a comment and is ignored
#
# This file is organized by keywords. The keywords are not case sensitive
# depend: and DEPEND: are the same.
#The following keywords are valid with the following meaning:
#
# BEGIN VARIABLE: new_var_name
# Starts a new variable and names it. The name of the variable that will show up in the variable
object list
#
# VARIABLE TYPE: One of "scalar", "vector", "tensor", or "constant".
# This is an optional keyword and if missing the variable is assumed to be of type scalar.
# This is used to display the variable in the correct var object group
#
# DEPEND: variable_name
# The computation of new_var_name depends on this variable. If new_var_name is dependent on a
variable that does
# not exist the variable will not be shown in the var object list.
# This is an optional keyword
# A DEPEND line, if it exists, must be defined after a VARIABLE NAME line
# There can be multiple DEPEND lines. If they exist the meaning is that new_var_name depends on
variable_name1 AND variable_name2.
# And only if both of these variables exist will new_var_name be shown in the var object list.
# There can be an unlimited number of DEPEND lines.
# This version of the DEPEND line is case senstive, that is, it will match the case exactly of
variable_name.
#
# DEPEND NOCASE: variable_name
# Same as the DEPEND definition except case will be ignored for the variable_name
#
# OR DEPEND: or_variable_name
# This is an optional keyword and if it is defined it must be defined after a DEPEND or OR DEPEND
line.
# This keyword defines optional variable names for the variable defined on the DEOEND line.
# For example, assume "new_var_name = Temperature*2".
# But for some solvers maybe Temperature is actually output as "degrees",
#         that is, new_var_name could be defined
#     with "Temperature" OR "degrees"
# This keyword uses the exact case for the or_variable_name
#
# OR DEPEND NOCASE: or_variable_name
# This is the case insenstive version
#
# EXECUTE: play_file_name
# Defines the command file that will be played when the variable is activated.
# The play file can be any file that can be executed via "play: play_file_name", thus
# EnSight commands file or python file should work. The play file must be located in the
# same directory as this definition file.
# You should not specify a path to the file - only the filename.
# This keyword is required.
# This playfile should select the parts of interest to calculate the variable and
#     should create a variable with the same name as the definition: new_var_name.
# Note that a user defined variable will not appear if an existing model variable
#     has that same name
# Note that the playfile can create multiple variables as well
#
# RECOMPUTE ON NEW MODEL PARTS: <YES | NO >
# Is an optional keyword. If missing NO is implied
# If YES, the variables created when play_file_name is executed are recomputed
#     to include any new model parts that are
# loaded. Thus for example is a new case is loaded the variable(s) would get
#     recomputed on the parts loaded from the new case
#
# END VARIABLE:
# Is a required keyword. It simply closes the variable definition

Example ensight_user_def_vars.dat file is shown below

Example 7: Computing a Scalar Named "Pressure_psi"

#####################################################################################
EnSight Variable Extension File
Version 1.0
#         Example 1: This will compute a scalar named "Pressure_psi"
#         by executing a command file called "pres_Pa_to_psi.py"
#         It will be shown in the variable lists if it finds a variable called
#         "pressure" (case insensitive).
#
BEGIN VARIABLE: Pressure_psi
VARIABLE TYPE: scalar
DEPEND NOCASE: pressure
EXECUTE: pres_Pa_to_psi.py
END VARIABLE:
#

Example 8: Create a Stress Tensor Variable from the Six Symmetric Stress Components

# Stress Tensor: This will compute a tensor variable named "Stress_Tensor"
#             by executing a command file called "Stress_Tensor.py"
#             It will appear in the variable list if it finds
#             all of the stress variable components
#             After it has executed it will update to include any new model parts created
#
BEGIN VARIABLE: Stress_Tensor
VARIABLE TYPE: tensor
RECOMPUTE ON NEW MODEL PARTS: YES
DEPEND NOCASE: S11
DEPEND NOCASE: S12
DEPEND NOCASE: S13
DEPEND NOCASE: S22
DEPEND NOCASE: S23
DEPEND NOCASE: S33
EXECUTE: Stress_Tensor.py
END VARIABLE:

Example 9: Create a Velocity Vector from the Components

#
BEGIN VARIABLE: Velocity
VARIABLE TYPE: vector
DEPEND: velx
DEPEND: vely
DEPEND: velz
EXECUTE: vel_vec.enc
END VARIABLE:
#####################################################################################

Example EnSight Command/Python files for the above ensight_user_def_vars.dat file

Example 10: EnSight Python File, Above: pres_Pa_to_psi.py

#####################################################################################
Example 1 EnSight Python File, above: pres_Pa_to_psi.py
# Convert Pressure from Pa to PSI
# psi = Pa / 6894.757
#
# import an EnSight utilities module
#
import ens_utils as eu
# For details on the functions available:
# print dir(eu)
#
# Get a list of variables exactly matching ‘pressure’
#     which should be only one
#     (must use a case independent search)
#     for details do the following:
#     print help(eu.get_vars_by_name)
#
pvars = eu.get_vars_by_name('pressure', flag='all', case_sensitive=False)
if pvars:
    # should only be one
ensight.variables.activate(pvars[0].DESCRIPTION)
ensight.part.select_all()
ensight.variables.evaluate("Pressure_psi = " + pvars[0].DESCRIPTION + " / 6894.757")
#####################################################################################
#####################################################################################

Example 11: EnSight Python File: Stress_Tensor.py

#
# Create a Stress Tensor using the components (exact match)
#
ensight.sendmesgoptions(version="10.16 (b)")
ensight.sendmesgoptions(version=0)
ensight.part.select_all()
ensight.variables.activate("S11")
ensight.variables.activate("S22")
ensight.variables.activate("S33")
ensight.variables.activate("S12")
ensight.variables.activate("S13")
ensight.variables.activate("S23")
ensight.variables.evaluate("Stress_Tensor = TensorMake(plist,S11,S22,S33,S12,S13,S23)")
#####################################################################################
#####################################################################################

Example 12: Ensight Command File: Make a Velocity Vector from the Component Scalars vel_vec.enc

#
#
#
part: select_all
variables: activate velx
variables: activate vely
variables: activate velz
variables: evaluate Velocity = MakeVect(plist,velx,vely,velz)