Skip to content

Commit 919c512

Browse files
authored
Merge pull request #223 from mdienst/testing
Additional tests for specific material models
2 parents 84d2617 + 050e360 commit 919c512

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

test/discretization/test_bond_associated_system.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,20 @@ end
7070
# end
7171

7272
end
73+
74+
@testitem "bond horizon" begin
75+
# setup
76+
pos, vol = uniform_box(1, 0.25, 0.25, 0.25)
77+
body = Body(BACMaterial(), pos, vol)
78+
@test_throws ArgumentError material!(body, horizon=0.5, bond_horizon=-1, rho=1, E=1,
79+
nu=0.25, Gc=1)
80+
@test_logs (:warn,) material!(body, horizon=0.5, bond_horizon=0.1, rho=1, E=1, nu=0.25,
81+
Gc=1)
82+
end
83+
84+
@testitem "bond-associated compatibility" begin
85+
# setup
86+
pos, vol = uniform_box(1, 0.25, 0.25, 0.25)
87+
body = Body(BBMaterial(), pos, vol)
88+
@test_throws ArgumentError Peridynamics.check_bond_associated_system_compat(body.mat)
89+
end

test/discretization/test_interaction_system.jl

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
system = Peridynamics.InteractionSystem(body, pd, 1)
1111

12+
@test Peridynamics.has_three_nis(body.point_params[1]) == false
13+
@test Peridynamics.has_three_nis(body,1) == false
14+
15+
@test Peridynamics.has_two_nis(body,1) == true
16+
1217
@test system.one_nis == [
1318
Peridynamics.Bond(2, 1.0, true),
1419
Peridynamics.Bond(3, 1.0, true),
@@ -27,6 +32,66 @@
2732
@test system.three_nis == Vector{Peridynamics.ThreeNeighborInteraction}()
2833
@test system.n_three_nis == Vector{Int}()
2934
@test system.three_ni_idxs == Vector{UnitRange{Int}}()
35+
36+
point_set!(body, :a, 1:2)
37+
material!(body, :a; horizon=1.5, rho=7e-6, E=200e3, nu=0.3, Gc=1.0, C1=1, C2=1)
38+
39+
ts = VelocityVerlet(steps=1)
40+
dh = Peridynamics.threads_data_handler(body, ts, 1)
41+
chunk = dh.chunks[1]
42+
@test Peridynamics.has_three_nis(chunk.paramsetup) == false
43+
end
44+
45+
@testitem "one- and three-neighbor interactions" begin
46+
position = [0.0 1.0 0.0 0.0
47+
0.0 0.0 0.0 1.0
48+
0.0 0.0 1.0 0.0]
49+
volume = fill(1.0, 4)
50+
body = Body(CKIMaterial(), position, volume)
51+
material!(body; horizon=1.5, rho=8e-6, E=210e3, nu=0.3, Gc=1.0, C1=1, C3=1)
52+
pd = Peridynamics.PointDecomposition(body, 1)
53+
54+
system = Peridynamics.InteractionSystem(body, pd, 1)
55+
56+
@test Peridynamics.has_two_nis(body.point_params[1]) == false
57+
@test Peridynamics.has_two_nis(body) == false
58+
@test Peridynamics.has_two_nis(body,1) == false
59+
60+
@test Peridynamics.has_three_nis(body,1) == true
61+
62+
@test system.one_nis == [
63+
Peridynamics.Bond(2, 1.0, true),
64+
Peridynamics.Bond(3, 1.0, true),
65+
Peridynamics.Bond(4, 1.0, true),
66+
Peridynamics.Bond(1, 1.0, true),
67+
Peridynamics.Bond(3, 2, true),
68+
Peridynamics.Bond(4, 2, true),
69+
Peridynamics.Bond(1, 1.0, true),
70+
Peridynamics.Bond(2, 2, true),
71+
Peridynamics.Bond(4, 2, true),
72+
Peridynamics.Bond(1, 1.0, true),
73+
Peridynamics.Bond(2, 2, true),
74+
Peridynamics.Bond(3, 2, true)]
75+
@test system.n_one_nis == [3, 3, 3, 3]
76+
@test system.one_ni_idxs == [1:3, 4:6, 7:9, 10:12]
77+
@test system.two_nis == Vector{Peridynamics.TwoNeighborInteraction}()
78+
@test system.n_two_nis == Vector{Int}()
79+
@test system.two_ni_idxs == Vector{UnitRange{Int}}()
80+
@test system.three_nis == [
81+
Peridynamics.ThreeNeighborInteraction(1, 2, 3, 1.0),
82+
Peridynamics.ThreeNeighborInteraction(4, 5, 6, 1.0),
83+
Peridynamics.ThreeNeighborInteraction(7, 8, 9, 1.0),
84+
Peridynamics.ThreeNeighborInteraction(10, 11, 12, 1.0)]
85+
@test system.n_three_nis == [1, 1, 1, 1]
86+
@test system.three_ni_idxs == [1:1, 2:2, 3:3, 4:4]
87+
88+
point_set!(body, :a, 1:2)
89+
material!(body, :a; horizon=1.5, rho=7e-6, E=200e3, nu=0.3, Gc=1.0, C1=1, C3=1)
90+
91+
ts = VelocityVerlet(steps=1)
92+
dh = Peridynamics.threads_data_handler(body, ts, 1)
93+
chunk = dh.chunks[1]
94+
@test Peridynamics.has_two_nis(chunk.paramsetup) == false
3095
end
3196

3297
@testitem "one-, two-, and three-neighbor interactions" begin
@@ -131,3 +196,10 @@ end
131196
@test is.volume_two_nis [fill(1.33333333333333, 4); 0.0]
132197
@test is.volume_three_nis [fill(4.0, 4); 0.0]
133198
end
199+
200+
@testitem "interaction system compatibility" begin
201+
# setup
202+
pos, vol = uniform_box(1, 0.25, 0.25, 0.25)
203+
body = Body(BBMaterial(), pos, vol)
204+
@test_throws ArgumentError Peridynamics.check_interaction_system_compat(body.mat)
205+
end

0 commit comments

Comments
 (0)