Skip to content

Commit

Permalink
fixed bond damage np1 switch
Browse files Browse the repository at this point in the history
  • Loading branch information
JTHesse committed Nov 20, 2024
1 parent 3f5f360 commit f47be48
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
22 changes: 16 additions & 6 deletions src/Core/data_manager.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,12 @@ function set_local_synch(model, name, download_from_cores, upload_to_cores, dof

end

function switch_bonds!(field_N, field_NP1)
for fieldID in eachindex(field_NP1)
copyto!(field_N[fieldID], field_NP1[fieldID])
end
end

"""
switch_NP1_to_N()
Expand All @@ -1566,15 +1572,19 @@ Switches the fields from NP1 to N.active
function switch_NP1_to_N()
active = _get_field("Active")
for key in keys(data["NP1_to_N"])
if key == "Bond Damage"
field_NP1 = get_field(key, "NP1")
field_N = get_field(key, "N")
switch_bonds!(field_N, field_NP1)
continue
end
data["NP1_to_N"][key][1], data["NP1_to_N"][key][2] =
data["NP1_to_N"][key][2], data["NP1_to_N"][key][1]
field_NP1 = get_field(key, "NP1")
if key != "Bond Damage"
if field_NP1[1] isa AbstractVector || field_NP1[1] isa AbstractArray
fill_in_place!(field_NP1, data["NP1_to_N"][key][3], active)
else
fill!(field_NP1, data["NP1_to_N"][key][3])
end
if field_NP1[1] isa AbstractVector || field_NP1[1] isa AbstractArray
fill_in_place!(field_NP1, data["NP1_to_N"][key][3], active)
else
fill!(field_NP1, data["NP1_to_N"][key][3])
end
end
end
Expand Down
Binary file modified test/fullscale_tests/test_DCB/Reference/DCBmodel_PD_solid.e
Binary file not shown.
23 changes: 15 additions & 8 deletions test/unit_tests/Core/ut_data_manager.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ testfield_keys = test_data_manager.get_all_field_keys()
@test B[1] == test_data_manager.get_field("B", "N")
@test B[2] == test_data_manager.get_field("B", "NP1")
@test C == test_data_manager.get_field("C")
@test C == test_data_manager.get_field("C", "constant")
@test "A" in testfield_keys
@test ("AN" in testfield_keys) == false
@test ("ANP1" in testfield_keys) == false
Expand Down Expand Up @@ -360,7 +361,7 @@ end
@test DN[1, 3] == DNtest[1, 3]
end

bd = test_data_manager.create_bond_field("Bond Damage", Float64, 1)
bdn, bdnp1 = test_data_manager.create_bond_field("Bond Damage", Float64, 1, 1)
test_data_manager.create_constant_node_field("Active", Bool, 1, true)
@testset "switch_NP1_to_N" begin
bmatrixN, bmatrixNP1 = test_data_manager.create_bond_field("Bmat", Float64, "Matrix", 2)
Expand Down Expand Up @@ -388,10 +389,21 @@ test_data_manager.create_constant_node_field("Active", Bool, 1, true)
bmatrixNP1[1][1, 2, 1] = 3
bmatrixNP1[1][2, 2, 2] = 4
# extra test, because Bond Damage is set to one, to avoid unneccessary operations
bd = test_data_manager.get_field("Bond Damage", "NP1")
@test sum(maximum(bd)) == 0
bdn = test_data_manager.get_field("Bond Damage", "N")
bdnp1 = test_data_manager.get_field("Bond Damage", "NP1")
bdnp1[2][1] = 0.5
@test bdn[2][1] == 1.0
@test bdnp1[2][1] == 0.5

test_data_manager.switch_NP1_to_N()

bdn = test_data_manager.get_field("Bond Damage", "N")
bdnp1 = test_data_manager.get_field("Bond Damage", "NP1")
@test bdn[2][1] == 0.5
@test bdn[2][2] == 1.0
@test bdnp1[2][1] == 0.5
@test bdnp1[2][2] == 1.0

DN = test_data_manager.get_field("D", "N")
DNP1 = test_data_manager.get_field("D", "NP1")
nmatrixN = test_data_manager.get_field("Nmat", "N")
Expand Down Expand Up @@ -427,11 +439,6 @@ test_data_manager.create_constant_node_field("Active", Bool, 1, true)
@test INP1[2][1][3] == 0
# bonds
@test IN[2][1][3] == 5
bd = test_data_manager.get_field("Bond Damage", "NP1")
for id in eachindex(bd)
# @test sum(bd[id]) == nn[id]
@test sum(bd[id]) == 0.0
end

end

Expand Down
10 changes: 1 addition & 9 deletions test/unit_tests/Models/Material/ut_material_basis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,7 @@ end
bond_damage[iID] .* mapreduce(permutedims, vcat, bond_force[iID]) .* volume[iID]
end

distribute_forces!(
force_densities,
nodes,
nlist,
bond_force,
volume,
bond_damage,
force_densities,
)
distribute_forces!(force_densities, nodes, nlist, bond_force, volume, bond_damage)
@test force_densities expected_force_densities
end
@testset "ut_flaw_function" begin
Expand Down

0 comments on commit f47be48

Please sign in to comment.