Skip to content

Commit

Permalink
bug fix and UMAT test
Browse files Browse the repository at this point in the history
  • Loading branch information
CWillberg committed Mar 23, 2024
1 parent ce2c9ba commit 607a182
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Physics/Material/Material_Models/Correspondence_UMAT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ function init_material_model(datamanager::Module, nodes::Union{SubArray,Vector{I
end
# properties include the material properties, etc.
num_props = material_parameter["Number of Properties"]
properties = datamanager.create_constant_free_size_field("Properties", Float64, num_props, 1)
properties = datamanager.create_constant_free_size_field("Properties", Float64, (num_props, 1))

for iID in 1:num_props
if !haskey(material_parameter, "Property_$iID")
@error "Property_$iID is missing. Number of properties is $num_props and properties have to be in order without a missing number."
return nothing
end
props[iID] = material_parameter["Property_$iID"]
properties[iID] = material_parameter["Property_$iID"]
end

if !haskey(material_parameter, "UMAT Material Name")
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ MPI.Init()
@includetests["unit_tests/Physics/Additive/ut_Additive_Factory"]
end
end

@testset "Corrosion" begin
@testset "ut_Corrosion_Factory" begin
@includetests["unit_tests/Physics/Corrosion/ut_Corrosion_Factory"]
Expand Down Expand Up @@ -158,6 +157,7 @@ MPI.Init()
end
@testset "ut_correspondence" begin
@includetests["unit_tests/Physics/Material/Material_Models/ut_Correspondence"]
@includetests["unit_tests/Physics/Material/Material_Models/ut_Correspondence_UMAT"]
end
@testset "ut_ordinary" begin
@includetests["unit_tests/Physics/Material/Material_Models/Ordinary/ut_ordinary"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SPDX-FileCopyrightText: 2023 Christian Willberg <christian.willberg@dlr.de>, Jan-Timo Hesse <jan-timo.hesse@dlr.de>
#
# SPDX-License-Identifier: BSD-3-Clause
using Test
include("../../../../../src/Physics/Material/Material_Models/Correspondence_UMAT.jl")
include("../../../../../src/Support/data_manager.jl")
include("../../../../../src/Support/data_manager.jl")
@testset "get_name&fe_support" begin
@test Correspondence_UMAT.correspondence_name() == "Correspondence UMAT"
@test Correspondence_UMAT.fe_support()
end
@testset "init exceptions" begin
nodes = 2
test_Data_manager = Data_manager
test_Data_manager.set_num_controller(nodes)
dof = 3
test_Data_manager.set_dof(dof)

@test isnothing(Correspondence_UMAT.init_material_model(test_Data_manager, Vector{Int64}(1:nodes), Dict()))
@test isnothing(Correspondence_UMAT.init_material_model(test_Data_manager, Vector{Int64}(1:nodes), Dict("Number of Properties" => 3, "Property_1" => 2, "Property_3" => 2)))
@test isnothing(Correspondence_UMAT.init_material_model(test_Data_manager, Vector{Int64}(1:nodes), Dict("Number of Properties" => 3, "Property_1" => 2, "Property_3" => 2, "Property_4" => 2)))


@test isnothing(Correspondence_UMAT.init_material_model(test_Data_manager, Vector{Int64}(1:nodes), Dict("Number of Properties" => 3, "Property_1" => 2, "Property_2" => 2, "Property_3" => 2.4, "UMAT Material Name" => "a"^81)))
@test !isnothing(Correspondence_UMAT.init_material_model(test_Data_manager, Vector{Int64}(1:nodes), Dict("Number of Properties" => 3, "Property_1" => 2, "Property_2" => 2, "Property_3" => 2.4, "UMAT Material Name" => "a"^80)))

@test isnothing(Correspondence_UMAT.init_material_model(test_Data_manager, Vector{Int64}(1:nodes), Dict("Number of Properties" => 3, "Property_1" => 2, "Property_2" => 2, "Property_3" => 2.4, "Property_4" => 2.4, "Predefined Field Names" => "s")))

properties = test_Data_manager.get_field("Properties")
@test length(properties) == 3
@test properties[1] == 2
@test properties[2] == 2
@test properties[3] == 2.4

test_Data_manager.create_constant_node_field("test_field", Float64, 2)
Correspondence_UMAT.init_material_model(test_Data_manager, Vector{Int64}(1:nodes), Dict("Number of Properties" => 3, "Property_1" => 2, "Property_2" => 2, "Property_3" => 2.4, "Predefined Field Names" => "test_field"))
@test ("test_field" in test_Data_manager.get_all_field_keys())
end

0 comments on commit 607a182

Please sign in to comment.