Skip to content

Commit

Permalink
lvdim: perf improvement for boundarynd()
Browse files Browse the repository at this point in the history
  • Loading branch information
tanderson92 committed Aug 31, 2024
1 parent cdb5018 commit 8877785
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
41 changes: 24 additions & 17 deletions src/reference_interpolation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -384,28 +384,35 @@ function boundary1d(els, msh)
return sort([res...])
end

function boundarynd(els, msh)
res = Set()
E, _ = first(els)
bdi = Inti.boundary_idxs(E)
for (E, i) in els
vertices = Inti.connectivity(msh, E)[:, i]
function boundarynd(::Type{T}, els, msh) where {T}
bdi = Inti.boundary_idxs(T)
edgelist = Vector{Int64}[]
edgelist_unsrt = Vector{Int64}[]
for i in els
vertices = Inti.connectivity(msh, T)[:, i]
bords = [[vertices[i] for i in bi] for bi in bdi]
for new_bord in bords
flag = true
for old_bord in res
if sort(new_bord) == sort(old_bord)
delete!(res, old_bord)
flag = false
end
end
flag && push!(res, new_bord)
for q in bords
push!(edgelist_unsrt, copy(q))
push!(edgelist, sort!(q))
end
end
return res
I = sortperm(edgelist)
uniqlist = Int64[]
i = 1
while i <= length(edgelist) - 1
if isequal(edgelist[I[i]], edgelist[I[i+1]])
i += 1
else
push!(uniqlist, i)
end
i += 1
end
if !isequal(edgelist[I[end-1]], edgelist[I[end]])
push!(uniqlist, i)
end
return edgelist_unsrt[I[uniqlist]]
end

##
function _dfs!(comp, el, nei, els)
for el_nei in nei[el]
if el_nei in els
Expand Down
8 changes: 5 additions & 3 deletions src/vdim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,11 @@ function _local_vdim_auxiliary_quantities(
Etype = first(Inti.element_types(mesh))
el_neighs = neighbors[(Etype, el)]

loc_bdry = Inti.boundarynd(el_neighs, mesh)
T = first(el_neighs)[1]
els_idxs = [i[2] for i in collect(el_neighs)]
els_list = mesh.etype2els[Etype][els_idxs]

loc_bdry = Inti.boundarynd(T, els_idxs, mesh)
# TODO handle curved boundary of Γ??
#bords = typeof(Inti.LagrangeLine(Inti.nodes(mesh)[first(loc_bdry)]...))[]
# TODO possible performance improvement over prev line
Expand Down Expand Up @@ -402,8 +406,6 @@ function _local_vdim_auxiliary_quantities(
need_layer_corr = sum(inrangecount(bdry_kdtree, vertices, diam / 2)) > 0

# build O(h) volume neighbors
els_idxs = [i[2] for i in collect(el_neighs)]
els_list = mesh.etype2els[Etype][els_idxs]
bdry_qorder = 2 * quadrature_order + 1
Yvol =
Inti.Quadrature(mesh, els_list; qorder = quadrature_order, center = center, scale)
Expand Down

0 comments on commit 8877785

Please sign in to comment.