8.4. Variable Units

EnSight is capable of reading datasets that include unit descriptions and using those descriptions in various ways. If a dataset has units, and the associated EnSight user defined reader is units-aware (using the user defined reader routine USERD_get_metadata) or if the data is in Case Gold with an .xml file containing the variable units mapping, then units will be used in EnSight as follows. Units will appear as labels in plotters, legends and other annotations. Units will be used in the calculator to filter each of the function input arguments to dimensionally valid variable choices. Units will be used in calculations to generate derived variables with units using the input variables' units. The user can change the global unit system so units are consistently converted at read time using the new unit system transformation, and all subsequent calculated variables are created in the new unit system. Finally, if the user reads in two datasets into two different EnSight cases, (and both datasets and readers are units-aware) with each dataset using a different unit system, EnSight will automatically convert both unit systems to the chosen unit system, ensuring consistency of the comparison.

The first step in working with units in EnSight is to use a dataset format that includes unit support. Several user-defined readers (including, but not limited to, Fluent, CFX and Ansys Mechanical) include intrinsic support for units. When you load a dataset in one of these formats, variables, in the variable list, will show their unit labels and when the variable is used, EnSight will often include the units in resulting annotations. The EnSight Case Gold file format also supports units via an external xml formatted file referenced in the case file. See the documentation for the case file format (see EnSight Gold Casefile Format) for additional details.

After starting EnSight (but before data is loaded), one may explicitly set the session units system. By default, EnSight starts with the current unit system set to From first loaded case. This can be changed to another setting using the EditUnits menu, environmental variable or command language command. If the environmental variable ENSIGHT_ANSYS_UNIT_SYSTEM is set to the name of a unit system (see table Variable Units), that system will be used for the EnSight session.


Note:  This cannot be overridden by menu selection or command language. Likewise, the command language command: ensight.objs.core.unit_system("desired unit system string")


May be issued before any data is loaded to select the session unit system. More commonly, you will select the unit system using the EditUnits menu as illustrated in Figure 8.3: Set the Global Unit System.

By default, the unit system will come from the first dataset loaded.

Once the first dataset is loaded, the unit system for the EnSight session is locked and cannot be changed. The unit system selected will become the session unit system or if From first loaded case is selected, the session unit system will match the one used by the dataset. All subsequently loaded datasets that support units will have their data loaded in the selected unit system. If any datasets are loaded in the session that do not support units (and the current unit system is not "User defined units") EnSight will present a warning message and disable unit processing for the remainder of the session to ensure that all unit labeled data displayed in the client are consistent.

Figure 8.3: Set the Global Unit System

Set the Global Unit System

There are several pre-defined unit systems. Each one has a name and defines the specific collection of units for individual base quantities (for example, length is in feet). The currently defined EnSight unit systems include the following:

The EnSight session itself has a current unit system and every loaded datasets (case) has unit system, potentially different from the current session unit system.

Units themselves are defined on EnSight variables. They consist of an optional unit label and a required unit dimension. The unit dimension is a string that describes the fundamental quantities that make up the variable units. It consists of a string of letters that represent the specific unit system (for example, Mass, Length, etc). The quantities are defined as follows:

For example, the dimension string ML/TT equates to force (label string N, for Newtons or kg-m/s2) while L/T equates to velocity (label string m/s). If the dataset has units and the reader supports units, then every variable in EnSight must have a unit dimensions string.


Note:  It can be empty, "", if the variable is dimensionless.


If the variable does not have a given label string (for example, N) then EnSight will generate a unit label string from the unit dimension string using the current unit system which will be accurate, but perhaps less common (for example, kg-m/s2). Calculated variables and variables being displayed in a session unit system different from the dataset unit system will always have the variable label generated using the variable dimension string (which will be accurate, but sometimes less common). More information on units in the calculator discussed in another section Variable Creation .

When a query is created using variables, the units mapping is performed implicitly through the EnSight variables associated with a specific axis. EnSight now supports a new formatting macro: <\\units>. This can be used in things like legend titles and plotter axis titles. The macro will be expanded to the unit description string for the associated EnSight variable. If the current session unit system is User defined, this macro will expand to an empty string. For situations where there is no directly associated variable, the syntax <\\units:varname> is also supported, varname should be replaced by the name of an EnSight variable. The unit string for that variable will replace the macro. If a @ character is placed after the word units, no braces will be included in the output. Finally, the s in units is also optional. If present, a space is inserted before the unit string. The complete syntax looks like: <\\unit{s}{@}{:varnane}>. If the current session unit system is User defined this macro will expand to an empty string.

Text annotations that use variables also support units by expanding the <\\const> macro to support the syntax:

<\\cnst C1 [%g] TEMPERATURE_REF\\>

The addition of the [ ] around the format specification will result in the units for the variable to be included in the annotation as well.

Unit conversions are performed as part of server I/O operations. All data in memory (client and server) will be in the session unit system. This ensures that datasets from different sources that might have overlapping variable names will always be consistently displayed in the client.

8.4.1. Unit Implementation Limitations

There are several limitations to the current EnSight unit system implementation.

The default unit system is determined by the first dataset that is loaded or the initial selection in the EditUnits menu by the user. Subsequent datasets are transformed into the unit system established by the first one. In older (non-unit aware) versions of EnSight, the second dataset would not have a unit transformation applied. Therefore, the loaded data values may differ from the previous version of EnSight. A work-around is to disable unit system processing using by setting the environmental variable ENSIGHT_ANSYS_UNIT_SYSTEM to user, however all unit processing and display will be disabled.

Various files record EnSight operations and state in files that lack support for units. Examples would include command language files, exported geometric entities, context files and saved view files. Saving one of these files with a specific unit system in effect and then loading them when a different unit system is in effect can result in incorrectly restored states, views, etc.

Specialized unit labels (for example, Pa) specified by dataset ENS_UNITS_LABELs, are replaced by a label generated using base-units (for example, kg/(m-s2)) under two specific conditions. First, base-unit labels are always used for computed variables (both from pre-defined functions and general expressions). Second, if the EnSight session unit system does not match the unit system of the dataset. In this case, all of the unit labels are generated by EnSight and the labels are ignored.

The case gold format supported periodic transforms applied to parts. This is done using periodic match files (.PMF). The current release does not support unit transformations on the translation element of periodic match files.

No unit transformations are currently supported for time.


Note:  The support unit system strings time is always represented in seconds. Therefore, the system display will always be correct, but there is no mechanism currently to support time other than seconds.