Skip to content

Commit 67de7e8

Browse files
authored
Fix TriRefinement to match docstring (#1291)
* Fix TriRefinement to match docstring * Fix test
1 parent e2d74ed commit 67de7e8

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/refinement/tri.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ TriRefinement() = TriRefinement(nothing)
1818

1919
function refine(mesh, method::TriRefinement)
2020
assertion(paramdim(mesh) == 2, "TriRefinement only defined for surface meshes")
21-
(eltype(mesh) <: Triangle) || return simplexify(mesh)
2221

2322
# retrieve geometry and topology
2423
points = vertices(mesh)

test/refinement.jl

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
11
@testitem "TriRefinement" setup = [Setup] begin
22
# CRS propagation
33
grid = CartesianGrid((3, 3), merc(0, 0), (T(1), T(1)))
4-
ref = refine(grid, TriRefinement())
5-
@test crs(ref) === crs(grid)
4+
rgrid = refine(grid, TriRefinement())
5+
@test crs(rgrid) === crs(grid)
6+
7+
# quadrangles are divided into 4 triangles
8+
grid = cartgrid(10, 10)
9+
rgrid = refine(grid, TriRefinement())
10+
@test nelements(rgrid) == 4 * nelements(grid)
611

712
# predicate
813
points = cart.([(0, 0), (4, 0), (8, 0), (3, 1), (5, 1), (2, 2), (4, 2), (6, 2), (4, 4)])
914
connec = connect.([(1, 2, 6), (2, 3, 8), (6, 8, 9), (2, 5, 4), (4, 5, 7), (4, 7, 6), (5, 8, 7)])
1015
mesh = SimpleMesh(points, connec)
11-
ref = refine(mesh, TriRefinement(e -> measure(e) > T(1) * u"m^2"))
12-
@test nelements(ref) == 13
13-
@test nvertices(ref) == 12
14-
ref = refine(mesh, TriRefinement(e -> measure(e) T(1) * u"m^2"))
15-
@test nelements(ref) == 15
16-
@test nvertices(ref) == 13
16+
rmesh = refine(mesh, TriRefinement(e -> measure(e) > T(1) * u"m^2"))
17+
@test nelements(rmesh) == 13
18+
@test nvertices(rmesh) == 12
19+
rmesh = refine(mesh, TriRefinement(e -> measure(e) T(1) * u"m^2"))
20+
@test nelements(rmesh) == 15
21+
@test nvertices(rmesh) == 13
1722

1823
# latlon
1924
points = latlon.([(0, 0), (0, 4), (0, 8), (1, 3), (1, 5), (2, 2), (2, 4), (2, 6), (4, 4)])
2025
connec = connect.([(1, 2, 6), (2, 3, 8), (6, 8, 9), (2, 5, 4), (4, 5, 7), (4, 7, 6), (5, 8, 7)])
2126
mesh = SimpleMesh(points, connec)
22-
ref = refine(mesh, TriRefinement())
23-
@test nelements(ref) == 21
24-
@test nvertices(ref) == 16
27+
rmesh = refine(mesh, TriRefinement())
28+
@test nelements(rmesh) == 21
29+
@test nvertices(rmesh) == 16
2530
end
2631

2732
@testitem "QuadRefinement" setup = [Setup] begin
@@ -117,5 +122,5 @@ end
117122
mesh = topoconvert(SimpleTopology, grid)
118123
rmesh = refine(mesh)
119124
@test eltype(rmesh) <: Triangle
120-
@test nelements(rmesh) == 200
125+
@test nelements(rmesh) == 400
121126
end

0 commit comments

Comments
 (0)