Adding support for new mesh formats in ParaView

The architecture of ParaView allows extending its functionality by creating plugins which can be loaded as dynamic libraries without recompiling ParaView.

The main mesh filetypes we are handling in our lab are .ugrid generated by AFLR3 and used widely within FUN3D, .meshb from INRIA Gamma Team and .su2 from the SU2 solver. Unfortunately there is no support for these from Paraview. Fortunately there is documentation for creating readers (plugin guides).

Here is the boilerplate for writting a reader for an unstructred grid based on the Paraview wiki.

[Read More]

Extract Cell types from mesh in Paraview

It is often usefull to select cells by their type for visualization in Paraview. Visualizing boundary layer meshes for example or extracting the surface elements of a mesh can be done by using the following script in the Programmable filter of Paraview.

input = self.GetUnstructuredGridInput()
output = self.GetUnstructuredGridOutput();

# copy all curent data
output.GetPointData().PassData(input.GetPointData())
output.GetCellData().PassData(input.GetCellData())

# create an array holding the VTK cell type id of each element
cellTypes = vtk.vtkUnsignedCharArray()
cellTypes.DeepCopy(input.GetCellTypesArray())
cellTypes.SetName("Cell Types")
output.GetCellData().AddArray(cellTypes)

Even simpler you can import this file (export_cell_types.cpd) from the menu Tools>Manage Custom Filters… > Import.

[Read More]

Simple macros in ParaView

If you use ParaView often you may want to automate some of your workflows. One way to do this is writing a macro using the Python interpreter that ships with ParaView. Here, is an example of extracting all elements from a tetrahedral mesh that have a minimum dihedral angle less that 5 degrees.

from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# get selection
G = GetActiveSource()
# create quality Data
# set min dihedraql angle as criterion
M = MeshQuality(Input=G, TetQualityMeasure="Minimum Dihedral Angle")
# select it
SetActiveSource(M)
# Create selector
S = SelectionQuerySource(QueryString = "Quality <=5")
# Create Extractor
E = ExtractSelection(Input = M,Selection = S)
Show()
Render()

#### uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).

Another advantage of this approach is that you can run it in a headless environment using the pvpython interpreter that ships with ParaView.

[Read More]