rmrsk / EBGeometry

A C++ package for embedded boundary (EB) geometry generation.
https://rmrsk.github.io/EBGeometry/
GNU General Public License v3.0
18 stars 4 forks source link

Wrong EB Surface Generated #70

Closed ankithadas closed 2 weeks ago

ankithadas commented 3 weeks ago

Dear rmrsk,

I suspect there may be a bug either in the implicit functions or the AMReX EB framework. The attached STL file produces incorrect surface features, as highlighted in red in the image below:

Screenshot 2024-09-02 at 8 52 58 PM

The STL file and the corresponding code at the following link: EBGeometry_bug

Kind regards, Ankith

rmrsk commented 3 weeks ago

Hi Ankith - thanks for reaching out.

I don't know if there are bugs in AMReX or EBGeometry, but I found lots of self-intersecting faces in your STL file. If your input file is not manifold (watertight, with coherently oriented and non-intersecting faces), the implicit function does not exist. It's a bit like the Klein bottle; it has a surface but no unique inside/outside region.

Try to clean the STL file first, and let me know if it still doesn't generate the correct geometry.

self_intersections

ankithadas commented 2 weeks ago

Dear Robert,

Thanks for the response. After cleaning up the geometry using Meshinspector, the generated geometry looked correct. Interestingly, the default AMReX STL implicit function also produced the correct geometry even for the broken STL file. But, the AMReX functions are very slow compared to your implementation.

Kind regards, Ankith

rmrsk commented 2 weeks ago

Glad it worked! AFAIK the AMReX STL functionality does a direct intersection and determines the sign using a known point on the inside/outside. So, they dont actually cast the STL to an implicit function, which also means you can't use CSG on STL inputs. All in all, the algorithms aren't really comparable.