Difference between revisions of "VTKpytools/Barfiletools"
(Add Python Category) |
|||
(17 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | ''' | + | '''barfiletools''' is a module within the [[VTKpytools]] package containing functions for converting *bar files (<code>velbar</code>, <code>stsbar</code>, etc.) into VTK files and for post-processing those VTK files. |
− | As a reminder, all | + | As a reminder, all vtkpytools functions and classes have inline documentation via docstrings. API documentation via Sphinx maybe implemented eventually... |
== Overview of Post-Processing *bar Files == | == Overview of Post-Processing *bar Files == | ||
# Create "blank" MultiBlock VTK (VTM, <code>*.vtm</code>) file using custom Python script | # Create "blank" MultiBlock VTK (VTM, <code>*.vtm</code>) file using custom Python script | ||
− | # Load *bar file data onto blank VTM file using | + | # Load *bar file data onto blank VTM file using [[Bar2vtk|bar2vtk]] CLI program |
− | # Read the "loaded" VTM file and post-process | + | # 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. | The first step only has to be performed once per mesh. The second has to be completed for every timestep to be post-processed. | ||
Line 13: | Line 13: | ||
Examples of each of the three processes listed above can be found in the [https://github.com/PHASTA/vtkpytools/tree/master/example/bar2vtk examples directory of the vtkpytools repository]. | Examples of each of the three processes listed above can be found in the [https://github.com/PHASTA/vtkpytools/tree/master/example/bar2vtk examples directory of the vtkpytools repository]. | ||
− | == | + | === VTM File Format === |
− | The VTM file simply holds the coordinate, connectivity, and geometry information for the domain. It should contain two blocks | + | The blank VTM file simply holds the coordinate, connectivity, and geometry information for the domain. Data is then loaded onto these points afterwards. |
+ | |||
+ | To allow the tools to be consistent regardless of mesh or geometry, the blank VTM files must have a specified format. It should contain two blocks named <code>grid</code> and <code>wall</code>: | ||
; <code>grid</code> | ; <code>grid</code> | ||
− | : A VTK Unstructured Grid of the 2D spanwise mesh and (after | + | : A VTK Unstructured Grid of the 2D spanwise mesh and (after data has been loaded onto the VTM file) the data associated with each node |
; <code>wall</code> | ; <code>wall</code> | ||
: A VTK PolyData of the line that defines the wall of the domain. It is a subset of the connectivity and vertices of <code>grid</code> | : A VTK PolyData of the line that defines the wall of the domain. It is a subset of the connectivity and vertices of <code>grid</code> | ||
+ | |||
+ | For a blank VTM file, <code>grid</code> should have no arrays loaded onto it, and <code>wall</code> should have an array named <code>Normals</code> that contains unit vectors normal to the wall. | ||
+ | |||
+ | == Creating Blank VTM File == | ||
+ | [[File:Vtkpytools flowchart-Making Blank VTM FIles.png]] | ||
The process of creating the blank VTM file is: | The process of creating the blank VTM file is: | ||
− | # Load mesh data | + | # Load 2D mesh data |
− | #* Specifically, the coordinate and connectivity information of the spanwise mesh | + | #* Specifically, the coordinate and connectivity information of the spanwise mesh. Note that the connectivity array should be indexed at 0 (ie. the first node should be zero). |
+ | #* If you don't have the connectivity of the 2D mesh, see [[Create 2D Mesh Connectivity]] to generate it. | ||
# Generate <code>grid</code> | # Generate <code>grid</code> | ||
#* Using <code>vpt.form2DGrid()</code> with the coordinate and connectivity information | #* Using <code>vpt.form2DGrid()</code> with the coordinate and connectivity information | ||
Line 42: | Line 50: | ||
== Load *bar File Data == | == Load *bar File Data == | ||
+ | [[File:Vtkpytools flowchart-Using bar2vtk.png]] | ||
− | Now that you have a "blank" VTM file, you can add *bar file data onto it using | + | Now that you have a "blank" VTM file, you can add *bar file data onto it using [[Bar2vtk|bar2vtk]], a CLI program. You can find documentation for it by running <code>bar2vtk --help</code> or looking at the [[Bar2vtk|Bar2vtk]] wiki page. It supports: |
* Creating timestep windows | * Creating timestep windows | ||
Line 49: | Line 58: | ||
* Custom file names/paths to data | * Custom file names/paths to data | ||
− | This process will create "Pressure", "Velocity", "ReynoldsStress | + | This process will create "Pressure", "Velocity", and "ReynoldsStress" quantities in both <code>grid</code> and <code>wall</code> objects. Note that the quantity names are from [https://cgns.github.io/CGNS_docs_current/sids/dataname.html Appendix A of the CGNS standard]. |
− | An example script | + | An example script demonstrating the shell commands for running <code>bar2vtk</code> is in [https://github.com/PHASTA/vtkpytools/blob/master/example/bar2vtk/runbar2vtk.sh <code>runbar2vtk.sh</code>] in the example directory of the repository. |
== Post-Process "Loaded" VTM File == | == Post-Process "Loaded" VTM File == | ||
Line 58: | Line 67: | ||
* 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 | ||
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 [https://docs.pyvista.org/getting-started/what-is-a-mesh.html#what-are-attributes section going over attributes] (as this is most relevant to "data extraction" post-processing). | 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 [https://docs.pyvista.org/getting-started/what-is-a-mesh.html#what-are-attributes section going over attributes] (as this is most relevant to "data extraction" post-processing). | ||
− | |||
[[Category:VTKpytools]] | [[Category:VTKpytools]] | ||
+ | [[Category:Post-processing]] | ||
+ | [[Category:Python]] |
Latest revision as of 10:17, 18 September 2022
barfiletools 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 vtkpytools functions and classes have inline documentation via docstrings. API documentation via Sphinx maybe implemented eventually...
Contents
Overview of Post-Processing *bar Files
- Create "blank" MultiBlock VTK (VTM,
*.vtm
) file using custom Python script - Load *bar file data onto blank VTM file using bar2vtk CLI program
- 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.
VTM File Format
The blank VTM file simply holds the coordinate, connectivity, and geometry information for the domain. Data is then loaded onto these points afterwards.
To allow the tools to be consistent regardless of mesh or geometry, the blank VTM files must have a specified format. It should contain two blocks named grid
and wall
:
-
grid
- A VTK Unstructured Grid of the 2D spanwise mesh and (after data has been loaded onto the VTM file) 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
For a blank VTM file, grid
should have no arrays loaded onto it, and wall
should have an array named Normals
that contains unit vectors normal to the wall.
Creating Blank VTM File
The process of creating the blank VTM file is:
- Load 2D mesh data
- Specifically, the coordinate and connectivity information of the spanwise mesh. Note that the connectivity array should be indexed at 0 (ie. the first node should be zero).
- If you don't have the connectivity of the 2D mesh, see Create 2D Mesh Connectivity to generate it.
- Generate
grid
- Using
vpt.form2DGrid()
with the coordinate and connectivity information
- Using
- Extract edges of
grid
- Using the
extract_feature_edges
method provided by pyvista,
- Using the
- Compute normal vectors of the feature edges
- Using
vpt.computeEdgeNormals()
- Using
- 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
- (Optional) Order wall points
- By default, they are not in order of the line. Done using
vpt.unstructuredToPoly()
andvpt.orderPolyDataLine()
- By default, they are not in order of the line. Done using
- Save
grid
andwall
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
or looking at the Bar2vtk wiki page. It supports:
- Creating timestep windows
- Loading Binary forms of *bar files
- Custom file names/paths to data
This process will create "Pressure", "Velocity", and "ReynoldsStress" quantities in both grid
and wall
objects. Note that the quantity names are from Appendix A of the CGNS standard.
An example script demonstrating the shell commands for running bar2vtk
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 (usingvpt.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).