Marching Cubes for EB Generation - #5607
Draft
ankithadas wants to merge 27 commits into
Draft
Conversation
ankithadas
force-pushed
the
marching-cubes-eb-plan
branch
from
August 12, 2026 15:35
84d1396 to
3faa27e
Compare
Contributor
Author
|
Not sure why the clang fast math test failed. Running with ASAN didn't give any insights. Any ideas ? |
Contributor
Author
ankithadas
force-pushed
the
marching-cubes-eb-plan
branch
from
August 19, 2026 18:45
fd336a6 to
bb701a0
Compare
ankithadas
force-pushed
the
marching-cubes-eb-plan
branch
from
August 19, 2026 18:51
bb701a0 to
7e32255
Compare
Contributor
Author
|
I am looking for collaborators for this PR. Email or ping me in AMReX slack if you are interested in working in this. |
ankithadas
force-pushed
the
marching-cubes-eb-plan
branch
from
September 1, 2026 10:43
8d6f1ec to
15b9fa8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
This PR extends the Marching Cubes (#4778) algorithm to EB generation. Users can select the new generator with:
The choice applies to every way of describing the geometry: the built-in implicit functions selected by
eb2.geom_type, user-defined implicit functions passed to any of theEB2::Buildoverloads throughEB2::makeShop, and STL files. It is ignored foreb2.geom_type = chkpt_file. The original EB2 construction (legacy) remains the default.The marching-cubes path:
eb2.cover_multiple_cutsto control whether unsupported faces and cells may be repaired.eb2.small_volfracandeb2.maxiterduring cleanup.extend_domain_faceis requested.eb2.build_coarse_level_by_coarsening = 0or the multi-levelEB2::Buildoverload); coarse levels obtained by coarsening are unaffected.eb2.mc_stl_file.WriteEBSurfaceSTLfor writing the planar EB reconstruction as an ASCII STL file.The generator is available only in 3D on Cartesian grids with cubic cells (
dx == dy == dz); a non-cubic grid is rejected even when the geometry is all regular. It is incompatible withBuildMultiValuedMultiCut.A sampled signed-distance field is insufficient to reproduce the position where the surface crosses a Cartesian edge. Linear interpolation between its endpoint samples can place the MC vertex at a different point from the actual crossing. To avoid this inconsistency, the builder resolves each sign-changing edge against the geometry source itself — root finding for implicit functions,
STLtools::fillMarchingCubesEdgeIntersectionsagainst the original triangles for STL — and stores the normalized crossing locations in eachMCFab. These crossings are then shared by all downstream geometry calculations. If cleanup places the interface exactly on an edge endpoint, the exact-zero endpoint is used.MC33 face decisions are retained in
MCFab. This ensures that ambiguous Cartesian faces use the same resolved topology when building face apertures as when generating the MC triangles.Because AMReX's EB representation is single-valued, the builder checks for:
eb2.small_volfrac.Small cells are repaired automatically. Other unsupported geometry requires
eb2.cover_multiple_cuts = 1, matching the existing behaviour for covering geometry that cannot be represented as a single-valued cell.The geometry-source adapters live in
AMReX_EB2_Level_MC.H/.cpp: a source that provides its own MC sampling (STLtools) is used as is, and every other source is served by generic adapters that reuse the shop'sfillFabandgetIntercept.Docs:
Docs/sphinx_documentation/source/EB.rstgains a "Marching-Cubes Geometry Generation" section and a note on the planar EB surface output;eb2.geometry_methodandeb2.mc_stl_fileare documented inRuntimeParameters.rst.The marching-cubes tests include
parserimplicit functions, plus theEB2::BuildAPI paths (single level, host, multi-level, and coarse-level rebuild)eb2.cover_multiple_cutsThe proposed changes:
FYI: Parts of the main code and all of the testing code was vibe coded using codex. So some modifications and cleanup will be required.