Skip to content

Commit

Permalink
Deprecate type piracy for simplexgrid(::Module; ..)
Browse files Browse the repository at this point in the history
Avoid codepath through this call.
  • Loading branch information
j-fu committed Nov 29, 2024
1 parent 1dad040 commit 5effa46
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 38 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Changes
## v2.3.0 Nov 28, 2024
- Allow for TetGen v1, v2
- Deprecate simplexgrid(Module...)

## v2.2.1 Nov 2, 2024
- Move repo to WIAS-PDELib org

Expand Down
2 changes: 1 addition & 1 deletion examples/examples2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ end
#

# ## Direct specification of input arrays
# Of course we can specify the input for Triangle
# We can specify the input for Triangle
# directly. The aim of SimplexBuilder is to avoid
# the tedious and error prone counting connected
# with this approach.
Expand Down
1 change: 1 addition & 0 deletions src/simplexgrid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function ExtendableGrids.simplexgrid(Generator::Module;
regionnumbers = Array{Cint, 1}(undef, 0),
regionvolumes = Array{Cdouble, 1}(undef, 0),
kwargs...)
@warn "ExtendableGrids.simplexgrid(::Module; kwargs...) is deprecated"
if size(points, 1) == 2
tio = triangulateio(Generator; points = points,
bfaces = bfaces,
Expand Down
24 changes: 14 additions & 10 deletions src/simplexgridbuilder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -327,21 +327,25 @@ function ExtendableGrids.simplexgrid(builder::SimplexGridBuilder; kwargs...)
facets[1, i] = builder.facets[i][1]
facets[2, i] = builder.facets[i][2]
end
make_tio=triangulateio
generator_type=TriangulateType
else
facets = builder.facets
make_tio= tetgenio
generator_type=TetGenType
end

options = blendoptions!(copy(builder.options); kwargs...)

ExtendableGrids.simplexgrid(builder.Generator;
points = builder.pointlist.points,
bfaces = facets,
bfaceregions = builder.facetregions,
regionpoints = builder.regionpoints,
regionnumbers = builder.regionnumbers,
regionvolumes = builder.regionvolumes,
Generator = builder.Generator,
options...)
tio = make_tio(builder.Generator;
points = builder.pointlist.points,
bfaces = facets,
bfaceregions = builder.facetregions,
regionpoints = builder.regionpoints,
regionnumbers = builder.regionnumbers,
regionvolumes = builder.regionvolumes)

ExtendableGrids.simplexgrid(generator_type, builder.Generator, tio; options...)
end

"""
Expand Down
55 changes: 28 additions & 27 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,14 @@ end

@testset "Simplexgrid (arrays 2d)" begin
function test_simplesquare(; kwargs...)
grid = simplexgrid(Triangulate;
points = [0 0; 0 1; 1 1; 1 0]',
bfaces = [1 2; 2 3; 3 4; 4 1]',
bfaceregions = [1, 2, 3, 4],
regionpoints = [0.5 0.5;]',
regionnumbers = [1],
regionvolumes = [0.01], kwargs...)
tio= SimplexGridFactory.triangulateio(Triangulate,
points = [0 0; 0 1; 1 1; 1 0]',
bfaces = [1 2; 2 3; 3 4; 4 1]',
bfaceregions = [1, 2, 3, 4],
regionpoints = [0.5 0.5;]',
regionnumbers = [1],
regionvolumes = [0.01])
grid = simplexgrid(SimplexGridFactory.TriangulateType,Triangulate, tio; kwargs...)
end

@test testgrid(test_simplesquare(), (89, 144, 32))
Expand Down Expand Up @@ -183,27 +184,27 @@ end

@testset "Simplexgrid (arrays 3d)" begin
function test_simplecube(; kwargs...)
grid = simplexgrid(TetGen;
points = [0 0 0;
1 0 0;
1 1 0;
0 1 0;
0 0 1;
1 0 1;
1 1 1;
0 1 1]', bfaces = [1 2 3 4;
5 6 7 8;
1 2 6 5;
2 3 7 6;
3 4 8 7;
4 1 5 8]',
bfaceregions = [i for i = 1:6],
regionpoints = [0.5 0.5 0.5]',
regionnumbers = [1],
regionvolumes = [0.01],
kwargs...)
tio= SimplexGridFactory.tetgenio(TetGen,
points = [0 0 0;
1 0 0;
1 1 0;
0 1 0;
0 0 1;
1 0 1;
1 1 1;
0 1 1]', bfaces = [1 2 3 4;
5 6 7 8;
1 2 6 5;
2 3 7 6;
3 4 8 7;
4 1 5 8]',
bfaceregions = [i for i = 1:6],
regionpoints = [0.5 0.5 0.5]',
regionnumbers = [1],
regionvolumes = [0.01])
grid = simplexgrid(SimplexGridFactory.TetGenType,TetGen, tio; kwargs...)
end

@test testgrid(test_simplecube(), (109, 286, 198))
@test testgrid(test_simplecube(; flags = "pAaqQD"), (109, 286, 198))
@test testgrid(test_simplecube(; maxvolume = 0.05), (50, 68, 96))
Expand Down

0 comments on commit 5effa46

Please sign in to comment.