Skip to content

Commit f89a4af

Browse files
committed
transitioned to Grassmann v0.5.17 improvements
1 parent 6d8932b commit f89a4af

File tree

2 files changed

+32
-31
lines changed

2 files changed

+32
-31
lines changed

Project.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Adapode"
22
uuid = "0750cfb5-909a-49d7-927e-29b6595444bf"
33
authors = ["Michael Reed"]
4-
version = "0.2.0"
4+
version = "0.2.1"
55

66
[deps]
77
DirectSum = "22fd7b30-a8c0-5bf2-aabe-97783860d07c"
@@ -13,9 +13,9 @@ AbstractTensors = "a8e43f4a-99b7-5565-8bf1-0165161caaea"
1313

1414
[compat]
1515
julia = "1"
16-
AbstractTensors = "0.4"
17-
DirectSum = "0.5"
18-
Grassmann = "0.5.16"
16+
AbstractTensors = "0.5"
17+
DirectSum = "0.6"
18+
Grassmann = "0.5.17"
1919
StaticArrays = "0"
2020

2121
[extras]

src/element.jl

+28-27
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,10 @@ end
100100

101101
gradient(t,u,m=volumes(t),g=gradienthat(t,m)) = [u[value(t[k])]value(g[k]) for k 1:length(t)]
102102

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
111107

112108
function assembledivergence(t,m,g)
113109
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))
126122
function stiffness(c,g,::Val{N}) where N
127123
A = zeros(MMatrix{N,N,typeof(c)})
128124
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]
130126
end
131127
return SMatrix{N,N,typeof(c)}(A)
132128
end
@@ -136,7 +132,7 @@ assemblestiffness(t,c=1,m=volumes(t),g=gradienthat(t,m)) = assembleglobal(stiffn
136132
function sonicstiffness(c,g,::Val{N}) where N
137133
A = zeros(MMatrix{N,N,typeof(c)})
138134
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
140136
end
141137
return SMatrix{N,N,typeof(c)}(A)
142138
end
@@ -234,12 +230,13 @@ function solvedirichlet(M,b,fixed)
234230
return ξ
235231
end
236232

237-
const boundary = pointset # deprecate
238233
interior(e) = interior(length(points(e)),pointset(e))
239234
interior(fixed,neq) = sort!(setdiff(1:neq,fixed))
240235
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
243240

244241
function edgesindices(t,cols=columns(t))
245242
np,nt = length(points(t)),length(t)
@@ -249,20 +246,13 @@ function edgesindices(t,cols=columns(t))
249246
e,[Chain{V,1}(A[j[n],k[n]],A[i[n],k[n]],A[i[n],j[n]]) for n 1:nt]
250247
end
251248

252-
const edgelengths = volumes # deprecate
253-
254249
function neighbor(k,a,b)::Int
255250
n = setdiff(intersect(a,b),k)
256251
isempty(n) ? 0 : n[1]
257252
end
258253

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)
266256
n = Chain{V,1,Int,3}[]; resize!(n,nt)
267257
@threads for k 1:nt
268258
tk = t[k]
@@ -272,6 +262,18 @@ function neighbors(T)
272262
return n
273263
end
274264

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+
275277
function basisnedelec(p)
276278
M = SubManifold(ℝ^3); V = (M)
277279
Chain{M,1}(
@@ -298,12 +300,11 @@ function jumps(t,c,a,f,u,m=volumes(t),g=gradienthat(t,m))
298300
end
299301
elseif N == 3
300302
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)
302304
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)
307308
jmps = abs.(intj.*abs.(jmps+jmps'))
308309
@threads for k = 1:nt
309310
tk,dsk = t[k],ds[k]

0 commit comments

Comments
 (0)