# Internal surfaces created when cliping by scalar OpenFOAM data

**URL:** https://discourse.vtk.org/t/internal-surfaces-created-when-cliping-by-scalar-openfoam-data/15655
**Category:** Support
**Tags:** python
**Created:** [May 21, 2025, 12:59pm UTC](https://discourse.vtk.org/t/internal-surfaces-created-when-cliping-by-scalar-openfoam-data/15655 "2025-05-21T12:59:51Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![gnikit](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gnikit/32/2624_2.png) [@gnikit](https://discourse.vtk.org/u/gnikit)
#### Post date: [May 21, 2025, 12:59pm UTC](https://discourse.vtk.org/t/internal-surfaces-created-when-cliping-by-scalar-openfoam-data/15655/1 "2025-05-21T12:59:51Z")

</div>

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.

 ![image](https://discourse.vtk.org/uploads/default/original/2X/1/1abd1f18e5cbb52a2fd60d788cf0cddb6b3f7211.jpeg)

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**
>
> ```auto
> 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

```py
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")

```

 ![image](https://discourse.vtk.org/uploads/default/original/2X/5/501466026f34abe2c24aa7e1e852b5623ee5eb64.jpeg)

> **Python Enf Info**
>
> Python 3.10.12
> 
> ```auto
> 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:

```sh
bash setup.sh

```

- OpenFOAM used to generated the data (OpenFOAM: v2212 )

### Data

[mwe-internal-surfs.zip](https://discourse.vtk.org/uploads/short-url/t2vi1iH0E3MDsyGHdschWAdy1Qi.zip) (4.6 KB)

---

<div class="post-metadata">

### Author: ![gnikit](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gnikit/32/2624_2.png) [@gnikit](https://discourse.vtk.org/u/gnikit)
#### Post date: [June 4, 2025, 6:03am UTC](https://discourse.vtk.org/t/internal-surfaces-created-when-cliping-by-scalar-openfoam-data/15655/2 "2025-06-04T06:03:19Z")

</div>

Gentle bump on this thread. I looked into it again and couldn’t spot the origin of the issue. Any thoughts?
