Skip to content

Commit ae97d00

Browse files
authored
Merge pull request #225 from mdienst/testing
Added tests
2 parents b5d59be + 82028f9 commit ae97d00

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/time_solvers/test_dynamic_relaxation.jl

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,46 @@
1+
@testitem "DynamicRelaxation wrong input" begin
2+
@test_throws ArgumentError DynamicRelaxation(steps=0)
3+
@test_throws ArgumentError DynamicRelaxation(steps=10, stepsize=0)
4+
@test_throws ArgumentError DynamicRelaxation(steps=10, damping_factor=0)
5+
end
6+
7+
@testitem "dynamic_relaxation_check" begin
8+
dr = DynamicRelaxation(steps=1)
9+
dr.n_steps = -1
10+
msg = "`n_steps` of DynamicRelaxation smaller than zero!\n"
11+
@test_throws ErrorException(msg) Peridynamics.dynamic_relaxation_check(dr)
12+
13+
dr = DynamicRelaxation(steps=1)
14+
dr.Δt = -1
15+
msg = "`Δt` of DynamicRelaxation smaller than zero!\n"
16+
@test_throws ErrorException(msg) Peridynamics.dynamic_relaxation_check(dr)
17+
18+
dr = DynamicRelaxation(steps=1)
19+
dr.Λ = -1
20+
msg = "`Λ` of DynamicRelaxation smaller than zero!\n"
21+
@test_throws ErrorException(msg) Peridynamics.dynamic_relaxation_check(dr)
22+
end
23+
24+
@testitem "_init_density_matrix" begin
25+
using Peridynamics
26+
position = [0.0 1.0 0.0 0.0
27+
0.0 0.0 0.0 1.0
28+
0.0 0.0 1.0 0.0]
29+
volume = fill(1.0, 4)
30+
body = Body(BBMaterial(), position, volume)
31+
material!(body; horizon=1.5, rho=8e-6, E=210e3)
32+
point_set!(body, :a, 1:2)
33+
material!(body, :a; horizon=1.5, rho=7.8e-6, E=200e3)
34+
35+
dr = DynamicRelaxation(steps=1)
36+
dh = Peridynamics.threads_data_handler(body, dr, 1)
37+
chunk = dh.chunks[1]
38+
Peridynamics._init_density_matrix!(chunk,dr,chunk.paramsetup)
39+
40+
@test chunk.storage.density_matrix [4.0e6 4.0e6 4.2e6 4.2e6
41+
4.0e6 4.0e6 4.2e6 4.2e6
42+
4.0e6 4.0e6 4.2e6 4.2e6]
43+
end
144

245
@testitem "show DynamicRelaxation" begin
346
io = IOBuffer()

0 commit comments

Comments
 (0)