VisIt-tutorial-in-situ

Revision as of 15:55, 10 June 2021 by Kat (talk | contribs) (Update links to DataManualExamples.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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:

  1. Presentation slides (pdf)
  2. Demonstration

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).

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.

MandelbrotAMR.png
Mandelbrot set

Other links:


Building the example

###############################################################################
# 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)

  1. Run 'visit
  2. Open ~/.visit/simulations in the File Open window
  3. 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.
  4. VisIt will try connecting to the simulation
  5. Look at terminal 1 to see if it contains VisIt connected
  6. Add a Pseudocolor plot of the mandelbrot variable
  7. Click Draw
  8. Go back to terminal 1

Terminal 1

  1. Type step at the simulation's command> prompt
  2. 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

  1. Open up VisIt's File->Simulations window
  2. Note the command buttons: halt, step, run, update
  3. The command buttons provide a limited way for VisIt to drive the simulation
  4. Click the run button and watch terminal 1 for messages
  5. Click the update button and watch VisIt recalculate the plots
  6. Click the halt button to halt the simulation
  7. Add a Subset plot of levels
  8. Open the Subset plot attributes and turn on single-color. Make it black.
  9. Turn on wireframe
  10. Click Apply and Dismiss the window
  11. Click Draw to draw the plot
  12. Click the toggleupdates button
  13. 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