@@ -95,6 +95,7 @@ function distmesh(fdist::Function,
95
95
# information on each iteration
96
96
lcount = 0 # iteration counter
97
97
triangulationcount = 0 # triangulation counter
98
+ num_pairs = 0
98
99
99
100
@inbounds while true
100
101
# if large move, retriangulation
@@ -103,18 +104,20 @@ function distmesh(fdist::Function,
103
104
# compute a new delaunay triangulation
104
105
retriangulate! (fdist, result, geps, setup, triangulationcount, pt_dists)
105
106
106
- tet_to_edges! (pair, pair_set, result. tetrahedra) # 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
107
108
108
109
# resize arrays for new pair counts
109
- resize! (bars, length (pair))
110
- resize! (L, length (pair))
110
+ if triangulationcount == 0
111
+ resize! (bars, length (result. tetrahedra)* 6 )
112
+ resize! (L, length (result. tetrahedra)* 6 )
113
+ end
111
114
non_uniform && resize! (L0, length (pair))
112
115
113
116
triangulationcount += 1
114
117
stats && push! (result. stats. retriangulations, lcount)
115
118
end
116
119
117
- compute_displacements! (fh, dp, pair, L, L0, bars, result. points, setup, VertType)
120
+ compute_displacements! (fh, dp, pair, num_pairs, L, L0, bars, result. points, setup, VertType)
118
121
119
122
# Zero out forces on fix points
120
123
if have_fixed
@@ -214,16 +217,17 @@ function retriangulate!(fdist, result::DistMeshResult, geps, setup, triangulatio
214
217
end
215
218
216
219
217
- function compute_displacements! (fh, dp, pair, L, L0, bars, p, setup,
218
- :: Type{VertType} ) where {VertType}
220
+
221
+ function compute_displacements! (fh, dp, pair, num_pairs, L, L0, bars, p, setup,
222
+ :: Type{VertType} ) where {VertType}
219
223
220
224
non_uniform = isa (typeof (L0), AbstractVector)
221
225
222
226
# compute edge lengths (L) and adaptive edge lengths (L0)
223
227
# Lp norm (p=3) is partially computed here
224
228
Lsum = zero (eltype (L))
225
229
L0sum = non_uniform ? zero (eltype (L0)) : length (pair)
226
- for i in eachindex (pair)
230
+ for i in 1 : num_pairs
227
231
pb = pair[i]
228
232
b1 = p[pb[1 ]]
229
233
b2 = p[pb[2 ]]
@@ -245,7 +249,7 @@ function compute_displacements!(fh, dp, pair, L, L0, bars, p, setup,
245
249
lscbrt = (1 + (0.4 / 2 ^ 2 ))* cbrt (Lsum/ L0sum)
246
250
247
251
# Move mesh points based on edge lengths L and forces F
248
- for i in eachindex (pair)
252
+ for i in 1 : num_pairs
249
253
if non_uniform && L[i] < L0[i]* lscbrt || L[i] < lscbrt
250
254
L0_f = non_uniform ? L0[i]. * lscbrt : lscbrt
251
255
# compute force vectors
0 commit comments