PolyVecMesh is a lightweight tool for visualising CFD polyhedral and hexahedral meshes in 2D vector format. It converts meshes exported from ParaView (VTK Multi-Block format) into clean, publication-quality (vector format) graphics that can be plotted directly with matplotlib.
This enables high-resolution, scalable mesh figures, something that is not easily achievable in ParaView for vector graphics.
- Mesh exported from ParaView as VTK Multi-Block
- Python ≥3.8
- numpy
- matplotlib
- Local install, from the root folder (where
pyproject.tomlis):
pip install -e .- In ParaView, create a 2D slice of your mesh.
- Export the slice as XML Multi Block Data (
.vtm) with Data Mode: ASCII. - In Python, load the file using the
PolyVecMeshclass. - Generate the mesh line data using
createCollection(). - Pass the resulting array into a
matplotlib.collections.PolyCollectionfor plotting.
Example (see the examples folder for full scripts):
from PolyVecMesh import PolyVecMesh as pvm
import matplotlib.pyplot as plt
from matplotlib.collections import PolyCollection
if __name__ == "__main__":
vtmFile = r"resources\topview.vtm"
pvm = pvm(vtmFile)
_, ax = plt.subplots(figsize=(10, 10))
meshLines = pvm.createCollection("internalMesh")
poly = PolyCollection(meshLines, closed=False, linewidths=0.5, facecolors='white', edgecolors="k", linewidths=0.5)
ax.add_collection(poly, autolim=True)
ax.autoscale(enable=True, tight=True)
ax.set_aspect("equal", adjustable="box")
plt.show()- Smarter detection of cells outside the slice plane when using implicit clipping
- e.g., pre-filter points with a large deviation from the normal
- introduce a
maxDistanceOffSlicethreshold
- Auto-detect
maxDistanceOffSlice(essentially a custom slicing tool) - Include off-normal 2D plane creation, now only a plane can be made in the mesh aligned with the axis
- e.g., rotate all points until it is aligned with the axis to remove excess points.
- PyPI installation
- -
- In
debug_plot, theself.colorslist is not updated when unwanted faces are removed. - Boundary layer faces not all showing, and some faces are removed.