Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topology optimization example in code gallery should use better use of topology #1031

Open
KristofferC opened this issue Jul 31, 2024 · 0 comments · May be fixed by #1035
Open

Topology optimization example in code gallery should use better use of topology #1031

KristofferC opened this issue Jul 31, 2024 · 0 comments · May be fixed by #1035

Comments

@KristofferC
Copy link
Collaborator

function cache_neighborhood(dh, topology)
nbgs = Vector{Vector{Int}}(undef, getncells(dh.grid))
_nfacets = nfacets(dh.grid.cells[1])
opp = Dict(1=>3, 2=>4, 3=>1, 4=>2)
for element in CellIterator(dh)
nbg = zeros(Int,_nfacets)
i = cellid(element)
for j in 1:_nfacets
nbg_cellid = getneighborhood(topology, dh.grid, FacetIndex(i,j))
if(!isempty(nbg_cellid))
nbg[j] = first(nbg_cellid)[1] # assuming only one face neighbor per cell
else # boundary face
nbg[j] = first(getneighborhood(topology, dh.grid, FacetIndex(i,opp[j])))[1]
end
end
nbgs[i] = nbg
end
return nbgs
end
#md nothing # hide

Some problems with this code:

  • _nfacets = nfacets(dh.grid.cells[1])
  • dh.grid is an implementation detail?
  • opp could be a tuple
  • It should use get_facet_facet_neighborhood instead (but this is undocumented?)
@KristofferC KristofferC linked a pull request Aug 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant