XDB Export

VisIt can export FieldView XDB files based on the plots that you have created. This feature is available when running VisIt interactively, when using Python scripting, and from in situ via Libsim.

Scripting

The following script provides some utility functions that can set up VisIt plots to save data to FieldView XDB format.

# Usage: visit -cli -nowin -s exportxdb.py [-np #]
import sys

def extract_slice(xdbfile, origin, normal, vars):
    # Set up a plot.
    AddPlot("Pseudocolor", vars[0])
    AddOperator("Slice")
    s = SliceAttributes()
    s.axisType = s.Arbitrary
    s.originType = s.Point
    s.originPoint = origin
    s.normal = normal
    s.project2d = 0
    SetOperatorOptions(s)
    DrawPlots()

    # Export the plot.
    options={"Strip mesh name prefix":True}
    dbAtts = ExportDBAttributes()
    dbAtts.db_type = "FieldViewXDB"
    dbAtts.filename = xdbfile
    dbAtts.variables = vars
    success = ExportDatabase(dbAtts, options)

    # Cleanup
    DeleteActivePlots()

def extract_coord_surface(xdbfile, axis, intercept, vars):
    # Set up a plot.
    AddPlot("Pseudocolor", vars[0])
    AddOperator("Slice")
    s = SliceAttributes()
    s.axisType = axis # x=0, y=1, z=2
    s.originType = s.Intercept
    s.originIntercept = intercept
    s.project2d = 0
    SetOperatorOptions(s)
    DrawPlots()

    # Export the plot.
    options={"Strip mesh name prefix":True}
    dbAtts = ExportDBAttributes()
    dbAtts.db_type = "FieldViewXDB"
    dbAtts.filename = xdbfile
    dbAtts.variables = vars
    success = ExportDatabase(dbAtts, options)

    # Cleanup
    DeleteActivePlots()

def extract_iso(xdbfile, isovalues, vars):
    # Set up a plot
    AddPlot("Contour", vars[0])
    c = ContourAttributes()
    c.contourMethod = c.Value
    c.contourValue = isovalues
    SetPlotOptions(c)
    DrawPlots()

    # Export the plot.
    options={"Strip mesh name prefix":True}
    dbAtts = ExportDBAttributes()
    dbAtts.db_type = "FieldViewXDB"
    dbAtts.filename = xdbfile
    dbAtts.variables = vars
    success = ExportDatabase(dbAtts, options)

    # Cleanup
    DeleteActivePlots()

def main():
    db = "~/Development/data/noise.silo"
    OpenDatabase(db)
    extract_coord_surface("coordsurf_x=5.xdb", 0, 5., ("hardyglobal", "radial"))
    extract_coord_surface("coordsurf_y=0.xdb", 1, 0., ("hardyglobal", "radial", "grad"))
    extract_slice("slice.xdb", (0,0,0), (1,1,1), ("hardyglobal", "radial", "grad"))
    extract_iso("iso.xdb", (1.2, 2.3, 3.4, 4.5), ("hardyglobal", "grad"))
    CloseDatabase(db)

main()
sys.exit(0)

To run the script, use the VisIt CLI:

visit -cli -nowin -s exportxdb.py

This will run the VisIt CLI without a window, start the VisIt processes (including the engine, which writes the XDB files) and then make plots and export them to XDB. If you list the directory after, you should see 4 XDB files:

% ls *.xdb
coordsurf_x=5.xdb	coordsurf_y=0.xdb	iso.xdb			slice.xdb

The iso.xdb file plotted in FieldView: FieldView iso xdb.png