You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
project_to_nodes in L2Projector projects to vertices
The project_to_nodes option in the L2-projection actually doesn't reorder values to the nodes of the Grid, but to the vertices of the elements. That is, for a QuadraticQuadrilateral, with a quadratic field on it, we will only get four values (one for each vertex) and all other values will be NaNs (as if the field didn't exist on these points).
I've been trying to fix this for a bit, but it seems that would require a general mapping of (geometric) nodes to dofs. Not sure that is worth the effort, considering that the L2Projection has some more flaws, like #330.
Thoughts on design of L2Projector
Perhaps it is a design error that the L2Projector creates it's own MixedDofHandler instead of taking in whichever one was used for the simulation. This would be easy to solve if the underlying dof handler knew the field dimensions properly (it always works with scalar fields). Solving #330 would also require to use a full MixedDofHandler with several FieldHandlers instead of the internally created one.
The text was updated successfully, but these errors were encountered:
using Ferrite
dim = 2
grid = generate_grid(QuadraticQuadrilateral, (1,1))
ip = Lagrange{dim, RefCube, 2}()
qr = QuadratureRule{dim, RefCube}(3)
cv = CellScalarValues(qr, ip)
# generate some data for a hypothetic field, here f(x, y) = x*y
qp_values = Vector{Float64}[]
for cell in CellIterator(grid)
reinit!(cv, cell)
vals = Vector{Float64}(undef, getnquadpoints(cv))
for qp in 1:getnquadpoints(cv)
x = spatial_coordinate(cv, qp, getcoordinates(cell))
vals[qp] = x[1]*x[2]
end
push!(qp_values, vals)
end
projector = L2Projector(ip, grid)
projected_vals_nodes = project(projector, qp_values, qr; project_to_nodes = true) # this is the default
projected_vals_dofs = project(projector, qp_values, qr; project_to_nodes = false)
# we can still save to vtk correctly when using project_to_nodes = false
vtk_grid("test", projector.dh) do vtk
vtk_point_data(vtk, projector.dh, projected_vals_dofs)
end
julia> projected_vals_nodes
9-element Vector{Float64}:
0.9999999999999998
NaN
-1.0
NaN
NaN
NaN
-1.0
NaN
1.0
julia> projected_vals_dofs
9-element Vector{Float64}:
0.9999999999999998
-1.0
1.0
-1.0
6.123031769111881e-17
7.31836466427715e-17
1.3660947373317333e-17
7.611099250848237e-17
-2.0491421059976015e-17
project_to_nodes
in L2Projector projects to verticesThe
project_to_nodes
option in the L2-projection actually doesn't reorder values to the nodes of theGrid
, but to the vertices of the elements. That is, for aQuadraticQuadrilateral
, with a quadratic field on it, we will only get four values (one for each vertex) and all other values will beNaNs
(as if the field didn't exist on these points).I've been trying to fix this for a bit, but it seems that would require a general mapping of (geometric) nodes to dofs. Not sure that is worth the effort, considering that the
L2Projection
has some more flaws, like #330.Thoughts on design of
L2Projector
Perhaps it is a design error that the
L2Projector
creates it's ownMixedDofHandler
instead of taking in whichever one was used for the simulation. This would be easy to solve if the underlying dof handler knew the field dimensions properly (it always works with scalar fields). Solving #330 would also require to use a fullMixedDofHandler
with severalFieldHandlers
instead of the internally created one.The text was updated successfully, but these errors were encountered: