Difference between revisions of "VTKpytools/Barfiletools"
(save state) |
|||
Line 1: | Line 1: | ||
'''bar2vtk''' 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. | '''bar2vtk''' 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 vtkpytool functions and classes have inline documentation via docstrings. API documentation maybe implemented eventually... | ||
== Overview of Post-Processing *bar Files == | == Overview of Post-Processing *bar Files == | ||
Line 6: | Line 8: | ||
# Load *bar file data onto blank VTM file using <code>bar2vtk</code> CLI program | # Load *bar file data onto blank VTM file using <code>bar2vtk</code> 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. | ||
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]. | ||
== Creating Blank VTM File == | == Creating Blank VTM File == | ||
− | The VTM file simply holds the coordinate, connectivity, and geometry information for the domain. It should contain two blocks: <code> | + | The VTM file simply holds the coordinate, connectivity, and geometry information for the domain. It should contain two blocks: <code>grid</code> and <code>wall</code>. |
− | ; <code> | + | ; <code>grid</code> |
: A VTK Unstructured Grid of the 2D spanwise mesh and (after running <code>bar2vtk</code>) the data associated with each node | : A VTK Unstructured Grid of the 2D spanwise mesh and (after running <code>bar2vtk</code>) 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> | + | : 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> |
The process of creating the blank VTM file is: | The process of creating the blank VTM file is: | ||
− | # | + | # Load mesh data |
− | # | + | #* Specifically, the coordinate and connectivity information of the spanwise mesh |
− | # Extract wall data | + | # Generate <code>grid</code> |
+ | #* Using <code>vpt.form2DGrid()</code> with the coordinate and connectivity information | ||
+ | # Extract edges of <code>grid</code> | ||
+ | #* Using the <code>extract_feature_edges</code> method provided by pyvista, | ||
+ | # Compute normal vectors of the feature edges | ||
+ | #* Using <code>vpt.computeEdgeNormals()</code> | ||
+ | # 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 <code>vpt.unstructuredToPoly()</code> and <code>vpt.orderPolyDataLine()</code> | ||
+ | # Save <code>grid</code> and <code>wall</code> to MultiBlock object | ||
+ | |||
+ | An example script of doing this process is in [https://github.com/PHASTA/vtkpytools/blob/master/example/bar2vtk/makeVTM.py <code>makeVTM.py</code>] 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 <code>wall</code> 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 <code>bar2vtk</code>, a CLI program. You can find documentation for it by running <code>bar2vtk --help</code>. 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 <code>grid</code> and <code>wall</code> objects. | ||
+ | |||
+ | An example script of doing this process 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 == | ||
+ | |||
+ | 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 <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 | ||
+ | |||
+ | 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]] |
Revision as of 18:27, 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...
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.
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:
- Load mesh data
- Specifically, the coordinate and connectivity information of the spanwise mesh
- 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
. 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 (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).