KML_FLASHEMBED_PROCESS_SCRIPT_CALLS

top menu

How to Create an EnSight Data Reader

Print Friendly

Want to write a direct reader so that you can bring your data into EnSight.   Don’t forget step #1,  check with CEI to make sure that such a reader is not already under development or even already available.

If you don’t already have a license of EnSight it can be easy and cheap to download EnSight Free version and use that on small models (< 2 million cells/elements).

EnSight loads it’s readers dynamically at startup.

Each of these readers is called from EnSight according to a fixed API, of version 1.0, 2.0 and a beta version of 3.0.

Look at the EnSight Interface Manual which describes the EnSight User Defined READER APIs available to you.  This manual documents the two APIs available: version 1 and version 2.

Now do the following:
1. skim through the table of contents, which you will see documents every single call that EnSight might make into your reader.
2. read the Overview which describes how to produce a user defined reader
3. Look at the section on the user defined api version 2 and skim through the list of routines
4. Now look at a sample reader that we’ve included in the EnSight install look through the source
$CEI_HOME/ensight100/src/readers/dummy_gold
a. Carefully study section 2.2 of the Interface Manual (which describes the order that these routines are called by EnSight)
b. Compare section 2.2 to your source code and use if for a guide as to how the existing reader is working.
c. Take a look at the Makefile in this directory, which includes a config file from a config directory.
5. Version control. The string returned in USERD_get_reader_release is returned in the comments section of EnSight’s data reader dialog which is a great way to keep track of your reader version
a. #define ZMYRDR_VERSION “10.28 12-13-2011″
b.
int  USERD_get_reader_release(char version_number[Z_MAX_USERD_NAME])
{

  if (Debug_mode) {
    fprintf(stderr,”USERD_get_reader_release\n”);
  }
  sprintf(version_number,”%s”,ZMYRDR_VERSION);
  return(Z_OK);
}

6. It is also a good idea to create a global called Verbose_mode and one called Debug_mode and allow the user to set them using the reader GUI capability which adds toggles, pulldowns and fields in the Format Options tab of your data reader’s dialog when the user picks File>open and chooses your reader format.

 *   The Enhanced GUI routines are added to allow
 *   the user to customize a portion of the Data
 *   Reader dialog to pass in options to their
 *   user defined reader.  There are
 *   three routines:
 *    USERD_get_extra_gui_numbers     (optional)
 *    USERD_get_extra_gui_defaults    (optional)
 *    USERD_set_extra_gui_data        (optional)
 *
 *   The existence of these routines indicates that
 *   you wish to add customize entries to the
 *   Data Reader dialog.
7. Once you get going, you’ll want to put your reader, compiled as a dynamically loaded library into a directory, say ~/mydir/

Now you will want to open two console windows: one for the server and one for the client.

On the server window, please define the following:
setenv ENSIGHT10_READER ~/mydir
and if it requires any additional libraries (optional)
setenv LD_LIBRARY_PATH ~/mylibs/mylocation/

This is important because you want to control where the server is started and what environmental variables are defined, and where it is loading it’s reader from.

8. Now start up EnSight in the server window to see if it loaded your reader
ensight100.server -readerdbg

and the resulting output will tell you if it tried to load your library.
Note if you set ENSIGHT10_READER then this location will be attempted to load first.
If you are missing any of the essential routines found in the Interface Manual, then the reader will fail to load.
Often it’s best to start with a dummy_gold reader and get going from there, as at least the routines are filled in for you.

You need to get this fixed and loading before you try to connect to a client.

9. Once you have a reader loading on the server, in the other console window, start the client.

ensight100.client -cm
which starts the client and tells it to connect manually.

Now in the server window tell it to connect to: and type in localhost if you are on the same computer, or the name of the client hostname if on a different computer.

9. If you are going to compile your reader as debug mode and want to step into it, the first one to break into is usually
USERD_set_filenames.

10. It’s sometimes a pain to have to trace into a dynamically loaded library and might be more helpful to compile your reader as a standalone app.
If you do a
make checker
then your reader will be compiled with an ensight checker app that simulates calling all of the required routines step by step so you can pretend you are running EnSight in a stand alone app.  The make file will link your library into ../checker/udr_checker.c which will make a standalone executable rather than a dynamically loaded library.

For example, for API 2.03:

 make checker
udr_checker.c
Building checker …
icc  -static-intel     -o checker -L’/home/users/wndunn/svn/apex/branches/92′/lib -L/home/dev/arch22/linux_2.6_64-icc111/lib udr_checker.o libuserd-netcdf.o                                      -lnetcdf360snl                                   -lm
udr_checker.o: In function `main’:
/scratch/users/wndunn/svn/apex/branches/92/ensight/user_defined_src/readers/goober/udr_checker.c:999: undefined reference to `USERD_exit_routine’
udr_checker.o: In function `gold_part_builder’:
/scratch/users/wndunn/svn/apex/branches/92/ensight/user_defined_src/readers/goober/udr_checker.c:3602: undefined reference to `USERD_rigidbody_values

 

This indicates that you are missing two routines:
USERD_exit_routine
USERD_rigidbody_values
This article comes from the knowledge base.

© 2014 CEI Inc., makers of EnSight. All Rights Reserved.