Ferrite-FEM / Ferrite-FEM/Ferrite.jl
write_cell_data LoadError when writing SymmetricTensor data.
- Dominant language
- Julia
- Stars
- 453
- Forks
- 115
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 11
Description
I get the error
"ERROR: LoadError: MethodError: no method matching length(::Type{SymmetricTensor{2, 3, Float64, 6}})
The function `length` exists, but no method is defined for this combination of argument types."
when calling write_cell_data where the cell data is a Vector{SymmetricTensor}.
Overloading the length function does make it work as intended, but this should already be the case as Tensors.jl (https://github.com/Ferrite-FEM/Tensors.jl/blob/83e84dad1e7fa1ac43847261bcf99dba70cbf1f1/src/Tensors.jl#L193)
Here is a small code I made with the issue : [MRE.zip](https://github.com/user-attachments/files/30002571/MRE.zip)
```julia
using Ferrite
#If we overload this, this works
#Base.length(::Type{SymmetricTensor{order,dim,T,M}}) where{order,dim,T,M} = M
grid = generate_grid(Quadrilateral, (1, 1));
dh = DofHandler(grid)
cell_data = [Tensor{2,3}((1.,2.,3.,4.,5.,6.,7.,8.,9.))]
cell_data_symmetric = [SymmetricTensor{2,3}((1.,2.,3.,4.,5.,6.))]
l1 = length(cell_data[1]) #9
l2 = length(cell_data_symmetric[1]) #Returns 9 no matter what, shouldn't it be 6?
VTKGridFile("example_cell_data", dh) do vtk
write_cell_data(vtk,cell_data,"cell_data") #This works
write_cell_data(vtk,cell_data_symmetric,"cell_data_symmetric") #This does not
#ERROR: LoadError: MethodError: no method matching length(::Type{SymmetricTensor{2, 3, Float64, 6}})
#The function `length` exists, but no method is defined for this combination of argument types.
end
```
Contributor guide
Assessment
This issue has not been assessed yet.