diff --git a/src/Dofs/DofHandler.jl b/src/Dofs/DofHandler.jl index 4db8f9eb65..475dc84d01 100644 --- a/src/Dofs/DofHandler.jl +++ b/src/Dofs/DofHandler.jl @@ -938,10 +938,10 @@ function _evaluate_at_grid_nodes(dh::DofHandler, u::AbstractVector{T}, fieldname # VTK output of solution field (or L2 projected scalar data) n_c = n_components(ip) vtk_dim = n_c == 2 ? 3 : n_c # VTK wants vectors padded to 3D - data = fill(NaN * zero(T), vtk_dim, getnnodes(get_grid(dh))) + data = fill(T(NaN) * zero(T), vtk_dim, getnnodes(get_grid(dh))) else # Just evaluation at grid nodes - data = fill(NaN * zero(RT), getnnodes(get_grid(dh))) + data = fill(T(NaN) * zero(RT), getnnodes(get_grid(dh))) end # Loop over the subdofhandlers for sdh in dh.subdofhandlers diff --git a/test/test_dofs.jl b/test/test_dofs.jl index 7cd3e47011..fffe577779 100644 --- a/test/test_dofs.jl +++ b/test/test_dofs.jl @@ -122,17 +122,22 @@ add!(dh, :v, Lagrange{RefQuadrilateral,1}()^2) add!(dh, :s, Lagrange{RefQuadrilateral,1}()) close!(dh) -u = [1.1, 1.2, 2.1, 2.2, 4.1, 4.2, 3.1, 3.2, 1.3, 2.3, 4.3, 3.3] +u = Float64[1.1, 1.2, 2.1, 2.2, 4.1, 4.2, 3.1, 3.2, 1.3, 2.3, 4.3, 3.3] +u2 = Float32[1.1, 1.2, 2.1, 2.2, 4.1, 4.2, 3.1, 3.2, 1.3, 2.3, 4.3, 3.3] uv = @view u[1:end] # :s on solution s_nodes = evaluate_at_grid_nodes(dh, u, :s) @test s_nodes ≈ [i+0.3 for i=1:4] +@test eltype(s_nodes) == Float64 +@test eltype(evaluate_at_grid_nodes(dh, u2, :s)) == Float32 # :s on a view into solution sv_nodes = evaluate_at_grid_nodes(dh, uv, :s) @test sv_nodes ≈ [i+0.3 for i=1:4] # :v on solution v_nodes = evaluate_at_grid_nodes(dh, u, :v) @test v_nodes ≈ [Vec{2,Float64}(i -> j+i/10) for j = 1:4] +@test eltype(v_nodes) == Vec{2,Float64} +@test eltype(evaluate_at_grid_nodes(dh, u2, :v)) == Vec{2,Float32} # :v on a view into solution vv_nodes = evaluate_at_grid_nodes(dh, uv, :v) @test vv_nodes ≈ [Vec{2,Float64}(i -> j+i/10) for j = 1:4] diff --git a/test/test_mixeddofhandler.jl b/test/test_mixeddofhandler.jl index 264324d4b0..6427bee5c4 100644 --- a/test/test_mixeddofhandler.jl +++ b/test/test_mixeddofhandler.jl @@ -649,7 +649,7 @@ function test_vtk_export() sdh_tri = SubDofHandler(dh, Set(2)) add!(sdh_tri, :u, ip_tri) close!(dh) - u = collect(1:ndofs(dh)) + u = collect(1.:ndofs(dh)) filename = "mixed_2d_grid" VTKGridFile(filename, dh) do vtk write_solution(vtk, dh, u)