@@ -100,14 +100,10 @@ end
100
100
101
101
gradient (t,u,m= volumes (t),g= gradienthat (t,m)) = [u[value (t[k])]⋅ value (g[k]) for k ∈ 1 : length (t)]
102
102
103
- function interp (t,ut)
104
- np,nt = length (points (t)),length (t)
105
- A = spzeros (np,nt)
106
- for i ∈ 1 : ndims (Manifold (t))
107
- A += sparse (column (t,i),1 : nt,1 ,np,nt)
108
- end
109
- sparse (1 : np,1 : np,inv .(sum (A,dims= 2 ))[:],np,np)* A* ut
110
- end
103
+ interp (t,ut,A= interp (t)) = A* ut
104
+ interp (t,A:: SparseMatrixCSC = incidence (t)) = Diagonal (inv .(degrees (t,A)))* A
105
+ pretni (t,A:: SparseMatrixCSC = incidence (t)) = interp (t,sparse (A' ))
106
+ pretni (t,ut,A= pretni (t)) = A* ut
111
107
112
108
function assembledivergence (t,m,g)
113
109
p = points (t); np,nt = length (p),length (t)
@@ -126,7 +122,7 @@ stiffness(c,g,::Val{2}) = (cg = c*g^2; SMatrix{2,2,typeof(c)}(cg,-cg,-cg,cg))
126
122
function stiffness (c,g,:: Val{N} ) where N
127
123
A = zeros (MMatrix{N,N,typeof (c)})
128
124
for i ∈ 1 : N, j ∈ 1 : N
129
- A[i,j] + = c* (g[i]⋅ g[j])[1 ]
125
+ A[i,j] = c* (g[i]⋅ g[j])[1 ]
130
126
end
131
127
return SMatrix {N,N,typeof(c)} (A)
132
128
end
@@ -136,7 +132,7 @@ assemblestiffness(t,c=1,m=volumes(t),g=gradienthat(t,m)) = assembleglobal(stiffn
136
132
function sonicstiffness (c,g,:: Val{N} ) where N
137
133
A = zeros (MMatrix{N,N,typeof (c)})
138
134
for i ∈ 1 : N, j ∈ 1 : N
139
- A[i,j] + = c* g[i][1 ]^ 2 + g[j][2 ]^ 2
135
+ A[i,j] = c* g[i][1 ]^ 2 + g[j][2 ]^ 2
140
136
end
141
137
return SMatrix {N,N,typeof(c)} (A)
142
138
end
@@ -234,12 +230,13 @@ function solvedirichlet(M,b,fixed)
234
230
return ξ
235
231
end
236
232
237
- const boundary = pointset # deprecate
238
233
interior (e) = interior (length (points (e)),pointset (e))
239
234
interior (fixed,neq) = sort! (setdiff (1 : neq,fixed))
240
235
solvehomogenous (e,M,b) = solvedirichlet (M,b,e)
241
- const solveboundary = solvedirichlet
242
- export solvehomogenous, solveboundary # deprecate
236
+ export solvehomogenous, solveboundary
237
+ const solveboundary = solvedirichlet # deprecate
238
+ const edgelengths = volumes # deprecate
239
+ const boundary = pointset # deprecate
243
240
244
241
function edgesindices (t,cols= columns (t))
245
242
np,nt = length (points (t)),length (t)
@@ -249,20 +246,13 @@ function edgesindices(t,cols=columns(t))
249
246
e,[Chain {V,1} (A[j[n],k[n]],A[i[n],k[n]],A[i[n],j[n]]) for n ∈ 1 : nt]
250
247
end
251
248
252
- const edgelengths = volumes # deprecate
253
-
254
249
function neighbor (k,a,b):: Int
255
250
n = setdiff (intersect (a,b),k)
256
251
isempty (n) ? 0 : n[1 ]
257
252
end
258
253
259
- function neighbors (T)
260
- np,nt,t = length (points (T)),length (T),value (T)
261
- n2e = spzeros (np,nt) # node-to-element adjacency matrix, n2e[i,j]==1 -> i ∈ j
262
- for i ∈ 1 : nt
263
- n2e[value (t[i]),i] .= (1 ,1 ,1 )
264
- end
265
- V,f = Manifold (Manifold (T)),(x-> x> 0 )
254
+ function neighbors (t,n2e= incidence (t))
255
+ V,f,nt = Manifold (Manifold (t)),(x-> x> 0 ),length (t)
266
256
n = Chain{V,1 ,Int,3 }[]; resize! (n,nt)
267
257
@threads for k ∈ 1 : nt
268
258
tk = t[k]
@@ -272,6 +262,18 @@ function neighbors(T)
272
262
return n
273
263
end
274
264
265
+ function centroidvectors (t,m= means (t))
266
+ p,nt = points (t),length (t)
267
+ V = Manifold (p)(2 ,3 )
268
+ c = Vector {SizedVector{3,Chain{V,1,Float64,2}}} (undef,nt)
269
+ δ = Vector {SizedVector{3,Float64}} (undef,nt)
270
+ for k ∈ 1 : nt
271
+ c[k] = V .(m[k]. - p[value (t[k])])
272
+ δ[k] = value .(abs .(c[k]))
273
+ end
274
+ return c,δ
275
+ end
276
+
275
277
function basisnedelec (p)
276
278
M = SubManifold (ℝ^ 3 ); V = ↓ (M)
277
279
Chain {M,1} (
@@ -298,12 +300,11 @@ function jumps(t,c,a,f,u,m=volumes(t),g=gradienthat(t,m))
298
300
end
299
301
elseif N == 3
300
302
ds,dn = trinormals (t) # ds.^1
301
- du,F = gradient (t,u,m,g),iterable (t,f)
303
+ du,F,cols = gradient (t,u,m,g),iterable (t,f), columns (t )
302
304
fl = [- c* column (value (dn[k]).⋅ du[k]) for k ∈ 1 : length (du)]
303
- i,j,k = columns (t)
304
- intj = sparse (j,k,1 ,np,np)+ sparse (k,i,1 ,np,np)+ sparse (i,j,1 ,np,np)
305
- intj = round .((intj+ transpose (intj))/ 3 )
306
- jmps = sparse (j,k,getindex .(fl,1 ),np,np)+ sparse (k,i,getindex .(fl,2 ),np,np)+ sparse (i,j,getindex .(fl,3 ),np,np)
305
+ intj = round .(adjacency (t,cols)/ 3 )
306
+ i,j,k = cols; x,y,z = getindex .(fl,1 ),getindex .(fl,2 ),getindex .(fl,3 )
307
+ jmps = sparse (j,k,x,np,np)+ sparse (k,i,y,np,np)+ sparse (i,j,z,np,np)
307
308
jmps = abs .(intj.* abs .(jmps+ jmps' ))
308
309
@threads for k = 1 : nt
309
310
tk,dsk = t[k],ds[k]
0 commit comments