refactor(materials): update LinearElastic for new trait system and compositional state

Update LinearElastic to support new material trait system and
compositional state design with NamedTuple instead of Nothing.

- Add supported_physics trait (Elasticity{3})
- Add required_state_variables trait (empty tuple for stateless)
- Change state_old parameter to Union{Nothing,NamedTuple}
- Return NamedTuple() instead of nothing for state update
- Support compositional state system in compute_stress
This commit is contained in:
Jukka Aho
2025-12-12 23:43:51 +02:00
parent 87d79f15b1
commit 6f0dd71d2e
+9 -2
View File
@@ -74,6 +74,13 @@ material_behavior(::LinearElastic) = StatelessConstantTangent()
# State type trait: LinearElastic is stateless (uses EmptyState)
state_type(::Type{LinearElastic}) = EmptyState
# New trait system: Physics and state variable requirements
# LinearElastic supports 3D elasticity only
supported_physics(::LinearElastic) = (Elasticity{3}(),)
# LinearElastic is stateless - no internal state variables
required_state_variables(::LinearElastic) = ()
"""
λ(material::LinearElastic) -> Float64
@@ -142,7 +149,7 @@ steel = LinearElastic(E=200e9, ν=0.3)
function compute_stress(
material::LinearElastic,
ε::SymmetricTensor{2,3,T},
state_old::Nothing,
state_old::Union{Nothing,NamedTuple},
Δt::Float64
) where T
@@ -160,7 +167,7 @@ function compute_stress(
𝕀ˢʸᵐ = one(SymmetricTensor{4,3,T,36}) # Symmetric 4th order identity
𝔻 = λ_val * (I I) + 2μ_val * 𝕀ˢʸᵐ
return σ, 𝔻, nothing # No state change (stateless material)
return σ, 𝔻, NamedTuple() # No state change (stateless material)
end
"""