Skip to content

Commit

Permalink
Fix bug where boundary sets are broken for mixed grids
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdAlazezAhmed committed Nov 13, 2024
1 parent dcab007 commit a38ed02
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Grid/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ function _create_boundaryset(f::Function, grid::AbstractGrid, top::ExclusiveTopo
cell_idx = ff_nh_idx[1]
facet_nr = ff_nh_idx[2]
cell = getcells(grid, cell_idx)
length(facets(cell)) < facet_nr && continue
facet_nodes = facets(cell)[facet_nr]
for (subentity_idx, subentity_nodes) in pairs(boundaryfunction(BI)(cell))
if Base.all(n -> n in facet_nodes, subentity_nodes)
Expand Down
17 changes: 17 additions & 0 deletions test/test_grid_addboundaryset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,21 @@
addboundaryfacetset!(grid, topology, "test_boundary_facetset", filter_function)
@test getfacetset(grid, "test_boundary_facetset") == Ferrite.create_boundaryfacetset(grid, topology, filter_function)
end

@testset "addboundaryset Mixed grid" begin
nodes = [Node((-1.0, 0.0)), Node((0.0, 0.0)), Node((1.0, 0.0)), Node((-1.0, 1.0)), Node((0.0, 1.0))]
cells = [
Quadrilateral((1, 2, 5, 4)),
Triangle((3, 5, 2)),
]
grid = Grid(cells, nodes)
topology = ExclusiveTopology(grid)
@test extractboundary(grid, topology) == extractboundarycheck(grid)

filter_function(x) = x[1] > 0
addboundaryvertexset!(grid, topology, "test_boundary_vertexset", filter_function)
@test getvertexset(grid, "test_boundary_vertexset") == Ferrite.create_boundaryvertexset(grid, topology, filter_function)
addboundaryfacetset!(grid, topology, "test_boundary_facetset", filter_function)
@test getfacetset(grid, "test_boundary_facetset") == Ferrite.create_boundaryfacetset(grid, topology, filter_function)
end
end

0 comments on commit a38ed02

Please sign in to comment.