Skip to content

Commit e64a05d

Browse files
committed
try to only grow arrays and track the length of edges after decomp
1 parent f781e62 commit e64a05d

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/decompositions.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function tet_to_edges!(pair::Vector, pair_set::Set, t)
5555
push!(pair_set, p1 > p2 ? (p2,p1) : (p1,p2))
5656
end
5757
end
58-
resize!(pair, length(pair_set))
58+
length(pair) < length(pair_set) && resize!(pair, length(pair_set))
5959
# copy pair set to array since sets are not sortable
6060
i = 1
6161
for elt in pair_set
@@ -64,7 +64,7 @@ function tet_to_edges!(pair::Vector, pair_set::Set, t)
6464
end
6565

6666
# sort the edge pairs for better point lookup
67-
sort!(pair)
67+
#sort!(pair)
6868

69-
return length(pair) # return the number of pairs
69+
return i - 1 # return the number of pairs
7070
end

src/distmeshnd.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,10 @@ function distmesh(fdist::Function,
106106

107107
num_pairs = tet_to_edges!(pair, pair_set, result.tetrahedra) # Describe each edge by a unique pair of nodes
108108

109-
# resize arrays for new pair counts
110-
if triangulationcount == 0
111-
resize!(bars, length(result.tetrahedra)*6)
112-
resize!(L, length(result.tetrahedra)*6)
113-
end
114-
non_uniform && resize!(L0, length(pair))
109+
# resize arrays for new pair count
110+
length(bars) < num_pairs && resize!(bars, num_pairs)
111+
length(L) < num_pairs && resize!(L, num_pairs)
112+
non_uniform && length(L0) < num_pairs && resize!(L0, num_pairs)
115113

116114
triangulationcount += 1
117115
stats && push!(result.stats.retriangulations, lcount)
@@ -226,7 +224,7 @@ function compute_displacements!(fh, dp, pair, num_pairs, L, L0, bars, p, setup,
226224
# compute edge lengths (L) and adaptive edge lengths (L0)
227225
# Lp norm (p=3) is partially computed here
228226
Lsum = zero(eltype(L))
229-
L0sum = non_uniform ? zero(eltype(L0)) : length(pair)
227+
L0sum = non_uniform ? zero(eltype(L0)) : num_pairs
230228
for i in 1:num_pairs
231229
pb = pair[i]
232230
b1 = p[pb[1]]

0 commit comments

Comments
 (0)