Skip to content

Commit 28ce7e0

Browse files
committed
Revert "wip"
This reverts commit 5e0acb8.
1 parent f03bb68 commit 28ce7e0

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

src/decompositions.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ end
4646
Decompose tets to edges, using a pre-allocated array and set.
4747
Set ensures uniqueness, and result will be sorted.
4848
"""
49-
function tet_to_edges!(pair::Vector, pair_set::Set, t, num_tets)
49+
function tet_to_edges!(pair::Vector, pair_set::Set, t)
5050
empty!(pair_set)
51-
length(pair) < num_tets*6 && resize!(pair, num_tets*6)
51+
length(pair) < length(t)*6 && resize!(pair, length(t)*6)
5252
num_pair = 1
53-
@inbounds for i in 1:num_tets
53+
@inbounds for i in eachindex(t)
5454
for ep in 1:6
5555
p1 = t[i][tetpairs[ep][1]]
5656
p2 = t[i][tetpairs[ep][2]]

src/distmeshnd.jl

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,15 @@ function distmesh(fdist::Function,
9696
lcount = 0 # iteration counter
9797
triangulationcount = 0 # triangulation counter
9898
num_pairs = 0
99-
num_tets = 0
10099

101100
@inbounds while true
102101
# if large move, retriangulation
103102
if maxmove>setup.ttol*h
104103

105104
# compute a new delaunay triangulation
106-
num_tets = retriangulate!(fdist, result, geps, setup, triangulationcount, pt_dists)
105+
retriangulate!(fdist, result, geps, setup, triangulationcount, pt_dists)
107106

108-
num_pairs = tet_to_edges!(pair, pair_set, result.tetrahedra, num_tets) # Describe each edge by a unique pair of nodes
107+
num_pairs = tet_to_edges!(pair, pair_set, result.tetrahedra) # Describe each edge by a unique pair of nodes
109108

110109
# resize arrays for new pair count
111110
length(bars) < num_pairs && resize!(bars, num_pairs)
@@ -171,7 +170,6 @@ function distmesh(fdist::Function,
171170

172171
# Termination criterion
173172
if maxdp<setup.ptol*h
174-
resize!(result.tetrahedra, num_tets)
175173
return result
176174
end
177175
end
@@ -197,23 +195,23 @@ function retriangulate!(fdist, result::DistMeshResult, geps, setup, triangulatio
197195
p = result.points
198196
triangulation = delaunayn(p)
199197
t_d = triangulation.tetrahedra
200-
length(t) < length(t_d) && resize!(t, length(t_d))
198+
resize!(t, length(t_d))
199+
copyto!(t, t_d) # we need to copy since we have a shared reference with tetgen
201200

202201
# average points to get mid point of each tetrahedra
203202
# if the mid point of the tetrahedra is outside of
204203
# the boundary we remove it.
205204
# TODO: this is an inlined filter call. Would be good to revert
206205
# TODO: can we use the point distance array to pass boundary points to
207206
# tetgen so this call is no longer required?
208-
j = 1
209-
for ai in t_d
207+
j = firstindex(t)
208+
for ai in t
210209
t[j] = ai
211210
pm = (p[ai[1]].+p[ai[2]].+p[ai[3]].+p[ai[4]])./4
212-
j = ifelse(fdist(pm) <= -geps, j+1, j)
211+
j = ifelse(fdist(pm) <= -geps, nextind(t, j), j)
213212
end
214-
#j <= lastindex(t) && resize!(t, j-1)
215-
j <= length(t_d) && return j-1
216-
return length(t_d)
213+
j <= lastindex(t) && resize!(t, j-1)
214+
nothing
217215
end
218216

219217

0 commit comments

Comments
 (0)