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

Extract boundary entities + getfaceedges helper #606

Merged
merged 1 commit into from
May 3, 2023

Conversation

AbdAlazezAhmed
Copy link
Collaborator

fixes #595 (addboundaryfaceset!, addboundaryedgeset!, addboundaryvertexset! ) and adds helper functions to get face/edge edges/vertices (getfaceedges, getfacevertices, getedgevertices).

Copy link
Member

@termi-official termi-official left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I left some comments which we should discuss.

src/Grid/grid.jl Outdated Show resolved Hide resolved
test/test_grid_addboundaryset.jl Outdated Show resolved Hide resolved
Copy link
Member

@termi-official termi-official left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR is really taking shape! I think we are close to the finish line here. I have left some comments.

Also, you need to merge the master branch (updated over the last few days) to see the developer API docs which I refer to. Tell me if you run into trouble.

docs/src/reference/grid.md Show resolved Hide resolved
src/Grid/grid.jl Outdated Show resolved Hide resolved
src/Grid/grid.jl Outdated Show resolved Hide resolved
src/Grid/grid.jl Outdated Show resolved Hide resolved
src/Grid/grid.jl Outdated Show resolved Hide resolved
src/Grid/grid.jl Outdated Show resolved Hide resolved
src/exports.jl Outdated Show resolved Hide resolved
src/Grid/grid.jl Outdated Show resolved Hide resolved
Copy link
Member

@koehlerson koehlerson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just few cosmetic suggestions

src/Grid/grid.jl Outdated Show resolved Hide resolved
src/Grid/grid.jl Outdated Show resolved Hide resolved
src/Grid/grid.jl Outdated Show resolved Hide resolved
src/Grid/grid.jl Outdated Show resolved Hide resolved
src/Grid/grid.jl Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Mar 9, 2023

Codecov Report

Patch coverage: 89.87% and project coverage change: -0.05 ⚠️

Comparison is base (13e1d39) 92.90% compared to head (e8023bb) 92.85%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #606      +/-   ##
==========================================
- Coverage   92.90%   92.85%   -0.05%     
==========================================
  Files          30       30              
  Lines        4324     4378      +54     
==========================================
+ Hits         4017     4065      +48     
- Misses        307      313       +6     
Impacted Files Coverage Δ
src/Grid/grid.jl 91.27% <89.87%> (-0.31%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@termi-official termi-official left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the PR really looks great! Thanks for your work. I have a last minor thing to fix (i.e. test should always be inside testsets to not leak any information) and if the CI does not fail, then things are fine from my side.

cc @fredrikekre

test/test_grid_addboundaryset.jl Outdated Show resolved Hide resolved
Copy link
Member

@termi-official termi-official left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I totally missed that tests for 3D are missing in the PR. Did we just discuss it in the comments/slack? Anyway, can you provide the test coverage for 3D grids? (Prism, Tet, Hex) I think we really can need the helpers in this PR for a full automated consistency check of interpolation implementations. :)

I also have a quick question on one of the tests.

test/test_grid_addboundaryset.jl Outdated Show resolved Hide resolved
Copy link
Member

@termi-official termi-official left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some found something to improve an the API and performance. Feel free to skip the stuff in grid.jl. However, I think there is some test missing (or lost during rebase?).

src/Grid/grid.jl Outdated Show resolved Hide resolved
src/Grid/grid.jl Outdated Show resolved Hide resolved
src/Grid/grid.jl Outdated
Comment on lines 1028 to 1033
function getinstances(grid::AbstractGrid, topology::ExclusiveTopology, entity::T, _ftype::Function, _indextype::Type) where T <: BoundaryIndex
_set = Set{_indextype}()
cells = getcells(grid)
cell = cells[entity[1]]
verts = _ftype(cell)[entity[2]] #_fparent returns global vertices ids of face/edge. _fentities transforms them to pairs for edges.
for cell_idx in topology.vertex_to_cell[verts[1]] #∩([topology.vertex_to_cell[vert] for vert in verts]...) took couple seconds more in testing than topology.vertex_to_cell[verts[1]]
entity_idx = findfirst(_x-> all( [x ∈ verts for x in _x]),_ftype(cells[cell_idx]))
!isnothing(entity_idx)&& push!(_set, _indextype(cell_idx, entity_idx))
end
return _set
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might be able to speed these functions up with code generators instead of passing the types and functions by hand. See e.g. https://github.com/Ferrite-FEM/Ferrite.jl/blob/master/src/Grid/grid.jl#L948-L961 . If it is too difficult to setup, then feel free to skip this comment. :)

src/Grid/grid.jl Outdated Show resolved Hide resolved
test/test_grid_addboundaryset.jl Outdated Show resolved Hide resolved
Copy link
Member

@termi-official termi-official left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (try 2) @fredrikekre

Copy link
Member

@termi-official termi-official left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 docstring typos

src/Grid/grid.jl Outdated Show resolved Hide resolved
src/Grid/grid.jl Outdated Show resolved Hide resolved
@fredrikekre
Copy link
Member

I pushed some formatting changes and squashed. Also changed for i in findall(pred, x) into for i in x; pred(x) || continue; ... in some places to avoid the allocation of the findall return value. Will merge on green.

Thanks for the contribution, and sorry for the slow review!

This patch adds `addboundaryfaceset!`, `addboundaryedgeset!`,
`addboundaryvertexset!` for adding entities that are located on the
boundary (defined as no cell neighbor). In addition, this adds internal
functions for getting subentites from entities and various other helpers
(`getfaceedges`, `getfacevertices`, `getedgevertices`,
`getfaceinstances`, `getedgeinstances`, `getvertexinstances`,
`filterfaces`, `filteredges`, `filtervertices`).

Fixes Ferrite-FEM#595.
@fredrikekre fredrikekre merged commit 363462b into Ferrite-FEM:master May 3, 2023
@AbdAlazezAhmed AbdAlazezAhmed deleted the boundary-entities branch May 3, 2023 15:37
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 this pull request may close these issues.

Extract boundary entities
5 participants