From 41e36e5543f5f9feaa9ec1a3b391b9d2a24b4857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Fuhrmann?= Date: Mon, 13 Apr 2026 18:13:49 +0200 Subject: [PATCH 1/3] Support writing of TetGen .smesh files --- Project.toml | 6 ++-- src/SimplexGridFactory.jl | 1 + src/tetgen.jl | 68 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 96b189b..aab01f9 100644 --- a/Project.toml +++ b/Project.toml @@ -1,9 +1,10 @@ name = "SimplexGridFactory" uuid = "57bfcd06-606e-45d6-baf4-4ba06da0efd5" -authors = ["Juergen Fuhrmann ", "Patrick Jaap "] version = "2.6.1" +authors = ["Juergen Fuhrmann ", "Patrick Jaap "] [deps] +Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" ElasticArrays = "fdbdab4c-e67f-52f5-8c3f-e7b388dad3d4" ExtendableGrids = "cfc395e8-590f-11e8-1f13-43a2532b2fa8" @@ -18,6 +19,7 @@ TetGen = "c5d3f3f7-f850-59f6-8a2e-ffc6dc1317ea" Triangulate = "f7e6ffb2-c36d-4f8f-a77e-16e897189344" [compat] +Dates = "1.10" DocStringExtensions = "0.8,0.9" ElasticArrays = "^1.2" ExtendableGrids = "1.6" @@ -28,4 +30,4 @@ MeshIO = "0.4, 0.5" Printf = "1.6" TetGen = "1.5,2" Triangulate = "2.3.1, 3" -julia = "1.9" +julia = "1.10" diff --git a/src/SimplexGridFactory.jl b/src/SimplexGridFactory.jl index 2eaef75..3bed7c4 100644 --- a/src/SimplexGridFactory.jl +++ b/src/SimplexGridFactory.jl @@ -11,6 +11,7 @@ using LinearAlgebra: norm using ElasticArrays: ElasticArray import ExtendableGrids using ExtendableGrids: dim_space, Coordinates, BFaceNodes, BFaceRegions, simplexgrid, BinnedPointList +using Dates: now using DocStringExtensions: SIGNATURES, TYPEDEF, TYPEDSIGNATURES using GridVisualize: GridVisualize, GridVisualizer, plot_triangulateio! using FileIO: load diff --git a/src/tetgen.jl b/src/tetgen.jl index 92ca1e8..a8126d6 100644 --- a/src/tetgen.jl +++ b/src/tetgen.jl @@ -151,3 +151,71 @@ function tetgenio(this::SimplexGridBuilder) regionvolumes = this.regionvolumes ) end + +function writesmesh(io::IO, tio) + shift = 1 + npoints = size(tio.pointlist, 2) + dimension = 3 + npointboundarymarkers = 0 + npointattributes = 0 + nfacets = length(tio.facetlist) + nfacetboundarymarkers = length(tio.facetmarkerlist) > 0 ? 1 : 0 + nholes = size(tio.holelist, 2) + nregions = size(tio.regionlist, 2) + + write(io, @sprintf("# TetGen input file\n")) + write(io, @sprintf("# Created by SimplexGridFactory.jl %s\n", string(now()))) + write(io, @sprintf("\n# part 1: node list.")) + write(io, @sprintf("\n%ld %d %d %d", npoints, dimension, npointboundarymarkers, npointattributes)) + for ipoint in 1:npoints + write( + io, @sprintf( + "\n%ld %.17g %.17g %.17g", ipoint - 1, + tio.pointlist[1, ipoint], tio.pointlist[2, ipoint], tio.pointlist[3, ipoint] + ) + ) + end + write(io, @sprintf("\n\n# part 2: facet list.")) + write(io, @sprintf("\n%ld %d", nfacets, nfacetboundarymarkers)) + for ifacet in 1:nfacets + facet = tio.facetlist[ifacet].polygonlist[1] + ncorners = length(facet) + write(io, @sprintf("\n%ld ", ncorners)) + for icorner in 1:ncorners + write(io, @sprintf("%ld ", facet[icorner] - 1)) + end + if nfacetboundarymarkers > 0 + write(io, @sprintf("%ld ", tio.facetmarkerlist[ifacet])) + end + end + write(io, @sprintf("\n\n# part 3: hole list.")) + write(io, @sprintf("\n%ld", nholes)) + for ihole in 1:nholes + write( + io, @sprintf( + "\n%ld %.17g %.17g %.17g", ihole - 1, + tio.holelist[1, ihole], tio.holelist[2, ihole], tio.holelist[3, ihole] + ) + ) + end + write(io, @sprintf("\n\n# part 4: region list.")) + write(io, @sprintf("\n%ld", nregions)) + for iregion in 1:nregions + write( + io, @sprintf( + "\n%ld %.17g %.17g %.17g %f %.17g", iregion - 1, + tio.regionlist[1, iregion], tio.regionlist[2, iregion], tio.regionlist[3, iregion], + tio.regionlist[4, iregion], tio.regionlist[5, iregion] + ) + ) + end + write(io, "\n") + return +end + +function writesmesh(fname::String, tetin) + open(fname, "w") do io + writesmesh(io, tetin) + end + return +end From e15d2f5a74bee7eda05efee53e5b18dd72b86d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Fuhrmann?= Date: Mon, 13 Apr 2026 18:21:06 +0200 Subject: [PATCH 2/3] bump minimum julia version to 1.10 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da2de7b..55a94c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false matrix: version: - - '1.9' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'. + - '1.10' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'. - '1' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia. # - 'nightly' os: From 0f9277793a72f815a9c74588f62e544c567bc7db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Fuhrmann?= Date: Tue, 14 Apr 2026 11:55:03 +0200 Subject: [PATCH 3/3] fix ambiguous method signature --- src/tetgen.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tetgen.jl b/src/tetgen.jl index a8126d6..f9e6bc0 100644 --- a/src/tetgen.jl +++ b/src/tetgen.jl @@ -152,6 +152,10 @@ function tetgenio(this::SimplexGridBuilder) ) end +function writesmesh(file::String, b::SimplexGridBuilder) + return writesmesh(file, tetgenio(b)) +end + function writesmesh(io::IO, tio) shift = 1 npoints = size(tio.pointlist, 2)