Chapter 5: User Defined Writer API

Users can write User-Defined Writers (UDW) to generate arbitrary data files for EnSight parts and variables. The EnSight server provides a UDW API that can be used to query the currently selected parts in the EnSight client part list. The UDW API includes methods to get, for example, node coordinates, element connectivity, ids, variable values, and time information. A UDW can call any of the methods as it wishes and create a data file(s) in any format desired. Additionally, the UDW dialog in the EnSight client has a Parameter field that provides a mechanism for passing user specified options to the UDW.

What Information Can Be Provided by the API?

Which parts are available to the UDW?All parts currently selected in the main Parts list (except those indicated below)
Where are the available parts located?On the EnSight server
Which parts are unavailable to the UDW?

Any client-based parts:

contours

vector arrows

particle traces

profiles

Example Writers

Several example User-Defined Writers (including source code, Makefile, and shared library) are included to demonstrate this capability. The easiest way to get started is to copy the whole directory of a simple writer, such as the Flatfile writer, then change it's name, modify the Makefile, set the environment variable ENSIGHT10_UDW, and make it. Once you have it made, start EnSight with the following option:

ensight242 -writerdbg

to verify that your writer is loading properly. Once loading properly, use print statements to aid in debugging. Alternatively, attach a debugger to the ensight242_server at run time and set breakpoints within the methods of the UDW.

The Flatfile UDW is designed to demonstrate the output of selected part nodal data (coordinates & IDs) as well as active variable values (scalar and/or vector only) in a comma delimited format easily imported into other applications. If any of the keywords Ansys or force or body is entered into the Parameter field of the EnSight client UDW dialog, then the Flatfile UDW will output an Ansys body force file. If keywords SSCALE #, VSCALE # and/or GSCALE # are entered then the scalars, vectors, and/or geometry are each scaled by the number following the keyword when written out to the file.

The HDF 5.0 UDW is designed to write out selected parts and their corresponding active variables using the HDF 5.0 API which is compatible with the EnSight HDF User-Defined Reader. The HDF writer ignores the Parameter field. The HDF 5.0 writer illustrates most of the routines available to retrieve data from EnSight.

The Case (Gold) Lite UDW is provided to demonstrate how to exercise most of the API and output a subset of the Case (Gold) format. Complex numbers and the custom Gold format are not supported in this writer. The Case (Gold) writer ignores the Parameter field. While the writer is not provided as a pre-built library, the source code and Makefile are provided.

The STL UDW is provided to write out the border geometry in the form of triangular 2D elements for the selected part(s) at the beginning timestep. The end time and the step time are ignored. The STL format does not support multiple parts in a single binary file, but does support multiple parts in a single ASCII file. Therefore, if multiple parts are selected and ASCII is checked, the STL writer outputs an ASCII file with the border of each of the parts. If multiple parts are selected and binary is checked, the STL writer outputs a binary file containing a single border of the multiple parts. The STL writer ignores the Parameter field.