SimV2 reader

Revision as of 02:15, 13 February 2009 by Mobrien (talk | contribs) (requested ability to save a picture withou opening up the GUI.)

VisIt currently interfaces to simulations via libsim and the SimV1 reader. There are a number of features that the SimV1 reader was not designed to provide. To address the list of missing features and other complications, libsim must be enhanced and a SimV2 reader must be created.

Helping out

If you have a NERSC account and can develop inside VisIt's svn repository there, then you can help. There is a development branch called "SimV2" created by user "whitlocb". Use VisIt's svn scripts to checkout the branch and help out.

co_branch SimV2 src -user whitlocb

Missing features

This table lists some features that should appear in a SimV2 plugin as well as the status of work on each particular feature.

For now, SimV2 has been started as an exact copy of the SimV1 reader. New structures have been added and new fields have been added to the existing data interface structures. For now, the control interface is unchanged. The control functions may eventually change somewhat in order to accommodate new SimV2 features. The data interface may also change as development continues in order to hide structure members and replace that access with accessor functions.

Features Status
Ghost zones returned as a field on a mesh Not started
Species Done
GetDomainList callback does not pass the name of the mesh, preventing simulations from having more than one domain per processor - or other funky domain decompositions Not started
CSG meshes Done
AMR meshes Not started
vector data Not started
tensor data Not started
libsim on Win32 Not started
C interface for calling individual VisIt queries from the simulation Not started
A way of saving a picture without bringing up the GUI. For example from running a simulation in batch mode. Not started
Add a void* data argument to all simulation callbacks so the simulation can pass in a pointer to its data structures rather than having to rely on global variables Not started
Support coordinates in single XY or XYZ array or maybe even strided array. Separating the coordinates out like we do not is not always convenient. Not started
Delete all of the structures that are returned from sim callback functions so we don't leak memory. Done

Headaches in the SimV1 interface

  • Too much access to struct data. It might be prudent to provide a functional interface instead as we do for Fortran applications that want to use libsim.
    • A functional interface could in theory make it possible to add new items to opaque structures without breaking simulations and the SimV2 reader.
  • The whole command interface added by prevost
  • Finding visitCallbacks from the SimV1 reader is a problem since it requires the application to be linked in such a way that the visitCallbacks structure is globally visible. Some developers of larger packages hate that. In addition, it is not possible to do on Windows and likely on other platforms as well.
    • I changed the mac version of V1 to use dlopen/dlsym to find it. This could be propagated to other platforms easily. --Jeremy
  • Maybe the writer interface can be combined with the SimV2 reader. A separate writer was provided for SimV1 so as not to break existing simulations due to missing writer symbols.

Notes about some design changes

  • We need to have a set of shared functions that get loaded at runtime for allocating and accessing data. These can have a libsim veneer that points to dynamically loaded functions from the visitenginev2 library. The sim would use the veneer functions and the SimV2 reader would use the real functions from visitenginev2.
  • Create XML state object descriptions of the structures in the data interface library. We may be able to use the real AVT metadata object XML files for the metadata-related structures.
  • Create a new XML tool to generate an opaque structure and C set/get functions. This generated code would go into visitenginev2 to be dynamically loaded at runtime. The sim and the simv2 reader would use the access functions to get at the data. This would eliminate problems with changing struct sizes once and for all. The XML tool could probably automatically generate sensible fortran bindings too.
  • Move visitengine library from engine/main into sim/V2 so we can add the data interface code to it while keeping all the source within sim.
  • Add VisItRegisterXXXCallback functions to let the sim register the callback that will get called for various operations. Internally, we can store things into a structure in visitenginev2.
/* This code would live in visitenginev2 and would be meant to address the
 * problem of having a globally visible visitCallbacks structure. Heck, by 
 * stuffing the callback data into visitenginev2, I think we avoid the 
 * problems of having to have a globally visible struct. It's also good that
 * the structure is hidden so we can extend it without breaking compiled code.
typedef struct
    VisIt_MeshData *(*GetMesh)(void *, int dom, const char *var);
    void           *GetMeshData;
    /* and so on */ 
} VisIt_SimulationCallbacks;

static VisIt_SimulationCallbacks *visitCallbacks = NULL;

static VisIt_SimulationCallbacks *
    if(visitCallbacks == NULL)
        visitCallbacks = (VisIt_SimulationCallbacks *)malloc(sizeof(VisIt_SimulationCallbacks));
        memset(visitCallbacks, 0, sizeof(VisIt_SimulationCallbacks));
    return visitCallbacks;

/* This gets called from the sim, indirectly */
visit_set_getmesh(VisIt_MeshData *(*cb)(void *, int dom, const char *var), void *cbdata)
    VisIt_SimulationCallbacks *cbs = GetVisItCallbacks();
    cbs->GetMesh = cb;
    cbs->GetMeshData = cbdata;

/* This gets called from the SimV2 reader */
VisIt_GetMesh *
visit_call_getmesh(int dom, const char *var)
    VisIt_SimulationCallbacks *cbs = GetVisItCallbacks();
    if(cbs->GetMesh != NULL)
        return (*cbs->GetMesh)(cbs->GetMeshData, dom, var);
    return NULL;

/********* libsim ************/
VisItSetCallback_GetMesh(VisIt_MeshData *(*cb)(void *, int dom, const char *var), void *cbdata)
    void *sym = SAFE_DLSYM("visit_set_getmesh");
    if(sym != NULL)
        (*(FUNC *)sym)(cb, cbdata);