Ferrite-FEM / Ferrite-FEM/Tensors.jl
`SymmetricTensor` not working nicely with Symbolics.jl
- Dominant language
- Julia
- Stars
- 182
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
I was working with the [`Symbolics.jl`](https://github.com/JuliaSymbolics/Symbolics.jl) package recently and it seems mostly to work out of the box.
However converting a `Tensor` to a `SymmetricTensor` leads to an error:
```
A symbolic expression appeared in a Boolean context. This error arises in situations where Julia expects a Bool, like
if boolean_condition use ifelse(boolean_condition, then branch, else branch)
x && y use x & y
boolean_condition ? a : b use ifelse(boolean_condition, a, b)
but a symbolic expression appeared instead of a Bool. For help regarding control flow with symbolic variables, see https://docs.sciml.ai/ModelingToolkit/dev/basics/FAQ/#How-do-I-handle-if-statements-in-my-symbolic-forms?
```
However that can be easily fixed with
```julia
using LinearAlgebra
using Symbolics
LinearAlgebra.issymmetric(t::Tensor{2, 2, Num}) = @inbounds t[1,2] === t[2,1]
```
(Note the three `=`).
If you are interested I could draft up a PR putting this code into an extension, marking it only to be used when Symbolics.jl is also used. If you think that is too user-specific its also fine.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.