Issue with union operation between bend and cylinder of same diameter

Hi everyone,

I’m encountering a consistent crash when trying to union a bend and a cylinder that share the same diameter in the Geometry module. Every time I perform this operation, MFIX exits immediately.

I have tested this in versions 25.1, 25.2.1, and 25.3, and the crash occurs in all of them.

Is there a known solution or workaround for this issue?

Thank you for any help.

  1. What platform are you running on (Windows, Linux, Mac)?

  2. Is there any error message when MFiX exits?

Dear Charles,

I have tested this on both Linux and Windows platforms, and MFIX crashes on both.

On Windows, the application simply closes without any error message.

On Linux, it exits with the error: “Segmentation fault (core dumped).”

I can reproduce on Linux. The union is handled by vtk, which is sometimes buggy. Apparently vtk doesn’t like to do the union when the bend and cylinder have the same diameter, and are aligned. I tried to move the cylinder so there is an overlap in the z-direction but that didn’t help. My workaround so far is to set the cylinder’s radius to 0.50001 so it is not exactly the same as the bend’s radius. Please let us know if this is an acceptable solution.

1 Like

Actually, if you want to extend the front section of the bend, you can just define a longer front section length and adjust the resolution in that direction instead:

1 Like

This is definitely a problem in VTK and not MFIX. The stack trace looks like this:

#0  0x00007fe323205cda in vtkPolyData::GetCell(long long) ()
   from /home/cgw/miniforge3/envs/mfix-git/lib/python3.13/site-packages/vtkmodules/../../.././libvtkCommonDataModel-9.3.so.1
#1  0x00007fe3237aa53c in vtkIntersectionPolyDataFilter::Impl::SplitMesh(int, vtkPolyData*, vtkPolyData*) ()
   from /home/cgw/miniforge3/envs/mfix-git/lib/python3.13/site-packages/vtkmodules/../../.././libvtkFiltersGeneral-9.3.so.1
#2  0x00007fe3237acb3d in vtkIntersectionPolyDataFilter::RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) ()
   from /home/cgw/miniforge3/envs/mfix-git/lib/python3.13/site-packages/vtkmodules/../../.././libvtkFiltersGeneral-9.3.so.1
...

This seems to be a known bug in VTK:

I tried a few workarounds in MFiX (adding a “nudge” before the union, doing a “clean” operation on the mesh, adjusting tolerances) and none of them help. Jeff’s suggestion to adjust the diameters is probably the best way to get around this problem.

1 Like

Thank you, Jeff.

Your suggestion worked perfectly.

Inspired by your advice, I may have found another way to seamlessly combine a straight pipe and a bend: move the start of the curved section of the bend to the end of the straight pipe, and then reduce the exit radius of the bend. As shown in the image below, performing the UNION this way also works without any issues.

The suggestion to extend the straight pipe section is indeed effective and solves my problem. Actually, I ran into this issue when trying to add a bend outlet at the end of an already built complex model—I was kind of stuck in a fixed mindset, haha.

By the way, you mentioned “adjusting the resolution.” I’d like to ask: Does the resolution setting affect the final mesh quality? I haven’t paid much attention to this value when creating geometries before.

Indeed, it was a VTK-related issue. Both of your suggestions worked perfectly and resolved my problem.

The resolution of the STL file may affect the final mesh quality and boolean vtk operation. For example if the front section length is 10 and the resolution in 20, you will have elongated triangles. Here you would increase the resolution to get triangles with a smaller aspect ratio. You also need to balance the size and number of stl triangles. Having too fine of an STL file (lots of small triangles, compared to the fluid mesh size) is not useful since we intersect the STL geometry and the fluid mesh along the fluid mesh edges. All the tiny triangles that do not intersect the edges are technically not needed. If you run a DEM simulation, having lots of small triangles will slow down the simulation since particles interact with each triangle. Usually, you want the STL file triangles to be slightly smaller than the mesh size and have an aspect ratio close to 1 as much as possible.

Finally, always check the normal vectors of your geometry (either before or after boolean operation). The normals point towards the fluid region. If you want an internal flow, make sure the normals points inwards to tube/bend. If this is not the case, apply a “flip normals” filter.

1 Like

Another workaround I found is to rotate the cylinder slightly around its axis:

union.mfx (4.2 KB)

I chose 22.5 degree rotation because the resolution is 32 and this is a rotation by 2 cells.

After doing this the union operation works, I guess the rotation changes the way facets are meeting and we are avoiding the VTK bug this way. However, there is some ugliness at the seam:

1 Like

FWIW I tried with the latest VTK version (9.5.2) and it still crashes (albeit in a slightly different place). I’ll report this to the VTK developers but don’t hold your breath waiting for a fix as this probIem is at least 12 (!) years old.

1 Like