Ferrite-FEM / Ferrite-FEM/Tensors.jl
Divergence not working for second order tensors
- Dominant language
- Julia
- Stars
- 182
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
MWE
```julia
julia> Tensors.divergence(x->Tensor{2,2}((x[1],0.0,0.0,x[2])), Vec((1.0,1.0)))
ERROR: MethodError: no method matching tr(::Tensor{3, 2, Float64, 8})
Closest candidates are:
tr(::Number)
@ LinearAlgebra ~/Tools/julia-1.9.3/share/julia/stdlib/v1.9/LinearAlgebra/src/generic.jl:1008
tr(::Matrix{T}) where T
@ LinearAlgebra ~/Tools/julia-1.9.3/share/julia/stdlib/v1.9/LinearAlgebra/src/dense.jl:344
tr(::LinearAlgebra.Hermitian)
@ LinearAlgebra ~/Tools/julia-1.9.3/share/julia/stdlib/v1.9/LinearAlgebra/src/symmetric.jl:366
...
Stacktrace:
[1] divergence(f::var"#5#6", v::Vec{2, Float64})
@ Tensors ~/.julia/packages/Tensors/ep7fg/src/automatic_differentiation.jl:554
[2] top-level scope
@ REPL[2]:1
```
Edit: Fix should be as easy as
```julia
Tensors.tr(t::Tensor{3,dim}) where dim = Vec{dim}(i->sum(t[:,i,:]))
```
but I have no good idea how to test this.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.