Difference between revisions of "VTKpytools/Barfiletools"

From PHASTA Wiki
Jump to: navigation, search
Line 58: Line 58:
  
 
* Generate profiles from walls
 
* Generate profiles from walls
* Compute C_f (using <code>vpt.calCf()</code>, T_w, or simply wall-shear velocity gradient (using <code>vpt.calcWallShearGradient()</code>
+
* Compute C_f (using <code>vpt.calCf()</code>), T_w, or simply wall-shear velocity gradient (using <code>vpt.calcWallShearGradient()</code>)
 
* Compute new quantities and save them to a new VTM file
 
* Compute new quantities and save them to a new VTM file
  

Revision as of 18:29, 24 August 2020

bar2vtk is a module within the VTKpytools package containing functions for converting *bar files (velbar, stsbar, etc.) into VTK files and for post-processing those VTK files.

As a reminder, all vtkpytool functions and classes have inline documentation via docstrings. API documentation maybe implemented eventually...

Overview of Post-Processing *bar Files

  1. Create "blank" MultiBlock VTK (VTM, *.vtm) file using custom Python script
  2. Load *bar file data onto blank VTM file using bar2vtk CLI program
  3. Read the "loaded" VTM file and post-process

The first step only has to be performed once per mesh. The second has to be completed for every timestep to be post-processed.

Examples of each of the three processes listed above can be found in the examples directory of the vtkpytools repository.

Creating Blank VTM File

The VTM file simply holds the coordinate, connectivity, and geometry information for the domain. It should contain two blocks: grid and wall.

grid
A VTK Unstructured Grid of the 2D spanwise mesh and (after running bar2vtk) the data associated with each node
wall
A VTK PolyData of the line that defines the wall of the domain. It is a subset of the connectivity and vertices of grid

The process of creating the blank VTM file is:

  1. Load mesh data
    • Specifically, the coordinate and connectivity information of the spanwise mesh
  2. Generate grid
    • Using vpt.form2DGrid() with the coordinate and connectivity information
  3. Extract edges of grid
    • Using the extract_feature_edges method provided by pyvista,
  4. Compute normal vectors of the feature edges
    • Using vpt.computeEdgeNormals()
  5. Extract the wall cells from the feature edges
    • The most straight forward way to do this is by doing boolean selections based on the wall normal components
  6. (Optional) Order wall points
    • By default, they are not in order of the line. Done using vpt.unstructuredToPoly() and vpt.orderPolyDataLine()
  7. Save grid and wall to MultiBlock object

An example script of doing this process is in makeVTM.py in the example directory of the repository.

Once you've saved the VTM file, I suggest you open the file in ParaView to check that it worked well. Specifically, check to make sure that wall was extracted correctly. Using ParaView's "Extract Block" filter may be useful for this task.

Load *bar File Data

Now that you have a "blank" VTM file, you can add *bar file data onto it using bar2vtk, a CLI program. You can find documentation for it by running bar2vtk --help. It supports:

  • Creating timestep windows
  • Loading Binary forms of *bar files
  • Custom file names/paths to data

This process will create "Pressure", "Velocity", "ReynoldsStress", and "TurbulentEnergyKinetic" quantities in both grid and wall objects.

An example script of doing this process is in runbar2vtk.sh in the example directory of the repository.

Post-Process "Loaded" VTM File

After the *bar data has been loaded, the file maybe viewed in ParaView for standard visualization. Alternatively (or rather in tandem), you can post-process in Python using a combination of pyvista and vtkpytools. Things you can do are:

  • Generate profiles from walls
  • Compute C_f (using vpt.calCf()), T_w, or simply wall-shear velocity gradient (using vpt.calcWallShearGradient())
  • Compute new quantities and save them to a new VTM file

Much of this is a function of using pyvista as the primary interface for VTK, so I'd recommend checking out pyvista's documentation, specifically the section going over attributes (as this is most relevant to "data extraction" post-processing).