VisIt-tutorial-in-situ
VisIt provides a library for in-situ visualization and analysis that we call LibSim. LibSim lets you instrument your simulation code so VisIt can connect to it and access its data directly as though the simulation was a VisIt compute engine. Trends show that as computers get faster, I/O cannot keep pace. This makes in-situ's properties appealing:
- Adds visualization capabilities inside the simulation so it can visualize the data
- Visualize the data using the same level of resources as are being used to calculate the data (vis often gets 1/10th the resources)
- Writing plot dump files not required so plot images can be saved at greater frequency
- Visualization routines get direct access to the simulation’s memory
- Good for making canned movies
This tutorial section will consist of:
- Presentation slides (pdf)
- Demonstration
Contents
Resources
Here are some resources for in-situ visualization with VisIt. The best reference is the Getting Data Into VisIt manual Chapter 5 (page 143).
- SC10 In-situ presentation slides (pdf) (powerpoint)
- Simulation code example programs
- Simulation Control Interface
- Development roadmaps SimV2 reader, Additional in-situ work
Example
While VisIt provides many example programs for in-situ visualization, we will focus on the Mandelbrot set examples. These example uses adaptive mesh refinement to more finely resolve the Mandelbrot set where it provides more detail.
![]() |
---|
Mandelbrot set |
Other links:
- Game of Life simulation example
- Parallel Jacobi solver for the Laplacian equation in 2D simulation example
- Find out more about the Mandelbrot set
- Find out more about Adaptive Mesh Refinement
Building the example
- Get the source code and example Makefile for the Mandelbrot simulation examples:
- Download and unpack one of the archives above
- Edit the Makefile, adjusting the contents to provide the correct location of VisIt's SimV2 library.
- Type make
###############################################################################
# Makefile for building mandelbrot examples that use libsim.
###############################################################################
############################## USER EDIT SECTION ################################
# Fill in the Path to the VisIt installation. This is the directory that contains
# VisIt's 2.13.0 directory. Mac users may want to
# use /path/to/VisIt.app/Contents/Resources to locate the "visit" directory
# within an app bundle.
VISITHOME=path/to/VisIt.app/Contents/Resources/
# Set this to the version of VisIt that you use
VISITVERSION=2.13.0
# Choose one, depending on your system architecture
VISITARCH=darwin-x86_64
#VISITARCH=linux-x86_64
# Edit your compiler and its settings
CXX=clang++
CPPFLAGS=
CXXFLAGS=-O3
LDFLAGS=
LIBS=
#################################################################################
SIMDIR=$(VISITHOME)/$(VISITVERSION)/$(VISITARCH)/libsim/V2
SIM_CXXFLAGS=-I$(SIMDIR)/include
SIM_LDFLAGS=-L$(SIMDIR)/lib
SIM_LIBS=-lsimV2 -ldl
SRC=mandelbrot.C patch.C
OBJ=$(SRC:.C=.o)
SRC_BATCH=mandelbrot_batch.C patch.C
OBJ_BATCH=$(SRC_BATCH:.C=.o)
all: mandelbrot mandelbrot_batch
clean:
rm -f mandelbrot mandelbrot_batch $(OBJ)
mandelbrot: $(OBJ)
$(CXX) -o mandelbrot $(OBJ) $(LDFLAGS) $(SIM_LDFLAGS) $(SIM_LIBS) $(LIBS)
mandelbrot_batch: $(OBJ_BATCH)
$(CXX) -o mandelbrot_batch $(OBJ_BATCH) $(LDFLAGS) $(SIM_LDFLAGS) $(SIM_LIBS) $(LIBS)
.C.o:
$(CXX) $(CXXFLAGS) $(SIM_CXXFLAGS) $(CPPFLAGS) -c $<
- Note: if you build and make complains about missing separators, replace the spaces before $(CXX) with a tab
Enabling the custom graphical user interface for the simulation
The Mandelbrot simulation supports a custom graphical user interface to the simulation. To enable it you must copy the ui file to the VisIt ui directory.
cp mandelbrot.ui ~/.visit/ui
Running the interactive example
You will need 2 terminal/shell windows. In the first window you will run the simulation. In the second window, you will launch VisIt and connect to the simulation.
Terminal 1 (Run the simulation)
./mandelbrot -trace trace.txt
For Mac users:
./mandelbrot -trace trace.txt -dir /path/to/VisIt.app/Contents/Resources
or:
env DYLD_LIBRARY_PATH=/path/to/VisIt.app/Contents/Resources/<VERSION>/darwin-x86_64/lib ./mandelbrot -trace trace.txt -dir /path/to/VisIt.app/Contents/Resources
Terminal 2 (Run VisIt)
- Run 'visit
- Open ~/.visit/simulations in the File Open window
- There should be a file ######.mandelbrot.sim2 that you'll want to open. If there are multiple files that match that pattern then open the most recent one.
- VisIt will try connecting to the simulation
- Look at terminal 1 to see if it contains VisIt connected
- Add a Pseudocolor plot of the mandelbrot variable
- Click Draw
- Go back to terminal 1
Terminal 1
- Type step at the simulation's command> prompt
- Type update at the simulation's command> prompt and watch the VisIt window update its plots with a different portion of the Mandelbrot set.
Within VisIt
- Open up VisIt's File->Simulations window
- Note the command buttons: halt, step, run, update
- The command buttons provide a limited way for VisIt to drive the simulation
- Click the run button and watch terminal 1 for messages
- Click the update button and watch VisIt recalculate the plots
- Click the halt button to halt the simulation
- Add a Subset plot of levels
- Open the Subset plot attributes and turn on single-color. Make it black.
- Turn on wireframe
- Click Apply and Dismiss the window
- Click Draw to draw the plot
- Click the toggleupdates button
- Click the run button and watch VisIt recalculate the plots as the simulation runs
Running the batch example
The batch example (mandelbrot_batch.C) uses LibSim without an active connection to VisIt. It renders a Pseudocolor Plot of the mandelbrot variable to a PNG every cycle and exports the data set to a set of VTK files every 10th cycle.
Terminal (Run the batch instrumented simulation)
./mandelbrot_batch -trace batch_trace.txt
For Mac users:
./mandelbrot_batch -trace batch_trace.txt -dir /path/to/VisIt.app/Contents/Resources
or:
env DYLD_LIBRARY_PATH=/path/to/VisIt.app/Contents/Resources/<VERSION>/darwin-x86_64/lib ./mandelbrot -trace trace.txt -dir /path/to/VisIt.app/Contents/Resources