Skip to content

Commit 2defce2

Browse files
committed
Minor updates to diff to improve type support
1 parent c9a0ad6 commit 2defce2

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/differentiation.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,12 @@ is defined already.
128128
"""
129129
function StressStateDerivatives(::AbstractStressState, m::AbstractMaterial)
130130
mderiv = MaterialDerivatives(m)
131+
T = get_vector_eltype(m)
131132
np = get_vector_length(m)
132133
nt = get_num_tensorcomponents(m) # Should be changed to only save non-controlled entries
133134
# Filled with `NaN`s to ensure we don't rely on these being defined.
134-
dϵdp = fill(NaN, nt, np)
135-
dσdp = fill(NaN, nt, np)
135+
dϵdp = fill(T(NaN), nt, np)
136+
dσdp = fill(T(NaN), nt, np)
136137
# TODO: Should be changed to only save non-controlled entries
137138
vo = Tensors.DEFAULT_VOIGT_ORDER[3]
138139
if nt == 6

src/stressiterations.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ end
414414
function get_full_tensor(state::GeneralStressState{Nσ}, ::TT, v::SVector{Nσ,T}) where {Nσ,T,TT}
415415
TB = Tensors.get_base(TT)
416416
shear_factor = if TB == SymmetricTensor{2,3}
417-
T(1/√2)
417+
1/sqrt(2 * one(T))
418418
elseif TB == Tensor{2,3}
419419
one(T)
420420
else
@@ -426,14 +426,14 @@ function get_full_tensor(state::GeneralStressState{Nσ}, ::TT, v::SVector{Nσ,T}
426426
end
427427

428428
function get_unknowns(state::GeneralStressState{Nσ}, a::AbstractTensor{2,3,T}) where {Nσ, T}
429-
shear_factor = a isa SymmetricTensor ? T(2) : one(T)
429+
shear_factor = a isa SymmetricTensor ? sqrt(2 * one(T)) : one(T)
430430
s(i,j) = i==j ? one(T) : shear_factor
431431
f(c) = ((i,j) = c; s(i,j)*(a[i,j]-state.σ[i,j]))
432432
return SVector{Nσ,T}((f(c) for c in state.σm_inds))
433433
end
434434

435435
function get_unknowns(state::GeneralStressState{Nσ}, a::AbstractTensor{4,3,T}) where {Nσ,T}
436-
shear_factor = a isa SymmetricTensor ? T(2) : one(T)
436+
shear_factor = a isa SymmetricTensor ? sqrt(2 * one(T)) : one(T)
437437
s(i,j) = i==j ? one(T) : shear_factor
438438
f(c1,c2) = ((i,j) = c1; (k,l) = c2; a[i,j,k,l]*s(i,j)*s(k,l))
439439
return SMatrix{Nσ,Nσ,T}((f(c1,c2) for c1 in state.σm_inds, c2 in state.σm_inds))

0 commit comments

Comments
 (0)