Skip to content

Commit

Permalink
Throw when asking for dof indices of vectorized interpolations (#1010)
Browse files Browse the repository at this point in the history
  • Loading branch information
KnutAM authored Jul 2, 2024
1 parent 8c897da commit 406a9d7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Dofs/DofHandler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -404,28 +404,29 @@ function _close_subdofhandler!(dh::DofHandler{sdim}, sdh::SubDofHandler, sdh_ind
ip_infos = InterpolationInfo[]
for interpolation in sdh.field_interpolations
ip_info = InterpolationInfo(interpolation)
base_ip = get_base_interpolation(interpolation)
begin
next_dof_index = 1
for vdofs vertexdof_indices(interpolation)
for vdofs vertexdof_indices(base_ip)
for dof_index vdofs
@assert dof_index == next_dof_index "Vertex dof ordering not supported. Please consult the dev docs."
next_dof_index += 1
end
end
for vdofs edgedof_interior_indices(interpolation)
for vdofs edgedof_interior_indices(base_ip)
for dof_index vdofs
@assert dof_index == next_dof_index "Edge dof ordering not supported. Please consult the dev docs."
next_dof_index += 1
end
end
for vdofs facedof_interior_indices(interpolation)
for vdofs facedof_interior_indices(base_ip)
for dof_index vdofs
@assert dof_index == next_dof_index "Face dof ordering not supported. Please consult the dev docs."
next_dof_index += 1
end
end
for dof_index volumedof_interior_indices(interpolation)
@assert next_dof_index <= dof_index <= getnbasefunctions(interpolation) "Cell dof ordering not supported. Please consult the dev docs."
for dof_index volumedof_interior_indices(base_ip)
@assert next_dof_index <= dof_index <= getnbasefunctions(base_ip) "Cell dof ordering not supported. Please consult the dev docs."
end
end
push!(ip_infos, ip_info)
Expand Down
15 changes: 15 additions & 0 deletions src/interpolations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,21 @@ end
get_n_copies(::VectorizedInterpolation{vdim}) where vdim = vdim
InterpolationInfo(ip::VectorizedInterpolation) = InterpolationInfo(ip.ip, get_n_copies(ip))

# Error when trying to get dof indicies from vectorized interpolations.
# Currently, this should only be done for the scalar interpolation.
function _entitydof_indices_vectorized_ip_error(f::Symbol)
throw(ArgumentError(string(f, " is not implemented for VectorizedInterpolations and should be called on the scalar base interpolation")))
end
vertexdof_indices(::VectorizedInterpolation) = _entitydof_indices_vectorized_ip_error(:vertexdof_indices)
edgedof_indices(::VectorizedInterpolation) = _entitydof_indices_vectorized_ip_error(:edgedof_indices)
facedof_indices(::VectorizedInterpolation) = _entitydof_indices_vectorized_ip_error(:facedof_indices)
edgedof_interior_indices(::VectorizedInterpolation) = _entitydof_indices_vectorized_ip_error(:edgedof_interior_indices)
facedof_interior_indices(::VectorizedInterpolation) = _entitydof_indices_vectorized_ip_error(:facedof_interior_indices)
volumedof_interior_indices(::VectorizedInterpolation) = _entitydof_indices_vectorized_ip_error(:volumedof_interior_indices)

get_base_interpolation(ip::Interpolation) = ip
get_base_interpolation(ip::VectorizedInterpolation) = ip.ip

function getnbasefunctions(ipv::VectorizedInterpolation{vdim}) where vdim
return vdim * getnbasefunctions(ipv.ip)
end
Expand Down
14 changes: 14 additions & 0 deletions test/test_interpolations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,18 @@ end
end
end

@testset "Errors for entitydof_indices on VectorizedInterpolations" begin
ip = Lagrange{RefQuadrilateral,2}()^2
@test_throws ArgumentError Ferrite.vertexdof_indices(ip)
@test_throws ArgumentError Ferrite.edgedof_indices(ip)
@test_throws ArgumentError Ferrite.facedof_indices(ip)
@test_throws ArgumentError Ferrite.facetdof_indices(ip)

@test_throws ArgumentError Ferrite.edgedof_interior_indices(ip)
@test_throws ArgumentError Ferrite.facedof_interior_indices(ip)
@test_throws ArgumentError Ferrite.volumedof_interior_indices(ip)
@test_throws ArgumentError Ferrite.facetdof_interior_indices(ip)
end


end # testset

0 comments on commit 406a9d7

Please sign in to comment.