From 346a09a55755910742b5429d4bd1228dbad939cc Mon Sep 17 00:00:00 2001 From: albert-de-montserrat Date: Wed, 11 Sep 2024 16:31:40 +0200 Subject: [PATCH 1/6] missing methods for get_Kb and get_G --- src/GeoParams.jl | 8 ++++++-- test/test_Traits.jl | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/GeoParams.jl b/src/GeoParams.jl index 9db97a60..dd400748 100644 --- a/src/GeoParams.jl +++ b/src/GeoParams.jl @@ -201,7 +201,6 @@ export dεII_dτII, NoSoftening, LinearSoftening, NonLinearSoftening, - DecaySoftening, # Plasticity AbstractPlasticity, @@ -444,12 +443,17 @@ for modulus in (:G, :Kb) @inline $(fun)(c::CompositeRheology) = $(fun)(isviscoelastic(c), c) @inline $(fun)(::ElasticRheologyTrait, c::CompositeRheology) = mapreduce(x->$(fun)(x), +, c.elements) @inline $(fun)(::AbstractCreepLaw) = 0 - @inline $(fun)(::AbstractPlasticity) = 0 @inline $(fun)(r::AbstractMaterialParamsStruct) = $(fun)(r.CompositeRheology[1]) @inline $(fun)(a::NTuple{N, AbstractMaterialParamsStruct}, phase) where N = nphase($(fun), phase, a) end end +@inline get_G(::NonElasticRheologyTrait, c::CompositeRheology) = 0 +@inline get_G(::NonElasticRheologyTrait) = 0 + +@inline get_Kb(::NonElasticRheologyTrait, c::CompositeRheology) = Inf +@inline get_Kb(::NonElasticRheologyTrait) = Inf + export get_G, get_Kb const get_shearmodulus = get_G diff --git a/test/test_Traits.jl b/test/test_Traits.jl index fa98ba0a..350baa82 100644 --- a/test/test_Traits.jl +++ b/test/test_Traits.jl @@ -63,6 +63,10 @@ using Test, GeoParams @test isviscoelastic(r1[3]) isa ElasticRheologyTrait @test isviscoelastic(r1[4]) isa NonElasticRheologyTrait + # test get_G and get_Kb + @test GeoParams.get_G(isviscoelastic(CompositeRheology(v1, v2, v3)), r) == 0 + @test GeoParams.get_Kb(isviscoelastic(CompositeRheology(v1, v2, v3)), r) == Inf + ## linear rheology traits # test basic cases for r in (v1, v2, pl) @@ -133,4 +137,5 @@ end @test isconstant(r1) isa NonConstantDensityTrait @test isconstant(r2) isa ConstantDensityTrait @test_throws ArgumentError isconstant("potato") -end \ No newline at end of file +end + From bab2e42b70d93f87f9e0e180fc94fa8a104feae1 Mon Sep 17 00:00:00 2001 From: albert-de-montserrat Date: Wed, 11 Sep 2024 16:32:52 +0200 Subject: [PATCH 2/6] revert change --- src/GeoParams.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/GeoParams.jl b/src/GeoParams.jl index dd400748..e9ccc8b9 100644 --- a/src/GeoParams.jl +++ b/src/GeoParams.jl @@ -201,6 +201,7 @@ export dεII_dτII, NoSoftening, LinearSoftening, NonLinearSoftening, + DecaySoftening, # Plasticity AbstractPlasticity, From 4f03ec09b2ff2a9cc1e37eeed7d5a6edaf6b193f Mon Sep 17 00:00:00 2001 From: albert-de-montserrat Date: Wed, 11 Sep 2024 16:55:32 +0200 Subject: [PATCH 3/6] more methods --- src/GeoParams.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/GeoParams.jl b/src/GeoParams.jl index e9ccc8b9..7e2298ce 100644 --- a/src/GeoParams.jl +++ b/src/GeoParams.jl @@ -436,24 +436,26 @@ end include("aliases.jl") export ntuple_idx - for modulus in (:G, :Kb) fun = Symbol("get_$(string(modulus))") @eval begin @inline $(fun)(a::ConstantElasticity) = a.$(modulus).val @inline $(fun)(c::CompositeRheology) = $(fun)(isviscoelastic(c), c) @inline $(fun)(::ElasticRheologyTrait, c::CompositeRheology) = mapreduce(x->$(fun)(x), +, c.elements) - @inline $(fun)(::AbstractCreepLaw) = 0 @inline $(fun)(r::AbstractMaterialParamsStruct) = $(fun)(r.CompositeRheology[1]) @inline $(fun)(a::NTuple{N, AbstractMaterialParamsStruct}, phase) where N = nphase($(fun), phase, a) end end @inline get_G(::NonElasticRheologyTrait, c::CompositeRheology) = 0 -@inline get_G(::NonElasticRheologyTrait) = 0 +@inline get_G(::NonElasticRheologyTrait) = 0 +@inline get_G(::AbstractCreepLaw) = 0 +@inline get_G(::AbstractPlasticity) = 0 @inline get_Kb(::NonElasticRheologyTrait, c::CompositeRheology) = Inf -@inline get_Kb(::NonElasticRheologyTrait) = Inf +@inline get_Kb(::NonElasticRheologyTrait) = Inf +@inline get_Kb(::AbstractCreepLaw) = Inf +@inline get_Kb(::AbstractPlasticity) = Inf export get_G, get_Kb From 05b51878f2abbc18ac5484a76410ff1b52745635 Mon Sep 17 00:00:00 2001 From: albert-de-montserrat Date: Wed, 11 Sep 2024 17:01:43 +0200 Subject: [PATCH 4/6] fix test --- test/test_Traits.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/test_Traits.jl b/test/test_Traits.jl index 350baa82..a2e3dc72 100644 --- a/test/test_Traits.jl +++ b/test/test_Traits.jl @@ -64,8 +64,9 @@ using Test, GeoParams @test isviscoelastic(r1[4]) isa NonElasticRheologyTrait # test get_G and get_Kb - @test GeoParams.get_G(isviscoelastic(CompositeRheology(v1, v2, v3)), r) == 0 - @test GeoParams.get_Kb(isviscoelastic(CompositeRheology(v1, v2, v3)), r) == Inf + r = CompositeRheology(v1, v2, v3) + @test GeoParams.get_G(isviscoelastic(r), r) == 0 + @test GeoParams.get_Kb(isviscoelastic(r), r) == Inf ## linear rheology traits # test basic cases From 0ae0785c99b703ab466efc275514c621b25abedd Mon Sep 17 00:00:00 2001 From: albert-de-montserrat Date: Wed, 11 Sep 2024 17:19:16 +0200 Subject: [PATCH 5/6] and more methods --- src/GeoParams.jl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/GeoParams.jl b/src/GeoParams.jl index 7e2298ce..520f91e7 100644 --- a/src/GeoParams.jl +++ b/src/GeoParams.jl @@ -448,14 +448,10 @@ for modulus in (:G, :Kb) end @inline get_G(::NonElasticRheologyTrait, c::CompositeRheology) = 0 -@inline get_G(::NonElasticRheologyTrait) = 0 -@inline get_G(::AbstractCreepLaw) = 0 -@inline get_G(::AbstractPlasticity) = 0 +@inline get_G(::Union{NonElasticRheologyTrait, AbstractCreepLaw, AbstractPlasticity, AbstractConstitutiveLaw}) = 0 @inline get_Kb(::NonElasticRheologyTrait, c::CompositeRheology) = Inf -@inline get_Kb(::NonElasticRheologyTrait) = Inf -@inline get_Kb(::AbstractCreepLaw) = Inf -@inline get_Kb(::AbstractPlasticity) = Inf +@inline get_Kb(::Union{NonElasticRheologyTrait, AbstractCreepLaw, AbstractPlasticity, AbstractConstitutiveLaw}) = Inf export get_G, get_Kb From 2842c966212fd150fc9578ce166d8e041137ce14 Mon Sep 17 00:00:00 2001 From: Albert de Montserrat <58044444+albert-de-montserrat@users.noreply.github.com> Date: Thu, 12 Sep 2024 09:46:07 +0200 Subject: [PATCH 6/6] bump minor --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 9f0c8e62..bc61ec73 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "GeoParams" uuid = "e018b62d-d9de-4a26-8697-af89c310ae38" authors = ["Boris Kaus , Albert De Montserrat "] -version = "0.6.2" +version = "0.6.3" [deps] BibTeX = "7b0aa2c9-049f-5cec-894a-2b6b781bb25e"