Difference between revisions of "ParaView"

From OSUPDOCS
Jump to navigation Jump to search
 
(36 intermediate revisions by the same user not shown)
Line 1: Line 1:
[http://www.paraview.org ParaView] is free andadvanced software with many options for visualization, especially when doing 3D calculations.  
[http://www.paraview.org ParaView] is free and advanced software with many options for visualization, especially when doing 3D calculations.  
__TOC__
__TOC__
== Getting Started  ==
== Getting Started  ==


This section gives the basic steps needs to start using [http://www.paraview.org ParaView] to visualize material point method output for [[NairnMPM]].
This section gives the basic steps needed to start using [http://www.paraview.org ParaView] to visualize material point method output from [[NairnMPM]].


# Download and install [http://www.paraview.org ParaView]. It is available for many platforms and can run in parallel (hence the name) if installed on a multiprocessor system or cluster of computers.
# Download and install [http://www.paraview.org ParaView]. It is available for many platforms and can run in parallel (hence the name) if installed on a multiprocessor system or cluster of computers.
# Run from [[NairnMPM]] calculations that use the [[VTKArchive Custom Task]] to save results as VTK legacy files. Save the quantties you might want to plot and one of them should be mass (because it is used in many plot options)
# Run some[[NairnMPM]] calculations. You have two options for visualizing results in [http://www.paraview.org ParaView]:
# Run ParaView, choose the open command and select the block of VTK legacy files that were just created. The files will be found in the archived results folder with the naming stlye "MPM_#.vtk" where "MPM" is the root name you used for the calculation's archived files and "#" is the step number. ParaView will let you select these as a block to open them all at once, or expand the block and select a single file. You need to open as a block to get movies of results.
## After a simulation is done, use the "Export Particle VTKs..." option to extract results of any simulation to particle VTK files. Include the data you want to visualize. it works best if you include "meansize" which means the simulation included "size" in the archived results. These VTK files can be used create particle plots.
# ParaView does not actually read files when they are opened. To read them, click the "Apply" button in the object inspector. When it is done reading, a wire frame surroinding the analysis space should appear in the plot area, but still not plot.
## Include the [[VTKArchive Custom Task]] to save results as VTK legacy files. Save the quantities you might want to plot and one of them should be mass (because it is used in many plot options). These VTK files can be used to create grid plots.
# These are numerous types of plots you can create. To try one, click the "Contour" icon. In the object inspector, set it to countour by mass. In the isosurfaces section, set the contour value to some number less than the maximum mass. The optimal value will depend on the structure of your model. You need a lowed number to visualize porous objects or a higher number for solid objects. You can also add several numbers to create contours at several values of mass.
# To open either type of VTK files in ParaView, choose the open command and select a block of VTK legacy files. Those exported as particle VTKs will be in the the archived results folder for your simulation and will have the root name you choose when exporting the files. Those created by a [[VTKArchive Custom Task]] will also be in the archived results folder with the naming style "MPM_#.vtk" where "MPM" is the root name you used for the calculation's archived files and "#" is the step number. If you used [[VTKArchive Custom Task]] to archive results for a single material type, the fille name will change to "MPM_mat_#_#.vtk" where the first number is a material number. ParaView will let you select such files as a block and will open them all at once. Alternatively, you can expand the block and select a single file. You need to open as a block to get movies of results.
# Finally, use the "Coloring" menu (in tool bar or in object inspector) to choose archived component to apply color the the mass surface. If you pick a tensor or vector, you can pick which component to use in the second menu.
# ParaView does not actually read files when they are opened. To read them, click the "Apply" button in the object inspector. When  
# If you loading the VTK files as a block, you can use the movies controls to animate the results.


These instructions gets just one type of plot. Once you have data in the ParaView, you can explore all its other options for plotting.
Once opened, you have many plotting options available. The available options will depend of if you opened particle VTK files or grid-based VTK files. The following sections gives to steps to get started with plotting. Once have one of these plots visible, you can explore all the ParaView options for more ways to visualize the results.
 
== Thresholded Plots ==


== Particle Plots in ParaView ==
== Particle Plots in ParaView ==


Using the [[VTKArchive Custom Task]] always gets grid-based plots. By extracting particle data using [[ExtractMPM]], you can also use ParaView to view particle-based plots. Here is an example to get started with particle plots in ParaView:
By extracting particle data to VTK files (either using the "Export Particle VTKs..." option in [[NairnFEAMPM]] or in [[NairnFEAMPMViz]] or by running [[ExtractMPM]] on a command line), you can also use ParaView to view particle-based plots. This section gives to examples to get started with particle plots.


<ol>
=== Particle Plot using "Cells" ===


<li>Run the <tt>TwoDisks.fmcmd</tt> example in <code>nairn-mpm-fea/NairnMPM/input/Scripted_Input</code> using its <tt>#analysis$="3D MPM"</tt> option.
The preferred visualization to exported to an unstructured grid (<b>-U</b> option in [[ExtractMPM]]) where each material point becomes a cell in the grid. Furthermore, the cells are transformed to reflect the particle deformation. Plotting such files is easy:


<li>Use <tt>ExtractMPM</tt> in the create subfolder in the <tt>Results</tt> folder with the following command line:
# Open the exported particle VTK files in ParaView (as described above). The plot should appear when you click "Apply: to finish the opening.
<pre>ExtractMPM -V -q sxx -q velx -q dispx -s -o TwoSpheres USAVG-uGIMP.*
# Once you have a plot, you can click and drag with mouse to change the viewing position.
</pre>
# Choose simulation result to plot from menu in second row of tool bars. (for [[#Vector and Tensor Plotting|tensor or vector quantities]], choose the component to plot from the second menu).
where <tt>USAVG-uGIMP.</tt> is the root for the archive files (and should be changed if you results are different).
This command will extract particle data (with the listed quantites) to a series of VTK files names "<tt>TwoSpheres_#.vtk</tt>" where "#" is the step number. The <tt>-s</tt> option is needed to get the step number in the file name, which ParaView uses to correctly order the results.


<li>Run ParaView, open the block of saved VTK files, and click "Apply" in the object inspector to load. The files will be read, but nothing will be plotted yet.
=== Particle Plots using Glyphs ===
 
</ol>
 
You now have two options for particle plots: plot point sprites or plot glyphs at each material point. Point sprites seem best for general use and are much faster. Glyphs may have more options for problems with relatively few number of material points.


=== Particle Plots using Point Sprite ===
The most advanced particle plots use glyphs. Here is an some steps to get started:


To plot using point sprites, do the following:
# Open the exported particle VTK files in ParaView (as described above)
# Choose icon to add "Glyph" in the tool bar (it is also in the "Filters" menu along with many more options)
# In the "Glyph Properties" window, make the following settings:
#* Set "Glyph Type" to box or sphere (other options normally do not make sense)
#* Set "Orientation Array" to "No Orientation Array" (otherwise boxes will rotate). Hint: changing "Glyph Type" to "Arrow" and setting orientation array to <tt>xmat</tt>, <tt>ymat</tt>, or <tt>zmat</tt> can visualize rotation of material point axes. ParaView does appear to have a way to apply a full rotation matrix to box glyphs, but sometimes orienting by <tt>xmat</tt>, <tt>ymat</tt>, or <tt>zmat</tt> can approximate that rotation and improve the visualization.
#* Set "Scale Array" to "meansize" and "Scale Factor" to 2 (because archive mean size is particle radius). If you did not archive particle size and export it to the particle VTK files, the "meansize" will not be available. In this case, set "Scale Array" to "No Scale Array" and set "Scale Factor" to half the grid size. This approach only works when all particle are the same size.
#* Set "Glyph Mode" to "All Points"
# Once all settings are made, click "Apply" to get the plot (often ParaView does nothing when you change something until you click "Apply"). Sometimes nothing appears (especially in Windows), but can be fixed by clicking view direction icon (right side of the second-row tool bar). Once you have a plot, you can click and drag with mouse to change the viewing position.
# Choose simulation result to plot from menu in second row of tool bars. (for [[#Vector and Tensor Plotting|tensor or vector quantities]], choose the component to plot from the second menu).


<ol>
A drawback of these plots is that geometry of the shapes plotted for each material point will not transform to reflect deformation of the material point. To get that feature, use [[#Particle Plot using "Cells"|particle cell plots]] instead. It also seems that plotting 3D glyphs from many points can be slow. The [[#Particle Plot using "Cells"|particle cell plots]] might draw faster.


<li>Use the "Manage Plugins…" menu command to load the <tt>PointSprite_Plugin</tt> (or better is to configure ParaView to load it when ever the application is launched
=== Particle Plots using Point Gaussians ===


<li>In the opened file, choose "Point Sprint" from the "Representation" menu.
To plot using point sprites (which might be faster than glyphs but has few options), do the following:


<li>For best results, set the radius to a constant radius and enter particle size (usually half the background grid element length). A future option might allow this setting to be automatic and support variable size particles).
# Open the exported particle VTK files in ParaView (as described above)
# In properties for the opened files
## Choose "Point Gaussian" from the "Representation" menu
## Choose simulations result to plot from the "Coloring" menu (for [#Vector and Tensor Plotting|tensor or vector quantities]], choose the component to plot from the second menu)
## Set the "Gaussian Radius" to about 2/3 the particle size (usually about 1/3 grid size). Note that this plot style only works when all particles have the same size. To handle variable size particles use [[#Particle Plots using Glyphs|glyph plots]] instead.
# When settings are done, you should see a plot. Sometimes nothing appears (especially in Windows), but can be fixed by clicking view direction icon (right side of the second-row tool bar). Once you have a plot, you can click and drag with mouse to change the viewing position.


<li>Also set opacity to contant value of one. A future option may allow this to be customized to support transparent materials.
A drawback of these plots is that geometry of point Gaussians for each material point will not transform to reflect deformation of the material point. To get that feature, use [[#Particle Plot using "Cells"|particle cell plots]] instead.


<li>Set coloring to the calculation result you want to visualize.
=== Combining Particle Plots with Crack Plots ===


</ol>
By exporting crack data to VTK files (the <b>-C</b> with <b>-V</b> options in [[ExtractMPM]]), you can plot them both. Furthermore, [[ParaView]] will synchronize the two data sets particle and crack data for the same time will plot together. After getting on the the above plots
 
=== Particle Plots using Glyphs ===


To plot particles with glyphs, do the following:
# Without closing particle files, open the exported crack VTK files in ParaView (as described above)
# If the cracks cannot be seen, add glyphs for crack data by methods similar to above glyph plots, but the size can not be set using <tt>meansize</tt>. Instead, pick a size for good visualization (using smaller than particle sizes).
# You can toggle crack or particle data on and off to see them separately or together


<ol>
== Mesh Plots ==


<li>To see the particles, click or use menu command to add Glyphs. Then in its object inspector, enter Radius = 1.25 (which is 1/4 of the 5 mm cell size, use a different Glyph size if you have changed the cell size of this example).
By saving simulations results using [[VTKArchive Custom Task]], you can get grid plot in ParaView. One type of mesh plot is to create contours based on one output variable and color the surface by another one.


<li>Scroll down, click to "Edit Scale" and edit it to be 1.
# Open the VTK files save by a [[VTKArchive Custom Task]]. If you did not include this custom task when running the simulation, you will have to add it and run again. If cannot be exported from prior simulations. Once opened, you should get a wire frame showing extent of the grid.
# Choose icon to add a "Contour" in the tool bar (it is also in the "Filters" menu along with many more options)
# In the "Contour Properties" window make the following settings
## Set "Contour By" to mass.
## In the isosurfaces section, set the contour value to some number less than the maximum mass. The optimal value will depend on the structure of your model. You need a lower number to visualize porous objects or a higher number for solid objects. You can also add several numbers to create contours at several values of mass.
# Once all settings are made, click "Apply" to get the plot (often ParaView does nothing when you change something until you click "Apply"). Once you have a plot, you can click and drag with mouse to change the viewing position.
# Choose simulation result to plot from menu in second row of tool bars. (for [[#Vector and Tensor Plotting|tensor or vector quantities]], choose the component to plot from the second menu).


<li>Scroll down and change "Maximum Number of Points" to be 10000 (or some number larger than the number of material points in the simulation).
== Vector and Tensor Plotting ==


<li>Click "Apply" to get the particle plot.
Archived vectors will include all components of the vector and ParaView can view the magnitude or any single component for constructing graphics. Archived tensors will include all components of the tensor. In ParaView, the magnitude and components 0 through 8 of tensors will be listed. The numbers correspond to the following tensor components:


</ol>
( xx  xy  xz )  ( 0  1  2 )
| yx  yy  yz | = | 3  4  5 |
( zx  zy  zz ) = ( 6  7  8 )


You should have gotten a plot of two spheres which each particle plotted as a small sphere. You can explore all the ParaView options for ways to visualize the results. For example, you can color by any of the properties extracted to the file, create cropping planes, animate the results with the movie controls, or plot different style Glyphs at each material point.
The magnitude appears to square all terms, add, and take the square root. In is generalize of vector length to a second-rank tensor.

Latest revision as of 13:22, 26 January 2023

ParaView is free and advanced software with many options for visualization, especially when doing 3D calculations.

Getting Started

This section gives the basic steps needed to start using ParaView to visualize material point method output from NairnMPM.

  1. Download and install ParaView. It is available for many platforms and can run in parallel (hence the name) if installed on a multiprocessor system or cluster of computers.
  2. Run someNairnMPM calculations. You have two options for visualizing results in ParaView:
    1. After a simulation is done, use the "Export Particle VTKs..." option to extract results of any simulation to particle VTK files. Include the data you want to visualize. it works best if you include "meansize" which means the simulation included "size" in the archived results. These VTK files can be used create particle plots.
    2. Include the VTKArchive Custom Task to save results as VTK legacy files. Save the quantities you might want to plot and one of them should be mass (because it is used in many plot options). These VTK files can be used to create grid plots.
  3. To open either type of VTK files in ParaView, choose the open command and select a block of VTK legacy files. Those exported as particle VTKs will be in the the archived results folder for your simulation and will have the root name you choose when exporting the files. Those created by a VTKArchive Custom Task will also be in the archived results folder with the naming style "MPM_#.vtk" where "MPM" is the root name you used for the calculation's archived files and "#" is the step number. If you used VTKArchive Custom Task to archive results for a single material type, the fille name will change to "MPM_mat_#_#.vtk" where the first number is a material number. ParaView will let you select such files as a block and will open them all at once. Alternatively, you can expand the block and select a single file. You need to open as a block to get movies of results.
  4. ParaView does not actually read files when they are opened. To read them, click the "Apply" button in the object inspector. When

Once opened, you have many plotting options available. The available options will depend of if you opened particle VTK files or grid-based VTK files. The following sections gives to steps to get started with plotting. Once have one of these plots visible, you can explore all the ParaView options for more ways to visualize the results.

Particle Plots in ParaView

By extracting particle data to VTK files (either using the "Export Particle VTKs..." option in NairnFEAMPM or in NairnFEAMPMViz or by running ExtractMPM on a command line), you can also use ParaView to view particle-based plots. This section gives to examples to get started with particle plots.

Particle Plot using "Cells"

The preferred visualization to exported to an unstructured grid (-U option in ExtractMPM) where each material point becomes a cell in the grid. Furthermore, the cells are transformed to reflect the particle deformation. Plotting such files is easy:

  1. Open the exported particle VTK files in ParaView (as described above). The plot should appear when you click "Apply: to finish the opening.
  2. Once you have a plot, you can click and drag with mouse to change the viewing position.
  3. Choose simulation result to plot from menu in second row of tool bars. (for tensor or vector quantities, choose the component to plot from the second menu).

Particle Plots using Glyphs

The most advanced particle plots use glyphs. Here is an some steps to get started:

  1. Open the exported particle VTK files in ParaView (as described above)
  2. Choose icon to add "Glyph" in the tool bar (it is also in the "Filters" menu along with many more options)
  3. In the "Glyph Properties" window, make the following settings:
    • Set "Glyph Type" to box or sphere (other options normally do not make sense)
    • Set "Orientation Array" to "No Orientation Array" (otherwise boxes will rotate). Hint: changing "Glyph Type" to "Arrow" and setting orientation array to xmat, ymat, or zmat can visualize rotation of material point axes. ParaView does appear to have a way to apply a full rotation matrix to box glyphs, but sometimes orienting by xmat, ymat, or zmat can approximate that rotation and improve the visualization.
    • Set "Scale Array" to "meansize" and "Scale Factor" to 2 (because archive mean size is particle radius). If you did not archive particle size and export it to the particle VTK files, the "meansize" will not be available. In this case, set "Scale Array" to "No Scale Array" and set "Scale Factor" to half the grid size. This approach only works when all particle are the same size.
    • Set "Glyph Mode" to "All Points"
  4. Once all settings are made, click "Apply" to get the plot (often ParaView does nothing when you change something until you click "Apply"). Sometimes nothing appears (especially in Windows), but can be fixed by clicking view direction icon (right side of the second-row tool bar). Once you have a plot, you can click and drag with mouse to change the viewing position.
  5. Choose simulation result to plot from menu in second row of tool bars. (for tensor or vector quantities, choose the component to plot from the second menu).

A drawback of these plots is that geometry of the shapes plotted for each material point will not transform to reflect deformation of the material point. To get that feature, use particle cell plots instead. It also seems that plotting 3D glyphs from many points can be slow. The particle cell plots might draw faster.

Particle Plots using Point Gaussians

To plot using point sprites (which might be faster than glyphs but has few options), do the following:

  1. Open the exported particle VTK files in ParaView (as described above)
  2. In properties for the opened files
    1. Choose "Point Gaussian" from the "Representation" menu
    2. Choose simulations result to plot from the "Coloring" menu (for [#Vector and Tensor Plotting|tensor or vector quantities]], choose the component to plot from the second menu)
    3. Set the "Gaussian Radius" to about 2/3 the particle size (usually about 1/3 grid size). Note that this plot style only works when all particles have the same size. To handle variable size particles use glyph plots instead.
  3. When settings are done, you should see a plot. Sometimes nothing appears (especially in Windows), but can be fixed by clicking view direction icon (right side of the second-row tool bar). Once you have a plot, you can click and drag with mouse to change the viewing position.

A drawback of these plots is that geometry of point Gaussians for each material point will not transform to reflect deformation of the material point. To get that feature, use particle cell plots instead.

Combining Particle Plots with Crack Plots

By exporting crack data to VTK files (the -C with -V options in ExtractMPM), you can plot them both. Furthermore, ParaView will synchronize the two data sets particle and crack data for the same time will plot together. After getting on the the above plots

  1. Without closing particle files, open the exported crack VTK files in ParaView (as described above)
  2. If the cracks cannot be seen, add glyphs for crack data by methods similar to above glyph plots, but the size can not be set using meansize. Instead, pick a size for good visualization (using smaller than particle sizes).
  3. You can toggle crack or particle data on and off to see them separately or together

Mesh Plots

By saving simulations results using VTKArchive Custom Task, you can get grid plot in ParaView. One type of mesh plot is to create contours based on one output variable and color the surface by another one.

  1. Open the VTK files save by a VTKArchive Custom Task. If you did not include this custom task when running the simulation, you will have to add it and run again. If cannot be exported from prior simulations. Once opened, you should get a wire frame showing extent of the grid.
  2. Choose icon to add a "Contour" in the tool bar (it is also in the "Filters" menu along with many more options)
  3. In the "Contour Properties" window make the following settings
    1. Set "Contour By" to mass.
    2. In the isosurfaces section, set the contour value to some number less than the maximum mass. The optimal value will depend on the structure of your model. You need a lower number to visualize porous objects or a higher number for solid objects. You can also add several numbers to create contours at several values of mass.
  4. Once all settings are made, click "Apply" to get the plot (often ParaView does nothing when you change something until you click "Apply"). Once you have a plot, you can click and drag with mouse to change the viewing position.
  5. Choose simulation result to plot from menu in second row of tool bars. (for tensor or vector quantities, choose the component to plot from the second menu).

Vector and Tensor Plotting

Archived vectors will include all components of the vector and ParaView can view the magnitude or any single component for constructing graphics. Archived tensors will include all components of the tensor. In ParaView, the magnitude and components 0 through 8 of tensors will be listed. The numbers correspond to the following tensor components:

( xx   xy   xz )   ( 0  1  2 )
| yx   yy   yz | = | 3  4  5 |
( zx   zy   zz ) = ( 6  7  8 )

The magnitude appears to square all terms, add, and take the square root. In is generalize of vector length to a second-rank tensor.