Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changes

## v2.6.0 June 24, 2025

- Fixed `minangle` parameter forwarding to TetGen
- New default value `minangle = 0` for `TetGen`, leave default value `20` for `Triangle`
- New flag `radius_edge_ratio` for `TetGen`

## v2.5.0 June 24, 2025
- Allow for Triangulate v3
- Re-implemented builderplot based on GridVisualize.plot_triangulateio
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SimplexGridFactory"
uuid = "57bfcd06-606e-45d6-baf4-4ba06da0efd5"
authors = ["Juergen Fuhrmann <juergen.fuhrmann@wias-berlin.de>"]
version = "2.5.0"
authors = ["Juergen Fuhrmann <juergen.fuhrmann@wias-berlin.de>", "Patrick Jaap <patrick.jaap@wias-berlin.de>"]
version = "2.6.0"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Expand Down
54 changes: 32 additions & 22 deletions src/options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,27 @@ Create dictionary of mesh generation options with default values. These at once
keyword arguments available to the methods of the package and are listed in the following table:


| keyword | default | 2D | 3D | Explanation |
|:---------------|:-------:|:---:|:---:|:-----------------------------------------------------------|
| PLC | true | -p | -p | Triangulate/tetraheralize PLSG/PLC |
| refine | false | -r | -r | Refines a previously generated mesh. |
| quality | true | -q | -q | Quality mesh generation |
| minangle | 20 | | | Minimum angle for quality |
| volumecontrol | true | -a | -a | Maximum area constraint |
| maxvolume | Inf | | | Value of area/volume constraint if less than Inf |
| attributes | true | -A | -A | Regional attribute to each simplex. |
| confdelaunay | true | -D | | Ensure that all circumcenter lie within the domain. |
| nosteiner | false | -Y | -Y | Prohibits insertion of Steiner points on the mesh boundary |
| quiet | true | -Q | -Q | Suppress all output unless an error occurs. |
| verbose | false | -V | -V | Give detailed information. |
| debugfacets | true | | -d | Detects self-intersections of facets of the PLC. |
| check | false | -C | -C | Checks the consistency of the final mesh. |
| optlevel | 1 | | -O | Specifies the level of mesh optimization. |
| unsuitable | nothing | | | Unsuitable function |
| addflags | "" | | | Additional flags |
| flags | nothing | | | Set flags, overwrite all other options |
| keyword | default | 2D | 3D | Explanation |
|:------------------|:-------:|:---:|:---:|:-----------------------------------------------------------|
| PLC | true | -p | -p | Triangulate/tetraheralize PLSG/PLC |
| refine | false | -r | -r | Refines a previously generated mesh. |
| quality | true | -q | -q | Quality mesh generation |
| minangle | 2D: 20 | | | Minimum angle for quality |
| | 3D: 0 | | | |
| radius_edge_ratio | 2.0 | | | (3D only) Minimum radius/edge ratio for quality |
| volumecontrol | true | -a | -a | Maximum area constraint |
| maxvolume | Inf | | | Value of area/volume constraint if less than Inf |
| attributes | true | -A | -A | Regional attribute to each simplex. |
| confdelaunay | true | -D | | Ensure that all circumcenter lie within the domain. |
| nosteiner | false | -Y | -Y | Prohibits insertion of Steiner points on the mesh boundary |
| quiet | true | -Q | -Q | Suppress all output unless an error occurs. |
| verbose | false | -V | -V | Give detailed information. |
| debugfacets | true | | -d | Detects self-intersections of facets of the PLC. |
| check | false | -C | -C | Checks the consistency of the final mesh. |
| optlevel | 1 | | -O | Specifies the level of mesh optimization. |
| unsuitable | nothing | | | Unsuitable function |
| addflags | "" | | | Additional flags |
| flags | nothing | | | Set flags, overwrite all other options |


For mesh generation, these are turned into mesh generator control flags. This process can be completely
Expand All @@ -39,11 +41,12 @@ The `unsuitable` parameter should be a function, see
[`triunsuitable!`](https://juliageometry.github.io/TetGen.jl/stable/#TetGen.triunsuitable!-Tuple{Function}) .

"""
default_options() = Dict{Symbol, Any}(
default_options(mesher) = Dict{Symbol, Any}(
:PLC => true,
:refine => false,
:quality => true,
:minangle => 20,
:minangle => mesher == :triangle ? 20 : 0,
:radius_edge_ratio => 2.0,
:volumecontrol => true,
:maxvolume => Inf,
:attributes => true,
Expand Down Expand Up @@ -82,8 +85,15 @@ function makeflags(options, mesher)
options[:PLC] ? flags *= "p" : nothing
options[:refine] ? flags *= "r" : nothing
if options[:quality]
radius_edge_ratio = Float64(options[:radius_edge_ratio])
minangle = Float64(options[:minangle])
flags *= @sprintf("q%.2f", minangle)
if mesher == :tetgen
flags *= @sprintf("q%.2f", radius_edge_ratio)
flags *= @sprintf("/%.2f", minangle)
else
flags *= @sprintf("q%.2f", minangle)
end

end
if options[:volumecontrol]
flags *= "a"
Expand Down
4 changes: 3 additions & 1 deletion src/simplexgridbuilder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ function SimplexGridBuilder(; Generator = nothing, tol = 1.0e-12, checkexisting

if istetgen(Generator)
dim = 3
mesher = :tetgen
elseif istriangulate(Generator)
dim = 2
mesher = :triangle
else
throw(ArgumentError("Wrong Generator: SimplexGridBuilder needs Generator=TetGen or Generator=Triangulate as argument"))
end
Expand All @@ -66,7 +68,7 @@ function SimplexGridBuilder(; Generator = nothing, tol = 1.0e-12, checkexisting
builder.regionpoints = ElasticArray{Cdouble}(undef, dim, 0)
builder.regionvolumes = []
builder.regionnumbers = []
builder.options = default_options()
builder.options = default_options(mesher)
builder.checkexisting = checkexisting
builder._savedpoint = 0
return builder
Expand Down
2 changes: 1 addition & 1 deletion src/tetgen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ See [`default_options`](@ref) for available `kwargs`.

"""
function ExtendableGrids.simplexgrid(::Type{TetGenType}, TetGen, input; kwargs...)
opts = blendoptions!(default_options(); kwargs...)
opts = blendoptions!(default_options(:tetgen); kwargs...)

flags = makeflags(opts, :tetgen)

Expand Down
2 changes: 1 addition & 1 deletion src/triangle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Create Grid from Triangle input data.
See [`default_options`](@ref) for available `kwargs`.
"""
function ExtendableGrids.simplexgrid(::Type{TriangulateType}, Triangulate, input; kwargs...)
opts = blendoptions!(default_options(); kwargs...)
opts = blendoptions!(default_options(:triangle); kwargs...)

flags = makeflags(opts, :triangle)

Expand Down
8 changes: 4 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ end
@test testgrid(test_simplecube(; flags = "pAaqQD"), (109, 286, 198))
@test testgrid(test_simplecube(; maxvolume = 0.05), (50, 68, 96))

@test testgrid(test_simplecube(; unsuitable = test_tetunsuitable), (223, 971, 198))
@test testgrid(test_simplecube(; unsuitable = test_tetunsuitable), (242, 1095, 198))
end

@testset "SimplexGridBuilder 3d" begin
Expand Down Expand Up @@ -264,7 +264,7 @@ end
end

@test SimplexGridFactory.tetgenio(test_buildercube0()) isa RawTetGenIO
@test testgrid(test_buildercube(; unsuitable = test_tetunsuitable), (223, 971, 198))
@test testgrid(test_buildercube(; unsuitable = test_tetunsuitable), (242, 1095, 198))
end

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

# @testset " PlutoGridFactory.jl" begin
Expand Down Expand Up @@ -382,7 +382,7 @@ end;
end
@test testgrid(prim2d(), (106, 179, 50))
@test testgrid(prim2d_lineto(), (24, 30, 16))
@test testgrid(prim3d(), (423, 1787, 822))
@test testgrid(prim3d(), (591, 2872, 822))
@test testgrid(prim3d_moveto(), (207, 564, 368))
end

Expand Down
Loading