Skip to content

CurrencyFinn/PolyVecMesh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License Version

Logo

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.

Requirements

  • Mesh exported from ParaView as VTK Multi-Block
  • Python ≥3.8

Python Dependencies

  • numpy
  • matplotlib

Mesh Visualisations

Motor Bike Mesh Coil Top Mesh

Usage

  1. Local install, from the root folder (where pyproject.toml is):
pip install -e .
  1. In ParaView, create a 2D slice of your mesh.
  2. Export the slice as XML Multi Block Data (.vtm) with Data Mode: ASCII.
  3. In Python, load the file using the PolyVecMesh class.
  4. Generate the mesh line data using createCollection().
  5. Pass the resulting array into a matplotlib.collections.PolyCollection for 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()

TODO

Functionality

  • 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 maxDistanceOffSlice threshold
  • 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

Optimization

  • -

Bugs

  • In debug_plot, the self.colors list is not updated when unwanted faces are removed.
  • Boundary layer faces not all showing, and some faces are removed.

License

MIT

About

PolyVecMesh (PVM) is a lightweight tool for visualising CFD polyhedral and hexahedral meshes in 2D vector format.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages