Skip to content

Commit 862b590

Browse files
authored
Merge pull request #243 from kaipartmann/kp/added-tests
Test coverage
2 parents 5993566 + a02db78 commit 862b590

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

test/integration/predefined_cracks.jl

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,59 @@ end
230230
@test ch.localizer[3] == 1
231231
@test ch.localizer[4] == 2
232232
end
233+
234+
@testitem "precrack bond system with filter" begin
235+
# setup
236+
position = [0.0 1.0 0.0 0.0
237+
0.0 0.0 1.0 0.0
238+
0.0 0.0 0.0 1.0]
239+
volume = [1.1, 1.2, 1.3, 1.4]
240+
mat = CKIMaterial()
241+
body = Body(mat, position, volume)
242+
material!(body, horizon=2, rho=1, E=1, nu=0.25, Gc=1)
243+
point_set!(body, :set_a, 1:2)
244+
point_set!(body, :set_b, 3:4)
245+
precrack!(body, :set_a, :set_b; update_dmg=false)
246+
pd = Peridynamics.PointDecomposition(body, 2)
247+
248+
# 1
249+
system = Peridynamics.InteractionSystem(body, pd, 1)
250+
251+
@test system.position == position[:, 1:2]
252+
@test system.volume == volume[1:2]
253+
@test system.one_nis == [
254+
Peridynamics.Bond(2, 1.0, true),
255+
Peridynamics.Bond(1, 1.0, true),
256+
]
257+
@test system.n_one_nis == [1, 1]
258+
@test system.one_ni_idxs == [1:1, 2:2]
259+
260+
ch = system.chunk_handler
261+
@test ch.point_ids == [1, 2]
262+
@test ch.loc_points == [1, 2]
263+
@test ch.halo_points == Int[]
264+
@test ch.hidxs_by_src == Dict{Int,UnitRange{Int}}()
265+
for i in 1:2
266+
@test ch.localizer[i] == i
267+
end
268+
269+
# 2
270+
system = Peridynamics.InteractionSystem(body, pd, 2)
271+
272+
@test system.position == position[:, 3:4]
273+
@test system.volume == volume[3:4]
274+
@test system.one_nis == [
275+
Peridynamics.Bond(2, 2, true),
276+
Peridynamics.Bond(1, 2, true),
277+
]
278+
@test system.n_one_nis == [1, 1]
279+
@test system.one_ni_idxs == [1:1, 2:2]
280+
281+
ch = system.chunk_handler
282+
@test ch.point_ids == [3, 4]
283+
@test ch.loc_points == [3, 4]
284+
@test ch.halo_points == Int[]
285+
@test ch.hidxs_by_src == Dict{Int,UnitRange{Int}}()
286+
@test ch.localizer[3] == 1
287+
@test ch.localizer[4] == 2
288+
end

test/time_solvers/test_newton_raphson.jl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,3 +503,37 @@ end
503503
job = Job(body, nr)
504504
@test_throws ErrorException submit(job)
505505
end
506+
507+
@testitem "Material limitation errors" begin
508+
using Peridynamics: NewtonRaphson, displacement_bc!
509+
510+
## CRMaterial should not work with NewtonRaphson
511+
position = [0.0 1.0 0.0 0.0
512+
0.0 0.0 1.0 0.0
513+
0.0 0.0 0.0 1.0]
514+
volume = [1.0, 1.0, 1.0, 1.0]
515+
body = Body(CRMaterial(), position, volume)
516+
material!(body, horizon=2, rho=1, E=1, nu=0.25)
517+
point_set!(body, :top, [4])
518+
point_set!(body, :bottom, [1])
519+
displacement_bc!(p -> 0.1, body, :top, :y)
520+
displacement_bc!(p -> 0.0, body, :bottom, :x)
521+
displacement_bc!(p -> 0.0, body, :bottom, :y)
522+
displacement_bc!(p -> 0.0, body, :bottom, :z)
523+
nr = NewtonRaphson(steps=10, stepsize=0.1, maxiter=2, tol=1e-6)
524+
job = Job(body, nr)
525+
@test_throws ArgumentError submit(job)
526+
527+
## RKCRMaterial should not work with NewtonRaphson
528+
body = Body(RKCRMaterial(), position, volume)
529+
material!(body, horizon=2, rho=1, E=1, nu=0.25)
530+
point_set!(body, :top, [4])
531+
point_set!(body, :bottom, [1])
532+
displacement_bc!(p -> 0.1, body, :top, :y)
533+
displacement_bc!(p -> 0.0, body, :bottom, :x)
534+
displacement_bc!(p -> 0.0, body, :bottom, :y)
535+
displacement_bc!(p -> 0.0, body, :bottom, :z)
536+
nr = NewtonRaphson(steps=10, stepsize=0.1, maxiter=2, tol=1e-6)
537+
job = Job(body, nr)
538+
@test_throws ArgumentError submit(job)
539+
end

0 commit comments

Comments
 (0)