Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
JTHesse committed May 24, 2024
1 parent 37a4a23 commit 9adcbc9
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@ function compute_stress_integral(nodes::Union{SubArray,Vector{Int64}}, nlist::Su
end
end

"""
correspondence_name()
Gives the correspondence material name. It is needed for comparison with the yaml input deck.
# Arguments
# Returns
- `name::String`: The name of the material.
Example:
```julia
println(correspondence_name())
"Material Template"
```
"""
function correspondence_name()
return "Correspondence Bond-Associated"
end

"""
https://link.springer.com/article/10.1007/s10409-021-01055-5
Expand Down Expand Up @@ -87,6 +106,7 @@ function compute_forces(datamanager::Module, nodes::Union{SubArray,Vector{Int64}
omega = datamanager.get_field("Influence Function")
volume = datamanager.get_field("Volume")
weighted_volume = datamanager.get_field("Bond Weighted Volume")
# bond_horizon = 2.2 #Temporary fix
weighted_volume = compute_bond_associated_weighted_volume(nodes, nlist, coordinates, bond_damage, omega, volume, bond_horizon, weighted_volume)

undeformed_bond = datamanager.get_field("Bond Geometry")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,88 @@
include("../../../../../src/Physics/Material/Material_Models/Bond_Associated_Correspondence.jl")
# include("../../../../../src/Core/data_manager.jl")
using Test
using TimerOutputs

const to = TimerOutput()

@testset "correspondence_name" begin
@test Bond_Associated_Correspondence.correspondence_name() == "Correspondence Bond-Associated"
end
# @testset "compute_forces" begin
# nodes = 3
# test_Data_manager = Data_manager
# test_Data_manager.clear_data_manager()
# test_Data_manager.set_num_controller(nodes)
# dof = 3
# test_Data_manager.set_dof(dof)
# nn = test_Data_manager.create_constant_node_field("Number of Neighbors", Int64, 1)
# nn[1] = 2
# nn[2] = 2
# nn[3] = 2
# nlist = test_Data_manager.create_constant_bond_field("Neighborhoodlist", Int64, 1)
# nlist[1] = [2, 3]
# nlist[2] = [1, 3]
# nlist[2] = [1, 2]
# h = test_Data_manager.create_constant_node_field("Horizon", Float64, 1)

# h[1:nodes] = 1:nodes
# bf = test_Data_manager.create_constant_bond_field("Bond Forces", Float64, dof)

# coor = test_Data_manager.create_constant_node_field("Coordinates", Float64, 2)
# coor[1, 1] = 0
# coor[1, 2] = 0
# coor[2, 1] = 1
# coor[2, 2] = 0
# coor[3, 1] = 0
# coor[3, 2] = 1
# omega = test_Data_manager.create_constant_node_field("Influence Function", Float64, 2)
# omega[1, 1] = 0.5
# omega[1, 2] = 0.8
# omega[2, 1] = 0.7
# omega[2, 2] = 0.9
# omega[3, 1] = 0.6
# omega[3, 2] = 0.4
# volume = test_Data_manager.create_constant_node_field("Volume", Float64, 1)
# volume[1:nodes] = [1.0, 2.0, 3.0]
# bw_volume = test_Data_manager.create_constant_node_field("Bond Weighted Volume", Float64, 2)
# bw_volume[1, 1] = 0
# bw_volume[1, 2] = 0
# bw_volume[2, 1] = 0
# bw_volume[2, 2] = 0
# bw_volume[3, 1] = 0
# bw_volume[3, 2] = 0

# bdN, bdNP1 = test_Data_manager.create_bond_field("Bond Damage", Float64, 1)
# dbN, dbNP1 = test_Data_manager.create_bond_field("Deformed Bond Geometry", Float64, dof)
# dbdN, dbdNP1 = test_Data_manager.create_bond_field("Deformed Bond Length", Float64, 1)
# bg = test_Data_manager.create_constant_bond_field("Bond Geometry", Float64, dof)
# bd = test_Data_manager.create_constant_bond_field("Bond Length", Float64, 1)
# for iID in 1:nodes
# bdNP1[iID] .= 1
# bd[iID] .= 1
# dbdNP1[iID] .= 1 + (-1)^iID * 0.1
# dbNP1[iID] .= 1
# end

# test_Data_manager = Bond_Associated_Correspondence.compute_forces(test_Data_manager, Vector{Int64}(1:nodes), Dict("Bulk Modulus" => 1.0, "Young's Modulus" => 1.0), 0.0, 0.0, to)

# bf = test_Data_manager.get_field("Bond Forces")
# @test isapprox(bf[1][1, 1], -0.31830988618379064)
# @test isapprox(bf[1][1, 2], -0.31830988618379064)
# @test isapprox(bf[1][1, 3], -0.31830988618379064)
# @test isapprox(bf[1][2, 1], -0.31830988618379064)
# @test isapprox(bf[1][2, 2], -0.31830988618379064)
# @test isapprox(bf[1][2, 3], -0.31830988618379064)
# @test isapprox(bf[2][1, 1], 0.016277210088943853)
# @test isapprox(bf[2][1, 2], 0.016277210088943853)
# @test isapprox(bf[2][1, 3], 0.016277210088943853)
# @test isapprox(bf[2][2, 1], 0.016277210088943853)
# @test isapprox(bf[2][2, 2], 0.016277210088943853)
# @test isapprox(bf[2][2, 3], 0.016277210088943853)
# @test isapprox(bf[2][3, 1], 0.016277210088943853)
# @test isapprox(bf[2][3, 2], 0.016277210088943853)
# @test isapprox(bf[2][3, 3], 0.016277210088943853)
# end
@testset "ut_find_local_neighbors" begin
coordinates = zeros(Float64, 5, 2)
coordinates[1, 1] = 0
Expand Down

0 comments on commit 9adcbc9

Please sign in to comment.