Skip to content

Commit a23b75d

Browse files
committed
Merge branch 'main' into thermo-visco
2 parents 091206e + c8a48f3 commit a23b75d

File tree

5 files changed

+70
-16
lines changed

5 files changed

+70
-16
lines changed

src/ComputationalModels/BoundaryConditions.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ struct MultiFieldBC <: BoundaryCondition
1010
BoundaryCondition::Vector{BoundaryCondition}
1111
end
1212

13+
getindex(bc::MultiFieldBC, i) = bc.BoundaryCondition[i]
14+
1315
include("EvolutionFunctions.jl")
1416
include("CartesianTags.jl")
1517

src/ComputationalModels/ComputationalModels.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ using WriteVTK
3434
using GridapGmsh
3535
using GridapGmsh: GmshDiscreteModel
3636

37+
import Base.getindex
3738

3839
include("BoundaryConditions.jl")
3940
export DirichletBC

src/ComputationalModels/FESpaces.jl

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,30 +44,23 @@ end
4444

4545
function Gridap.FESpaces.TrialFESpace!(space::MultiFieldFESpace, bc::MultiFieldBC, Λ::Float64)
4646
@inbounds for (i, space) in enumerate(space.spaces)
47-
TrialFESpace!(space, bc.BoundaryCondition[i], Λ)
47+
TrialFESpace!(space, bc[i], Λ)
4848
end
4949
end
5050

5151
function Gridap.FESpaces.TrialFESpace!(space::MultiFieldFESpace, bc::MultiFieldBC, Λ::Float64, ΔΛ::Float64)
5252
@inbounds for (i, space) in enumerate(space.spaces)
53-
TrialFESpace!(space, bc.BoundaryCondition[i], Λ, ΔΛ)
53+
TrialFESpace!(space, bc[i], Λ, ΔΛ)
5454
end
5555
end
5656

57-
function Gridap.FESpaces.TrialFESpace(space::SingleFieldFESpace, bc::DirichletBC)
58-
TrialFESpace(space, bc, 0.0)
59-
end
60-
61-
function Gridap.FESpaces.TrialFESpace(space::MultiFieldFESpace, bc::MultiFieldBC)
62-
TrialFESpace(space, bc, 0.0)
63-
end
64-
6557

66-
function Gridap.FESpaces.TrialFESpace(space::SingleFieldFESpace, ::NothingBC, Λ::Float64)
58+
function Gridap.FESpaces.TrialFESpace(space::SingleFieldFESpace, ::NothingBC, Λ::Float64=0.0)
6759
space
6860
end
6961

70-
function Gridap.FESpaces.TrialFESpace(space::SingleFieldFESpace, bc::DirichletBC, Λ::Float64)
62+
63+
function Gridap.FESpaces.TrialFESpace(space::SingleFieldFESpace, bc::DirichletBC, Λ::Float64=0.0)
7164
trialspace= TrialFESpace(space, map(f -> f(Λ), bc.values))
7265
@inbounds for i in eachindex(bc.tags)
7366
if bc.caches[i] isa InterpolableBC
@@ -78,13 +71,13 @@ function Gridap.FESpaces.TrialFESpace(space::SingleFieldFESpace, bc::DirichletBC
7871
return trialspace
7972
end
8073

81-
function Gridap.FESpaces.TrialFESpace(space::MultiFieldFESpace, bc::MultiFieldBC, Λ::Float64)
74+
75+
function Gridap.FESpaces.TrialFESpace(space::MultiFieldFESpace, bc::MultiFieldBC, Λ::Float64=0.0)
8276
U_ = Vector{Union{TrialFESpace,UnconstrainedFESpace}}(undef, length(space))
8377
@inbounds for (i, space) in enumerate(space.spaces)
84-
U_[i] = TrialFESpace(space, bc.BoundaryCondition[i], Λ)
78+
U_[i] = TrialFESpace(space, bc[i], Λ)
8579
end
8680
return MultiFieldFESpace(U_)
87-
8881
end
8982

9083

src/PhysicalModels/MagnetoMechanicalModels.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct MagnetoMechModel{MG<:Magneto,MC<:Mechano} <: MagnetoMechano
1515
new{MG,MC}(magneto, mechano)
1616
end
1717

18-
function (obj::MagnetoMechModel)(Λ::Float64=1.0)
18+
function (obj::MagnetoMechModel{<:Magneto,<:IsoElastic})(Λ::Float64=1.0)
1919
Ψm, ∂Ψm_u, ∂Ψm_uu = obj.mechano(Λ)
2020
Ψmm, ∂Ψmm_u, ∂Ψmm_φ, ∂Ψmm_uu, ∂Ψmm_φu, ∂Ψmm_φφ = _getCoupling(obj.magneto, obj.mechano, Λ)
2121

@@ -28,9 +28,26 @@ struct MagnetoMechModel{MG<:Magneto,MC<:Mechano} <: MagnetoMechano
2828

2929
return (Ψ, ∂Ψu, ∂Ψφ, ∂Ψuu, ∂Ψφu, ∂Ψφφ)
3030
end
31+
32+
function (obj::MagnetoMechModel{<:Magneto,<:AnisoElastic})(Λ::Float64=1.0)
33+
Ψm, ∂Ψm_u, ∂Ψm_uu = obj.mechano(Λ)
34+
Ψmm, ∂Ψmm_u, ∂Ψmm_φ, ∂Ψmm_uu, ∂Ψmm_φu, ∂Ψmm_φφ = _getCoupling(obj.magneto, obj.mechano, Λ)
35+
36+
Ψ(F, ℋ₀, N) = Ψm(F,N) + Ψmm(F, ℋ₀, N)
37+
∂Ψu(F, ℋ₀, N) = ∂Ψm_u(F,N) + ∂Ψmm_u(F, ℋ₀, N)
38+
∂Ψφ(F, ℋ₀, N) = ∂Ψmm_φ(F, ℋ₀, N)
39+
∂Ψuu(F, ℋ₀, N) = ∂Ψm_uu(F,N) + ∂Ψmm_uu(F, ℋ₀, N)
40+
∂Ψφu(F, ℋ₀, N) = ∂Ψmm_φu(F, ℋ₀, N)
41+
∂Ψφφ(F, ℋ₀, N) = ∂Ψmm_φφ(F, ℋ₀, N)
42+
43+
return (Ψ, ∂Ψu, ∂Ψφ, ∂Ψuu, ∂Ψφu, ∂Ψφφ)
44+
end
45+
46+
3147
end
3248

3349

50+
3451
function _getCoupling(mag::Union{IdealMagnetic,IdealMagnetic2D}, ::Mechano, Λ::Float64)
3552
Ψmm, ∂Ψmm_∂u, ∂Ψmm_∂φ, ∂Ψmm_∂uu, ∂Ψmm_∂φu, ∂Ψmm_∂φφ = mag(Λ)
3653

test/TestConstitutiveModels/PhysicalModelTests.jl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,47 @@ end
644644
end
645645

646646

647+
@testset "HardMagnetic_SoftMaterial3D_aniso" begin
648+
649+
∇u = TensorValue(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0) * 1e-3
650+
∇φ = VectorValue(1.0, 2.0, 3.0)
651+
N = VectorValue(0.0, 0.0, 1.0)
652+
653+
modelMRiso = MooneyRivlin3D=3.0, μ1=1.0, μ2=2.0)
654+
modelMRaniso = MooneyRivlin3D=3.0, μ1=1.0, μ2=2.0)
655+
modelMR=modelMRiso+modelMRaniso
656+
modelID = HardMagnetic(μ0=1.2566e-6, αr=40e-3, χe=0.0, χr=8.0; βmok=1.0, βcoup=1.0)
657+
modelmagneto=modelMR+modelID
658+
Ψ, ∂Ψu, ∂Ψφ, ∂Ψuu, ∂Ψφu, ∂Ψφφ = modelmagneto()
659+
K=Kinematics(Mechano,Solid)
660+
F, _, _ = get_Kinematics(K)
661+
Km=Kinematics(Magneto,Solid)
662+
H0 = get_Kinematics(Km)
663+
664+
665+
# ∂Ψu_(F) =TensorValue(ForwardDiff.gradient(x -> Ψ(x, get_array( H0(∇φ)),get_array(N) ), get_array(F)))
666+
# ∂Ψφ_(H) =VectorValue(ForwardDiff.gradient(x -> Ψ(get_array( F(∇u)), x,get_array(N) ), get_array(H)))
667+
# ∂Ψuu_(F) =TensorValue(ForwardDiff.hessian(x -> Ψ(x, get_array( H0(∇φ)),get_array(N) ), get_array(F)))
668+
# ∂Ψφu_(H) =TensorValue(ForwardDiff.jacobian(x -> ∂Ψφ(x, get_array( H0(∇φ)),get_array(N) ), get_array(F(∇u))))
669+
# ∂Ψφφ_(H) =TensorValue(ForwardDiff.jacobian(x -> ∂Ψφ(get_array( F(∇u)), x,get_array(N) ), get_array(H)))
670+
671+
# norm(∂Ψu_(F(∇u)))
672+
# norm(∂Ψφ_(H0(∇φ)))
673+
# norm(∂Ψuu_(F(∇u)))
674+
# norm(∂Ψφu_(H0(∇φ)))
675+
# norm(∂Ψφφ_(H0(∇φ)))
676+
677+
678+
@test Ψ(F(∇u), H0(∇φ), N) == 0.003187725760804994
679+
@test norm(∂Ψu(F(∇u), H0(∇φ), N)) == 0.4966662732306754
680+
@test norm(∂Ψφ(F(∇u), H0(∇φ), N)) == 4.660348298920368e-6
681+
@test norm(∂Ψuu(F(∇u), H0(∇φ), N)) ==60.735729041745294
682+
@test norm(∂Ψφu(F(∇u), H0(∇φ), N)) == 1.2369035467980284e-5
683+
@test norm(∂Ψφφ(F(∇u), H0(∇φ), N)) == 2.1878750641250348e-6
684+
end
685+
686+
687+
647688

648689
@testset "HardMagnetic_SoftMaterial3D" begin
649690

0 commit comments

Comments
 (0)