Blood Flow Aneurysm Tutorial Vector Field Visualization
Contents
Simulation Data
This tutorial uses the aneurysm dataset -- available at: http://www.visitusers.org/index.php?title=Tutorial_Data
To begin:
- Launch VisIt
- In VisIt's GUI, under the [Sources] section, click Open
- Navigate your file system to select the aneurysm.visit file.
Visualizing the Velocity Vector Field
This section of the tutorial outlines using Glyphs, Streamlines, and Pathlines to visualize the velocity vector field from the simulation.
This section follows the Initial Dataset Exploration Tutorial section. To create the reference blue semi-transparent plot of the simulation mesh, review the Blood_Flow_Aneurysm_Tutorial_Dataset_Exploration#Creating_a_Semi-Transparent_Exterior_Mesh_Plot content.
Plotting the Vector Field Directly with Glyphs
VisIt's vector plot renders a vector field at each time step as a collection of Arrow Glyphs. This allows us to see the direction of the vectors as well as their magnitude. We will create a vector plot to directly view the simulated velocity vector field.
- Add a Vector Plot of velocity
- [Plot List] Add->Vector->velocity
- Open the Vector Plot Attributes Window
- In the Vectors tab
- Set Stride to 5
- In the Data tab, Color section
- Change the color table to Spectral, and check the Invert option
- In the Glyphs tab:
- Under the Scale section, set the scale to 0.5
- Under the Style section, chance the Arrow body to Cylinder
- Under the Rendering section, set Geometry Quality to High
- Click Apply and dismiss the window.
- In the Vectors tab
- Click Draw and use the Play button to animate
Examining features of the Flow Field with Streamlines
To explore the flow field further we will seed and advect a set of streamlines near the inflow of the artery. Streamlines show the path massless tracer particles would take if advected by a static vector field. To construct Streamlines, the first step is selecting a set of spatial locations that can serve as the initial seed points.
We want to center our seed points around the peak velocity value on a slice near the inflow of the artery. To find this location, we query a sliced pseudocolor plot of the velocity_magnitude.
- Add a Pseudocolor Plot of velocity_magnitude
- [Plot List] Add->Pseudocolor->velocity_magnitude
- Open Pseudocolor Plot Attributes Window and set the color table options as before.
- Add a Slice Operator near the inlet
- [Plot List] Operators->Slicing->Slice
- Open the Slice Operator Attributes Window
- Under the Normal Section
- Set Orthogonal to Y Axis
- Under the Origin Section
- Select Point and set the value to 3 3 3
- Under the Up Axis Section
- Uncheck Project to 2D
- Click Apply and dismiss the window.
- Under the Normal Section
- [Plot List] Click Draw
Query to find the Maximum Velocity on the Slice
- [Plot list] Click to make sure the Pseudocolor plot of your velocity_magnitude slice is active
- [Controls Menu]->Query
- Select Max
- Select Actual Data
- Click Query
This will give you the maximum scalar value on the slice and the x,y,z coordinates of the element associated with this value. We will use the x,y,z coordinates of this element to seed a set of streamlines.
- Add a Streamline Plot of velocity
- [Plot List] Add->Streamline->velocity
- Open the Streamline Plot Attributes Window
- In the Streamlines tab
- Under the Source section
- Set the Source type to Circle
- Set the Origin to the value returned from the max query: 3.45115 3.0 5.54927
- (Exclude any commas in the input text box)
- Set the Normal to the y-axis: 0 1 0
- Set the Up axis to the z-axis: 0 0 1
- Set the Radius to 0.12
- Under the Sampling section
- Set Sampling along: to Boundary
- Set Samples in Theta to 12
- Under the Source section
- In the Appearance tab
- Under the Color section,
- Change the Color table to Reds
- Under the Display section
- Change Draw as to Tubes
- Check the Show heads check box, and set Display as to Cone
- Set the Display quality to High
- Under the Color section,
- In the Advanced tab:
- Under the Warnings section, uncheck all of the warning checkboxes
- Click Apply and dismiss the Streamline plot attributes window.
- Click Draw and use the [Time Slider] Control to view a few time steps.
Examining features of the Flow Field with Pathlines
Finally, to explore the time varying behavior of the flow field we will use Pathlines. Pathlines show the path massless tracer particles would take if advected by the vector field at each timestep of the simulation.
We will modify our previous Streamline plot to create Pathlines.
- Set the [Time Slider] Control to the first timestep.
- Open the Streamline Plot Attributes Window
- Under the Advanced tab
- In the Streamlines vs Pathlines section
- Select Pathline
- In the Pathlines Options section
- Set How to perform interpolation over time to Mesh is static over time
- In the Streamlines vs Pathlines section
- Under the Advanced tab
- Click Apply and dismiss the window.
This will process all 200 files in the dataset and construct the Pathlines that originate at our seed points.
After this calculation is done, we can animate the Pathlines by cropping away portions of the curves based on advection time.
- Open the Commands Window
- [Controls Menu]->Command
- Find an empty tab
- Paste the following Python snipper into this tab
# Animate our pathlines by cropping based on time
satts = StreamlineAttributes()
satts.referenceTypeForDisplay = satts.Time
satts.displayEndFlag = 1
nsteps = 100 # Number of steps
final_time = .995
for i in range(nsteps+1):
satts.displayEnd = final_time * i /nsteps
SetPlotOptions(satts)
- Click Execute
Sharing content and video encoding using SeedMe.org
Results from visualization and analysis are often shared with collaborators. SeedMe.org provides an easy to automate sharing and collaboration platform.
Required setup
- Sign-up at SeedMe.org
- Download your API Key file, then move it to your Home directory.
Sharing automation script
In this section we will render and save pathline trace in 20 steps. Then upload and share the rendered 20 images as a sequence and instuct SeedMe to encode a video from these set of images at 2 frames per second. A sample video can be seen here
Brief explanation is provided in comments and detailed example can be seen here.
- Open the Commands Window
- [Controls Menu]->Command
- Find an empty tab
- Paste the following Python snipper into this tab
##############################################################################
# To do : Set the following four variables
##############################################################################
seedme_apikey_path = '/absolute/path/to/seedme.txt'
my_rendered_image_path = "/absolute/path/for/images/" # does not traverse recurssively
my_content_privacy = "public" # private (default), group, public
my_share_list = "one@example.com, two@example.com" # comma delimted emails
# Set save window attributes including path where the rendered images will be saved
sa = SaveWindowAttributes()
sa.outputToCurrentDirectory = 0
sa.outputDirectory = my_rendered_image_path
sa.fileName = "pathline"
sa.family = 1
sa.format = sa.PNG
sa.width = 512
sa.height = 512
sa.screenCapture = 0
sa.saveTiled = 0
sa.quality = 80
sa.progressive = 0
sa.binary = 0
sa.stereo = 0
sa.compression = sa.PackBits # None, PackBits, Jpeg, Deflate
sa.forceMerge = 0
sa.resConstraint = sa.ScreenProportions # NoConstraint, EqualWidthHeight, ScreenProportions
sa.advancedMultiWindowSave = 0
SetSaveWindowAttributes(sa)
# Now save this pathline visualization in 20 frames (images)
# Animate our pathlines by cropping based on time
satts = StreamlineAttributes()
satts.referenceTypeForDisplay = satts.Time
satts.displayEndFlag = 1
nsteps = 20 # Number of steps
final_time = .995
for i in range(nsteps+1):
satts.displayEnd = final_time * i /nsteps
SetPlotOptions(satts)
SaveWindow() # will save images at the sa.outputDirectory provided above
##############################################################################
# Upload and share content at SeedMe.org
# Instruct the seedme module to upload 20 images then encode a video from it
# seedme module ships with VisIt 2.9.x +
##############################################################################
import seedme
# Set path to the APIKey file
obj.set_auth_via_file(seedme_apikey_path)
# Create a dictionary for rendered image sequence
my_seq = {
"filepath": my_rendered_image_path,
"title": "Pathline",
"description": "Pathlines show the path massless tracer particles would take if advected by the vector field at each timestep of the simulation.",
"fps": 2,
"encode": True,
}
# Create seedme object
obj = seedme.SeedMe()
##############################################################################
# Create a new collection using create_collection method
# comprising of title and sequence with public access, shared with two people
##############################################################################
result=obj.create_collection(title="Aneurysm vis",
privacy=my_content_privacy, # string = One of private(default), group, public
sharing=my_share_list, # string = Comma delimited emails
notify=True, # Boolean = False(default) send email notification to above two emails
sequences=my_seq, # upload sequence
)
# create_collection returns the result as a string in json format
print result
url = obj.get_url(result)
# Visit this url on your web browser
print("The url for this collection is: " + url)
- Click Execute
To view your shared content login to SeedMe.org then navigate to My collections.