Skip to content

Commit fad46ec

Browse files
authored
Merge pull request #26 from WIAS-PDELib/fix/tetgen-minangle
Fix `minangle` forwarding to `TetGen` and adjust default value
2 parents ef9be6a + 042a6af commit fad46ec

File tree

7 files changed

+49
-31
lines changed

7 files changed

+49
-31
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changes
22

3+
## v2.6.0 June 24, 2025
4+
5+
- Fixed `minangle` parameter forwarding to TetGen
6+
- New default value `minangle = 0` for `TetGen`, leave default value `20` for `Triangle`
7+
- New flag `radius_edge_ratio` for `TetGen`
8+
39
## v2.5.0 June 24, 2025
410
- Allow for Triangulate v3
511
- Re-implemented builderplot based on GridVisualize.plot_triangulateio

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SimplexGridFactory"
22
uuid = "57bfcd06-606e-45d6-baf4-4ba06da0efd5"
3-
authors = ["Juergen Fuhrmann <juergen.fuhrmann@wias-berlin.de>"]
4-
version = "2.5.0"
3+
authors = ["Juergen Fuhrmann <juergen.fuhrmann@wias-berlin.de>", "Patrick Jaap <patrick.jaap@wias-berlin.de>"]
4+
version = "2.6.0"
55

66
[deps]
77
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"

src/options.jl

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,27 @@ Create dictionary of mesh generation options with default values. These at once
44
keyword arguments available to the methods of the package and are listed in the following table:
55
66
7-
| keyword | default | 2D | 3D | Explanation |
8-
|:---------------|:-------:|:---:|:---:|:-----------------------------------------------------------|
9-
| PLC | true | -p | -p | Triangulate/tetraheralize PLSG/PLC |
10-
| refine | false | -r | -r | Refines a previously generated mesh. |
11-
| quality | true | -q | -q | Quality mesh generation |
12-
| minangle | 20 | | | Minimum angle for quality |
13-
| volumecontrol | true | -a | -a | Maximum area constraint |
14-
| maxvolume | Inf | | | Value of area/volume constraint if less than Inf |
15-
| attributes | true | -A | -A | Regional attribute to each simplex. |
16-
| confdelaunay | true | -D | | Ensure that all circumcenter lie within the domain. |
17-
| nosteiner | false | -Y | -Y | Prohibits insertion of Steiner points on the mesh boundary |
18-
| quiet | true | -Q | -Q | Suppress all output unless an error occurs. |
19-
| verbose | false | -V | -V | Give detailed information. |
20-
| debugfacets | true | | -d | Detects self-intersections of facets of the PLC. |
21-
| check | false | -C | -C | Checks the consistency of the final mesh. |
22-
| optlevel | 1 | | -O | Specifies the level of mesh optimization. |
23-
| unsuitable | nothing | | | Unsuitable function |
24-
| addflags | "" | | | Additional flags |
25-
| flags | nothing | | | Set flags, overwrite all other options |
7+
| keyword | default | 2D | 3D | Explanation |
8+
|:------------------|:-------:|:---:|:---:|:-----------------------------------------------------------|
9+
| PLC | true | -p | -p | Triangulate/tetraheralize PLSG/PLC |
10+
| refine | false | -r | -r | Refines a previously generated mesh. |
11+
| quality | true | -q | -q | Quality mesh generation |
12+
| minangle | 2D: 20 | | | Minimum angle for quality |
13+
| | 3D: 0 | | | |
14+
| radius_edge_ratio | 2.0 | | | (3D only) Minimum radius/edge ratio for quality |
15+
| volumecontrol | true | -a | -a | Maximum area constraint |
16+
| maxvolume | Inf | | | Value of area/volume constraint if less than Inf |
17+
| attributes | true | -A | -A | Regional attribute to each simplex. |
18+
| confdelaunay | true | -D | | Ensure that all circumcenter lie within the domain. |
19+
| nosteiner | false | -Y | -Y | Prohibits insertion of Steiner points on the mesh boundary |
20+
| quiet | true | -Q | -Q | Suppress all output unless an error occurs. |
21+
| verbose | false | -V | -V | Give detailed information. |
22+
| debugfacets | true | | -d | Detects self-intersections of facets of the PLC. |
23+
| check | false | -C | -C | Checks the consistency of the final mesh. |
24+
| optlevel | 1 | | -O | Specifies the level of mesh optimization. |
25+
| unsuitable | nothing | | | Unsuitable function |
26+
| addflags | "" | | | Additional flags |
27+
| flags | nothing | | | Set flags, overwrite all other options |
2628
2729
2830
For mesh generation, these are turned into mesh generator control flags. This process can be completely
@@ -39,11 +41,12 @@ The `unsuitable` parameter should be a function, see
3941
[`triunsuitable!`](https://juliageometry.github.io/TetGen.jl/stable/#TetGen.triunsuitable!-Tuple{Function}) .
4042
4143
"""
42-
default_options() = Dict{Symbol, Any}(
44+
default_options(mesher) = Dict{Symbol, Any}(
4345
:PLC => true,
4446
:refine => false,
4547
:quality => true,
46-
:minangle => 20,
48+
:minangle => mesher == :triangle ? 20 : 0,
49+
:radius_edge_ratio => 2.0,
4750
:volumecontrol => true,
4851
:maxvolume => Inf,
4952
:attributes => true,
@@ -82,8 +85,15 @@ function makeflags(options, mesher)
8285
options[:PLC] ? flags *= "p" : nothing
8386
options[:refine] ? flags *= "r" : nothing
8487
if options[:quality]
88+
radius_edge_ratio = Float64(options[:radius_edge_ratio])
8589
minangle = Float64(options[:minangle])
86-
flags *= @sprintf("q%.2f", minangle)
90+
if mesher == :tetgen
91+
flags *= @sprintf("q%.2f", radius_edge_ratio)
92+
flags *= @sprintf("/%.2f", minangle)
93+
else
94+
flags *= @sprintf("q%.2f", minangle)
95+
end
96+
8797
end
8898
if options[:volumecontrol]
8999
flags *= "a"

src/simplexgridbuilder.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ function SimplexGridBuilder(; Generator = nothing, tol = 1.0e-12, checkexisting
4949

5050
if istetgen(Generator)
5151
dim = 3
52+
mesher = :tetgen
5253
elseif istriangulate(Generator)
5354
dim = 2
55+
mesher = :triangle
5456
else
5557
throw(ArgumentError("Wrong Generator: SimplexGridBuilder needs Generator=TetGen or Generator=Triangulate as argument"))
5658
end
@@ -66,7 +68,7 @@ function SimplexGridBuilder(; Generator = nothing, tol = 1.0e-12, checkexisting
6668
builder.regionpoints = ElasticArray{Cdouble}(undef, dim, 0)
6769
builder.regionvolumes = []
6870
builder.regionnumbers = []
69-
builder.options = default_options()
71+
builder.options = default_options(mesher)
7072
builder.checkexisting = checkexisting
7173
builder._savedpoint = 0
7274
return builder

src/tetgen.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ See [`default_options`](@ref) for available `kwargs`.
77
88
"""
99
function ExtendableGrids.simplexgrid(::Type{TetGenType}, TetGen, input; kwargs...)
10-
opts = blendoptions!(default_options(); kwargs...)
10+
opts = blendoptions!(default_options(:tetgen); kwargs...)
1111

1212
flags = makeflags(opts, :tetgen)
1313

src/triangle.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Create Grid from Triangle input data.
66
See [`default_options`](@ref) for available `kwargs`.
77
"""
88
function ExtendableGrids.simplexgrid(::Type{TriangulateType}, Triangulate, input; kwargs...)
9-
opts = blendoptions!(default_options(); kwargs...)
9+
opts = blendoptions!(default_options(:triangle); kwargs...)
1010

1111
flags = makeflags(opts, :triangle)
1212

test/runtests.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ end
224224
@test testgrid(test_simplecube(; flags = "pAaqQD"), (109, 286, 198))
225225
@test testgrid(test_simplecube(; maxvolume = 0.05), (50, 68, 96))
226226

227-
@test testgrid(test_simplecube(; unsuitable = test_tetunsuitable), (223, 971, 198))
227+
@test testgrid(test_simplecube(; unsuitable = test_tetunsuitable), (242, 1095, 198))
228228
end
229229

230230
@testset "SimplexGridBuilder 3d" begin
@@ -264,7 +264,7 @@ end
264264
end
265265

266266
@test SimplexGridFactory.tetgenio(test_buildercube0()) isa RawTetGenIO
267-
@test testgrid(test_buildercube(; unsuitable = test_tetunsuitable), (223, 971, 198))
267+
@test testgrid(test_buildercube(; unsuitable = test_tetunsuitable), (242, 1095, 198))
268268
end
269269

270270
@testset "examples2d.jl" begin
@@ -284,7 +284,7 @@ end;
284284
@test testgrid(tetrahedralization_of_cube(), (718, 2456, 1094))
285285
@test testgrid(tet_cube_with_primitives(), (5658, 27324, 6888))
286286
@test testgrid(glue_3d(), (29832, 173202, 13200))
287-
@test testgrid(stl_3d(), (4740, 13605, 9464))
287+
@test testgrid(stl_3d(), (5979, 20640, 9818))
288288
end;
289289

290290
# @testset " PlutoGridFactory.jl" begin
@@ -382,7 +382,7 @@ end;
382382
end
383383
@test testgrid(prim2d(), (106, 179, 50))
384384
@test testgrid(prim2d_lineto(), (24, 30, 16))
385-
@test testgrid(prim3d(), (423, 1787, 822))
385+
@test testgrid(prim3d(), (591, 2872, 822))
386386
@test testgrid(prim3d_moveto(), (207, 564, 368))
387387
end
388388

0 commit comments

Comments
 (0)