Skip to content

Comments

EB: First batch of Marching Cubes#4778

Merged
WeiqunZhang merged 9 commits intoAMReX-Codes:developmentfrom
WeiqunZhang:march_cubes
Jan 21, 2026
Merged

EB: First batch of Marching Cubes#4778
WeiqunZhang merged 9 commits intoAMReX-Codes:developmentfrom
WeiqunZhang:march_cubes

Conversation

@WeiqunZhang
Copy link
Member

This adds the marching cubes algorithm of "Efficient implementation of Marching Cubes' cases with topological guarantees" by Lewiner, Lopes, Vieira & Tavares, Journal of Graphics Tools 8(2): pp. 1-15 (2003). The implementation is adapted from the source code available at http://thomas.lewiner.org/publication_page.php%EF%B9%96pubkey=marching_cubes_jgt.html.

Given a signed distance function (e.g., from our STL tools), this generates a list of topologically consistent triangles. Every cut cell's EB surfaces are decomposed into up to 9 triangles. There could be multiple cuts and/or volumes in a cell. The cuts are shared faces and edges between neighbor cells are consistent.

For debugging purpose, we have also added a function that can save these triangles into a STL file.

Future work involves the computation of EB information such as volume fraction, area faction, etc. based on the triangles.

This adds the marching cubes algorithm of "Efficient implementation of
Marching Cubes' cases with topological guarantees" by Lewiner, Lopes, Vieira
& Tavares, Journal of Graphics Tools 8(2): pp. 1-15 (2003). The
implementation is adapted from the source code available at
http://thomas.lewiner.org/publication_page.php%EF%B9%96pubkey=marching_cubes_jgt.html.

Given a signed distance function (e.g., from our STL tools), this generates
a list of topologically consistent triangles. Every cut cell's EB surfaces
are decomposed into up to 9 triangles. There could be multiple cuts and/or
volumes in a cell. The cuts are shared faces and edges between neighbor
cells are consistent.

For debugging purpose, we have also added a function that can save these
triangles into a STL file.

Future work involves the computation of EB information such as volume
fraction, area faction, etc. based on the triangles.
@WeiqunZhang WeiqunZhang marked this pull request as ready for review November 14, 2025 00:58
@WeiqunZhang WeiqunZhang requested a review from atmyers November 14, 2025 00:58
@ruohai0925
Copy link
Contributor

Hi @weiqun, are there examples that I can test and play with this feature?

@WeiqunZhang
Copy link
Member Author

There is a test at Tests/EB/MarchingCubes. It reads an STL file and write out another one. The output is the re-triangulation of the EB surface within cells.

@ankithadas
Copy link
Contributor

Can we expect Multi Cut-Cell support with this PR sometime in the future ?

@WeiqunZhang
Copy link
Member Author

Currently we are not actively working on it. So we cannot promise anything.

@ruohai0925
Copy link
Contributor

Hi Weiqun, I have another question. Since marching cube algorithm cuts cubes based on sdf values, it is highly possible to generate very very small cut cells in real complex cases. Are there some special treatments for these tiny cells in this PR? Do you have some suggestions? Thanks!

@WeiqunZhang
Copy link
Member Author

No, we are not doing anything special here. I think that belongs to the next step of generating EB information based on the triangles generated with the marching cubes.

@WeiqunZhang WeiqunZhang enabled auto-merge (squash) January 20, 2026 04:16
@WeiqunZhang WeiqunZhang requested a review from asalmgren January 21, 2026 20:04
@WeiqunZhang WeiqunZhang merged commit 9570c1c into AMReX-Codes:development Jan 21, 2026
73 checks passed
@WeiqunZhang WeiqunZhang deleted the march_cubes branch January 21, 2026 20:07
WeiqunZhang pushed a commit that referenced this pull request Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants