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

m (Typo)
(Update links to DataManualExamples.)
 
(27 intermediate revisions by 6 users not shown)
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://portal.nersc.gov/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
  
 
=Resources=
 
=Resources=
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://visit-dav.github.io/visit-website/pdfs/GettingDataIntoVisIt2.0.0.pdf Getting Data Into VisIt manual] Chapter 5 (page 143).
  
*In-situ presentation slides ([[Media:SC2010-in-situ.pdf|pdf]]) ([http://portal.nersc.gov/svn/visit/trunk/docs/Presentations/SC2010-in-situ.pptx powerpoint])
+
*[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 ]
*[https://wci.llnl.gov/codes/visit/2.0.0/GettingDataIntoVisIt2.0.0.pdf Getting Data Into VisIt manual] chapter 5
+
 
*[http://portal.nersc.gov/svn/visit/branches/2.1RC/src/tools/DataManualExamples/Simulations/ Simulation code example programs]
+
*SC10 In-situ presentation slides ([[Media:SC2010-in-situ.pdf|pdf]]) ([https://github.com/visit-dav/visit/blob/develop/docs/Presentations/SC2010-in-situ.pptx powerpoint])
 +
*[https://github.com/visit-dav/visit/tree/develop/src/tools/data/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://portal.nersc.gov/svn/visit/branches/2.1RC/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 [https://github.com/visit-dav/visit/tree/develop/src/tools/data/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 30: Line 31:
  
 
Other links:
 
Other links:
*[http://portal.nersc.gov/svn/visit/branches/2.1RC/src/tools/DataManualExamples/Simulations/life.c Game of Life simulation example]
+
*[https://github.com/visit-dav/visit/tree/develop/src/tools/data/DataManualExamples/Simulations/life.c Game of Life simulation example]
*[http://portal.nersc.gov/svn/visit/trunk/src/tools/DataManualExamples/Simulations/contrib/pjacobi/ Parallel Jacobi solver for the Laplacian equation in 2D simulation example]
+
*[https://github.com/visit-dav/visit/tree/develop/src/tools/data/DataManualExamples/Simulations/contrib/pjacobi/ Parallel Jacobi solver for the Laplacian equation in 2D simulation example]
 
*Find out more about the [http://en.wikipedia.org/wiki/Mandelbrot_set Mandelbrot set]
 
*Find out more about the [http://en.wikipedia.org/wiki/Mandelbrot_set Mandelbrot set]
 
*Find out more about [http://en.wikipedia.org/wiki/Adaptive_mesh_refinement Adaptive Mesh Refinement]
 
*Find out more about [http://en.wikipedia.org/wiki/Adaptive_mesh_refinement Adaptive Mesh Refinement]
Line 38: Line 39:
  
 
==Building the example==
 
==Building the example==
# Get the source code for the Mandelbrot simulation example: [http://portal.nersc.gov/svn/visit/branches/2.1RC/src/tools/DataManualExamples/Simulations/mandelbrot.C mandelbrot.C],[http://portal.nersc.gov/svn/visit/branches/2.1RC/src/tools/DataManualExamples/Simulations/patch.C patch.C],[http://portal.nersc.gov/svn/visit/branches/2.1RC/src/tools/DataManualExamples/Simulations/patch.h patch.h],[http://portal.nersc.gov/svn/visit/branches/2.1RC/src/tools/DataManualExamples/Simulations/SimulationExample.h SimulationExample.h].
+
* Get the source code and example Makefile for the Mandelbrot simulation examples:  
# Make a '''simulation''' directory on your Desktop and copy the source code files to it
+
**[http://portal.nersc.gov/project/visit/cyrush/2018_02_ecp/visit_libsim_mandelbrot_example.tar.gz visit_libsim_mandelbrot_example.tar.gz ]
# Copy the Makefile below to the '''simulation''' directory, adjusting the contents to provide the correct location of VisIt's SimV2 library.
+
**[http://portal.nersc.gov/project/visit/cyrush/2018_02_ecp/visit_libsim_mandelbrot_example.zip visit_libsim_mandelbrot_example.zip ]
# Type ''make''
+
<!--- [https://github.com/visit-dav/visit/tree/develop/src/tools/data/DataManualExamples/Simulations/mandelbrot.C mandelbrot.C],[https://github.com/visit-dav/visit/tree/develop/src/tools/data/DataManualExamples/Simulations/patch.C patch.C],[https://github.com/visit-dav/visit/tree/develop/src/tools/data/DataManualExamples/Simulations/patch.h patch.h],[https://github.com/visit-dav/visit/tree/develop/src/tools/data/DataManualExamples/Simulations/SimulationExample.h SimulationExample.h],[https://github.com/visit-dav/visit/tree/develop/src/tools/data/DataManualExamples/Simulations/mandelbrot.ui mandelbrot.ui].
 +
---->
 +
* 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''
  
 
<code><pre>
 
<code><pre>
############## Makefile for building the simulation using libsim. ###############
+
###############################################################################
 +
# Makefile for building mandelbrot examples that use libsim.  
 +
###############################################################################
  
 
############################## USER EDIT SECTION ################################
 
############################## USER EDIT SECTION ################################
  
 
# Fill in the Path to the VisIt installation. This is the directory that contains  
 
# Fill in the Path to the VisIt installation. This is the directory that contains  
# VisIt's 2.0.0, 2.0.1, 2.1.0, 2.1.1 directories
+
# VisIt's 2.13.0 directory. Mac users may want to
VISITHOME=/path/to/visit
+
# 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
 
# Set this to the version of VisIt that you use
VISITVERSION=2.1.1
+
VISITVERSION=2.13.0
  
 
# Choose one, depending on your system architecture
 
# Choose one, depending on your system architecture
#VISITARCH=linux-intel
+
VISITARCH=darwin-x86_64
 
#VISITARCH=linux-x86_64
 
#VISITARCH=linux-x86_64
VISITARCH=darwin-i386
 
  
 
# Edit your compiler and its settings
 
# Edit your compiler and its settings
CXX=g++
+
CXX=clang++
 
CPPFLAGS=
 
CPPFLAGS=
 
CXXFLAGS=-O3
 
CXXFLAGS=-O3
Line 72: Line 80:
 
SIM_CXXFLAGS=-I$(SIMDIR)/include
 
SIM_CXXFLAGS=-I$(SIMDIR)/include
 
SIM_LDFLAGS=-L$(SIMDIR)/lib
 
SIM_LDFLAGS=-L$(SIMDIR)/lib
SIM_LIBS=-lsimV2
+
SIM_LIBS=-lsimV2 -ldl
  
 
SRC=mandelbrot.C patch.C
 
SRC=mandelbrot.C patch.C
 
OBJ=$(SRC:.C=.o)
 
OBJ=$(SRC:.C=.o)
  
all: mandelbrot
+
 
 +
SRC_BATCH=mandelbrot_batch.C patch.C
 +
OBJ_BATCH=$(SRC_BATCH:.C=.o)
 +
 
 +
all: mandelbrot mandelbrot_batch
  
 
clean:
 
clean:
rm -f mandelbrot $(OBJ)
+
rm -f mandelbrot mandelbrot_batch $(OBJ)
  
 
mandelbrot: $(OBJ)
 
mandelbrot: $(OBJ)
 
$(CXX) -o mandelbrot $(OBJ) $(LDFLAGS) $(SIM_LDFLAGS) $(SIM_LIBS) $(LIBS)
 
$(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:
 
.C.o:
Line 91: Line 107:
 
*''Note: if you build and make complains about missing separators, replace the spaces before $(CXX) with a tab''
 
*''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
 +
 +
<!--
 
===Additional step for MacOS X===
 
===Additional step for MacOS X===
 
VisIt relinks its libraries during installation so its libraries are positioned relative to ''@executable_path/../lib''. Unfortunately, this means that when the VisIt libraries are dynamically loaded into your MacOS X simulation by libsim, it expects to find dependent libraries in ''../lib'' relative to your application. For the time being, you will need to create a ''lib'' symbolic link to VisIt's libraries.
 
VisIt relinks its libraries during installation so its libraries are positioned relative to ''@executable_path/../lib''. Unfortunately, this means that when the VisIt libraries are dynamically loaded into your MacOS X simulation by libsim, it expects to find dependent libraries in ''../lib'' relative to your application. For the time being, you will need to create a ''lib'' symbolic link to VisIt's libraries.
 
# cd ~/Desktop
 
# cd ~/Desktop
# ln -s /path/to/visit/2.1.1/darwin-i386/lib .
+
# ln -s /path/to/VisIt.app/Contents/Resources/2.13.0/darwin-x86_64/lib .
 +
-->
  
==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:
 +
  ./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)'''
 
'''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 131: Line 161:
 
# 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]]

Latest revision as of 15:55, 10 June 2021

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