From 74a3e1d4a7ad741e86410d329f52a20bb9f774c5 Mon Sep 17 00:00:00 2001 From: Albert de Montserrat <58044444+albert-de-montserrat@users.noreply.github.com> Date: Fri, 16 Aug 2024 17:13:08 +0200 Subject: [PATCH] viscoelastic trait compatibility with AbstractPlasticty (#212) --- src/Traits/rheology.jl | 6 +++--- test/test_Traits.jl | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Traits/rheology.jl b/src/Traits/rheology.jl index 3ec04d21..ecf6f059 100644 --- a/src/Traits/rheology.jl +++ b/src/Traits/rheology.jl @@ -39,7 +39,7 @@ struct NonPlasticRheologyTrait <: RheologyTrait end @inline isviscoelastic(::RheologyTrait, ::ElasticRheologyTrait) = ElasticRheologyTrait() @inline isviscoelastic(::ElasticRheologyTrait, ::RheologyTrait) = ElasticRheologyTrait() @inline isviscoelastic(::RheologyTrait, ::RheologyTrait) = NonElasticRheologyTrait() -@inline isviscoelastic(v1::AbstractConstitutiveLaw, v2::AbstractConstitutiveLaw) = isviscoelastic(isviscoelastic(v1), isviscoelastic(v2)) +@inline isviscoelastic(v1::Union{AbstractConstitutiveLaw, AbstractPlasticity}, v2::Union{AbstractConstitutiveLaw, AbstractPlasticity}) = isviscoelastic(isviscoelastic(v1), isviscoelastic(v2)) # traits for composite rheologies @inline isviscoelastic(c::CompositeRheology) = isviscoelastic(c.elements) @@ -47,8 +47,8 @@ struct NonPlasticRheologyTrait <: RheologyTrait end @inline isviscoelastic(r::MaterialParams) = isviscoelastic(r.CompositeRheology...) # recursively (pairwise, right-to-left) compare rheology traits of a composite or tuple of material params -@inline isviscoelastic(r::NTuple{N, Union{AbstractConstitutiveLaw, MaterialParams}}) where N = isviscoelastic(isviscoelastic(first(r)), isviscoelastic(Base.tail(r))) -@inline isviscoelastic(v::NTuple{1, Union{AbstractConstitutiveLaw, MaterialParams}}) = isviscoelastic(v...) +@inline isviscoelastic(r::NTuple{N, Union{AbstractConstitutiveLaw, AbstractPlasticity, MaterialParams}}) where N = isviscoelastic(isviscoelastic(first(r)), isviscoelastic(Base.tail(r))) +@inline isviscoelastic(v::NTuple{1, Union{AbstractConstitutiveLaw, AbstractPlasticity, MaterialParams}}) = isviscoelastic(v...) ## PLASTIC RHEOLOGY TRAITS diff --git a/test/test_Traits.jl b/test/test_Traits.jl index 747e429e..fa98ba0a 100644 --- a/test/test_Traits.jl +++ b/test/test_Traits.jl @@ -54,8 +54,8 @@ using Test, GeoParams @test isviscoelastic(tuple(v1, v3)) isa NonElasticRheologyTrait @test isviscoelastic(tuple(v3, el)) isa ElasticRheologyTrait - @test isviscoelastic(CompositeRheology(v1, v2, v3)) isa NonElasticRheologyTrait - @test isviscoelastic(CompositeRheology(el, v3)) isa ElasticRheologyTrait + @test isviscoelastic(CompositeRheology(v1, v2, v3, pl)) isa NonElasticRheologyTrait + @test isviscoelastic(CompositeRheology(el, v3, pl)) isa ElasticRheologyTrait # test MaterialParams cases @test isviscoelastic(r1[1]) isa ElasticRheologyTrait