Skip to content

Commit 7ff891b

Browse files
authored
Merge pull request #24 from MineralsCloud:isequivalent
Deprecate `isequivalent`, add `⩵` & `⩶`
2 parents f867329 + 65b75f4 commit 7ff891b

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

src/operations.jl

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ using Tensorial: fromvoigt, ⊡, ⋅
22

33
import Tensorial: contraction, double_contraction
44

5-
export to_tensor, to_voigt, isequivalent,
5+
export to_tensor, to_voigt, ,
66

77
TensorStress::EngineeringStress) = TensorStress(σ[1], σ[6], σ[5], σ[2], σ[4], σ[3])
88

@@ -105,16 +105,34 @@ contraction(s::ComplianceTensor, σ::TensorStress, ::Val{2}) = TensorStrain(s.da
105105
@inline double_contraction(s::ComplianceTensor, σ::TensorStress) = contraction(s, σ, Val(2))
106106

107107
# See https://discourse.julialang.org/t/how-to-compare-two-vectors-whose-elements-are-equal-but-their-types-are-not-the-same/94309/6
108+
for T in (
109+
:EngineeringStrain,
110+
:EngineeringStress,
111+
:TensorStrain,
112+
:TensorStress,
113+
:StiffnessMatrix,
114+
:StiffnessTensor,
115+
:ComplianceMatrix,
116+
:ComplianceTensor,
117+
)
118+
@eval begin
119+
(s::$T, t::$T) = s == t
120+
(s, t::$T) = s isa $T && s == t
121+
(s::$T, t) = t s
122+
(s, t::$T) = s === t
123+
(s::$T, t) = t s
124+
end
125+
end
108126
for (S, T) in (
109-
(:EngineeringStress, :EngineeringStrain),
110-
(:TensorStress, :TensorStrain),
111-
(:StiffnessTensor, :ComplianceTensor),
112-
(:StiffnessMatrix, :ComplianceMatrix),
127+
(:EngineeringStress, :TensorStress),
128+
(:EngineeringStrain, :TensorStrain),
129+
(:StiffnessMatrix, :StiffnessTensor),
130+
(:ComplianceMatrix, :ComplianceTensor),
113131
)
114132
@eval begin
115-
isequivalent(s::$S, t::$T) = false
116-
isequivalent(t::$T, s::$S) = isequivalent(s, t)
133+
(s::$S, t::$T) = to_voigt(t) s
134+
(t::$T, s::$S) = s t
135+
(s::$S, t::$T) = to_voigt(t) s
136+
(t::$T, s::$S) = s t
117137
end
118138
end
119-
isequivalent(x, y) = x == y # Fallback
120-
const = isequivalent

0 commit comments

Comments
 (0)