Ferrite-FEM / Ferrite-FEM/Ferrite.jl

`create_boundary....set` is broken for mixed grids

Open
#1,110 1 comment 0 reactions 0 assignees View on GitHub
bug bugfix
Dominant language
Julia
Stars
453
Forks
115
Avg merge
1d 17h
Merged PRs (30d)
11

Description

Ran into it while testing #1108 , probably https://github.com/Ferrite-FEM/Ferrite.jl/blob/a38ed022dbc7914b344920698ddab7debf7f1e57/src/Grid/utils.jl#L168 will solve it

MWE:
```Julia
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);
```
```julia
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.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.