-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathIsotropicDamageTests.jl
134 lines (99 loc) · 2.73 KB
/
IsotropicDamageTests.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
module IsotropicDamageTests
using Gridap
using LinearAlgebra
using Test
# max imposed displacement
const udx_max = 0.05
const L = 1
# Elastic model
const E = 2.1e4 # Pa
const ν = 0.3 # dim-less
const λ = (E*ν)/((1+ν)*(1-2*ν))
const μ = E/(2*(1+ν))
σe(ε) = λ*tr(ε)*one(ε) + 2*μ*ε # Pa
τ(ε) = sqrt(inner(ε,σe(ε))) # Pa^(1/2)
# Damage model
const σ_u = 5.5 # Pa
const r_0 = σ_u / sqrt(E) # Pa^(1/2)
const H = 0.1 # dim-less
function d(r)
1 - q(r)/r
end
function q(r)
r_0 + H*(r-r_0)
end
function new_state(r_in,d_in,ε_in)
τ_in = τ(ε_in)
if τ_in <= r_in
r_out = r_in
d_out = d_in
damaged = false
else
r_out = τ_in
d_out = d(r_out)
damaged = true
end
damaged, r_out, d_out
end
function σ(ε_in,r_in,d_in)
_, _, d_out = new_state(r_in,d_in,ε_in)
(1-d_out)*σe(ε_in)
end
function dσ(dε_in,ε_in,state)
damaged, r_out, d_out = state
if ! damaged
return (1-d_out)*σe(dε_in)
else
c_inc = ((q(r_out) - H*r_out)*inner(σe(ε_in),dε_in))/(r_out^3)
return (1-d_out)*σe(dε_in) - c_inc*σe(ε_in)
end
end
u(x) = VectorValue( udx_max*x[1]/L, -ν*udx_max*x[2]/L, -ν*udx_max*x[3]/L )
function main(;n,nsteps)
domain = (0,L,0,L,0,L)
partition = (n,n,n)
model = CartesianDiscreteModel(domain,partition)
labeling = get_face_labeling(model)
add_tag_from_tags!(labeling,"ux0",[5,7,13,15,17,19,25])
add_tag_from_tags!(labeling,"ux1",[2,4,6,8,14,16,18,20,26])
add_tag_from_tags!(labeling,"uxyz0",[1])
add_tag_from_tags!(labeling,"uxz0",[3])
order = 1
V = TestFESpace(
model,
ReferenceFE(lagrangian,VectorValue{3,Float64},order),
labels = labeling,
dirichlet_tags=["ux0","ux1","uxyz0","uxz0"],
dirichlet_masks=[(true,false,false),(true,false,false),(true,true,true),(true,false,true)])
degree = 2*order
Ω = Triangulation(model)
dΩ = Measure(Ω,degree)
r = CellState(r_0,dΩ)
d = CellState(0.0,dΩ)
nls = NLSolver(show_trace=false, method=:newton)
solver = FESolver(nls)
function step(uh_in,factor)
udx = factor*udx_max
u0 = VectorValue(0.0,0.0,0.0)
ud = VectorValue(udx,0.0,0.0)
U = TrialFESpace(V,[u0,ud,u0,u0])
res(u,v) = ∫( inner( ε(v), σ∘(ε(u),r,d) ) )*dΩ
jac(u,du,v) = ∫( inner( ε(v), dσ∘(ε(du),ε(u),new_state∘(r,d,ε(u))) ) )*dΩ
op = FEOperator(res,jac,U,V)
free_values = get_free_dof_values(uh_in)
uh0 = FEFunction(U,free_values)
uh_out, = solve!(uh0,solver,op)
update_state!(new_state,r,d,ε(uh_out))
uh_out
end
factors = collect(1:nsteps)*(1/nsteps)
uh = zero(V)
for (istep,factor) in enumerate(factors)
uh = step(uh,factor)
end
e = uh - u
e_l2 = sqrt(sum(∫(e⋅e)*dΩ))
@test e_l2 < 1.0e-9
end
main(n=5,nsteps=10)
end # module