|
55 | 55 | msg = String(take!(io)) |
56 | 56 | @test contains(msg, "DynamicRelaxation:\n n_steps 1\n Δt 1\n Λ 1") |
57 | 57 | end |
| 58 | + |
| 59 | +@testitem "init_density_matrix! and relaxation_timestep! for all data handlers" begin |
| 60 | + import Peridynamics: init_density_matrix!, relaxation_timestep! |
| 61 | + # Setup single body |
| 62 | + position = [0.0 1.0 0.0 0.0; |
| 63 | + 0.0 0.0 0.0 1.0; |
| 64 | + 0.0 0.0 1.0 0.0] |
| 65 | + volume = fill(1.0, 4) |
| 66 | + body = Body(BBMaterial(), position, volume) |
| 67 | + material!(body; horizon=1.5, rho=8e-6, E=210e3) |
| 68 | + point_set!(body, :a, 1:2) |
| 69 | + material!(body, :a; horizon=3, rho=7.8e-6, E=200e3) |
| 70 | + forcedensity_bc!((p,t) -> 1e5 * p[1], body, :a, :x) |
| 71 | + dr = DynamicRelaxation(steps=2) |
| 72 | + options = Peridynamics.JobOptions(body) |
| 73 | + |
| 74 | + # ThreadsBodyDataHandler |
| 75 | + dh_threads = Peridynamics.threads_data_handler(body, dr, 1) |
| 76 | + init_density_matrix!(dh_threads, dr) |
| 77 | + @test all(dh_threads.chunks[1].storage.density_matrix .>= 0) |
| 78 | + @test dh_threads.chunks[1].storage.position ≈ position |
| 79 | + relaxation_timestep!(dh_threads, options, dr.Δt, 1) |
| 80 | + relaxation_timestep!(dh_threads, options, dr.Δt, 2) |
| 81 | + # Check that the density matrix is updated correctly |
| 82 | + @test dh_threads.chunks[1].storage.position[1, 2] ≈ 1.05 |
| 83 | + |
| 84 | + # ThreadsMultibodyDataHandler |
| 85 | + b2 = Body(BBMaterial(), position, volume) |
| 86 | + material!(b2; horizon=1.5, rho=8e-6, E=210e3) |
| 87 | + ms = MultibodySetup(:b1 => body, :b2 => b2) |
| 88 | + dh_multibody = Peridynamics.threads_data_handler(ms, dr, 1) |
| 89 | + options_multi = Peridynamics.JobOptions(ms) |
| 90 | + init_density_matrix!(dh_multibody, dr) |
| 91 | + for body_idx in Peridynamics.each_body_idx(dh_multibody) |
| 92 | + for chunk in Peridynamics.get_body_dh(dh_multibody, body_idx).chunks |
| 93 | + @test all(chunk.storage.density_matrix .>= 0) |
| 94 | + @test chunk.storage.position ≈ position |
| 95 | + end |
| 96 | + end |
| 97 | + relaxation_timestep!(dh_multibody, options_multi, dr.Δt, 1) |
| 98 | + relaxation_timestep!(dh_multibody, options_multi, dr.Δt, 2) |
| 99 | + # Check that the density matrix is updated correctly |
| 100 | + @test dh_multibody.body_dhs[1].chunks[1].storage.position[1, 2] ≈ 1.05 |
| 101 | + |
| 102 | + # AbstractMPIBodyDataHandler |
| 103 | + dh_mpi = Peridynamics.mpi_data_handler(body, dr) |
| 104 | + init_density_matrix!(dh_mpi, dr) |
| 105 | + @test all(dh_mpi.chunk.storage.density_matrix .>= 0) |
| 106 | + @test dh_mpi.chunk.storage.position ≈ position |
| 107 | + relaxation_timestep!(dh_mpi, options, dr.Δt, 1) |
| 108 | + relaxation_timestep!(dh_mpi, options, dr.Δt, 2) |
| 109 | + # Check that the density matrix is updated correctly |
| 110 | + @test dh_mpi.chunk.storage.position[1, 2] ≈ 1.05 |
| 111 | +end |
0 commit comments