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

Fix crash with dof handler on true subdomains #967

Merged
merged 6 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Dofs/DofHandler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ function ndofs_per_cell(dh::DofHandler)
return @inbounds ndofs_per_cell(dh.subdofhandlers[1])
end
function ndofs_per_cell(dh::DofHandler, cell::Int)
return ndofs_per_cell(dh.subdofhandlers[dh.cell_to_subdofhandler[cell]])
sdhidx = dh.cell_to_subdofhandler[cell]
sdhidx ∉ 1:length(dh.subdofhandlers) && return 0 # Dof handler is just defined on a subdomain
return ndofs_per_cell(dh.subdofhandlers[sdhidx])
end
ndofs_per_cell(sdh::SubDofHandler) = sdh.ndofs_per_cell[]
ndofs_per_cell(sdh::SubDofHandler, ::Int) = sdh.ndofs_per_cell[] # for compatibility with DofHandler
Expand Down
19 changes: 19 additions & 0 deletions test/test_mixeddofhandler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,24 @@ function test_vtk_export()
rm(filename*".vtu") # clean up
end

function test_celliterator_on_true_subdomain_smoketest()
grid = generate_grid(Hexahedron, (3,3,3))
termi-official marked this conversation as resolved.
Show resolved Hide resolved

dh = DofHandler(grid)
sdh = SubDofHandler(dh, [1,2,3])
add!(sdh, :u, Lagrange{RefHexahedron,1}()^3)
termi-official marked this conversation as resolved.
Show resolved Hide resolved
close!(dh)

for cell in CellIterator(sdh)
end

for cell in CellIterator(dh, [1,2,3])
end
termi-official marked this conversation as resolved.
Show resolved Hide resolved

for cell in CellIterator(dh)
end
termi-official marked this conversation as resolved.
Show resolved Hide resolved
end

@testset "DofHandler" begin
test_1d_bar_beam();
test_2d_scalar();
Expand Down Expand Up @@ -670,4 +688,5 @@ end
test_celliterator_subdomain()
test_show()
test_vtk_export()
test_celliterator_on_true_subdomain_smoketest()
end
Loading