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

create_boundary....set is broken for mixed grids #1110

Open
AbdAlazezAhmed opened this issue Nov 13, 2024 · 1 comment
Open

create_boundary....set is broken for mixed grids #1110

AbdAlazezAhmed opened this issue Nov 13, 2024 · 1 comment

Comments

@AbdAlazezAhmed
Copy link
Collaborator

Ran into it while testing #1108 , probably

length(facets(cell)) < facet_nr && continue
will solve it

MWE:

 using Ferrite

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);

 filter_function(x) = x[1] > 0;

addboundaryvertexset!(grid, topology, "test_boundary_vertexset", filter_function);
ERROR: BoundsError: attempt to access Tuple{Tuple{Int64, Int64}, Tuple{Int64, Int64}, Tuple{Int64, Int64}} at index [4]
Stacktrace:
 [1] getindex(t::Tuple, i::Int64)
   @ Base ./tuple.jl:31
 [2] (::Ferrite.var"#_makeset#174"{})(ff_nh::Ferrite.CollectionsOfViews.ArrayOfVectorViews{…})
   @ Ferrite ~/.julia/dev/Ferrite/src/Grid/utils.jl:168
 [3] _create_boundaryset(f::typeof(filter_function), grid::Grid{…}, top::ExclusiveTopology, ::Type{…}; all::Bool)
   @ Ferrite ~/.julia/dev/Ferrite/src/Grid/utils.jl:182
 [4] _create_boundaryset(f::Function, grid::Grid{…}, top::ExclusiveTopology, ::Type{…})
   @ Ferrite ~/.julia/dev/Ferrite/src/Grid/utils.jl:158
 [5] create_boundaryvertexset
   @ ~/.julia/dev/Ferrite/src/Grid/utils.jl:210 [inlined]
 [6] addboundaryvertexset!(grid::Grid{…}, top::ExclusiveTopology, name::String, f::Function; kwargs::@Kwargs{})
   @ Ferrite ~/.julia/dev/Ferrite/src/Grid/utils.jl:100
 [7] addboundaryvertexset!(grid::Grid{2, Ferrite.AbstractCell, Float64}, top::ExclusiveTopology, name::String, f::Function)
   @ Ferrite ~/.julia/dev/Ferrite/src/Grid/utils.jl:99
 [8] top-level scope
   @ REPL[18]:1
Some type information was truncated. Use `show(err)` to see complete types.
@KnutAM
Copy link
Member

KnutAM commented Nov 13, 2024

That change looks good to me. Adding a comment why it works would be good + some test.

Not ideal that looping over the neighbourhood includes facet indices that the cell doesn't have, but avoiding this would require another layer outside to modify the iterations / allowed indices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants