Skip to content

Replace Shewchuk Triangle with fortfem's MIT-licensed Triangle-compatible mesher - #27

Closed
krystophny wants to merge 5 commits into
mainfrom
drop-triangle
Closed

Replace Shewchuk Triangle with fortfem's MIT-licensed Triangle-compatible mesher#27
krystophny wants to merge 5 commits into
mainfrom
drop-triangle

Conversation

@krystophny

@krystophny krystophny commented Jun 10, 2026

Copy link
Copy Markdown
Member

Replaces Shewchuk's Triangle with fortfem's clean-room, MIT-licensed
triangle_compat mesher. Triangle's distribution restriction conflicts with
MEPHIT's MIT license.

Resolves #25

Changes

  • Replaces the C Triangle wrapper with the Fortran
    mephit_triangulate adapter.
  • Keeps the MEPHIT mesh contract: two constrained closed loops, one hole,
    fixed boundary segments, q20 quality refinement, and FreeFem .msh
    output.
  • Removes the Triangle fetch and the old C implementation.
  • Fetches only fortfem's dependency-free fortfem_triangle_compat target.

Dependency pin

Fortfem PR #56 is now
merged. This branch pins FortFEM main at
605dc7f.
FORTFEM_PATH can be set for local source testing.

Verification

  • A clean configure fetched exactly 605dc7f056aa9b15cf8e0673eaa13b13ce12a273.
  • The full MEPHIT mephit target built successfully with gfortran.
  • On the 128-point inner and 16-point outer annulus fixture, the adapter
    produced 262 points, 380 triangles, 144 segments, and a 20.1546 degree
    minimum angle.
  • The annulus area was 22763.8 in the fixture. No Triangle library is
    present in the resulting shared-library dependencies.

Triangle forbids distribution as part of a commercial system without
arrangement with the author, which conflicts with MEPHIT's MIT license.
fortfem's clean-room triangle_compat module reproduces Triangle's
behavior for the flags MEPHIT uses (BejnpqYz): on the TCFP annulus
geometry of write_FreeFem_mesh, the generated outer.msh has
byte-identical vertices and segments and the same triangles up to
enumeration order; on the AUG annulus the file is byte-identical.

The mesher is now called directly from Fortran (mephit_triangulate),
so the C wrapper around triangulate() goes away along with the
Triangle fetch-and-patch machinery. fortfem is fetched via
FetchContent with FORTFEM_TRIANGLE_COMPAT_ONLY=ON, which builds only
the dependency-free mesher library.

Resolves #25
# Conflicts:
#	CMakeLists.txt
#	cmake/SetupCODE.cmake
@krystophny

Copy link
Copy Markdown
Member Author

Merged main; resolved conflicts in CMakeLists.txt (kept fortfem include dirs plus main's FFTW_INCLUDE_DIRS) and cmake/SetupCODE.cmake (kept main's hermetic-build overrides, dropped the Triangle override). #14 and #27 remain alternative TRIANGLE replacements to choose between.

@krystophny

Copy link
Copy Markdown
Member Author

Closing for now; branch archived as z_archive/drop-triangle. It remains the reference implementation for the fortfem triangle_compat route in #25 and can be restored from the archived ref.

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.

Triangle (Shewchuk) has a non-commercial restriction incompatible with MIT license

1 participant