# 7.3 Post-processing with EnSight

Post-processing OpenFOAM cases with EnSight is supported in several ways:

• convert OpenFOAM data to EnSight format with the foamToEnsight utility (serial or parallel);
• generate data in EnSight format during the simulation with the ensightWrite function object (serial or parallel). This functionality largely mirrors that of the foamToEnsight utility;
• convert the OpenFOAM data to EnSight format with the foamToEnsightParts utility. This is serial only, but supports separate parts for each cell-zone;
• read the OpenFOAM data within EnSight using the native EnSight capabilities (available in EnSight 9.2.2 and 10 - https://www.ensight.com/openfoam/);
• read the OpenFOAM data within EnSight using the ensightFoamReader module supplied with OpenFOAM.

### 7.3.1 Converting data to EnSight format

The foamToEnsight and foamToEnsightParts convert data from OpenFOAM to EnSight file format and are executed as normal OpenFOAM applications. The foamToEnsight normally creates a directory named EnSight in the case directory and deletes any existing EnSight directory. The foamToEnsightParts normally creates a directory named Ensight in the case directory, but does not delete an existing directory. In both cases, the output directory can be adjusted using the -name option. The principal difference between the two utilities is that while foamToEnsight runs in serial and parallel, it only writes the internal mesh as a single EnSight part. By contrast, The foamToEnsightParts utility writes each cell-zone as a separate EnSight part, which can make post-processing in EnSight easier and faster, but only runs in serial. The operation of both utilities and their are similar. They read the OpenFOAM data for the specified times and write corresponding EnSight data files and a case file with the details of the data names and directory layout. The data subdirectory contains all data and transient geometry. For non-moving cases, the geometry file will be located within the top-level directory.

The data directory contains a series of numbered sub-directories that contain the converted data at different times. For documentation and scripting purposes, these numbered sub-directories each contain plain text time file with index and time value. The converted EnSight data are stored with their original OpenFOAM names, e.g.T for temperature, etc.

Once converted, the data can be read into EnSight:

1. from the EnSight GUI, the user should select Data (Reader) from the File menu;
2. the appropriate EnSight_Case file should be highlighted in the Files box;
3. the Format selector should be set to Case, the EnSight default setting;
4. the user should click (Set) Case and Okay.

### 7.3.2 Converting data during the simulation

If desired, most of the foamToEnsight functionality (currently no output for Lagrangian fields) can be harnessed during the simulation by using the ensightWrite function object (serial or parallel). See the tutorials/incompressible/simpleFoam/motorBike for an example.

Since there was historically no native means of loading OpenFOAM data within EnSight, the ensightFoamReader reader module has been provided. This user-defined reader provides the capability to employ a user-defined module to read data from a format other than the standard EnSight format. OpenFOAM includes its own reader module ensightFoamReader that is compiled into a library named libuserd-foam. This library must be available to EnSight, i.e. it must be able to locate it on the filing system.

#### 7.3.3.1 Configuration of EnSight for the reader module

It is necessary to set some environment variables to use the EnSight reader module. The settings are made in the ensight file in the $WM_PROJECT_DIR/etc/config.sh or$WM_PROJECT_DIR/etc/config.csh directories The environment variables associated with EnSight are prefixed by $CEI_ or$ENSIGHT9_ and listed in Table 7.2. With a standard user setup, only $CEI_HOME may need to be set manually, to the path of the EnSight installation.  Environment variable Description and options$CEI_HOME Path where EnSight is installed, eg /usr/local/ensight, added to the system path by default $CEI_ARCH Machine architecture, from a choice of names corresponding to the machine directory names in$CEI_HOME/ensight74/machines; default settings include linux_2.4 and sgi_6.5_n32 $ENSIGHT7_READER Path that EnSight searches for the user defined libuserd-foam reader library, set by default to$FOAM_LIBBIN \$ENSIGHT7_INPUT Set by default to dummy

Table 7.2: Environment variable settings for EnSight.

#### 7.3.3.2 Using the reader module

The main difficulty in using the EnSight reader lies in the fact that EnSight expects that a case is defined by the contents of a particular file, rather than a directory as used by OpenFOAM. Therefore, in the following instructions for the using the reader below, the user should pay particular attention to the details of case selection, since EnSight does not permit selection by directory name.

1. from the EnSight GUI, the user should select Data (Reader) from the File menu;
2. The user should now be able to select the OpenFOAM from the Format menu; if not, there is a problem with the configuration described above.
3. The user should find their case directory from the File Selection window, highlight one of top 2 entries in the Directories box ending in /. or /.. and click (Set) Geometry.
4. The path field should now contain an entry for the case. The (Set) Geometry text box should contain a ‘/’.
5. The user may now click Okay and EnSight will begin reading the data.