Skip to content

Commit fff32af

Browse files
committed
Added tests
1 parent a80f12f commit fff32af

File tree

2 files changed

+127
-0
lines changed

2 files changed

+127
-0
lines changed

test/integration/b_int_correspondence.jl

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,70 @@ end
166166
# @test isapprox(b_int, b_int_theory; atol=5eps())
167167
@test b_int[:,5] [0.0, 0.0, 0.0]
168168
end
169+
170+
@testitem "Exported von Mises stress CMaterial" begin
171+
using Peridynamics.StaticArrays
172+
173+
ref_position = [0.0 1.0 0.0 0.0 2.0
174+
0.0 0.0 1.0 0.0 2.0
175+
0.0 0.0 0.0 1.0 2.0]
176+
volume = fill(1.0, 5)
177+
δ = 1.5
178+
body = Body(CMaterial(), ref_position, volume)
179+
material!(body, horizon=δ, rho=8000, E=210e9, nu=0.25, Gc=100.0)
180+
no_failure!(body)
181+
182+
dh = Peridynamics.threads_data_handler(body, VelocityVerlet(steps=1), 1)
183+
chunk = dh.chunks[1]
184+
(; mat, storage, system, paramsetup) = chunk
185+
(; cauchy_stress) = storage
186+
187+
# set some stresses
188+
σx, σy, σz = 100.0, 100.0, 100.0
189+
τxy, τyz, τzx = 100.0, 100.0, 100.0
190+
σ = @SMatrix [σx τxy τzx; τxy σy τyz; τzx τyz σz]
191+
for i in 1:5
192+
Peridynamics.update_tensor!(cauchy_stress, i, σ)
193+
end
194+
195+
field_val = Val(:von_mises_stress)
196+
σvm = Peridynamics.export_field(field_val, mat, system, storage, paramsetup, 0.0)
197+
198+
@test all(σvm .≈ 300.0)
199+
end
200+
201+
@testitem "Exported von Mises stress CRMaterial" begin
202+
using Peridynamics.StaticArrays, Peridynamics.LinearAlgebra
203+
204+
ref_position = [0.0 1.0 0.0 0.0 2.0
205+
0.0 0.0 1.0 0.0 2.0
206+
0.0 0.0 0.0 1.0 2.0]
207+
volume = fill(1.0, 5)
208+
δ = 1.5
209+
body = Body(CRMaterial(), ref_position, volume)
210+
material!(body, horizon=δ, rho=8000, E=210e9, nu=0.25, Gc=100.0)
211+
no_failure!(body)
212+
213+
dh = Peridynamics.threads_data_handler(body, VelocityVerlet(steps=1), 1)
214+
chunk = dh.chunks[1]
215+
(; mat, storage, system, paramsetup) = chunk
216+
(; unrotated_stress) = storage
217+
218+
# rotation should be identity at initialization
219+
for i in 1:5
220+
R = Peridynamics.get_tensor(storage.rotation, i)
221+
@test R I
222+
end
223+
224+
# set some stresses
225+
σx, σy, σz = 100.0, 100.0, 100.0
226+
τxy, τyz, τzx = 100.0, 100.0, 100.0
227+
σ = @SMatrix [σx τxy τzx; τxy σy τyz; τzx τyz σz]
228+
for i in 1:5
229+
Peridynamics.update_tensor!(unrotated_stress, i, σ)
230+
end
231+
232+
field_val = Val(:von_mises_stress)
233+
σvm = Peridynamics.export_field(field_val, mat, system, storage, paramsetup, 0.0)
234+
@test all(σvm .≈ 300.0)
235+
end

test/physics/test_stress.jl

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,66 @@
1313
@test Peridynamics.cauchy_stress(P, F) σ
1414
end
1515

16+
@testitem "Von Mises stress calculation" begin
17+
using Peridynamics.StaticArrays
18+
19+
# zero stress
20+
σx, σy, σz = 0, 0, 0
21+
τxy, τyz, τzx = 0, 0, 0
22+
σ = @SMatrix [σx τxy τzx; τxy σy τyz; τzx τyz σz]
23+
σvm = Peridynamics.von_mises_stress(σ)
24+
@test σvm 0 atol=eps()
25+
26+
# uniaxial stress x
27+
σx, σy, σz = 100.0, 0, 0
28+
τxy, τyz, τzx = 0, 0, 0
29+
σ = @SMatrix [σx τxy τzx; τxy σy τyz; τzx τyz σz]
30+
σvm = Peridynamics.von_mises_stress(σ)
31+
@test σvm σx
32+
33+
# uniaxial stress y
34+
σx, σy, σz = 0, 100.0, 0
35+
τxy, τyz, τzx = 0, 0, 0
36+
σ = @SMatrix [σx τxy τzx; τxy σy τyz; τzx τyz σz]
37+
σvm = Peridynamics.von_mises_stress(σ)
38+
@test σvm σy
39+
40+
# uniaxial stress z
41+
σx, σy, σz = 0, 0, 100.0
42+
τxy, τyz, τzx = 0, 0, 0
43+
σ = @SMatrix [σx τxy τzx; τxy σy τyz; τzx τyz σz]
44+
σvm = Peridynamics.von_mises_stress(σ)
45+
@test σvm σz
46+
47+
# shear and axial loading
48+
σx, σy, σz = 500, 300, 400
49+
τxy, τyz, τzx = 300, 0, 0
50+
σ = @SMatrix [σx τxy τzx; τxy σy τyz; τzx τyz σz]
51+
σvm = Peridynamics.von_mises_stress(σ)
52+
@test σvm 300000
53+
54+
# shear and axial loading
55+
σx, σy, σz = 500, 300, 400
56+
τxy, τyz, τzx = 0, 300, 0
57+
σ = @SMatrix [σx τxy τzx; τxy σy τyz; τzx τyz σz]
58+
σvm = Peridynamics.von_mises_stress(σ)
59+
@test σvm 300000
60+
61+
# shear and axial loading
62+
σx, σy, σz = 500, 300, 400
63+
τxy, τyz, τzx = 0, 0, 300
64+
σ = @SMatrix [σx τxy τzx; τxy σy τyz; τzx τyz σz]
65+
σvm = Peridynamics.von_mises_stress(σ)
66+
@test σvm 300000
67+
68+
# all shear and axial loading
69+
σx, σy, σz = 100, 100, 100
70+
τxy, τyz, τzx = 100, 100, 100
71+
σ = @SMatrix [σx τxy τzx; τxy σy τyz; τzx τyz σz]
72+
σvm = Peridynamics.von_mises_stress(σ)
73+
@test σvm 300
74+
end
75+
1676
@testitem "init_stress_rotation!" begin
1777
using Peridynamics.StaticArrays
1878

0 commit comments

Comments
 (0)