Difference between revisions of "VisIt-tutorial-in-situ"

m (Building the example)
Line 1: Line 1:
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:
+
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
 
*Adds visualization capabilities inside the simulation so it can visualize the data
Line 8: Line 8:
  
 
This tutorial section will consist of:
 
This tutorial section will consist of:
# Presentation slides ([[Media:SC2010-in-situ.pdf|pdf]]) ([http://visit.ilight.com/svn/visit/trunk/docs/Presentations/SC2010-in-situ.pptx powerpoint])
+
# Presentation slides ([http://portal.nersc.gov/project/visit/cyrush/2018_02_ecp/2018_02_VisIt_ECP_LibSim_Tutorial.pdf pdf])
 
# Demonstration
 
# Demonstration
  
Line 14: Line 14:
 
Here are some resources for in-situ visualization with VisIt. The best reference is the [https://wci.llnl.gov/codes/visit/2.0.0/GettingDataIntoVisIt2.0.0.pdf Getting Data Into VisIt manual].
 
Here are some resources for in-situ visualization with VisIt. The best reference is the [https://wci.llnl.gov/codes/visit/2.0.0/GettingDataIntoVisIt2.0.0.pdf Getting Data Into VisIt manual].
  
*ECP 2nd Annual Meeting (2018) LibSim presentation slides [pdf] [pptx]
+
*[http://portal.nersc.gov/project/visit/cyrush/2018_02_ecp/2018_02_VisIt_ECP_LibSim_Tutorial.pdf ECP 2nd Annual Meeting (2018) LibSim presentation slides ]
  
 
*SC10 In-situ presentation slides ([[Media:SC2010-in-situ.pdf|pdf]]) ([http://visit.ilight.com/svn/visit/trunk/docs/Presentations/SC2010-in-situ.pptx powerpoint])
 
*SC10 In-situ presentation slides ([[Media:SC2010-in-situ.pdf|pdf]]) ([http://visit.ilight.com/svn/visit/trunk/docs/Presentations/SC2010-in-situ.pptx powerpoint])
 
*[https://wci.llnl.gov/codes/visit/2.0.0/GettingDataIntoVisIt2.0.0.pdf Getting Data Into VisIt manual] chapter 5
 
*[https://wci.llnl.gov/codes/visit/2.0.0/GettingDataIntoVisIt2.0.0.pdf Getting Data Into VisIt manual] chapter 5
*[http://visit.ilight.com/svn/visit/branches/2.13RC/src/tools/DataManualExamples/Simulations/ Simulation code example programs]
+
*[http://visit.ilight.com/svn/visit/trunk/src/tools/DataManualExamples/Simulations/ Simulation code example programs]
 
*[[Simulation Control Interface]]
 
*[[Simulation Control Interface]]
 
*Development roadmaps [[SimV2 reader]], [[Additional in-situ work]]
 
*Development roadmaps [[SimV2 reader]], [[Additional in-situ work]]
  
 
=Example=
 
=Example=
While VisIt provides many [http://visit.ilight.com/svn/visit/trunk/src/tools/DataManualExamples/Simulations/ example programs] for in-situ visualization, we will focus on the Mandelbrot set example. This example uses adaptive mesh refinement to more finely resolve the Mandelbrot set where it provides more detail.
+
While VisIt provides many [http://visit.ilight.com/svn/visit/trunk/src/tools/DataManualExamples/Simulations/ 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.
  
 
{| align="center" border="1"
 
{| align="center" border="1"
Line 110: Line 110:
 
===Enabling the custom graphical user interface for the simulation===
 
===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.
 
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
+
 
 +
  cp mandelbrot.ui ~/.visit/ui
 +
 
 
<!--  
 
<!--  
 
===Additional step for MacOS X===
 
===Additional step for MacOS X===
Line 118: Line 120:
 
-->
 
-->
  
==Running the example==
+
==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.
 
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)'''
 
'''Terminal 1 (Run the simulation)'''
# cd ~/Desktop/simulation
+
 
# ./mandelbrot -trace trace.txt  
+
  ./mandelbrot -trace trace.txt  
  
 
For Mac users:
 
For Mac users:
* ./mandelbrot -trace trace.txt -dir /path/to/VisIt.app/Contents/Resources
+
  ./mandelbrot -trace trace.txt -dir /path/to/VisIt.app/Contents/Resources
  
 
or:
 
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
+
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)'''
 
'''Terminal 2 (Run VisIt)'''
# Run '''visit -small'''
+
# Run '''visit''
 
# Open ''~/.visit/simulations'' in the File Open window
 
# 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.
 
# 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.
Line 160: Line 162:
 
# Click the '''toggleupdates''' button
 
# Click the '''toggleupdates''' button
 
# Click the '''run''' button and watch VisIt recalculate the plots as the simulation runs
 
# 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
  
 
[[Category: VisIt Tutorial]]
 
[[Category: VisIt Tutorial]]
 
[[Category: libsim]]
 
[[Category: libsim]]

Revision as of 03:39, 3 February 2018

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.

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