gridap / Gridap.jl

Grid-based approximation of partial differential equations in Julia
MIT License
665 stars 94 forks source link

Fix incorrect dof value type for linear constraints fe spaces #1009

Open dnuy opened 1 month ago

dnuy commented 1 month ago

When e.g. solving the Helmholtz equation we set vector_type=Vector{ComplexF64} for the FESpace, in that case we obtain correctly that get_dof_value_type(V) == ComplexF64. When the space is a FESpaceWithLinearConstraints then get_dof_value_type incorrectly returns Float64; based on the default implementation in FESpaceInterface.jl.

My fix is to add

get_dof_value_type(f::FESpaceWithLinearConstraints) = eltype(get_vector_type(f.space))

to FESpacesWithLinearConstraints.jl.

PS: It might be that the default implementation for get_dof_value_type in FESpaceInterface.jl is incorrect, as also for V a FESpace with vector_type=Vector{ComplexF64} I obtain get_dof_value_type(get_fe_basis(V), get_fe_dof_basis(V)) == Float64 instead of ComplexF64.

I have extended the tests in FESpacesWithLinearConstraintsTests.jl to have vector_type=Vector{ComplexF64} and added appropriate tests. The first commit in this merge request just shows the current bug with @test get_dof_value_type(Vc) == ComplexF64 broken=true and then fixes the bug as above and runs the test again without the broken=true; the second commit corrects the bug in FESpacesWithLinearConstraints.jl and just leaves a @test get_dof_value_type(Vc) == ComplexF64 in place.