Hi I am facing some problems with reading to VTK OpenFOAM data and performing a scalar clip on the mesh. The issue seems to be present when refinement regions are present, which in turn results to internal surfaces in ParaView/PyVista/VTK. Full description and a MWE are bellow.
Description
Loading an OpenFOAM mesh in ParaView/PyVista which contains refinement regions and then performing a Clip by a Scalar Field results into internal surfaces near the refinement regions. I am suspecting that there might be something wrong with the VTK OpenFOAM reader.
I have tried a few different combinations of PyVista/VTK and the issue seems to persist.
The only “solution” I could come up with uniformly resampling my volumetric data, which seems to not create the internal surfaces when Clip>Extract Surface is performed. However, this is not a particularly viable approach since it significantly alters the boundary representation of more complex geometries.
ParaView Pipeline
- Load
foam.foam
(do not skip zero time, and Create cell-to-point filtered data) - Clip, Clip Type (Scalar), select
fieldA
, Value=0.5, invert=False) - Extract Surface (Change opacity to see internal surfaces being formed)
Client Info
Client Info
Client Information:
Version: 5.13.1
VTK Version: 9.3.20240617
Qt Version: 5.15.10
vtkIdType size: 64bits
Embedded Python: On
Python Library Path: /home/gn/Programs/ParaView-5.13.1/lib/python3.10
Python Library Version: 3.10.13 (main, Sep 27 2024, 19:33:16) [GCC 10.2.1 20210130 (Red Hat 10.2.1-11)]
Python Numpy Support: On
Python Numpy Path: /home/gn/.local/lib/python3.10/site-packages/numpy
Python Numpy Version: 1.26.4
Python Matplotlib Support: On
Python Matplotlib Path: /home/gn/.local/lib/python3.10/site-packages/matplotlib
Python Matplotlib Version: 3.9.0
Python Testing: Off
MPI Enabled: On
ParaView Build ID: superbuild abdf9aa5f109ffa3558a63d86365a0203aaab773 (!1224)
Disable Registry: Off
Test Directory:
Data Directory:
SMP Backend: TBB
SMP Max Number of Threads: 32
OpenGL Vendor: NVIDIA Corporation
OpenGL Version: 3.2.0 NVIDIA 535.230.02
OpenGL Renderer: NVIDIA RTX A2000 12GB/PCIe/SSE2
Accelerated filters overrides available: No
Connection Information:
Remote Connection: No
PyVista MWE
from pathlib import Path
import pyvista as pv
root = Path(__file__).parent
fname = root / "foam.foam"
reader: pv.OpenFOAMReader = pv.get_reader(fname)
mesh = reader.read()
mesh.clear_all_cell_data()
# clean() and triangulate() don't really have an effect
clip = (
mesh["internalMesh"]
.clip_scalar("fieldA", value=0.5, invert=False)
.extract_surface()
.clean()
.triangulate()
)
clip.save(root / "internal_surfs.stl")
Python Enf Info
Python 3.10.12
certifi==2025.4.26
charset-normalizer==3.4.2
contourpy==1.3.2
cycler==0.12.1
fonttools==4.58.0
idna==3.10
kiwisolver==1.4.8
matplotlib==3.10.3
numpy==2.2.6
packaging==25.0
pillow==11.2.1
platformdirs==4.3.8
pooch==1.8.2
pyparsing==3.2.3
python-dateutil==2.9.0.post0
pyvista==0.45.2
requests==2.32.3
scooby==0.10.1
six==1.17.0
typing_extensions==4.13.2
urllib3==2.4.0
vtk==9.4.2
Full MWE
Assuming you have an OpenFOAM with cartesianMesh
(i.e cfMesh) unzip the example and run:
bash setup.sh
- OpenFOAM used to generated the data (OpenFOAM: v2212 )
Data
mwe-internal-surfs.zip (4.6 KB)