Ferrite.jl icon indicating copy to clipboard operation
Ferrite.jl copied to clipboard

`FunctionValues` with `VectorInterpolation` are not initialized

Open gijswl opened this issue 1 year ago • 2 comments

While using write_solution to save a vector solution to a vtk file, I found that all exported data is zero. Scalar solutions are exported properly. After some digging, I found that function_value was returning different results for a VectorInterpolation than for a ScalarInterpolation in the context of evaluate_at_grid_nodes. This is only an issue at this point in the code because reinit! is not used during the evaluation.

The following example reproduces the issue

qr = QuadratureRule{RefTriangle}(2)
ip_geo = Lagrange{RefTriangle, 1}()

cv_scalar = CellValues(qr, Lagrange{RefTriangle, 1}(), ip_geo)
cv_vector = CellValues(qr, Nedelec{RefTriangle, 1}(), ip_geo)

Then for the scalar interpolation we get, as expected

julia> cv_scalar.fun_values.Nξ
3×3 Matrix{Float64}:
 0.166667  0.166667  0.666667
 0.166667  0.666667  0.166667
 0.666667  0.166667  0.166667

julia> cv_scalar.fun_values.Nx
3×3 Matrix{Float64}:
 0.166667  0.166667  0.666667
 0.166667  0.666667  0.166667
 0.666667  0.166667  0.166667

whereas for the vector interpolation, we get an uninitialized Nx

julia> cv_vector.fun_values.Nξ
3×3 Matrix{Vec{2, Float64}}:
 [-0.166667, 0.166667]   [-0.666667, 0.166667]   [-0.166667, 0.666667]
 [-0.166667, -0.833333]  [-0.666667, -0.833333]  [-0.166667, -0.333333]
 [0.833333, 0.166667]    [0.333333, 0.166667]    [0.833333, 0.666667]

julia> cv_vector.fun_values.Nx
3×3 Matrix{Vec{2, Float64}}:
 [1.36288e-311, 1.36244e-311]  [1.36244e-311, 1.3629e-311]  [0.0, 0.0]
 [1.3629e-311, 1.36232e-311]   [1.3629e-311, 1.3629e-311]   [0.0, 0.0]
 [1.36244e-311, 1.36244e-311]  [1.36244e-311, 0.0]          [0.0, 0.0]

gijswl avatar Feb 25 '25 11:02 gijswl

To be clear, the effect was observed in _evaluate_at_grid_nodes DofHandler.jl:937

gijswl avatar Feb 25 '25 11:02 gijswl

Fixed in https://github.com/Ferrite-FEM/Ferrite.jl/pull/1161. Since Nedelec is discontinuous, that PR (or #867 ) adds export for that. Otherwise it won't give resonable results.

KnutAM avatar Feb 25 '25 14:02 KnutAM