diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml index 0950e4ae1..f6ca375b8 100644 --- a/.github/workflows/TagBot.yml +++ b/.github/workflows/TagBot.yml @@ -32,9 +32,7 @@ jobs: - uses: JuliaRegistries/TagBot@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - # Edit the following line to reflect the actual name of the GitHub Secret containing your private key - ssh: ${{ secrets.DOCUMENTER_KEY }} - # ssh: ${{ secrets.NAME_OF_MY_SSH_PRIVATE_KEY_SECRET }} + ssh: ${{ secrets.SSH_KEY }} DockerHub: if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' runs-on: ubuntu-latest diff --git a/src/IO/IO.jl b/src/IO/IO.jl index 99462ec95..9af929d58 100644 --- a/src/IO/IO.jl +++ b/src/IO/IO.jl @@ -24,6 +24,8 @@ using Reexport @reexport using .Parameter_Handling export initialize_data export init_write_results +export get_results_mapping +export init_orientations export write_results export merge_exodus_files export show_block_summary diff --git a/src/Support/data_manager.jl b/src/Support/data_manager.jl index d9a93c6ec..6e93d688e 100644 --- a/src/Support/data_manager.jl +++ b/src/Support/data_manager.jl @@ -377,9 +377,13 @@ Returns a list of all field keys. """ function clear_data_manager() global field_types + global nsets + global nnsets global physics_options field_types = Dict() + nsets = Dict() + nnsets = 0 physics_options = Dict("Deformed Bond Geometry" => true, "Deformation Gradient" => false, "Shape Tensor" => false, @@ -391,13 +395,11 @@ function clear_data_manager() # global properties # global fields # global model_modules - # global nsets # field_array_type = Dict() # fields_to_synch = Dict() # properties = Dict() # fields = Dict() # model_modules = Dict() - # nsets = Dict() end """ diff --git a/test/unit_tests/Compute/ut_compute_field_values.jl b/test/unit_tests/Compute/ut_compute_field_values.jl index d2f2c4fcc..977febe4f 100644 --- a/test/unit_tests/Compute/ut_compute_field_values.jl +++ b/test/unit_tests/Compute/ut_compute_field_values.jl @@ -3,10 +3,11 @@ # SPDX-License-Identifier: BSD-3-Clause using Test -include("../../../src/Support/data_manager.jl") +# include("../../../src/Support/data_manager.jl") include("../../../src/Compute/compute_field_values.jl") @testset "ut_get_forces_from_force_density" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager + test_Data_manager.clear_data_manager() test_Data_manager.set_num_controller(5) test_Data_manager.create_node_field("Forces", Float64, 3) @@ -27,7 +28,7 @@ include("../../../src/Compute/compute_field_values.jl") end @testset "ut_get_partial_stresses" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.set_dof(3) test_Data_manager.set_num_controller(5) nn = test_Data_manager.create_constant_node_field("Number of Neighbors", Int64, 1) diff --git a/test/unit_tests/Compute/ut_compute_global_values.jl b/test/unit_tests/Compute/ut_compute_global_values.jl index 23cd8ee05..8e472eac5 100644 --- a/test/unit_tests/Compute/ut_compute_global_values.jl +++ b/test/unit_tests/Compute/ut_compute_global_values.jl @@ -3,11 +3,11 @@ # SPDX-License-Identifier: BSD-3-Clause using Test -include("../../../src/Support/data_manager.jl") +# include("../../../src/Support/data_manager.jl") include("../../../src/Compute/compute_global_values.jl") @testset "ut_global_value_sum" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.set_num_controller(4) nodes = Vector{Int64}(1:4) (forcesN, forcesNP1) = test_Data_manager.create_node_field("Forces", Float64, 3) @@ -41,7 +41,7 @@ include("../../../src/Compute/compute_global_values.jl") end @testset "ut_global_value_max" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.set_num_controller(4) nodes = Vector{Int64}(1:4) (forcesN, forcesNP1) = test_Data_manager.create_node_field("Forces", Float64, 3) @@ -76,7 +76,7 @@ end end @testset "ut_global_value_min" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.set_num_controller(4) nodes = Vector{Int64}(1:4) (forcesN, forcesNP1) = test_Data_manager.create_node_field("Forces", Float64, 3) @@ -108,7 +108,7 @@ end @test isnothing(calculate_nodelist(test_Data_manager, "not there", 1, "Minimum", nodes)) end @testset "ut_global_value_avg" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.set_num_controller(4) nodes = Vector{Int64}(1:4) (forcesN, forcesNP1) = test_Data_manager.create_node_field("Forces", Float64, 3) @@ -141,7 +141,7 @@ end end @testset "ut_calculate_block" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.create_constant_node_field("Block_Id", Int64, 1) @test isnothing(calculate_block(test_Data_manager, "no field", 1, "sum", 1)) @test isnothing(calculate_block(test_Data_manager, "Disp", 1, "no option", 1)) diff --git a/test/unit_tests/Core/Module_inclusion/ut_set_Modules.jl b/test/unit_tests/Core/Module_inclusion/ut_set_Modules.jl index e247505a4..a85e59f25 100644 --- a/test/unit_tests/Core/Module_inclusion/ut_set_Modules.jl +++ b/test/unit_tests/Core/Module_inclusion/ut_set_Modules.jl @@ -7,7 +7,7 @@ include("../../../../src/Core/Module_inclusion/set_Modules.jl") using Test using Random -using .Set_modules +# using .Set_modules @testset "ut_find_jl_files" begin Random.seed!(rand(1:100000)) @@ -47,7 +47,7 @@ using .Set_modules io = open(folder * "/" * filename4 * ".dat", "w") close(io) - list = Set_modules.find_jl_files(base) + list = PeriLab.Solver.FEM.Set_modules.find_jl_files(base) folder * "/" * filename1 * ".jl" in list @test subfolder1 * "/" * filename2 * ".jl" in list @test subfolder1 * "/" * filename3 * ".jl" in list diff --git a/test/unit_tests/Core/Solver/ut_Solver_control.jl b/test/unit_tests/Core/Solver/ut_Solver_control.jl index fc07a3f81..bcae04ea7 100644 --- a/test/unit_tests/Core/Solver/ut_Solver_control.jl +++ b/test/unit_tests/Core/Solver/ut_Solver_control.jl @@ -5,19 +5,19 @@ using Test using MPI using TimerOutputs -include("../../../../src/Core/Solver/Solver_control.jl") -include("../../../../src/Support/geometry.jl") -if !isdefined(@__MODULE__, :Data_manager) - include("../../../../src/Support/data_manager.jl") -end -include("../../../../src/Support/Parameters/parameter_handling.jl") -using Reexport -@reexport using .Parameter_Handling -import .Solver +# include("../../../../src/Core/Solver/Solver_control.jl") +# include("../../../../src/Support/geometry.jl") +# if !isdefined(@__MODULE__, :Data_manager) +# include("../../../../src/Support/data_manager.jl") +# end +# include("../../../../src/Support/Parameters/parameter_handling.jl") +# using Reexport +# @reexport using .Parameter_Handling +# import .Solver @testset "ut_get_block_nodes" begin block_ids = [1, 1, 1, 2, 2, 3, 3, 3, 3, 1, 1, 2, 3, 3, 1, 1, 2] - block_nodes = Solver.get_block_nodes(block_ids, length(block_ids)) + block_nodes = PeriLab.Solver.get_block_nodes(block_ids, length(block_ids)) @test block_nodes[1] == [1, 2, 3, 10, 11, 15, 16] @test block_nodes[2] == [4, 5, 12, 17] @test block_nodes[3] == [6, 7, 8, 9, 13, 14] diff --git a/test/unit_tests/Core/Solver/ut_Verlet.jl b/test/unit_tests/Core/Solver/ut_Verlet.jl index 1830edbe3..4f58de70b 100644 --- a/test/unit_tests/Core/Solver/ut_Verlet.jl +++ b/test/unit_tests/Core/Solver/ut_Verlet.jl @@ -5,45 +5,45 @@ using Test -include("../../../../src/Core/BC_manager.jl") -include("../../../../src/Core/Solver/Verlet.jl") -include("../../../../src/Core/Solver/Solver_control.jl") -include("../../../../src/Support/geometry.jl") +# include("../../../../src/Core/BC_manager.jl") +# include("../../../../src/Core/Solver/Verlet.jl") +# include("../../../../src/Core/Solver/Solver_control.jl") +# include("../../../../src/Support/geometry.jl") -if !isdefined(@__MODULE__, :Data_manager) - include("../../../../src/Support/data_manager.jl") -end -include("../../../../src/Support/Parameters/parameter_handling.jl") -using Reexport -@reexport using .Parameter_Handling -using .Data_manager -using .Geometry -using .Boundary_conditions -using .Solver -using .Verlet +# if !isdefined(@__MODULE__, :Data_manager) +# include("../../../../src/Support/data_manager.jl") +# end +# include("../../../../src/Support/Parameters/parameter_handling.jl") +# using Reexport +# @reexport using .Parameter_Handling +# using .Data_manager +# using .Geometry +# using .Boundary_conditions +# using .Solver +# using .Verlet using MPI @testset "ut_test_timestep" begin - @test Verlet.test_timestep(1.0, 2.0) == 1 - @test Verlet.test_timestep(2.0, 1.1) == 1.1 - @test Verlet.test_timestep(2.0, 2.0) == 2 + @test PeriLab.Solver.Verlet.test_timestep(1.0, 2.0) == 1 + @test PeriLab.Solver.Verlet.test_timestep(2.0, 1.1) == 1.1 + @test PeriLab.Solver.Verlet.test_timestep(2.0, 2.0) == 2 end @testset "ut_get_integration_steps" begin - @test isnothing(Verlet.get_integration_steps(0.0, 0.0, -1.0)) - @test Verlet.get_integration_steps(0.0, 1.0, 1.0) == (1, 1.0) - @test Verlet.get_integration_steps(0.0, 2.0, 1.0) == (2, 1.0) - @test Verlet.get_integration_steps(0.0, 6.0, 2.0) == (3, 2.0) - @test Verlet.get_integration_steps(2.0, 6.0, 2.0) == (2, 2.0) + @test isnothing(PeriLab.Solver.Verlet.get_integration_steps(0.0, 0.0, -1.0)) + @test PeriLab.Solver.Verlet.get_integration_steps(0.0, 1.0, 1.0) == (1, 1.0) + @test PeriLab.Solver.Verlet.get_integration_steps(0.0, 2.0, 1.0) == (2, 1.0) + @test PeriLab.Solver.Verlet.get_integration_steps(0.0, 6.0, 2.0) == (3, 2.0) + @test PeriLab.Solver.Verlet.get_integration_steps(2.0, 6.0, 2.0) == (2, 2.0) end @testset "ut_get_cs_denominator" begin volume = Float64[1, 2, 3] undeformed_bond = [1, 2, 3] - @test Verlet.get_cs_denominator(volume, undeformed_bond) == 3 + @test PeriLab.Solver.Verlet.get_cs_denominator(volume, undeformed_bond) == 3 undeformed_bond = [2, 4, 6] - @test Verlet.get_cs_denominator(volume, undeformed_bond) == 1.5 + @test PeriLab.Solver.Verlet.get_cs_denominator(volume, undeformed_bond) == 1.5 undeformed_bond = [1, 0.5, 2] - @test Verlet.get_cs_denominator(volume, undeformed_bond) == 6.5 + @test PeriLab.Solver.Verlet.get_cs_denominator(volume, undeformed_bond) == 6.5 end # nnodes = 5 diff --git a/test/unit_tests/Core/ut_BC_manager.jl b/test/unit_tests/Core/ut_BC_manager.jl index 0a84adf5e..d2487922e 100644 --- a/test/unit_tests/Core/ut_BC_manager.jl +++ b/test/unit_tests/Core/ut_BC_manager.jl @@ -2,31 +2,31 @@ # # SPDX-License-Identifier: BSD-3-Clause -include("../../../src/Core/BC_manager.jl") -include("../../../src/Support/data_manager.jl") -include("../../../src/Support/Parameters/parameter_handling.jl") -using Reexport -@reexport using .Parameter_Handling -@reexport using .Boundary_conditions +# include("../../../src/Core/BC_manager.jl") +# include("../../../src/Support/data_manager.jl") +# include("../../../src/Support/Parameters/parameter_handling.jl") +# using Reexport +# @reexport using .Parameter_Handling +# @reexport using .Boundary_conditions using Test @testset "ut_clean_up" begin - @test Boundary_conditions.clean_up("") == "" - @test Boundary_conditions.clean_up("-") == " .- " - @test Boundary_conditions.clean_up("+") == " .+ " - @test Boundary_conditions.clean_up("*") == " .* " - @test Boundary_conditions.clean_up("/") == " ./ " - @test Boundary_conditions.clean_up("5e-8") == "5e-8" - @test Boundary_conditions.clean_up("5.0e-8") == "5.0e-8" - @test Boundary_conditions.clean_up("5.0e-8-5") == "5.0e-8 .- 5" - @test Boundary_conditions.clean_up("5.0e-8/5e+5*t") == "5.0e-8 ./ 5e+5 .* t" - @test Boundary_conditions.clean_up("5-8.0/5e+5") == "5 .- 8.0 ./ 5e+5" - @test Boundary_conditions.clean_up("2") == "2" - @test Boundary_conditions.clean_up("2.") == "2." - @test Boundary_conditions.clean_up("2.0") == "2.0" - @test Boundary_conditions.clean_up("2.0.-1") == "2.0 .- 1" + @test PeriLab.Solver.Boundary_conditions.clean_up("") == "" + @test PeriLab.Solver.Boundary_conditions.clean_up("-") == " .- " + @test PeriLab.Solver.Boundary_conditions.clean_up("+") == " .+ " + @test PeriLab.Solver.Boundary_conditions.clean_up("*") == " .* " + @test PeriLab.Solver.Boundary_conditions.clean_up("/") == " ./ " + @test PeriLab.Solver.Boundary_conditions.clean_up("5e-8") == "5e-8" + @test PeriLab.Solver.Boundary_conditions.clean_up("5.0e-8") == "5.0e-8" + @test PeriLab.Solver.Boundary_conditions.clean_up("5.0e-8-5") == "5.0e-8 .- 5" + @test PeriLab.Solver.Boundary_conditions.clean_up("5.0e-8/5e+5*t") == "5.0e-8 ./ 5e+5 .* t" + @test PeriLab.Solver.Boundary_conditions.clean_up("5-8.0/5e+5") == "5 .- 8.0 ./ 5e+5" + @test PeriLab.Solver.Boundary_conditions.clean_up("2") == "2" + @test PeriLab.Solver.Boundary_conditions.clean_up("2.") == "2." + @test PeriLab.Solver.Boundary_conditions.clean_up("2.0") == "2.0" + @test PeriLab.Solver.Boundary_conditions.clean_up("2.0.-1") == "2.0 .- 1" end @testset "ut_evaluation" begin @@ -36,48 +36,49 @@ end coor = zeros(3, 3) bc = Int64(10) values = ones(Float64, 3) - @test (10 * unit) == Boundary_conditions.eval_bc(values, bc, coor, time, dof, false) + @test (10 * unit) == PeriLab.Solver.Boundary_conditions.eval_bc(values, bc, coor, time, dof, false) bc = Float64(10) - @test (10 * unit) == Boundary_conditions.eval_bc(values, bc, coor, time, dof, false) + @test (10 * unit) == PeriLab.Solver.Boundary_conditions.eval_bc(values, bc, coor, time, dof, false) bc = Float64(10) - @test (10 * unit) == Boundary_conditions.eval_bc(values, bc, coor, time, dof, false) + @test (10 * unit) == PeriLab.Solver.Boundary_conditions.eval_bc(values, bc, coor, time, dof, false) bc = string(10) - @test (10 * unit) == Boundary_conditions.eval_bc(values, bc, coor, time, dof, false) + @test (10 * unit) == PeriLab.Solver.Boundary_conditions.eval_bc(values, bc, coor, time, dof, false) bc = "x" for i in 1:4 coor[3, 1] = i * i - 2 - @test (coor[:, 1]) == Boundary_conditions.eval_bc(values, bc, coor, time, dof, false) + @test (coor[:, 1]) == PeriLab.Solver.Boundary_conditions.eval_bc(values, bc, coor, time, dof, false) end dof = 3 bc = "t" - @test (time * unit) == Boundary_conditions.eval_bc(values, bc, coor, time, dof, false) + @test (time * unit) == PeriLab.Solver.Boundary_conditions.eval_bc(values, bc, coor, time, dof, false) bc = "t*x" - @test (time .* coor[:, 1]) == Boundary_conditions.eval_bc(values, bc, coor, time, dof, false) + @test (time .* coor[:, 1]) == PeriLab.Solver.Boundary_conditions.eval_bc(values, bc, coor, time, dof, false) for t in 0:4 bc = "if t>2 0 else 20 end" if t > 2 - @test (0.0 * unit) == Boundary_conditions.eval_bc(values, bc, coor, Float64(t), dof, false) + @test (0.0 * unit) == PeriLab.Solver.Boundary_conditions.eval_bc(values, bc, coor, Float64(t), dof, false) else - @test (20.0 * unit) == Boundary_conditions.eval_bc(values, bc, coor, Float64(t), dof, false) + @test (20.0 * unit) == PeriLab.Solver.Boundary_conditions.eval_bc(values, bc, coor, Float64(t), dof, false) end end for t in 0:2 bc = "100.0" if t == 0 - @test (100.0 * unit) == Boundary_conditions.eval_bc(values, bc, coor, Float64(t), dof, false) - @test (100.0 * unit) == Boundary_conditions.eval_bc(values, bc, coor, Float64(t), dof, true) + @test (100.0 * unit) == PeriLab.Solver.Boundary_conditions.eval_bc(values, bc, coor, Float64(t), dof, false) + @test (100.0 * unit) == PeriLab.Solver.Boundary_conditions.eval_bc(values, bc, coor, Float64(t), dof, true) else - @test unit == Boundary_conditions.eval_bc(values, bc, coor, Float64(t), dof, true) + @test unit == PeriLab.Solver.Boundary_conditions.eval_bc(values, bc, coor, Float64(t), dof, true) end end - @test values == Boundary_conditions.eval_bc(values, bc, Matrix{Float64}(undef, 0, 0), time, dof, false) + @test values == PeriLab.Solver.Boundary_conditions.eval_bc(values, bc, Matrix{Float64}(undef, 0, 0), time, dof, false) end @testset "ut_boundary_condition" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager + test_Data_manager.clear_data_manager() test_Data_manager.set_dof() = 2 params = Dict() - bcs = Boundary_conditions.boundary_condition(params, test_Data_manager) + bcs = PeriLab.Solver.Boundary_conditions.boundary_condition(params, test_Data_manager) @test length(bcs) == 0 params = Dict("Boundary Conditions" => Dict("BC_1" => Dict("Type" => "Forces", "Node Set" => "Nset_1", "Coordinate" => "x", "Value" => "20*t"), "BC_2" => Dict("Type" => "Displacements", "Node Set" => "Nset_2", "Coordinate" => "z", "Value" => "0"), "BC_3" => Dict("Type" => "Displacements", "Node Set" => "Nset_3", "Coordinate" => "z", "Value" => "0"))) @@ -85,11 +86,11 @@ end test_Data_manager.set_nset("Nset_2", [3, 4, 7, 10]) test_Data_manager.set_glob_to_loc(Dict(1 => 1, 2 => 3, 3 => 4, 4 => 2, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10)) - bcs = Boundary_conditions.boundary_condition(params, test_Data_manager) + bcs = PeriLab.Solver.Boundary_conditions.boundary_condition(params, test_Data_manager) @test isnothing(bcs) params = Dict("Boundary Conditions" => Dict("BC_1" => Dict("Type" => "Forces", "Node Set" => "Nset_1", "Coordinate" => "x", "Value" => "20*t"), "BC_2" => Dict("Type" => "Displacements", "Node Set" => "Nset_2", "Coordinate" => "z", "Value" => "0"))) - bcs = Boundary_conditions.boundary_condition(params, test_Data_manager) + bcs = PeriLab.Solver.Boundary_conditions.boundary_condition(params, test_Data_manager) @test length(bcs) == 2 @test "BC_1" in keys(bcs) @@ -107,19 +108,19 @@ end @test !("BC_3" in keys(bcs)) end @testset "ut_check_valid_bcs" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager params = Dict("Boundary Conditions" => Dict("BC_1" => Dict("Type" => "Forces", "Node Set" => "Nset_1", "Coordinate" => "x", "Value" => "20*t"), "BC_2" => Dict("Type" => "not there", "Node Set" => "Nset_2", "Coordinate" => "z", "Value" => "0"))) test_Data_manager.set_nset("Nset_1", [1, 2, 3]) test_Data_manager.set_nset("Nset_2", [3, 4, 7, 10]) test_Data_manager.set_glob_to_loc(Dict(1 => 1, 2 => 3, 3 => 4, 4 => 2, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10)) - bcs = Boundary_conditions.boundary_condition(params, test_Data_manager) - @test isnothing(Boundary_conditions.check_valid_bcs(bcs, test_Data_manager)) + bcs = PeriLab.Solver.Boundary_conditions.boundary_condition(params, test_Data_manager) + @test isnothing(PeriLab.Solver.Boundary_conditions.check_valid_bcs(bcs, test_Data_manager)) end @testset "ut_init_BCs" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.set_num_controller(10) test_Data_manager.create_constant_node_field("Coordinates", Float64, 3) @@ -129,7 +130,7 @@ end params = Dict("Boundary Conditions" => Dict("BC_1" => Dict("Type" => "Forces", "Node Set" => "Nset_1", "Coordinate" => "x", "Value" => "20*t"), "BC_2" => Dict("Type" => "Displacements", "Node Set" => "Nset_2", "Coordinate" => "z", "Value" => "5"))) - bcs = Boundary_conditions.init_BCs(params, test_Data_manager) + bcs = PeriLab.Solver.Boundary_conditions.init_BCs(params, test_Data_manager) @test length(bcs) == 1 # clean up params representation @test "BC_1" in keys(bcs) @@ -140,7 +141,7 @@ end @test bcs["BC_1"]["Node Set"] == [1, 3, 4] test_Data_manager.set_dof(3) - bcs = Boundary_conditions.init_BCs(params, test_Data_manager) + bcs = PeriLab.Solver.Boundary_conditions.init_BCs(params, test_Data_manager) @test length(bcs) == 2 @test "BC_1" in keys(bcs) @test "BC_2" in keys(bcs) @@ -157,7 +158,7 @@ end @testset "ut_apply_bc" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.set_dof(3) test_Data_manager.create_constant_node_field("Coordinates", Float64, 3) @@ -170,15 +171,15 @@ end disp = test_Data_manager.get_field("Displacements", "NP1") @test sum(force) == 0 @test sum(disp) == 0 - bcs = Boundary_conditions.init_BCs(params, test_Data_manager) - Boundary_conditions.apply_bc(bcs, test_Data_manager, 0.0) + bcs = PeriLab.Solver.Boundary_conditions.init_BCs(params, test_Data_manager) + PeriLab.Solver.Boundary_conditions.apply_bc(bcs, test_Data_manager, 0.0) force = test_Data_manager.get_field("Forces") disp = test_Data_manager.get_field("Displacements", "NP1") @test sum(force) == 0 @test sum(disp) == 20 @test disp == [0 0 0; 0 0 5; 0 0 0; 0 0 5; 0 0 0; 0 0 0; 0 0 5; 0 0 0; 0 0 0; 0 0 5] - Boundary_conditions.apply_bc(bcs, test_Data_manager, 0.2) + PeriLab.Solver.Boundary_conditions.apply_bc(bcs, test_Data_manager, 0.2) force = test_Data_manager.get_field("Forces") disp = test_Data_manager.get_field("Displacements", "NP1") @test sum(force) == 12 @@ -190,11 +191,11 @@ end bcs["BC_2"]["Node Set"] = [] force .= 0 disp .= 0 - Boundary_conditions.apply_bc(bcs, test_Data_manager, 0.2) + PeriLab.Solver.Boundary_conditions.apply_bc(bcs, test_Data_manager, 0.2) @test sum(force) == 0 @test sum(disp) == 0 params = Dict("Boundary Conditions" => Dict("BC_2" => Dict("Type" => "Displacements", "Node Set" => "Nset_2", "Coordinate" => "u", "Value" => "5"))) - bcs = Boundary_conditions.init_BCs(params, test_Data_manager) - @test isnothing(Boundary_conditions.apply_bc(bcs, test_Data_manager, 0.2)) + bcs = PeriLab.Solver.Boundary_conditions.init_BCs(params, test_Data_manager) + @test isnothing(PeriLab.Solver.Boundary_conditions.apply_bc(bcs, test_Data_manager, 0.2)) end \ No newline at end of file diff --git a/test/unit_tests/FEM/Element_formulation/ut_lagrange_element.jl b/test/unit_tests/FEM/Element_formulation/ut_lagrange_element.jl index 2987bf31f..be0970f32 100644 --- a/test/unit_tests/FEM/Element_formulation/ut_lagrange_element.jl +++ b/test/unit_tests/FEM/Element_formulation/ut_lagrange_element.jl @@ -1,8 +1,8 @@ # SPDX-FileCopyrightText: 2023 Christian Willberg , Jan-Timo Hesse # # SPDX-License-Identifier: BSD-3-Clause -include("../../../../src/FEM/FEM_routines.jl") -include("../../../../src/FEM/Element_formulation/lagrange_element.jl") +# include("../../../../src/FEM/FEM_routines.jl") +# include("../../../../src/FEM/Element_formulation/lagrange_element.jl") #using .Lagrange_element using Test diff --git a/test/unit_tests/FEM/ut_FEM_Factory.jl b/test/unit_tests/FEM/ut_FEM_Factory.jl index 94b20fc8f..789e3936e 100644 --- a/test/unit_tests/FEM/ut_FEM_Factory.jl +++ b/test/unit_tests/FEM/ut_FEM_Factory.jl @@ -1,37 +1,37 @@ # SPDX-FileCopyrightText: 2023 Christian Willberg , Jan-Timo Hesse # # SPDX-License-Identifier: BSD-3-Clause -include("../../../src/FEM/FEM_Factory.jl") using Test -include("../../../src/Support/data_manager.jl") -using Reexport -@reexport using .Data_manager +# include("../../../src/FEM/FEM_Factory.jl") +# include("../../../src/Support/data_manager.jl") +# using .Data_manager +PeriLab.Data_manager.clear_data_manager() @testset "ut_valid_models" begin - @test isnothing(FEM.valid_models(Dict())) - @test isnothing(FEM.valid_models(Dict("Additive Model" => "a"))) - @test isnothing(FEM.valid_models(Dict("Damage Model" => "a"))) - @test FEM.valid_models(Dict("Damage Model" => "a", "Additive Model" => "a", "Material Model" => "a Correspondence")) - @test isnothing(FEM.valid_models(Dict("Thermal Model" => "a"))) - @test FEM.valid_models(Dict("Material Model" => "a")) + @test isnothing(PeriLab.Solver.FEM.valid_models(Dict())) + @test isnothing(PeriLab.Solver.FEM.valid_models(Dict("Additive Model" => "a"))) + @test isnothing(PeriLab.Solver.FEM.valid_models(Dict("Damage Model" => "a"))) + @test PeriLab.Solver.FEM.valid_models(Dict("Damage Model" => "a", "Additive Model" => "a", "Material Model" => "a Correspondence")) + @test isnothing(PeriLab.Solver.FEM.valid_models(Dict("Thermal Model" => "a"))) + @test PeriLab.Solver.FEM.valid_models(Dict("Material Model" => "a")) end @testset "ut_init_FEM" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager nelements = 2 test_Data_manager.set_dof(2) test_Data_manager.set_num_elements(nelements) test_Data_manager.set_num_controller(6) rho = test_Data_manager.create_constant_node_field("Density", Float64, 1) rho .= 2 - test = FEM.init_FEM(Dict(), test_Data_manager) + test = PeriLab.Solver.FEM.init_FEM(Dict(), test_Data_manager) @test isnothing(test) - test = FEM.init_FEM(Dict("FEM" => Dict()), test_Data_manager) + test = PeriLab.Solver.FEM.init_FEM(Dict("FEM" => Dict()), test_Data_manager) @test isnothing(test) test_Data_manager.set_dof(1) - test = FEM.init_FEM(Dict("FEM" => Dict("Degree" => 1)), test_Data_manager) + test = PeriLab.Solver.FEM.init_FEM(Dict("FEM" => Dict("Degree" => 1)), test_Data_manager) @test isnothing(test) - test = FEM.init_FEM(Dict("FEM" => Dict("Degree" => 4)), test_Data_manager) + test = PeriLab.Solver.FEM.init_FEM(Dict("FEM" => Dict("Degree" => 4)), test_Data_manager) @test isnothing(test) dof = 2 test_Data_manager.set_dof(dof) @@ -63,11 +63,11 @@ end test_Data_manager.init_property() params = Dict("FEM" => Dict("Degree" => 1, "Element Type" => "Lagrange", "Material Model" => "Elastic Model"), "Physics" => Dict("Material Models" => Dict("Not FEM name" => Dict("Material Model" => "Correspondence Elastic", "Symmetry" => "isotropic plane strain", "Young's Modulus" => 2.5e+3, "Poisson's Ratio" => 0.33, "Shear Modulus" => 2.0e3)))) - @test isnothing(FEM.init_FEM(params, test_Data_manager)) + @test isnothing(PeriLab.Solver.FEM.init_FEM(params, test_Data_manager)) params = Dict("FEM" => Dict("Degree" => 1, "Element Type" => "Lagrange", "Material Model" => "Elastic Model"), "Physics" => Dict("Material Models" => Dict("Elastic Model" => Dict("Material Model" => "Correspondence Elastic", "Symmetry" => "isotropic plane strain", "Young's Modulus" => 2.5e+3, "Poisson's Ratio" => 0.33, "Shear Modulus" => 2.0e3)))) - test_Data_manager = FEM.init_FEM(params, test_Data_manager) + test_Data_manager = PeriLab.Solver.FEM.init_FEM(params, test_Data_manager) @test "N Matrix" in test_Data_manager.get_all_field_keys() @test "B Matrix" in test_Data_manager.get_all_field_keys() @@ -92,11 +92,11 @@ end @test isapprox(lumped_mass[:, 2], [0.49999999999999994, 0.9999999999999998, 0.49999999999999994, 0.9999999999999998, 0.4999999999999999, 0.49999999999999994]) # only in tests for resize or redefinition reasons test_Data_manager.fields[Int64]["FE Topology"] = zeros(Int64, 1, 6) - @test isnothing(FEM.init_FEM(params, test_Data_manager)) + @test isnothing(PeriLab.Solver.FEM.init_FEM(params, test_Data_manager)) end @testset "ut_eval" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager dof = 2 test_Data_manager.set_dof(dof) test_Data_manager.set_num_elements(2) @@ -134,9 +134,9 @@ end params = Dict("FEM" => Dict("Degree" => 1, "Element Type" => "Lagrange", "Material Model" => "Elastic Model"), "Physics" => Dict("Material Models" => Dict("Elastic Model" => Dict("Material Model" => "Correspondence Elastic", "Symmetry" => "isotropic plane strain", "Young's Modulus" => 1.5, "Poisson's Ratio" => 0.33, "Shear Modulus" => 0.5639)))) - test_Data_manager = FEM.init_FEM(params, test_Data_manager) + test_Data_manager = PeriLab.Solver.FEM.init_FEM(params, test_Data_manager) elements = Vector{Int64}([1, 2]) - test_Data_manager = FEM.eval(test_Data_manager, elements, test_Data_manager.get_properties(1, "FEM"), 0.0, 1.0e-6) + test_Data_manager = PeriLab.Solver.FEM.eval(test_Data_manager, elements, test_Data_manager.get_properties(1, "FEM"), 0.0, 1.0e-6) stress = test_Data_manager.get_field("Element Stress", "NP1") strain = test_Data_manager.get_field("Element Strain", "NP1") @@ -162,7 +162,7 @@ end displacements[5, 2] = 0.5 displacements[6, 1] = 1 displacements[6, 2] = 0.5 - test_Data_manager = FEM.eval(test_Data_manager, elements, test_Data_manager.get_properties(1, "FEM"), 0.0, 1.0e-6) + test_Data_manager = PeriLab.Solver.FEM.eval(test_Data_manager, elements, test_Data_manager.get_properties(1, "FEM"), 0.0, 1.0e-6) stress = test_Data_manager.get_field("Element Stress", "NP1") strain = test_Data_manager.get_field("Element Strain", "NP1") @@ -180,9 +180,9 @@ end end @testset "ut_get_FEM_nodes" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager topology = test_Data_manager.get_field("FE Topology") - test_Data_manager = FEM.get_FEM_nodes(test_Data_manager, topology) + test_Data_manager = PeriLab.Solver.FEM.get_FEM_nodes(test_Data_manager, topology) @test "FE Nodes" in test_Data_manager.get_all_field_keys() fem_nodes = test_Data_manager.get_field("FE Nodes") for i in eachindex(fem_nodes) @@ -197,7 +197,7 @@ end topology[2, 2] = 5 topology[2, 3] = 3 topology[2, 4] = 4 - test_Data_manager = FEM.get_FEM_nodes(test_Data_manager, topology) + test_Data_manager = PeriLab.Solver.FEM.get_FEM_nodes(test_Data_manager, topology) @test fem_nodes[1] @test !fem_nodes[2] @test fem_nodes[3] diff --git a/test/unit_tests/FEM/ut_FEM_routines.jl b/test/unit_tests/FEM/ut_FEM_routines.jl index 1d1b687e5..fc3a64f3d 100644 --- a/test/unit_tests/FEM/ut_FEM_routines.jl +++ b/test/unit_tests/FEM/ut_FEM_routines.jl @@ -3,11 +3,11 @@ # SPDX-License-Identifier: BSD-3-Clause include("../../../src/FEM/FEM_routines.jl") include("../../../src/FEM/Element_formulation/lagrange_element.jl") -include("../../../src/Support/data_manager.jl") +# include("../../../src/Support/data_manager.jl") using Test @testset "ut_jacobi" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager dof = 2 nelements = 1 test_Data_manager.set_dof(dof) @@ -111,7 +111,7 @@ using Test end @testset "ut_lumped_mass" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager dof = 2 nelements = 1 test_Data_manager.set_dof(dof) diff --git a/test/unit_tests/IO/ut_IO.jl b/test/unit_tests/IO/ut_IO.jl index 7b930701c..11b286bc2 100644 --- a/test/unit_tests/IO/ut_IO.jl +++ b/test/unit_tests/IO/ut_IO.jl @@ -2,23 +2,26 @@ # # SPDX-License-Identifier: BSD-3-Clause +#TODO: Remove include include("../../../src/IO/IO.jl") -include("../../../src/Support/data_manager.jl") -include("../../../src/Support/Parameters/parameter_handling.jl") +# include("../../../src/Support/data_manager.jl") +# include("../../../src/Support/Parameters/parameter_handling.jl") using TimerOutputs -using Reexport -@reexport using .Parameter_Handling +# using Reexport +# @reexport using .Parameter_Handling using Test import .IO -@reexport using Exodus -@reexport using MPI -test_Data_manager = Data_manager +# @reexport using Exodus +# @reexport using MPI +test_Data_manager = PeriLab.Data_manager +test_Data_manager.clear_data_manager() filename1 = "test1" filename2 = "test2" dof = 2 nnodes = 5 comm = MPI.COMM_WORLD test_Data_manager.set_num_controller(nnodes) +test_Data_manager.set_num_responder(0) test_Data_manager.set_comm(comm) test_Data_manager.set_dof(dof) test_Data_manager.set_max_rank(1) @@ -83,7 +86,7 @@ end exo_coords = read_coordinates(exo["file"]) exo_nsets = read_sets(exo["file"], NodeSet) @test coords == exo_coords - @test exo_nsets == [] + # @test exo_nsets == [] end for i in 1:2 dofForce = 0 diff --git a/test/unit_tests/IO/ut_mesh_data.jl b/test/unit_tests/IO/ut_mesh_data.jl index 39807e66c..444f18808 100644 --- a/test/unit_tests/IO/ut_mesh_data.jl +++ b/test/unit_tests/IO/ut_mesh_data.jl @@ -2,28 +2,29 @@ # # SPDX-License-Identifier: BSD-3-Clause -include("../../../src/IO/IO.jl") -include("../../../src/Support/data_manager.jl") -include("../../../src/Support/Parameters/parameter_handling.jl") +include("../../../src/IO/mesh_data.jl") +# include("../../../src/IO/IO.jl") +# include("../../../src/Support/data_manager.jl") +# include("../../../src/Support/Parameters/parameter_handling.jl") using Test using TimerOutputs using Reexport -@reexport using .Parameter_Handling -@reexport using .Data_manager -@reexport using .IO +# @reexport using .Parameter_Handling +# @reexport using .Data_manager +# @reexport using .IO using DataFrames @testset "ut_read_mesh" begin params = Dict("Discretization" => Dict("Type" => "not supported")) - @test isnothing(IO.read_mesh("./", params)) + @test isnothing(read_mesh("./", params)) params = Dict("Discretization" => Dict("Type" => "Text File")) - @test isnothing(IO.read_mesh("./", params)) + @test isnothing(read_mesh("./", params)) path = "./unit_tests/IO/" - data = IO.read_mesh(joinpath(path, "example_mesh.txt"), params) + data = read_mesh(joinpath(path, "example_mesh.txt"), params) if isnothing(data) path = "./test/unit_tests/IO/" - data = IO.read_mesh(joinpath(path, "example_mesh.txt"), params) + data = read_mesh(joinpath(path, "example_mesh.txt"), params) end @test length(data[:, 1]) == 3 @test data[!, "x"] == [-1.5, -0.5, 0.5] @@ -31,8 +32,8 @@ using DataFrames @test data[!, "block_id"] == [1, 1, 2] @test data[!, "volume"] == [0.1, 0.1, 0.1] - @test isnothing(IO.read_external_topology("./")) - data = IO.read_external_topology(joinpath(path, "example_FE_mesh.txt")) + @test isnothing(read_external_topology("./")) + data = read_external_topology(joinpath(path, "example_FE_mesh.txt")) @test length(data[:, 1]) == 4 @test collect(skipmissing(data[1, :])) == [1, 2, 3, 4] @test collect(skipmissing(data[2, :])) == [3, 4, 5, 6] @@ -44,39 +45,39 @@ end @testset "ut_check_dataframe" begin path = "./unit_tests/IO/" params = Dict("Discretization" => Dict("Type" => "Text File")) - data = IO.read_mesh(joinpath(path, "example_mesh.txt"), params) - data_wrong = IO.read_mesh(joinpath(path, "example_wrong_mesh.txt"), params) + data = read_mesh(joinpath(path, "example_mesh.txt"), params) + data_wrong = read_mesh(joinpath(path, "example_wrong_mesh.txt"), params) if isnothing(data) path = "./test/unit_tests/IO/" - data = IO.read_mesh(joinpath(path, "example_mesh.txt"), params) - data_wrong = IO.read_mesh(joinpath(path, "example_wrong_mesh.txt"), params) + data = read_mesh(joinpath(path, "example_mesh.txt"), params) + data_wrong = read_mesh(joinpath(path, "example_wrong_mesh.txt"), params) end - @test IO.check_types_in_dataframe(data) + @test check_types_in_dataframe(data) @test !IO.check_types_in_dataframe(data_wrong) - @test !(IO.check_for_duplicate_in_dataframe(data)) + @test !(check_for_duplicate_in_dataframe(data)) data[1, :] = data[2, :] - @test IO.check_for_duplicate_in_dataframe(data) + @test check_for_duplicate_in_dataframe(data) data[1, :] = data[3, :] - @test IO.check_for_duplicate_in_dataframe(data) + @test check_for_duplicate_in_dataframe(data) data[2, :] = data[3, :] - @test IO.check_for_duplicate_in_dataframe(data) + @test check_for_duplicate_in_dataframe(data) end @testset "ut_create_consistent_neighborhoodlist" begin path = "./unit_tests/IO/" - external_topology = IO.read_external_topology(joinpath(path, "example_FE_mesh.txt")) + external_topology = read_external_topology(joinpath(path, "example_FE_mesh.txt")) if isnothing(external_topology) path = "./test/unit_tests/IO/" - external_topology = IO.read_external_topology(joinpath(path, "example_FE_mesh.txt")) + external_topology = read_external_topology(joinpath(path, "example_FE_mesh.txt")) end dof::Int64 = 2 params = Dict() nlist::Vector{Vector{Int64}} = [[2, 3, 4, 11], [1, 3, 4], [1, 2, 22, 23], [4], [8], [9], [1, 6], [3, 2], [10]] - nlist_test, topology, nodes_to_element = IO.create_consistent_neighborhoodlist(external_topology, params, nlist, dof) + nlist_test, topology, nodes_to_element = PeriLab.IO.create_consistent_neighborhoodlist(external_topology, params, nlist, dof) @test topology[1] == [1, 2, 3, 4] @test topology[2] == [3, 4, 5, 6] @@ -86,12 +87,12 @@ end @test nlist == [[2, 3, 4], [1, 3, 4, 5, 6, 7], [1, 2, 4, 5, 6, 7], [1, 2, 3, 5, 6, 7], [3, 4, 6, 2, 7, 8], [3, 4, 5, 2, 7, 8], [2, 3, 4, 5, 6, 8], [5, 6, 7], [10]] params = Dict("Add Neighbor Search" => false) nlist = [[2, 3, 4, 11], [1, 3, 4], [1, 2, 22, 23], [4], [8], [9], [1, 6], [3, 2], [10]] - nlist, topology, nodes_to_element = IO.create_consistent_neighborhoodlist(external_topology, params, nlist, dof) + nlist, topology, nodes_to_element = PeriLab.IO.create_consistent_neighborhoodlist(external_topology, params, nlist, dof) @test nlist == [[2, 3, 4], [1, 3, 4, 5, 6, 7], [1, 2, 4, 5, 6, 7], [1, 2, 3, 5, 6, 7], [3, 4, 6, 2, 7, 8], [3, 4, 5, 2, 7, 8], [2, 3, 4, 5, 6, 8], [5, 6, 7], [10]] params = Dict("Add Neighbor Search" => true) nlist = [[2, 3, 4, 11], [1, 3, 4], [1, 2, 22, 23], [4], [8], [9], [1, 6], [3, 2], [10]] - nlist, topology, nodes_to_element = IO.create_consistent_neighborhoodlist(external_topology, params, nlist, dof) + nlist, topology, nodes_to_element = PeriLab.IO.create_consistent_neighborhoodlist(external_topology, params, nlist, dof) @test topology[1] == [1, 2, 3, 4] @test topology[2] == [3, 4, 5, 6] @@ -107,18 +108,18 @@ end ptc::Vector{Int64} = zeros(8) ptc[:] .= 1 ranksize = 1 - element_distribution = IO.element_distribution(topology, ptc, ranksize) + element_distribution = PeriLab.IO.element_distribution(topology, ptc, ranksize) @test length(element_distribution) == 1 @test element_distribution[1] == [1, 2, 3] ptc[5:8] .= 2 ranksize = 2 - element_distribution = IO.element_distribution(topology, ptc, ranksize) + element_distribution = PeriLab.IO.element_distribution(topology, ptc, ranksize) @test length(element_distribution) == 2 @test element_distribution[1] == [1] @test element_distribution[2] == [2, 3] topology = Vector([[7, 8, 5, 6], [1, 2, 3, 4], [2, 4, 5, 6]]) - element_distribution = IO.element_distribution(topology, ptc, ranksize) + element_distribution = PeriLab.IO.element_distribution(topology, ptc, ranksize) @test length(element_distribution) == 2 @test element_distribution[1] == [2] @@ -127,10 +128,10 @@ end end @testset "ut_get_local_element_topology" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager topology::Vector{Vector{Int64}} = [[1, 2, 3, 4], [3, 4, 2, 1]] distribution::Vector{Vector{Int64}} = [[2, 3, 4, 1], [1, 2, 3, 4], [5, 6, 3, 2, 8, 1, 4]] - test_Data_manager = IO.get_local_element_topology(test_Data_manager, topology, distribution[1]) + test_Data_manager = get_local_element_topology(test_Data_manager, topology, distribution[1]) topo = test_Data_manager.get_field("FE Topology") @test topo[1, 1] == 4 @@ -141,7 +142,7 @@ end @test topo[2, 2] == 3 @test topo[2, 3] == 1 @test topo[2, 4] == 4 - test_Data_manager = IO.get_local_element_topology(test_Data_manager, topology, distribution[2]) + test_Data_manager = get_local_element_topology(test_Data_manager, topology, distribution[2]) topo = test_Data_manager.get_field("FE Topology") @test topo[1, 1] == 1 @test topo[1, 2] == 2 @@ -151,7 +152,7 @@ end @test topo[2, 2] == 4 @test topo[2, 3] == 2 @test topo[2, 4] == 1 - test_Data_manager = IO.get_local_element_topology(test_Data_manager, topology, distribution[3]) + test_Data_manager = get_local_element_topology(test_Data_manager, topology, distribution[3]) topo = test_Data_manager.get_field("FE Topology") @test topo[1, 1] == 6 @test topo[1, 2] == 4 @@ -162,7 +163,7 @@ end @test topo[2, 3] == 4 @test topo[2, 4] == 6 - test_Data_manager = IO.get_local_element_topology(test_Data_manager, Vector([Vector{Int64}([])]), distribution[3]) + test_Data_manager = get_local_element_topology(test_Data_manager, Vector([Vector{Int64}([])]), distribution[3]) # nothing happens, because no field is initialized topo = test_Data_manager.get_field("FE Topology") @test topo[1, 1] == 6 @@ -176,32 +177,32 @@ end topology = [[1, 2, 3, 4], [3, 4, 2, 1, 3]] - @test isnothing(IO.get_local_element_topology(test_Data_manager, topology, distribution[3])) + @test isnothing(get_local_element_topology(test_Data_manager, topology, distribution[3])) end @testset "ut_create_distribution" begin - distribution, point_to_core = IO.create_distribution(4, 1) + distribution, point_to_core = create_distribution(4, 1) @test length(distribution) == 1 @test distribution[1] == Int64[1, 2, 3, 4] @test point_to_core == Int64[1, 1, 1, 1] - distribution, point_to_core = IO.create_distribution(4, 2) + distribution, point_to_core = create_distribution(4, 2) @test length(distribution) == 2 @test distribution[1] == Int64[1, 2] @test distribution[2] == Int64[3, 4] @test point_to_core == Int64[1, 1, 2, 2] - distribution, point_to_core = IO.create_distribution(4, 3) + distribution, point_to_core = create_distribution(4, 3) @test length(distribution) == 3 @test distribution[1] == Int64[1] @test distribution[2] == Int64[2] @test distribution[3] == Int64[3, 4] @test point_to_core == Int64[1, 2, 3, 3] - distribution, point_to_core = IO.create_distribution(4, 4) + distribution, point_to_core = create_distribution(4, 4) @test length(distribution) == 4 @test distribution[1] == Int64[1] @test distribution[2] == Int64[2] @test distribution[3] == Int64[3] @test distribution[4] == Int64[4] @test point_to_core == Int64[1, 2, 3, 4] - distribution, point_to_core = IO.create_distribution(4, 5) + distribution, point_to_core = create_distribution(4, 5) @test isnothing(distribution) @test isnothing(point_to_core) @@ -210,16 +211,16 @@ end nlist[2] = [1, 3, 4] nlist[3] = [1, 2] nlist[4] = [2] - @test IO.create_distribution_node_based(4, nlist, 1) == IO.create_distribution(4, 1) - distribution, point_to_core = IO.create_distribution_node_based(4, nlist, 2) + @test create_distribution_node_based(4, nlist, 1) == create_distribution(4, 1) + distribution, point_to_core = create_distribution_node_based(4, nlist, 2) @test distribution[1] == Int64[1, 2] @test distribution[2] == Int64[3, 4] - distribution, point_to_core = IO.create_distribution_node_based(4, nlist, 3) + distribution, point_to_core = create_distribution_node_based(4, nlist, 3) @test distribution[1] == Int64[1] @test distribution[2] == Int64[2] @test distribution[3] == Int64[3, 4] - distribution, point_to_core = IO.create_distribution_neighbor_based(4, nlist, 2) + distribution, point_to_core = create_distribution_neighbor_based(4, nlist, 2) @test distribution[1] == Int64[1, 2] @test distribution[2] == Int64[3, 4] @test point_to_core == Int64[1, 1, 2, 2] @@ -228,7 +229,7 @@ end nlist[2] = [3, 4] nlist[3] = [2] nlist[4] = [1, 2] - distribution, point_to_core = IO.create_distribution_node_based(4, nlist, 2) + distribution, point_to_core = create_distribution_node_based(4, nlist, 2) @test distribution[1] == Int64[1, 4] @test distribution[2] == Int64[2, 3] @test point_to_core == Int64[1, 2, 2, 1] @@ -237,7 +238,7 @@ end @testset "ut_local_nodes_from_dict" begin glob_to_loc = Dict{Int64,Int64}(1 => 2, 2 => 4, 3 => 3, 4 => 1) global_nodes = Vector{Int64}(1:4) - test = IO.local_nodes_from_dict(glob_to_loc, global_nodes) + test = local_nodes_from_dict(glob_to_loc, global_nodes) @test test == [2, 4, 3, 1] end @testset "ut_check_mesh_elements" begin @@ -246,21 +247,21 @@ end "block_id" => [1, 1, 1] ) df = DataFrame(data) - @test isnothing(IO.check_mesh_elements(df, 2)) + @test isnothing(check_mesh_elements(df, 2)) data = Dict( "x" => [1.0, 1.1, 3], "y" => [25, 30, 22], "block_id" => [1, 1, 1] ) df = DataFrame(data) - @test isnothing(IO.check_mesh_elements(df, 2)) + @test isnothing(check_mesh_elements(df, 2)) data = Dict( "x" => [1.0, 1.1, 3], "y" => [25, 30, 22], "volume" => [1, 1, 1] ) df = DataFrame(data) - @test isnothing(IO.check_mesh_elements(df, 2)) + @test isnothing(check_mesh_elements(df, 2)) data = Dict( "x" => [1.0, 1.1, 3], @@ -271,7 +272,7 @@ end ) df = DataFrame(data) - meshInfoDict = IO.check_mesh_elements(df, 2) + meshInfoDict = check_mesh_elements(df, 2) @test haskey(meshInfoDict, "Coordinates") @test haskey(meshInfoDict, "Block_Id") @test haskey(meshInfoDict, "Volume") @@ -296,7 +297,7 @@ end "field" => [1.0, 3.3, 2.3] ) df = DataFrame(data) - meshInfoDict = IO.check_mesh_elements(df, 3) + meshInfoDict = check_mesh_elements(df, 3) @test meshInfoDict["Coordinates"]["Mesh ID"] == ["x", "y", "z"] @test meshInfoDict["Coordinates"]["Type"] == Int64 @test meshInfoDict["Block_Id"]["Mesh ID"] == ["block_id"] @@ -310,19 +311,19 @@ end end @testset "ut__init_overlap_map_" begin - overlap_map = IO._init_overlap_map_(1) + overlap_map = _init_overlap_map_(1) @test sort(collect(keys(overlap_map))) == [1] @test sort(collect(keys(overlap_map[1]))) == [] - overlap_map = IO._init_overlap_map_(2) + overlap_map = _init_overlap_map_(2) @test sort(collect(keys(overlap_map))) == [1, 2] @test sort(collect(keys(overlap_map[1]))) == [2] @test sort(collect(keys(overlap_map[2]))) == [1] - overlap_map = IO._init_overlap_map_(3) + overlap_map = _init_overlap_map_(3) @test sort(collect(keys(overlap_map))) == [1, 2, 3] @test sort(collect(keys(overlap_map[1]))) == [2, 3] @test sort(collect(keys(overlap_map[2]))) == [1, 3] @test sort(collect(keys(overlap_map[3]))) == [1, 2] - overlap_map = IO._init_overlap_map_(4) + overlap_map = _init_overlap_map_(4) @test sort(collect(keys(overlap_map))) == [1, 2, 3, 4] @test sort(collect(keys(overlap_map[1]))) == [2, 3, 4] @test sort(collect(keys(overlap_map[2]))) == [1, 3, 4] @@ -334,7 +335,7 @@ end distribution = Vector([Vector{Int64}([1, 2, 3]), Vector{Int64}([2, 3, 4]), Vector{Int64}([4, 1, 3])]) size::Int64 = 3 ptc = [1, 2, 2, 3] - overlap_map = IO.create_overlap_map(distribution, ptc, size) + overlap_map = create_overlap_map(distribution, ptc, size) @test overlap_map[1][2]["Responder"] == overlap_map[2][1]["Controller"] @test overlap_map[1][3]["Responder"] == overlap_map[3][1]["Controller"] @@ -364,7 +365,7 @@ end end @testset "ut_get_local_overlap_map" begin - overlap_map = IO._init_overlap_map_(3) + overlap_map = _init_overlap_map_(3) distribution = [[1, 2, 3], [2, 3, 4], [4, 1, 3]] overlap_map[1][2]["Responder"] = [] @@ -382,9 +383,9 @@ end overlap_map[3][2]["Responder"] = [4] overlap_map[3][2]["Controller"] = [3] - test_overlap_map = IO.get_local_overlap_map(overlap_map, distribution, 1) + test_overlap_map = get_local_overlap_map(overlap_map, distribution, 1) @test test_overlap_map == overlap_map - test_overlap_map = IO.get_local_overlap_map(overlap_map, distribution, 3) + test_overlap_map = get_local_overlap_map(overlap_map, distribution, 3) @test sort(test_overlap_map[1][2]["Responder"]) == [] @test sort(test_overlap_map[1][2]["Controller"]) == [2, 3] @@ -407,20 +408,20 @@ end nlist[i] = Vector{Int64}(collect(1:3*i*i-2)) end - lenNlist = IO.get_number_of_neighbornodes(nlist, false) + lenNlist = get_number_of_neighbornodes(nlist, false) for i in 1:4 @test lenNlist[i] == 3 * i * i - 2 end nlist[1] = [] - @test isnothing(IO.get_number_of_neighbornodes(nlist, false)) + @test isnothing(get_number_of_neighbornodes(nlist, false)) end @testset "ut_glob_to_loc" begin distribution = [1, 2, 3, 4, 5] - glob_to_loc = IO.glob_to_loc(distribution) + glob_to_loc = PeriLab.IO.glob_to_loc(distribution) len = length(distribution) #check trivial case of global and local are identical for id in 1:len @@ -429,7 +430,7 @@ end @test length(distribution) == length(glob_to_loc) # reverse -> glob_to_loc_to_glob distribution = [1, 4, 2, 5, 6] - glob_to_loc = IO.glob_to_loc(distribution) + glob_to_loc = PeriLab.IO.glob_to_loc(distribution) for id in 1:len @test distribution[id] == distribution[glob_to_loc[distribution[id]]] end @@ -440,9 +441,9 @@ end nsets_predef = Dict{String,Any}("Nset_2" => [11, 12, 13, 44, 125], "Nset_1" => [1, 2, 3, 4, 5, 6, 7]) - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager @test test_Data_manager.get_nnsets() == 0 - IO.define_nsets(nsets_predef, test_Data_manager) + define_nsets(nsets_predef, test_Data_manager) @test test_Data_manager.get_nnsets() == 2 nsets = test_Data_manager.get_nsets() @test nsets["Nset_1"] == [1, 2, 3, 4, 5, 6, 7] @@ -451,8 +452,9 @@ end end @testset "get_bond_geometry" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.set_num_controller(3) + test_Data_manager.set_num_responder(0) test_Data_manager.set_dof(2) lenNlist = test_Data_manager.create_constant_node_field("Number of Neighbors", Int64, 1) lenNlist[:] = [2, 2, 2] @@ -468,8 +470,12 @@ end coor[2, 2] = 0 coor[3, 1] = 0 coor[3, 2] = 1 - IO.get_bond_geometry(test_Data_manager) - undeformed_bond = test_Data_manager.get_field("Bond Geometry") + dof = test_Data_manager.get_dof() + nnodes = test_Data_manager.get_nnodes() + nlist = test_Data_manager.get_field("Neighborhoodlist") + coor = test_Data_manager.get_field("Coordinates") + undeformed_bond = test_Data_manager.create_constant_bond_field("Bond Geometry", Float64, dof + 1) + undeformed_bond = PeriLab.IO.Geometry.bond_geometry(Vector(1:nnodes), dof, nlist, coor, undeformed_bond) @test undeformed_bond[1][1, 1] == 1 @test undeformed_bond[1][1, 2] == 0 diff --git a/test/unit_tests/Physics/Additive/ut_Additive_Factory.jl b/test/unit_tests/Physics/Additive/ut_Additive_Factory.jl index 7ebdfa148..550c04b3a 100644 --- a/test/unit_tests/Physics/Additive/ut_Additive_Factory.jl +++ b/test/unit_tests/Physics/Additive/ut_Additive_Factory.jl @@ -3,7 +3,7 @@ # SPDX-License-Identifier: BSD-3-Clause include("../../../../src/Physics/Additive/Additive_Factory.jl") -include("../../../../src/Support/data_manager.jl") +# include("../../../../src/Support/data_manager.jl") using Test @@ -12,7 +12,8 @@ using .Additive @testset "init_additive_model_fields" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager + test_Data_manager.clear_data_manager() test_Data_manager.set_dof(3) test_Data_manager.set_num_controller(4) nn = test_Data_manager.create_constant_node_field("Number of Neighbors", Int64, 1) @@ -36,7 +37,7 @@ using .Additive end @testset "init_additive" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.properties[23] = Dict("Additive Model" => Dict("Additive Model" => "does not exist")) @test isnothing(Additive.init_additive_model(test_Data_manager, Vector{Int64}([1, 2, 3]), 23)) end \ No newline at end of file diff --git a/test/unit_tests/Physics/Corrosion/ut_Corrosion_Factory.jl b/test/unit_tests/Physics/Corrosion/ut_Corrosion_Factory.jl index e40fe373e..8a4c34ff5 100644 --- a/test/unit_tests/Physics/Corrosion/ut_Corrosion_Factory.jl +++ b/test/unit_tests/Physics/Corrosion/ut_Corrosion_Factory.jl @@ -3,7 +3,7 @@ # SPDX-License-Identifier: BSD-3-Clause include("../../../../src/Physics/Corrosion/Corrosion_Factory.jl") -include("../../../../src/Support/data_manager.jl") +# include("../../../../src/Support/data_manager.jl") using Test using .Corrosion @testset "test_empty" begin diff --git a/test/unit_tests/Physics/Damage/ut_Damage_Factory.jl b/test/unit_tests/Physics/Damage/ut_Damage_Factory.jl index 9ebc8f9cf..438e04a2d 100644 --- a/test/unit_tests/Physics/Damage/ut_Damage_Factory.jl +++ b/test/unit_tests/Physics/Damage/ut_Damage_Factory.jl @@ -3,12 +3,13 @@ # SPDX-License-Identifier: BSD-3-Clause include("../../../../src/Physics/Damage/Damage_Factory.jl") -include("../../../../src/Support/data_manager.jl") +# include("../../../../src/Support/data_manager.jl") using Test using .Damage @testset "init_damage_model_fields" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager + test_Data_manager.clear_data_manager() test_Data_manager.set_dof(3) test_Data_manager.set_num_controller(4) nn = test_Data_manager.create_constant_node_field("Number of Neighbors", Int64, 1) @@ -28,7 +29,7 @@ using .Damage end @testset "damage_index" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.set_num_controller(3) nn = test_Data_manager.create_constant_node_field("Number of Neighbors", Int64, 1) nn[1] = 1 @@ -82,7 +83,7 @@ end @test damageNP1_test[3] == 1 end @testset "set_bond_damage" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.set_num_controller(3) nn = test_Data_manager.create_constant_node_field("Number of Neighbors", Int64, 1) nn[1] = 1 @@ -110,7 +111,7 @@ end end end @testset "ut_Damage_factory_exceptions" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.properties[1] = Dict("Damage Model" => Dict("Damage Model" => "not there")) @test isnothing(Damage.init_damage_model(test_Data_manager, Vector{Int64}(1:3), 1)) end \ No newline at end of file diff --git a/test/unit_tests/Physics/Damage/ut_Energy_release.jl b/test/unit_tests/Physics/Damage/ut_Energy_release.jl index 3f20df661..872067408 100644 --- a/test/unit_tests/Physics/Damage/ut_Energy_release.jl +++ b/test/unit_tests/Physics/Damage/ut_Energy_release.jl @@ -3,7 +3,7 @@ # SPDX-License-Identifier: BSD-3-Clause include("../../../../src/Physics/Damage/Energy_release.jl") -include("../../../../src/Support/data_manager.jl") +# include("../../../../src/Support/data_manager.jl") using Test using .Critical_Energy_Model @testset "get_quad_horizon" begin diff --git a/test/unit_tests/Physics/Material/Material_Models/BondBased/ut_Bondbased_Elastic.jl b/test/unit_tests/Physics/Material/Material_Models/BondBased/ut_Bondbased_Elastic.jl index 44f217f6f..ae87cb17b 100644 --- a/test/unit_tests/Physics/Material/Material_Models/BondBased/ut_Bondbased_Elastic.jl +++ b/test/unit_tests/Physics/Material/Material_Models/BondBased/ut_Bondbased_Elastic.jl @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: BSD-3-Clause include("../../../../../../src/Physics/Material/BondBased/Bondbased_Elastic.jl") -include("../../../../../../src/Support/data_manager.jl") +# include("../../../../../../src/Support/data_manager.jl") using .Bondbased_Elastic using Test @@ -15,7 +15,7 @@ const to = TimerOutput() end @testset "compute_forces" begin nodes = 2 - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.set_num_controller(nodes) dof = 3 test_Data_manager.set_dof(dof) diff --git a/test/unit_tests/Physics/Material/Material_Models/ut_Correspondence.jl b/test/unit_tests/Physics/Material/Material_Models/ut_Correspondence.jl index 935294524..cc157e583 100644 --- a/test/unit_tests/Physics/Material/Material_Models/ut_Correspondence.jl +++ b/test/unit_tests/Physics/Material/Material_Models/ut_Correspondence.jl @@ -3,13 +3,13 @@ # SPDX-License-Identifier: BSD-3-Clause include("../../../../../src/Physics/Material/Material_Models/Correspondence.jl") -include("../../../../../src/Support/data_manager.jl") +# include("../../../../../src/Support/data_manager.jl") using Test using .Correspondence @testset "zero_energy_mode_compensation_exception" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager nnodes = 2 test_Data_manager.set_num_controller(nnodes) nn = test_Data_manager.create_constant_node_field("Number of Neighbors", Int64, 1) diff --git a/test/unit_tests/Physics/Material/Material_Models/ut_Correspondence_UMAT.jl b/test/unit_tests/Physics/Material/Material_Models/ut_Correspondence_UMAT.jl index 9843b8b2f..3cd65bc2c 100644 --- a/test/unit_tests/Physics/Material/Material_Models/ut_Correspondence_UMAT.jl +++ b/test/unit_tests/Physics/Material/Material_Models/ut_Correspondence_UMAT.jl @@ -3,15 +3,14 @@ # 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") +# 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 = PeriLab.Data_manager test_Data_manager.set_num_controller(nodes) dof = 3 test_Data_manager.set_dof(dof) diff --git a/test/unit_tests/Physics/Material/Material_Models/ut_PD_Solid_Plastic.jl b/test/unit_tests/Physics/Material/Material_Models/ut_PD_Solid_Plastic.jl index 2f7011f80..12809068e 100644 --- a/test/unit_tests/Physics/Material/Material_Models/ut_PD_Solid_Plastic.jl +++ b/test/unit_tests/Physics/Material/Material_Models/ut_PD_Solid_Plastic.jl @@ -3,7 +3,6 @@ # SPDX-License-Identifier: BSD-3-Clause using Test include("../../../../../src/Physics/Material/Material_Models/PD_Solid_Plastic.jl") -include("../../../../../src/Support/data_manager.jl") @testset "get_name&fe_support" begin diff --git a/test/unit_tests/Physics/Material/ut_Material_Factory.jl b/test/unit_tests/Physics/Material/ut_Material_Factory.jl index 243311180..9013bda75 100644 --- a/test/unit_tests/Physics/Material/ut_Material_Factory.jl +++ b/test/unit_tests/Physics/Material/ut_Material_Factory.jl @@ -3,13 +3,14 @@ # SPDX-License-Identifier: BSD-3-Clause include("../../../../src/Physics/Material/Material_Factory.jl") -include("../../../../src/Support/data_manager.jl") +# include("../../../../src/Support/data_manager.jl") include("../../../../src/Support/Parameters/parameter_handling.jl") using Test import .Material @testset "ut_init_material_model_fields" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager + test_Data_manager.clear_data_manager() test_Data_manager.set_dof(3) test_Data_manager.set_num_controller(4) test_Data_manager.create_constant_node_field("Coordinates", Float64, 3) diff --git a/test/unit_tests/Physics/Thermal/ut_Heat_transfer.jl b/test/unit_tests/Physics/Thermal/ut_Heat_transfer.jl index 9a9d4c2fa..8f1a855dd 100644 --- a/test/unit_tests/Physics/Thermal/ut_Heat_transfer.jl +++ b/test/unit_tests/Physics/Thermal/ut_Heat_transfer.jl @@ -6,7 +6,7 @@ using Test include("../../../../src/Physics/Thermal/heat_transfer.jl") using .Heat_transfer -include("../../../../src/Support/data_manager.jl") +# include("../../../../src/Support/data_manager.jl") @test Heat_transfer.thermal_model_name() == "Heat Transfer" @@ -14,7 +14,8 @@ include("../../../../src/Support/data_manager.jl") nnodes = 10 dof = 2 nodes = Vector{Int64}(1:nnodes) - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager + test_Data_manager.clear_data_manager() test_Data_manager.set_num_controller(nnodes) test_Data_manager.set_dof(dof) nn = test_Data_manager.create_constant_node_field("Number of Neighbors", Int64, 1) diff --git a/test/unit_tests/Physics/Thermal/ut_Thermal_Factory.jl b/test/unit_tests/Physics/Thermal/ut_Thermal_Factory.jl index d96be4e50..13d482920 100644 --- a/test/unit_tests/Physics/Thermal/ut_Thermal_Factory.jl +++ b/test/unit_tests/Physics/Thermal/ut_Thermal_Factory.jl @@ -5,11 +5,12 @@ using Test include("../../../../src/Physics/Thermal/Thermal_Factory.jl") using .Thermal -include("../../../../src/Support/data_manager.jl") +# include("../../../../src/Support/data_manager.jl") @testset "init_thermal_model_fields" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager + test_Data_manager.clear_data_manager() test_Data_manager.set_dof(3) test_Data_manager.set_num_controller(4) nn = test_Data_manager.create_constant_node_field("Number of Neighbors", Int64, 1) @@ -33,7 +34,7 @@ end nnodes = 2 nodes = Vector{Int64}(1:nnodes) dof = 2 - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.set_num_controller(2) nn = test_Data_manager.create_constant_node_field("Number of Neighbors", Int64, 1) volume = test_Data_manager.create_constant_node_field("Volume", Float64, 1) diff --git a/test/unit_tests/Physics/Thermal/ut_Thermal_expansion.jl b/test/unit_tests/Physics/Thermal/ut_Thermal_expansion.jl index 04d1573a1..d971216e4 100644 --- a/test/unit_tests/Physics/Thermal/ut_Thermal_expansion.jl +++ b/test/unit_tests/Physics/Thermal/ut_Thermal_expansion.jl @@ -6,7 +6,7 @@ using Test include("../../../../src/Physics/Thermal/thermal_expansion.jl") using .Thermal_expansion -include("../../../../src/Support/data_manager.jl") +# include("../../../../src/Support/data_manager.jl") @test Thermal_expansion.thermal_model_name() == "Thermal Expansion" @@ -36,7 +36,8 @@ end @testset "ut_thermal_deformation" begin nnodes = 2 dof = 2 - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager + test_Data_manager.clear_data_manager() test_Data_manager.set_num_controller(2) nn = test_Data_manager.create_constant_node_field("Number of Neighbors", Int64, 1) nn[1] = 2 diff --git a/test/unit_tests/Physics/Thermal/ut_Thermal_flow.jl b/test/unit_tests/Physics/Thermal/ut_Thermal_flow.jl index 5e7f0e809..fcab55986 100644 --- a/test/unit_tests/Physics/Thermal/ut_Thermal_flow.jl +++ b/test/unit_tests/Physics/Thermal/ut_Thermal_flow.jl @@ -6,11 +6,11 @@ using Test include("../../../../src/Physics/Thermal/thermal_flow.jl") using .Thermal_Flow -include("../../../../src/Support/data_manager.jl") +# include("../../../../src/Support/data_manager.jl") @test Thermal_Flow.thermal_model_name() == "Thermal Flow" @testset "ut_compute_thermal_model" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager @test Thermal_Flow.compute_thermal_model(test_Data_manager, Vector{Int64}(1:3), Dict("a" => 1), 1.0, 1.0) == test_Data_manager end diff --git a/test/unit_tests/Physics/ut_Physics_Factory.jl b/test/unit_tests/Physics/ut_Physics_Factory.jl index 70d245bf8..639a31165 100644 --- a/test/unit_tests/Physics/ut_Physics_Factory.jl +++ b/test/unit_tests/Physics/ut_Physics_Factory.jl @@ -3,12 +3,13 @@ # SPDX-License-Identifier: BSD-3-Clause include("../../../src/Physics/Physics_Factory.jl") -include("../../../src/Support/data_manager.jl") +# include("../../../src/Support/data_manager.jl") include("../../../src/Support/Parameters/parameter_handling.jl") using Test import .Physics @testset "ut_get_block_model_definition" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager + test_Data_manager.clear_data_manager() block_list = [1, 2, 3] test_Data_manager.set_block_list(block_list) prop_keys = test_Data_manager.init_property() @@ -29,7 +30,7 @@ import .Physics end @testset "ut_read_properties" begin - test_Data_manager_read_properties = Data_manager + test_Data_manager_read_properties = PeriLab.Data_manager block_list = [1, 2, 3] test_Data_manager_read_properties.set_block_list(block_list) @@ -56,7 +57,7 @@ end end @testset "init_pre_calculation" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.set_dof(3) test_Data_manager.set_num_controller(4) nn = test_Data_manager.create_constant_node_field("Number of Neighbors", Int64, 1) diff --git a/test/unit_tests/Support/Parameters/ut_parameter_handling.jl b/test/unit_tests/Support/Parameters/ut_parameter_handling.jl index 45f11b633..149471edc 100644 --- a/test/unit_tests/Support/Parameters/ut_parameter_handling.jl +++ b/test/unit_tests/Support/Parameters/ut_parameter_handling.jl @@ -2,56 +2,56 @@ # # SPDX-License-Identifier: BSD-3-Clause -if !isdefined(@__MODULE__, :Data_manager) - include("../../../../src/Support/data_manager.jl") -end -include("../../../../src/Support/Parameters/parameter_handling.jl") -include("../../../../src/Support/helpers.jl") +# if !isdefined(@__MODULE__, :Data_manager) +# include("../../../../src/Support/data_manager.jl") +# end +# include("../../../../src/Support/Parameters/parameter_handling.jl") +# include("../../../../src/Support/helpers.jl") using Test using Random using Dierckx -using Reexport -@reexport using .Helpers -@reexport using .Parameter_Handling +# using Reexport +# @reexport using .Helpers +# @reexport using .Parameter_Handling @testset "ut_get_element_degree" begin - @test isnothing(get_element_degree(Dict())) - @test isnothing(get_element_degree(Dict("Degree" => "ABC"))) - @test isnothing(get_element_degree(Dict("Degree" => "1"))) - @test get_element_degree(Dict("Degree" => 1)) == 1 - @test get_element_degree(Dict("Degree" => [1, 2, 3])) == [1, 2, 3] - @test get_element_degree(Dict("Degree" => [1, 2, 3, 5])) == [1, 2, 3, 5] + @test isnothing(PeriLab.Solver.Parameter_Handling.get_element_degree(Dict())) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_element_degree(Dict("Degree" => "ABC"))) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_element_degree(Dict("Degree" => "1"))) + @test PeriLab.Solver.Parameter_Handling.get_element_degree(Dict("Degree" => 1)) == 1 + @test PeriLab.Solver.Parameter_Handling.get_element_degree(Dict("Degree" => [1, 2, 3])) == [1, 2, 3] + @test PeriLab.Solver.Parameter_Handling.get_element_degree(Dict("Degree" => [1, 2, 3, 5])) == [1, 2, 3, 5] end @testset "ut_get_element_type" begin - @test isnothing(get_element_type(Dict())) - @test get_element_type(Dict("Element Type" => "ABC")) == "ABC" - @test get_element_type(Dict("Element Type" => 12)) == "12" + @test isnothing(PeriLab.Solver.Parameter_Handling.get_element_type(Dict())) + @test PeriLab.Solver.Parameter_Handling.get_element_type(Dict("Element Type" => "ABC")) == "ABC" + @test PeriLab.Solver.Parameter_Handling.get_element_type(Dict("Element Type" => 12)) == "12" end @testset "ut_get_output_type" begin - @test get_output_type(Dict("Output1" => Dict()), "Output1") == "Exodus" - @test get_output_type(Dict("Output1" => Dict("Output File Type" => "CSV")), "Output1") == "CSV" - @test get_output_type(Dict("Output1" => Dict("Output File Type" => "Exodus"), "Output2" => Dict("Output File Type" => "CSV")), "Output1") == "Exodus" - @test get_output_type(Dict("Output1" => Dict("Output File Type" => "Exodus"), "Output2" => Dict("Output File Type" => "CSV")), "Output2") == "CSV" - @test get_output_type(Dict("Output1" => Dict("Output File Type" => "CSV"), "Output2" => Dict()), "Output2") == "Exodus" - @test get_output_type(Dict("Output1" => Dict("Output File Type" => "Exodus")), "Output1") == "Exodus" + @test PeriLab.Solver.Parameter_Handling.get_output_type(Dict("Output1" => Dict()), "Output1") == "Exodus" + @test PeriLab.Solver.Parameter_Handling.get_output_type(Dict("Output1" => Dict("Output File Type" => "CSV")), "Output1") == "CSV" + @test PeriLab.Solver.Parameter_Handling.get_output_type(Dict("Output1" => Dict("Output File Type" => "Exodus"), "Output2" => Dict("Output File Type" => "CSV")), "Output1") == "Exodus" + @test PeriLab.Solver.Parameter_Handling.get_output_type(Dict("Output1" => Dict("Output File Type" => "Exodus"), "Output2" => Dict("Output File Type" => "CSV")), "Output2") == "CSV" + @test PeriLab.Solver.Parameter_Handling.get_output_type(Dict("Output1" => Dict("Output File Type" => "CSV"), "Output2" => Dict()), "Output2") == "Exodus" + @test PeriLab.Solver.Parameter_Handling.get_output_type(Dict("Output1" => Dict("Output File Type" => "Exodus")), "Output1") == "Exodus" end @testset "ut_get_bond_filters" begin params = Dict("Discretization" => Dict()) - check, bfList = get_bond_filters(params) + check, bfList = PeriLab.Solver.Parameter_Handling.get_bond_filters(params) @test !check @test bfList == Dict{String,Dict{String,Any}}() params = Dict("Discretization" => Dict("Bond Filters" => Dict())) - check, bfList = get_bond_filters(params) + check, bfList = PeriLab.Solver.Parameter_Handling.get_bond_filters(params) @test check @test bfList == Dict() params = Dict("Discretization" => Dict("Bond Filters" => Dict("a" => Dict("a" => 1)))) - check, bfList = get_bond_filters(params) + check, bfList = PeriLab.Solver.Parameter_Handling.get_bond_filters(params) @test check @test bfList == Dict("a" => Dict("a" => 1)) params = Dict("Discretization" => Dict("Bond Filters" => Dict("a" => Dict("a" => 1), "g" => Dict("a" => 1), "adas" => Dict("a" => 1)))) - check, bfList = get_bond_filters(params) + check, bfList = PeriLab.Solver.Parameter_Handling.get_bond_filters(params) @test check @test bfList == Dict("a" => Dict("a" => 1), "g" => Dict("a" => 1), "adas" => Dict("a" => 1)) end @@ -62,7 +62,7 @@ end lenNumbers = length(numbers) params = Dict("Discretization" => Dict()) - @test get_node_sets(params, "") == Dict{String,Any}() + @test PeriLab.Solver.Parameter_Handling.get_node_sets(params, "") == Dict{String,Any}() params = Dict("Discretization" => Dict("Node Sets" => Dict("Nset_1" => "1 2 3 4 5 6 7", "Nset_2" => filename))) file = open(filename, "w") @@ -72,7 +72,7 @@ end end close(file) - nsets = get_node_sets(params, "") + nsets = PeriLab.Solver.Parameter_Handling.get_node_sets(params, "") @test "Nset_1" in keys(nsets) @test "Nset_2" in keys(nsets) @test length(nsets["Nset_1"]) == 7 @@ -89,14 +89,14 @@ end file = open(filename, "w") println(file, "header: global_id") close(file) - nsets = get_node_sets(params, "") + nsets = PeriLab.Solver.Parameter_Handling.get_node_sets(params, "") @test haskey(nsets, "Nset_1") @test !haskey(nsets, "Nset_2") rm(filename) filename = "test.txt" file = open(filename, "w") close(file) - nsets = get_node_sets(params, "") + nsets = PeriLab.Solver.Parameter_Handling.get_node_sets(params, "") @test haskey(nsets, "Nset_1") @test !haskey(nsets, "Nset_2") rm(filename) @@ -114,64 +114,64 @@ end params = Dict("Discretization" => Dict("Type" => "Text File")) computes = Dict("Node Setas" => 12) - @test [] == get_node_set(computes, "", params) + @test [] == PeriLab.Solver.Parameter_Handling.get_node_set(computes, "", params) computes = Dict("Node Set" => 12) - @test [12] == get_node_set(computes, "", params) + @test [12] == PeriLab.Solver.Parameter_Handling.get_node_set(computes, "", params) computes = Dict("Node Set" => filename) - @test [11, 12, 13, 44, 125] == get_node_set(computes, "", params) + @test [11, 12, 13, 44, 125] == PeriLab.Solver.Parameter_Handling.get_node_set(computes, "", params) computes = Dict("Node Set" => "13 44 125") - @test [13, 44, 125] == get_node_set(computes, "", params) + @test [13, 44, 125] == PeriLab.Solver.Parameter_Handling.get_node_set(computes, "", params) rm(filename) end @testset "ut_validate_yaml" begin params = Dict{Any,Any}() @info "Error messages are tested and therefore okay." - @test isnothing(validate_yaml(params)) + @test isnothing(PeriLab.Solver.Parameter_Handling.validate_yaml(params)) params = Dict{Any,Any}("PeriLab" => Dict{Any,Any}("Physics" => Dict{Any,Any}())) - @test isnothing(validate_yaml(params)) + @test isnothing(PeriLab.Solver.Parameter_Handling.validate_yaml(params)) params = Dict{Any,Any}("PeriLab" => Dict{Any,Any}("Physics" => Dict{Any,Any}("Material Models" => Dict{Any,Any}()), "Discretization" => Dict{Any,Any}())) - @test isnothing(validate_yaml(params)) + @test isnothing(PeriLab.Solver.Parameter_Handling.validate_yaml(params)) params = Dict{Any,Any}("PeriLab" => Dict{Any,Any}("Physics" => Dict{Any,Any}("Material Models" => Dict{Any,Any}()), "Discretization" => Dict{Any,Any}(), "Blocks" => Dict{Any,Any}())) - @test isnothing(validate_yaml(params)) + @test isnothing(PeriLab.Solver.Parameter_Handling.validate_yaml(params)) params = Dict{Any,Any}("PeriLab" => Dict{Any,Any}("Physics" => Dict{Any,Any}("Material Models" => Dict{Any,Any}()), "Blocks" => Dict{Any,Any}())) - @test isnothing(validate_yaml(params)) + @test isnothing(PeriLab.Solver.Parameter_Handling.validate_yaml(params)) params = Dict{Any,Any}("PeriLab" => Dict{Any,Any}("Blocks" => Dict{Any,Any}())) - @test isnothing(validate_yaml(params)) + @test isnothing(PeriLab.Solver.Parameter_Handling.validate_yaml(params)) params = Dict{Any,Any}("PeriLab" => Dict{Any,Any}("Physics" => Dict{Any,Any}(), "Discretization" => Dict{Any,Any}(), "Blocks" => Dict{Any,Any}(), "Solver" => Dict{Any,Any}())) - @test isnothing(validate_yaml(params)) + @test isnothing(PeriLab.Solver.Parameter_Handling.validate_yaml(params)) params = Dict{Any,Any}("PeriLab" => Dict{Any,Any}("Physics" => Dict{Any,Any}("Material Models" => Dict{Any,Any}("mat_1" => Dict{Any,Any}("Material Model" => "a"))), "Discretization" => Dict{Any,Any}("Input Mesh File" => "test", "Type" => "test"), "Blocks" => Dict{Any,Any}("Block_1" => Dict{Any,Any}("Block Names" => "Block_1", "Density" => 1.0, "Horizon" => "1.0")), "Solver" => Dict{Any,Any}("Final Time" => 1.0, "Initial Time" => 0.0))) - @test isnothing(validate_yaml(params)) + @test isnothing(PeriLab.Solver.Parameter_Handling.validate_yaml(params)) params = Dict{Any,Any}("PeriLab" => Dict{Any,Any}("Physics" => Dict{Any,Any}("Material Models" => Dict{Any,Any}("mat_1" => Dict{Any,Any}("Material Model" => "a"))), "Discretization" => Dict{Any,Any}("Input Mesh File" => "test", "Type" => "test"), "Blocks" => Dict{Any,Any}("Block_1" => Dict{Any,Any}("Block Names" => "Block_1", "Density" => 1.0, "Horizon" => 1.0)), "Solver" => Dict{Any,Any}("Final Time" => 1.0, "Initial Time" => 0.0))) - @test validate_yaml(params) == params["PeriLab"] + @test PeriLab.Solver.Parameter_Handling.validate_yaml(params) == params["PeriLab"] end @testset "ut_get_external_topology_name" begin params = Dict("Discretization" => Dict()) - @test isnothing(get_external_topology_name(params)) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_external_topology_name(params)) params = Dict("Discretization" => Dict("Input External Topology" => Dict())) - @test isnothing(get_external_topology_name(params)) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_external_topology_name(params)) name = randstring(12) params = Dict("Discretization" => Dict("Input External Topology" => Dict("File" => name))) - @test get_external_topology_name(params) == name + @test PeriLab.Solver.Parameter_Handling.get_external_topology_name(params) == name end @testset "ut_get_mesh_name" begin params = Dict("Discretization" => Dict()) - @test get_mesh_name(params) === nothing + @test PeriLab.Solver.Parameter_Handling.get_mesh_name(params) === nothing name = randstring(12) params = Dict("Discretization" => Dict("Input Mesh File" => name)) - @test get_mesh_name(params) == name + @test PeriLab.Solver.Parameter_Handling.get_mesh_name(params) == name end @testset "ut_get_output_filenames" begin params = Dict() - filenames = get_output_filenames(params, "") + filenames = PeriLab.Solver.Parameter_Handling.get_output_filenames(params, "") @test filenames == [] params = Dict("Outputs" => Dict("Output1" => Dict("Output Filename" => "1"), "Output2" => Dict("Output Filename" => "2"))) - filenames = get_output_filenames(params, "") + filenames = PeriLab.Solver.Parameter_Handling.get_output_filenames(params, "") @test filenames[1] == "1.e" @test filenames[2] == "2.e" params = Dict("Outputs" => Dict("Output1" => Dict("Output Filename" => "3", "Output File Type" => "CSV"), "Output2" => Dict("Output Filename" => "4", "Output File Type" => "Exodus"))) - filenames = get_output_filenames(params, "test") + filenames = PeriLab.Solver.Parameter_Handling.get_output_filenames(params, "test") @test filenames[1] == "test/3.csv" @test filenames[2] == "test/4.e" end @@ -180,29 +180,29 @@ end nsteps = 40 params = Dict() params = Dict("Outputs" => Dict("Output1" => Dict("Output Frequency" => 2), "Output2" => Dict("Number of Output Steps" => 1, "Output Frequency" => 1))) - freq = get_output_frequency(params, nsteps) + freq = PeriLab.Solver.Parameter_Handling.get_output_frequency(params, nsteps) @test freq[1] == 2 @test freq[2] == 40 params = Dict("Outputs" => Dict("Output1" => Dict("Output Frequency" => 20), "Output2" => Dict("Number of Output Steps" => 10))) - freq = get_output_frequency(params, nsteps) + freq = PeriLab.Solver.Parameter_Handling.get_output_frequency(params, nsteps) @test freq[1] == 20 @test freq[2] == 4 nsteps = 1000 - freq = get_output_frequency(params, nsteps) + freq = PeriLab.Solver.Parameter_Handling.get_output_frequency(params, nsteps) @test freq[1] == 20 @test freq[2] == 100 nsteps = 2 - freq = get_output_frequency(params, nsteps) + freq = PeriLab.Solver.Parameter_Handling.get_output_frequency(params, nsteps) @test freq[1] == 2 @test freq[2] == 1 params = Dict("Outputs" => Dict("Output1" => Dict("Output Frequency" => 20, "Number of Output Steps" => 10), "Output2" => Dict("Number of Output Steps" => 10, "Output Frequency" => 20))) nsteps = 1000 - freq = get_output_frequency(params, nsteps) + freq = PeriLab.Solver.Parameter_Handling.get_output_frequency(params, nsteps) @test (freq[1] == 100) || (freq[1] == 20) @test (freq[2] == 100) || (freq[2] == 20) end -test_Data_manager = Data_manager +test_Data_manager = PeriLab.Data_manager @testset "ut_get_outputs" begin test_Data_manager.set_num_controller(5) test_Data_manager.create_constant_node_field("A", Float64, 1) @@ -215,7 +215,7 @@ test_Data_manager = Data_manager params = Dict("Outputs" => Dict("Output1" => Dict("fieldnames" => [], "Output Variables" => Dict("A" => true, "B" => false, "C" => true)), "Output2" => Dict("fieldnames" => [], "Output Variables" => Dict("A" => true, "B" => true, "D" => false, "E" => true, "M" => true)))) - outputs = get_outputs(params, testfield_keys, String[]) + outputs = PeriLab.Solver.Parameter_Handling.get_outputs(params, testfield_keys, String[]) @test "A" in outputs["Output1"]["fieldnames"] @test ("BNP1" in outputs["Output1"]["fieldnames"]) == false @@ -226,7 +226,7 @@ test_Data_manager = Data_manager @test "E" in outputs["Output2"]["fieldnames"] @test !("M" in outputs["Output2"]["fieldnames"]) params = Dict("Outputs" => Dict("Output1" => Dict("fieldnames" => [], "Output File Type" => "CSV", "Output Variables" => Dict("E" => true, "B" => false, "C" => true)), "Output2" => Dict("fieldnames" => [], "Output Variables" => Dict("A" => true, "B" => true, "D" => false, "E" => true, "M" => true)))) - outputs = get_outputs(params, testfield_keys, String["M"]) + outputs = PeriLab.Solver.Parameter_Handling.get_outputs(params, testfield_keys, String["M"]) @test !("A" in outputs["Output1"]["fieldnames"]) @test !("BNP1" in outputs["Output1"]["fieldnames"]) @test !("C" in outputs["Output1"]["fieldnames"]) @@ -235,25 +235,25 @@ test_Data_manager = Data_manager @test ("E" in outputs["Output2"]["fieldnames"]) @test ("M" in outputs["Output2"]["fieldnames"]) params = Dict("Outputs" => Dict("Output1" => Dict("fieldnames" => [], "Output File Type" => "CSV", "Output Variables" => Dict("M" => true, "A" => true)))) - outputs = get_outputs(params, testfield_keys, String["M"]) + outputs = PeriLab.Solver.Parameter_Handling.get_outputs(params, testfield_keys, String["M"]) @test !("A" in outputs["Output1"]["fieldnames"]) @test "M" in outputs["Output1"]["fieldnames"] params = Dict("Outputs" => Dict("Output1" => Dict("fieldnames" => [], "Output Variables" => Dict()))) - outputs = get_outputs(params, testfield_keys, String[]) + outputs = PeriLab.Solver.Parameter_Handling.get_outputs(params, testfield_keys, String[]) @test outputs["Output1"]["fieldnames"] == [] params = Dict("Outputs" => Dict("Output1" => Dict("fieldnames" => []))) - outputs = get_outputs(params, testfield_keys, String[]) + outputs = PeriLab.Solver.Parameter_Handling.get_outputs(params, testfield_keys, String[]) @test outputs["Output1"]["fieldnames"] == [] end @testset "ut_get_computes" begin params = Dict() testfield_keys = test_Data_manager.get_all_field_keys() - @test get_computes(params, testfield_keys) == Dict() + @test PeriLab.Solver.Parameter_Handling.get_computes(params, testfield_keys) == Dict() params = Dict("Compute Class Parameters" => Dict("External_Forces" => Dict("Compute Class" => "Block_Data", "Calculation Type" => "Sum", "Block" => "block_2", "Variable" => "A"), "External_Displacements" => Dict("Compute Class" => "Block_Data", "Calculation Type" => "Maximum", "Block" => "block_1", "Variable" => "B"), "warn_test" => Dict("Compute Class" => "Block_Data", "Calculation Type" => "Maximum", "Block" => "block_1"))) - computes = get_computes(params, testfield_keys) + computes = PeriLab.Solver.Parameter_Handling.get_computes(params, testfield_keys) @test haskey(computes, "External_Forces") @test haskey(computes, "External_Displacements") @@ -266,7 +266,7 @@ end params = Dict("Compute Class Parameters" => Dict("External_Forces" => Dict("Compute Class" => "Block_Data", "Calculation Type" => "Sum", "Block" => "block_2", "Variable" => "A"), "External_Displacements" => Dict("Compute Class" => "Block_Data", "Calculation Type" => "Maximum", "Block" => "block_1", "Variable" => "B"))) - computes_names = get_computes_names(params) + computes_names = PeriLab.Solver.Parameter_Handling.get_computes_names(params) @test "External_Forces" in computes_names @test "External_Displacements" in computes_names @@ -274,33 +274,33 @@ end @testset "ut_get_bc_definitions" begin params = Dict() - bcs = get_bc_definitions(params) + bcs = PeriLab.Solver.Parameter_Handling.get_bc_definitions(params) @test length(bcs) == 0 params = Dict("Boundary Conditions" => Dict()) - bcs = get_bc_definitions(params) + bcs = PeriLab.Solver.Parameter_Handling.get_bc_definitions(params) @test length(bcs) == 0 params = Dict("Boundary Conditions" => Dict("BC_1" => Dict("Type" => "Force", "Node Set" => "Nset_1", "Coordinate" => "x", "Value" => "20*t"), "BC_2" => Dict("Type" => "Displacement", "Node Set" => "Nset_2", "Coordinate" => "y", "Value" => "0"))) - bcs = get_bc_definitions(params) + bcs = PeriLab.Solver.Parameter_Handling.get_bc_definitions(params) @test length(bcs) == 2 @test bcs["BC_1"] == Dict("Type" => "Force", "Node Set" => "Nset_1", "Coordinate" => "x", "Value" => "20*t") @test bcs["BC_2"] == Dict("Type" => "Displacement", "Node Set" => "Nset_2", "Coordinate" => "y", "Value" => "0") end @testset "ut_get_solver_options" begin params = Dict("Solver" => Dict("Material Models" => true, "Damage Models" => true, "Additive Models" => true, "Thermal Models" => true)) - solver_options = get_solver_options(params) + solver_options = PeriLab.Solver.Parameter_Handling.get_solver_options(params) @test solver_options["Additive Models"] @test solver_options["Damage Models"] @test solver_options["Material Models"] @test solver_options["Thermal Models"] params = Dict("Solver" => Dict()) - solver_options = get_solver_options(params) + solver_options = PeriLab.Solver.Parameter_Handling.get_solver_options(params) @test solver_options["Additive Models"] == false @test solver_options["Damage Models"] == false @test solver_options["Material Models"] @test solver_options["Thermal Models"] == false params = Dict("Solver" => Dict("Material Models" => false, "Damage Models" => true, "Thermal Models" => true)) - solver_options = get_solver_options(params) + solver_options = PeriLab.Solver.Parameter_Handling.get_solver_options(params) @test solver_options["Additive Models"] == false @test solver_options["Damage Models"] @test solver_options["Material Models"] == false @@ -308,76 +308,76 @@ end end @testset "ut_get_number_of_blocks" begin - @test isnothing(get_number_of_blocks(Dict())) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_number_of_blocks(Dict())) params = Dict("Blocks" => Dict()) - @test isnothing(get_number_of_blocks(params)) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_number_of_blocks(params)) params = Dict("Blocks" => Dict("block_1" => Dict(), "block_2" => Dict())) - @test get_number_of_blocks(params) == 2 + @test PeriLab.Solver.Parameter_Handling.get_number_of_blocks(params) == 2 params = Dict("Blocks" => Dict("block_1" => Dict(), "block_2" => Dict(), "block_3" => Dict())) - @test get_number_of_blocks(params) == 3 + @test PeriLab.Solver.Parameter_Handling.get_number_of_blocks(params) == 3 params = Dict("Blocks" => Dict("block_1" => Dict(), "block_2" => Dict(), "block_3" => Dict(), "block_4" => Dict())) - @test get_number_of_blocks(params) == 4 + @test PeriLab.Solver.Parameter_Handling.get_number_of_blocks(params) == 4 end @testset "ut_block_values" begin params = Dict("Blocks" => Dict()) - @test isnothing(get_horizon(params, 1)) - @test isnothing(get_density(params, 1)) - @test isnothing(get_heat_capacity(params, 1)) - @test isnothing(get_values(params, 1, "Density")) - @test isnothing(get_values(params, 1, "not there")) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_horizon(params, 1)) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_density(params, 1)) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_heat_capacity(params, 1)) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_values(params, 1, "Density")) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_values(params, 1, "not there")) params = Dict("Blocks" => Dict("block_1" => Dict(), "block_2" => Dict())) - @test isnothing(get_horizon(params, 1)) - @test isnothing(get_density(params, 1)) - @test isnothing(get_heat_capacity(params, 1)) - @test isnothing(get_values(params, 1, "Density")) - @test isnothing(get_horizon(params, 2)) - @test isnothing(get_density(params, 2)) - @test isnothing(get_heat_capacity(params, 2)) - @test isnothing(get_values(params, 2, "Density")) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_horizon(params, 1)) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_density(params, 1)) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_heat_capacity(params, 1)) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_values(params, 1, "Density")) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_horizon(params, 2)) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_density(params, 2)) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_heat_capacity(params, 2)) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_values(params, 2, "Density")) params = Dict("Blocks" => Dict("block_1" => Dict("Density" => 1, "Specific Heat Capacity" => 3), "block_2" => Dict("Density" => 12.3, "Horizon" => 2))) - @test get_values(params, 1, "Density") == 1 - @test get_values(params, 2, "Density") == 12.3 - @test isnothing(get_values(params, 3, "Density")) - @test get_values(params, 1, "Specific Heat Capacity") == 3 - @test isnothing(get_values(params, 2, "Specific Heat Capacity")) - @test isnothing(get_values(params, 3, "Specific Heat Capacity")) - @test isnothing(get_values(params, 1, "Horizon")) - @test get_values(params, 2, "Horizon") == 2 - @test isnothing(get_values(params, 3, "Horizon")) - @test get_values(params, 1, "Density") == get_density(params, 1) - @test get_values(params, 2, "Density") == get_density(params, 2) - @test get_values(params, 3, "Density") == get_density(params, 3) - - @test get_values(params, 1, "Horizon") == get_horizon(params, 1) - @test get_values(params, 2, "Horizon") == get_horizon(params, 2) - @test get_values(params, 3, "Horizon") == get_horizon(params, 3) - - @test get_values(params, 1, "Specific Heat Capacity") == get_heat_capacity(params, 1) - @test get_values(params, 2, "Specific Heat Capacity") == get_heat_capacity(params, 2) - @test get_values(params, 3, "Specific Heat Capacity") == get_heat_capacity(params, 3) + @test PeriLab.Solver.Parameter_Handling.get_values(params, 1, "Density") == 1 + @test PeriLab.Solver.Parameter_Handling.get_values(params, 2, "Density") == 12.3 + @test isnothing(PeriLab.Solver.Parameter_Handling.get_values(params, 3, "Density")) + @test PeriLab.Solver.Parameter_Handling.get_values(params, 1, "Specific Heat Capacity") == 3 + @test isnothing(PeriLab.Solver.Parameter_Handling.get_values(params, 2, "Specific Heat Capacity")) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_values(params, 3, "Specific Heat Capacity")) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_values(params, 1, "Horizon")) + @test PeriLab.Solver.Parameter_Handling.get_values(params, 2, "Horizon") == 2 + @test isnothing(PeriLab.Solver.Parameter_Handling.get_values(params, 3, "Horizon")) + @test PeriLab.Solver.Parameter_Handling.get_values(params, 1, "Density") == PeriLab.Solver.Parameter_Handling.get_density(params, 1) + @test PeriLab.Solver.Parameter_Handling.get_values(params, 2, "Density") == PeriLab.Solver.Parameter_Handling.get_density(params, 2) + @test PeriLab.Solver.Parameter_Handling.get_values(params, 3, "Density") == PeriLab.Solver.Parameter_Handling.get_density(params, 3) + + @test PeriLab.Solver.Parameter_Handling.get_values(params, 1, "Horizon") == PeriLab.Solver.Parameter_Handling.get_horizon(params, 1) + @test PeriLab.Solver.Parameter_Handling.get_values(params, 2, "Horizon") == PeriLab.Solver.Parameter_Handling.get_horizon(params, 2) + @test PeriLab.Solver.Parameter_Handling.get_values(params, 3, "Horizon") == PeriLab.Solver.Parameter_Handling.get_horizon(params, 3) + + @test PeriLab.Solver.Parameter_Handling.get_values(params, 1, "Specific Heat Capacity") == PeriLab.Solver.Parameter_Handling.get_heat_capacity(params, 1) + @test PeriLab.Solver.Parameter_Handling.get_values(params, 2, "Specific Heat Capacity") == PeriLab.Solver.Parameter_Handling.get_heat_capacity(params, 2) + @test PeriLab.Solver.Parameter_Handling.get_values(params, 3, "Specific Heat Capacity") == PeriLab.Solver.Parameter_Handling.get_heat_capacity(params, 3) end @testset "ut_solver" begin params = Dict("Solver" => Dict("Initial Time" => 0.0, "Final Time" => 1.0, "Verlet" => Dict("Safety Factor" => 0.95, "Fixed dt" => 1e-3), "Numerical Damping" => 5e-6)) - @test get_solver_name(params) == "Verlet" - @test get_final_time(params) == params["Solver"]["Final Time"] - @test get_initial_time(params) == params["Solver"]["Initial Time"] - @test get_safety_factor(params) == params["Solver"]["Verlet"]["Safety Factor"] - @test get_fixed_dt(params) == params["Solver"]["Verlet"]["Fixed dt"] - @test get_numerical_damping(params) == params["Solver"]["Numerical Damping"] + @test PeriLab.Solver.Parameter_Handling.get_solver_name(params) == "Verlet" + @test PeriLab.Solver.Parameter_Handling.get_final_time(params) == params["Solver"]["Final Time"] + @test PeriLab.Solver.Parameter_Handling.get_initial_time(params) == params["Solver"]["Initial Time"] + @test PeriLab.Solver.Parameter_Handling.get_safety_factor(params) == params["Solver"]["Verlet"]["Safety Factor"] + @test PeriLab.Solver.Parameter_Handling.get_fixed_dt(params) == params["Solver"]["Verlet"]["Fixed dt"] + @test PeriLab.Solver.Parameter_Handling.get_numerical_damping(params) == params["Solver"]["Numerical Damping"] params = Dict("Solver" => Dict("Verlet" => Dict())) - @test get_safety_factor(params) == 1 - @test get_fixed_dt(params) == -1.0 - @test get_nsteps(params) == 1 - @test get_nsteps(Dict("Solver" => Dict("Verlet" => Dict("Safety Factor" => 0.95, "Number of Steps" => 6), "Numerical Damping" => 5e-6))) == 6 - @test get_numerical_damping(params) == 0.0 - @test isnothing(get_initial_time(Dict("Solver" => Dict()))) - @test isnothing(get_final_time(Dict("Solver" => Dict()))) - @test isnothing(get_final_time(Dict("Solver" => Dict()))) - @test isnothing(get_solver_name(Dict("Solver" => Dict("Solvername" => Dict())))) + @test PeriLab.Solver.Parameter_Handling.get_safety_factor(params) == 1 + @test PeriLab.Solver.Parameter_Handling.get_fixed_dt(params) == -1.0 + @test PeriLab.Solver.Parameter_Handling.get_nsteps(params) == 1 + @test PeriLab.Solver.Parameter_Handling.get_nsteps(Dict("Solver" => Dict("Verlet" => Dict("Safety Factor" => 0.95, "Number of Steps" => 6), "Numerical Damping" => 5e-6))) == 6 + @test PeriLab.Solver.Parameter_Handling.get_numerical_damping(params) == 0.0 + @test isnothing(PeriLab.Solver.Parameter_Handling.get_initial_time(Dict("Solver" => Dict()))) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_final_time(Dict("Solver" => Dict()))) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_final_time(Dict("Solver" => Dict()))) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_solver_name(Dict("Solver" => Dict("Solvername" => Dict())))) params = Dict("Solver" => Dict("Initial Time" => 0.0, "Final Time" => 1.0, "External" => Dict("Safety Factor" => 0.95, "Fixed dt" => 1e-3), "Numerical Damping" => 5e-6)) - @test get_solver_name(params) == "External" + @test PeriLab.Solver.Parameter_Handling.get_solver_name(params) == "External" end path = "./test/unit_tests/Support/Parameters/" @@ -387,26 +387,26 @@ end params = Dict("Physics" => Dict("Material Models" => Dict("A" => Dict("s" => 0, "d" => true, "test_file" => path * "test_data_file.txt", "test_file_2" => path * "test_data_file.txt"), "B" => Dict("sa" => [3.2, 2, 3], "d" => "true", "test_file_B" => path * "test_data_file.txt")), "Damage Models" => Dict("E" => Dict("ss" => 0, "d" => 1.1))), "Blocks" => Dict("block_1" => Dict("Material Model" => "A", "Damage Model" => "E"), "block_2" => Dict("Material Model" => "B"))) @testset "ut_find_data_files" begin - @test sort(find_data_files(params["Physics"]["Material Models"]["A"])) == ["test_file", "test_file_2"] - @test find_data_files(params["Physics"]["Material Models"]["B"]) == ["test_file_B"] - @test find_data_files(params["Physics"]["Damage Models"]["E"]) == [] + @test sort(PeriLab.Solver.Parameter_Handling.find_data_files(params["Physics"]["Material Models"]["A"])) == ["test_file", "test_file_2"] + @test PeriLab.Solver.Parameter_Handling.find_data_files(params["Physics"]["Material Models"]["B"]) == ["test_file_B"] + @test PeriLab.Solver.Parameter_Handling.find_data_files(params["Physics"]["Damage Models"]["E"]) == [] end @testset "ut_get_model_parameter" begin blockModels = Dict{Int32,Dict{String,String}}() for id in 1:2 - blockModels[id] = get_block_models(params, id) + blockModels[id] = PeriLab.Solver.Parameter_Handling.get_block_models(params, id) end @test blockModels[1]["Material Model"] == "A" @test blockModels[1]["Damage Model"] == "E" @test blockModels[2]["Material Model"] == "B" testData = Dict("Material Model" => Dict(), "Damage Model" => Dict()) - @test isnothing(get_model_parameter(params, "Does not exist Model", blockModels[1]["Material Model"])) - @test isnothing(get_model_parameter(params, "Does not exist Model", "s")) - @test isnothing(get_model_parameter(params, "Material Model", "s")) - testData["Material Model"] = get_model_parameter(params, "Material Model", blockModels[1]["Material Model"]) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_model_parameter(params, "Does not exist Model", blockModels[1]["Material Model"])) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_model_parameter(params, "Does not exist Model", "s")) + @test isnothing(PeriLab.Solver.Parameter_Handling.get_model_parameter(params, "Material Model", "s")) + testData["Material Model"] = PeriLab.Solver.Parameter_Handling.get_model_parameter(params, "Material Model", blockModels[1]["Material Model"]) @test testData["Material Model"]["s"] == 0 @test testData["Material Model"]["d"] == true - testData["Material Model"] = get_model_parameter(params, "Material Model", blockModels[2]["Material Model"]) + testData["Material Model"] = PeriLab.Solver.Parameter_Handling.get_model_parameter(params, "Material Model", blockModels[2]["Material Model"]) @test testData["Material Model"]["sa"] == [3.2, 2, 3] @test testData["Material Model"]["d"] == "true" test_dict = testData["Material Model"]["test_file_B"] @@ -414,7 +414,7 @@ end @test test_dict["min"] == -2.5 @test typeof(test_dict["spl"]) == Dierckx.Spline1D - testData["Damage Model"] = get_model_parameter(params, "Damage Model", blockModels[1]["Damage Model"]) + testData["Damage Model"] = PeriLab.Solver.Parameter_Handling.get_model_parameter(params, "Damage Model", blockModels[1]["Damage Model"]) @test testData["Damage Model"]["ss"] == 0 @test testData["Damage Model"]["d"] == 1.1 end @@ -429,7 +429,7 @@ end "Shape Tensor" => false, "Bond Associated Shape Tensor" => false, "Bond Associated Deformation Gradient" => false) - optionTest = Parameter_Handling.get_physics_option(params, options) + optionTest = PeriLab.Solver.Parameter_Handling.get_physics_option(params, options) # no material models included @test optionTest == params["Physics"]["Pre Calculation"] @@ -439,22 +439,22 @@ end "Bond Associated Shape Tensor" => false, "Bond Associated Deformation Gradient" => true), "Material Models" => Dict("a" => Dict("value" => 1), "c" => Dict("value" => [1 2], "value2" => 1)))) - optionTest = Parameter_Handling.get_physics_option(params, options) + optionTest = PeriLab.Solver.Parameter_Handling.get_physics_option(params, options) @test isnothing(optionTest) params = Dict("Physics" => Dict( "Material Models" => Dict("a" => Dict("Material Model" => "adaCoB", "value" => 1), "c" => Dict("value" => [1 2], "value2" => 1)))) - optionTest = Parameter_Handling.get_physics_option(params, options) + optionTest = PeriLab.Solver.Parameter_Handling.get_physics_option(params, options) @test isnothing(optionTest) params = Dict("Physics" => Dict( "Material Models" => Dict("a" => Dict("value" => 1), "c" => Dict("value" => [1 2], "value2" => 1, "Material Model" => "adaCoB")))) - optionTest = Parameter_Handling.get_physics_option(params, options) + optionTest = PeriLab.Solver.Parameter_Handling.get_physics_option(params, options) @test isnothing(optionTest) params = Dict("Physics" => Dict( "Material Models" => Dict("a" => Dict("value" => 1, "Material Model" => "adaCoB"), "c" => Dict("value" => [1 2], "value2" => 1, "Material Model" => "adaCoB")))) - optionTest = Parameter_Handling.get_physics_option(params, options) + optionTest = PeriLab.Solver.Parameter_Handling.get_physics_option(params, options) @test optionTest == options params = Dict("Physics" => Dict( @@ -464,7 +464,7 @@ end "Shape Tensor" => false, "Bond Associated Shape Tensor" => false, "Bond Associated Deformation Gradient" => false) - optionTest = Parameter_Handling.get_physics_option(params, options) + optionTest = PeriLab.Solver.Parameter_Handling.get_physics_option(params, options) @test optionTest["Shape Tensor"] @test !optionTest["Bond Associated Shape Tensor"] @test !optionTest["Bond Associated Deformation Gradient"] @@ -473,7 +473,7 @@ end params = Dict("Physics" => Dict( "Material Models" => Dict("aBond Associated" => Dict("Material Model" => "adaCoBond Associated", "value" => 1), "c" => Dict("value" => [1 2], "value2" => 1, "Material Model" => "adaCoB")))) - optionTest = Parameter_Handling.get_physics_option(params, options) + optionTest = PeriLab.Solver.Parameter_Handling.get_physics_option(params, options) @test optionTest["Shape Tensor"] @test optionTest["Bond Associated Shape Tensor"] @@ -489,6 +489,6 @@ end "Bond Associated Deformation Gradient" => false) end @testset "ut_check_for_duplicates" begin - @test !(check_for_duplicates(["a", "b", "c"])) - @test isnothing(check_for_duplicates(["a", "b", "c", "a"])) + @test !(PeriLab.Solver.Parameter_Handling.check_for_duplicates(["a", "b", "c"])) + @test isnothing(PeriLab.Solver.Parameter_Handling.check_for_duplicates(["a", "b", "c", "a"])) end \ No newline at end of file diff --git a/test/unit_tests/Support/ut_data_manager.jl b/test/unit_tests/Support/ut_data_manager.jl index 76a0e02e1..79eadd2d0 100644 --- a/test/unit_tests/Support/ut_data_manager.jl +++ b/test/unit_tests/Support/ut_data_manager.jl @@ -2,13 +2,14 @@ # # SPDX-License-Identifier: BSD-3-Clause -include("../../../src/Support/data_manager.jl") +# include("../../../src/Support/data_manager.jl") using MPI using Test @testset "set_comm" begin # MPI.Init() comm = MPI.COMM_WORLD - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager + test_Data_manager.clear_data_manager() test_Data_manager.set_comm(comm) b = test_Data_manager.get_comm() @test comm == b @@ -16,7 +17,7 @@ using Test end @testset "ranks" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.set_rank(2) test_Data_manager.set_max_rank(3) @test test_Data_manager.get_rank() == 2 @@ -26,7 +27,7 @@ end end @testset "get_local_nodes" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.set_glob_to_loc(Dict{Int64,Int64}(1 => 1, 3 => 2, 2 => 3)) @test test_Data_manager.get_local_nodes([1, 2, 3]) == [1, 3, 2] @test test_Data_manager.get_local_nodes([1]) == [1] @@ -42,7 +43,7 @@ end @testset "get_set_functions" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager for i in 1:20 test_Data_manager.set_dof(i) @test test_Data_manager.get_dof() == i @@ -62,7 +63,7 @@ end @test test_Data_manager.get_nnodes() == 97 @test nnodes == 3 end -test_Data_manager = Data_manager +test_Data_manager = PeriLab.Data_manager num_controller = 3 num_responder = 2 test_Data_manager.set_num_controller(num_controller) @@ -413,6 +414,7 @@ end end @testset "ut_block_list" begin + test_Data_manager.set_block_list(Vector{Int64}()) block_list = test_Data_manager.get_block_list() @test length(block_list) == 0 test_Data_manager.set_block_list([1, 2, 3, 4, 4, 4, 1, 1, 1, 2, 2]) @@ -462,7 +464,7 @@ end end @testset "get_physics_options" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager physics_options = test_Data_manager.get_physics_options() @test physics_options["Deformed Bond Geometry"] @test !physics_options["Bond Associated Shape Tensor"] diff --git a/test/unit_tests/Support/ut_geometry.jl b/test/unit_tests/Support/ut_geometry.jl index f5c1b44a4..8dbfe9862 100644 --- a/test/unit_tests/Support/ut_geometry.jl +++ b/test/unit_tests/Support/ut_geometry.jl @@ -3,14 +3,16 @@ # SPDX-License-Identifier: BSD-3-Clause using Test -include("../../../src/Support/data_manager.jl") -include("../../../src/Support/geometry.jl") +# include("../../../src/Support/data_manager.jl") +# include("../../../src/Support/geometry.jl") @testset "ut_undeformed_bond" begin nnodes = 4 dof = 2 - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager + test_Data_manager.clear_data_manager() test_Data_manager.set_num_controller(nnodes) + test_Data_manager.set_num_responder(0) test_Data_manager.set_dof(dof) nn = test_Data_manager.create_constant_node_field("Number of Neighbors", Int32, 1) nn[:] = [2, 2, 2, 1] @@ -31,7 +33,7 @@ include("../../../src/Support/geometry.jl") coor[4, 1] = 0 coor[4, 2] = 1 - undeformed_bond = Geometry.bond_geometry(Vector(1:nnodes), dof, nlist, coor, undeformed_bond) + undeformed_bond = PeriLab.IO.Geometry.bond_geometry(Vector(1:nnodes), dof, nlist, coor, undeformed_bond) @test undeformed_bond[1][1, 1] == 0.5 @test undeformed_bond[1][1, 2] == 0.5 @@ -57,7 +59,7 @@ include("../../../src/Support/geometry.jl") @test undeformed_bond[4][1, 1] == 0.5 @test undeformed_bond[4][1, 2] == -0.5 @test undeformed_bond[4][1, 3] / sqrt(1.25) - 1 < 1e-8 - undeformed_bond = Geometry.bond_geometry(Vector(1:nnodes), dof, nlist, coor, undeformed_bond) + undeformed_bond = PeriLab.IO.Geometry.bond_geometry(Vector(1:nnodes), dof, nlist, coor, undeformed_bond) # test if a sum exists or not @test undeformed_bond[1][1, 1] == 0.5 @test undeformed_bond[1][1, 2] == 0.5 @@ -92,7 +94,7 @@ include("../../../src/Support/geometry.jl") undeformed_bond[3][:, :] .= 0 undeformed_bond[4][:, :] .= 0 - undeformed_bond = Geometry.bond_geometry(Vector(1:nnodes), dof, nlist, coor, undeformed_bond) + undeformed_bond = PeriLab.IO.Geometry.bond_geometry(Vector(1:nnodes), dof, nlist, coor, undeformed_bond) println() @test isnothing(undeformed_bond) end @@ -100,7 +102,7 @@ end nnodes = 4 dof = 2 nodes = Vector{Int64}(1:nnodes) - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.set_num_controller(nnodes) test_Data_manager.set_dof(dof) nn = test_Data_manager.create_constant_node_field("Number of Neighbors", Int32, 1) @@ -144,12 +146,12 @@ end coor[4, 1] = 1 coor[4, 2] = 0.5 - undeformed_bond = Geometry.bond_geometry(Vector(1:nnodes), dof, nlist, coor, undeformed_bond) - shapeTensor, inverse_shape_tensor = Geometry.shape_tensor(view(nodes, eachindex(nodes)), dof, nlist, volume, omega, bond_damage, undeformed_bond, shapeTensor, inverse_shape_tensor) + undeformed_bond = PeriLab.IO.Geometry.bond_geometry(Vector(1:nnodes), dof, nlist, coor, undeformed_bond) + shapeTensor, inverse_shape_tensor = PeriLab.IO.Geometry.shape_tensor(view(nodes, eachindex(nodes)), dof, nlist, volume, omega, bond_damage, undeformed_bond, shapeTensor, inverse_shape_tensor) deformed_coor = copy(coor) - deformation_gradient = Geometry.deformation_gradient(view(nodes, eachindex(nodes)), dof, nlist, volume, omega, bond_damage, undeformed_bond, undeformed_bond, inverse_shape_tensor, deformation_gradient) + deformation_gradient = PeriLab.IO.Geometry.deformation_gradient(view(nodes, eachindex(nodes)), dof, nlist, volume, omega, bond_damage, undeformed_bond, undeformed_bond, inverse_shape_tensor, deformation_gradient) for i in 1:nnodes @test deformation_gradient[i, 1, 1] - 1 < 1e-7 @test deformation_gradient[i, 1, 2] < 1e-7 @@ -161,8 +163,8 @@ end deformed_coor[2, 1] = 0.25 deformed_coor[4, 1] = 0.25 - deformed_bond = Geometry.bond_geometry(Vector(1:nnodes), dof, nlist, deformed_coor, deformed_bond) - deformation_gradient = Geometry.deformation_gradient(view(nodes, eachindex(nodes)), dof, nlist, volume, omega, bond_damage, deformed_bond, undeformed_bond, inverse_shape_tensor, deformation_gradient) + deformed_bond = PeriLab.IO.Geometry.bond_geometry(Vector(1:nnodes), dof, nlist, deformed_coor, deformed_bond) + deformation_gradient = PeriLab.IO.Geometry.deformation_gradient(view(nodes, eachindex(nodes)), dof, nlist, volume, omega, bond_damage, deformed_bond, undeformed_bond, inverse_shape_tensor, deformation_gradient) for i in 1:nnodes for j in 1:nn[i] @@ -177,8 +179,8 @@ end deformed_coor[3, 2] = 1.5 deformed_coor[4, 2] = 1.5 - deformed_bond = Geometry.bond_geometry(Vector(1:nnodes), dof, nlist, deformed_coor, deformed_bond) - deformation_gradient = Geometry.deformation_gradient(view(nodes, eachindex(nodes)), dof, nlist, volume, omega, bond_damage, deformed_bond, undeformed_bond, inverse_shape_tensor, deformation_gradient) + deformed_bond = PeriLab.IO.Geometry.bond_geometry(Vector(1:nnodes), dof, nlist, deformed_coor, deformed_bond) + deformation_gradient = PeriLab.IO.Geometry.deformation_gradient(view(nodes, eachindex(nodes)), dof, nlist, volume, omega, bond_damage, deformed_bond, undeformed_bond, inverse_shape_tensor, deformation_gradient) for i in 1:nnodes for j in nn[i] test_vector = deformation_gradient[i, :, :] * undeformed_bond[i][j, 1:dof] - deformed_bond[i][j, 1:dof] @@ -197,8 +199,8 @@ end deformed_coor[4, 1] = 1.5 deformed_coor[4, 2] = 0.5 - deformed_bond = Geometry.bond_geometry(Vector(1:nnodes), dof, nlist, deformed_coor, deformed_bond) - deformation_gradient = Geometry.deformation_gradient(view(nodes, eachindex(nodes)), dof, nlist, volume, omega, bond_damage, deformed_bond, undeformed_bond, inverse_shape_tensor, deformation_gradient) + deformed_bond = PeriLab.IO.Geometry.bond_geometry(Vector(1:nnodes), dof, nlist, deformed_coor, deformed_bond) + deformation_gradient = PeriLab.IO.Geometry.deformation_gradient(view(nodes, eachindex(nodes)), dof, nlist, volume, omega, bond_damage, deformed_bond, undeformed_bond, inverse_shape_tensor, deformation_gradient) for i in 1:nnodes for j in nn[i] test_vector = deformation_gradient[i, :, :] * undeformed_bond[i][j, 1:dof] - deformed_bond[i][j, 1:dof] @@ -212,13 +214,13 @@ end bond_damage[3][:] .= 0 bond_damage[4][:] .= 0 - shapeTensor, inverse_shape_tensor = Geometry.shape_tensor(view(nodes, eachindex(nodes)), dof, nlist, volume, omega, bond_damage, undeformed_bond, shapeTensor, inverse_shape_tensor) + shapeTensor, inverse_shape_tensor = PeriLab.IO.Geometry.shape_tensor(view(nodes, eachindex(nodes)), dof, nlist, volume, omega, bond_damage, undeformed_bond, shapeTensor, inverse_shape_tensor) @test isnothing(shapeTensor) @test isnothing(inverse_shape_tensor) end @testset "ut_strain" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager dof = test_Data_manager.get_dof() nnodes = 4 nodes = Vector{Int64}(1:nnodes) @@ -233,10 +235,10 @@ end inverse_shape_tensor = test_Data_manager.create_constant_node_field("Inverse Shape Tensor", Float64, "Matrix", dof) - deformation_gradient = Geometry.deformation_gradient(view(nodes, eachindex(nodes)), dof, nlist, volume, omega, bond_damage, undeformed_bond, undeformed_bond, inverse_shape_tensor, deformation_gradient) - strain = Geometry.strain(view(nodes, eachindex(nodes)), deformation_gradient, strain) - deformation_gradient = Geometry.deformation_gradient(view(nodes, eachindex(nodes)), dof, nlist, volume, omega, bond_damage, undeformed_bond, undeformed_bond, inverse_shape_tensor, deformation_gradient) - strain = Geometry.strain(view(nodes, eachindex(nodes)), deformation_gradient, strain) - strain + deformation_gradient = PeriLab.IO.Geometry.deformation_gradient(view(nodes, eachindex(nodes)), dof, nlist, volume, omega, bond_damage, undeformed_bond, undeformed_bond, inverse_shape_tensor, deformation_gradient) + strain = PeriLab.IO.Geometry.strain(view(nodes, eachindex(nodes)), deformation_gradient, strain) + deformation_gradient = PeriLab.IO.Geometry.deformation_gradient(view(nodes, eachindex(nodes)), dof, nlist, volume, omega, bond_damage, undeformed_bond, undeformed_bond, inverse_shape_tensor, deformation_gradient) + strain = PeriLab.IO.Geometry.strain(view(nodes, eachindex(nodes)), deformation_gradient, strain) - strain for i in 1:nnodes @test strain[i, 1, 1] == 0 @@ -255,7 +257,7 @@ end deformation_gradient_3D[1, 3, 2] = -1.0 deformation_gradient_3D[1, 3, 3] = 3.0 strain_3D = test_Data_manager.create_constant_node_field("Strain_3D", Float64, "Matrix", 3) - strain_3D = Geometry.strain(view(nodes, eachindex(nodes)), deformation_gradient_3D, strain_3D) + strain_3D = PeriLab.IO.Geometry.strain(view(nodes, eachindex(nodes)), deformation_gradient_3D, strain_3D) identity = zeros(3, 3) identity[1, 1] = 1 identity[2, 2] = 1 @@ -268,7 +270,7 @@ end end end @testset "ut_rotation_tensor" begin - rot = Geometry.rotation_tensor(fill(Float64(0), (1))) + rot = PeriLab.IO.Geometry.rotation_tensor(fill(Float64(0), (1))) @test rot[1, 1] == 1 @test rot[1, 2] == 0 @test rot[1, 3] == 0 @@ -278,7 +280,7 @@ end @test rot[3, 1] == 0 @test rot[3, 2] == 0 @test rot[3, 3] == 1 - rot = Geometry.rotation_tensor(fill(Float64(0), (3))) + rot = PeriLab.IO.Geometry.rotation_tensor(fill(Float64(0), (3))) @test rot[1, 1] == 1 @test rot[1, 2] == 0 @test rot[1, 3] == 0 @@ -288,7 +290,7 @@ end @test rot[3, 1] == 0 @test rot[3, 2] == 0 @test rot[3, 3] == 1 - rot = Geometry.rotation_tensor(fill(Float64(90), (1))) + rot = PeriLab.IO.Geometry.rotation_tensor(fill(Float64(90), (1))) @test rot[1, 1] < 1e-10 @test rot[1, 2] == -1 @test rot[1, 3] < 1e-10 diff --git a/test/unit_tests/Support/ut_helpers.jl b/test/unit_tests/Support/ut_helpers.jl index a80f8e2b0..d7e00b82e 100644 --- a/test/unit_tests/Support/ut_helpers.jl +++ b/test/unit_tests/Support/ut_helpers.jl @@ -3,48 +3,48 @@ # SPDX-License-Identifier: BSD-3-Clause using Test -include("../../../src/Support/helpers.jl") -include("../../../src/Support/data_manager.jl") -using Reexport -@reexport using .Helpers +# include("../../../src/Support/helpers.jl") +# include("../../../src/Support/data_manager.jl") +# using Reexport +# @reexport using .Helpers using ProgressBars @testset "ut_interpolation" begin x = [0.0, 1.0, 2.0, 3.0, 4.0] y = [-1.0, 0.0, 7.0, 26.0, 63.0] # x.^3 - 1. values_dict = Dict() - values_dict["value"] = Helpers.interpolation(x, y) - @test isapprox(Helpers.interpol_data([1.5, 2.5], values_dict["value"])[1], 2.375) - @test isapprox(Helpers.interpol_data([1.5, 2.5], values_dict["value"])[2], 14.625) - @test isapprox(Helpers.interpol_data(1.5, values_dict["value"]), 2.375) - @test Helpers.interpol_data(-1, values_dict["value"]) == minimum(y) - @test Helpers.interpol_data([-1, -8], values_dict["value"]) == [minimum(y), minimum(y)] - @test Helpers.interpol_data(5, values_dict["value"]) == maximum(y) + values_dict["value"] = PeriLab.Solver.Helpers.interpolation(x, y) + @test isapprox(PeriLab.Solver.Helpers.interpol_data([1.5, 2.5], values_dict["value"])[1], 2.375) + @test isapprox(PeriLab.Solver.Helpers.interpol_data([1.5, 2.5], values_dict["value"])[2], 14.625) + @test isapprox(PeriLab.Solver.Helpers.interpol_data(1.5, values_dict["value"]), 2.375) + @test PeriLab.Solver.Helpers.interpol_data(-1, values_dict["value"]) == minimum(y) + @test PeriLab.Solver.Helpers.interpol_data([-1, -8], values_dict["value"]) == [minimum(y), minimum(y)] + @test PeriLab.Solver.Helpers.interpol_data(5, values_dict["value"]) == maximum(y) end @testset "ut_find_indices" begin - @test Helpers.find_indices([1, 1, 2, 3, 3, 4, 4, 4, 1], 1) == [1, 2, 9] - @test Helpers.find_indices([1, 1, 2, 3, 3, 4, 4, 4, 1], 2) == [3] - @test Helpers.find_indices([1, 1, 2, 3, 3, 4, 4, 4, 1], 3) == [4, 5] - @test Helpers.find_indices([1, 1, 2, 3, 3, 4, 4, 4, 1], 4) == [6, 7, 8] - @test Helpers.find_indices([1, 1, 2, 3, 3, 4, 4, 4, 1], 5) == [] + @test PeriLab.Solver.Helpers.find_indices([1, 1, 2, 3, 3, 4, 4, 4, 1], 1) == [1, 2, 9] + @test PeriLab.Solver.Helpers.find_indices([1, 1, 2, 3, 3, 4, 4, 4, 1], 2) == [3] + @test PeriLab.Solver.Helpers.find_indices([1, 1, 2, 3, 3, 4, 4, 4, 1], 3) == [4, 5] + @test PeriLab.Solver.Helpers.find_indices([1, 1, 2, 3, 3, 4, 4, 4, 1], 4) == [6, 7, 8] + @test PeriLab.Solver.Helpers.find_indices([1, 1, 2, 3, 3, 4, 4, 4, 1], 5) == [] end # Define a test case for the find_active function @testset "ut_find_active" begin # Test case 1: Empty input - @test isempty(Helpers.find_active(Bool[])) + @test isempty(PeriLab.Solver.Helpers.find_active(Bool[])) # Test case 2: All elements are active - @test Helpers.find_active([true, true, true]) == [1, 2, 3] + @test PeriLab.Solver.Helpers.find_active([true, true, true]) == [1, 2, 3] # Test case 3: No elements are active - @test isempty(Helpers.find_active([false, false, false])) + @test isempty(PeriLab.Solver.Helpers.find_active([false, false, false])) # Test case 4: Mix of active and inactive elements - @test Helpers.find_active([false, true, false, true, true]) == [2, 4, 5] + @test PeriLab.Solver.Helpers.find_active([false, true, false, true, true]) == [2, 4, 5] # Test case 5: SubList of active and inactive elements list = [false, true, false, true, true] - @test Helpers.find_active(list[[2, 3, 5]]) == [1, 3] + @test PeriLab.Solver.Helpers.find_active(list[[2, 3, 5]]) == [1, 3] end @testset "ut_find_inverse_bond_id" begin - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager nnodes = 2 num_responder = 1 test_Data_manager.set_num_controller(nnodes) @@ -57,7 +57,7 @@ end nlist[1] = [2] nlist[2] = [1, 3] nlist[3] = [1, 2] - inverse_nlist = Helpers.find_inverse_bond_id(nlist) + inverse_nlist = PeriLab.Solver.Helpers.find_inverse_bond_id(nlist) @test length(inverse_nlist[1]) == 1 @test length(inverse_nlist[2]) == 2 @@ -71,31 +71,31 @@ end @testset "ut_check_inf_or_nan" begin a = ones(2, 2) - @test Helpers.check_inf_or_nan(a, "a") == false + @test PeriLab.Solver.Helpers.check_inf_or_nan(a, "a") == false a[1, 1] = 1 / 0 - @test Helpers.check_inf_or_nan(a, "Testing infinite test vector") + @test PeriLab.Solver.Helpers.check_inf_or_nan(a, "Testing infinite test vector") a = 0 - @test Helpers.check_inf_or_nan(a, "a") == false + @test PeriLab.Solver.Helpers.check_inf_or_nan(a, "a") == false end @testset "get_matrix_style" begin A = 1 @test length(size(A)) == 0 - Atest = Helpers.matrix_style(A) + Atest = PeriLab.Solver.Helpers.matrix_style(A) @test sum(size(Atest)) == 2 A = [1] @test length(size(A)) == 1 @test sum(size(A)) == 1 - Atest = Helpers.matrix_style(A) + Atest = PeriLab.Solver.Helpers.matrix_style(A) @test sum(size(Atest)) == 2 A = [1 1; 1 1] @test length(size(A)) == 2 @test sum(size(A)) == 4 - Atest = Helpers.matrix_style(A) + Atest = PeriLab.Solver.Helpers.matrix_style(A) @test length(size(A)) == 2 @test sum(size(A)) == 4 A = [1 1 1; 1 1 1; 1 1 1] @test sum(size(A)) == 6 - Atest = Helpers.matrix_style(A) + Atest = PeriLab.Solver.Helpers.matrix_style(A) @test sum(size(A)) == 6 end @@ -110,10 +110,10 @@ end # Test case 1: Find .txt files - @test Helpers.find_files_with_ending(tmpdir, ".txt") == ["file1.txt", "file2.txt"] + @test PeriLab.Solver.Helpers.find_files_with_ending(tmpdir, ".txt") == ["file1.txt", "file2.txt"] # Test case 2: Find .csv files - @test Helpers.find_files_with_ending(tmpdir, ".csv") == ["file3.csv", "file4.csv"] + @test PeriLab.Solver.Helpers.find_files_with_ending(tmpdir, ".csv") == ["file3.csv", "file4.csv"] # Clean up: Remove the temporary test directory and files rm(tmpdir; recursive=true) @@ -121,40 +121,40 @@ end # only interface test, because the called fromVoigt function is tested in "Tensors" @testset "ut_get_fourth_order" begin - @test size(Helpers.get_fourth_order(zeros(Float64, 6, 6), 3)) == (3, 3, 3, 3) - @test size(Helpers.get_fourth_order(zeros(Float64, 3, 3), 2)) == (2, 2, 2, 2) + @test size(PeriLab.Solver.Helpers.get_fourth_order(zeros(Float64, 6, 6), 3)) == (3, 3, 3, 3) + @test size(PeriLab.Solver.Helpers.get_fourth_order(zeros(Float64, 3, 3), 2)) == (2, 2, 2, 2) end @testset "ut_progress_bar" begin nsteps::Int64 = rand(1:100) - @test Helpers.progress_bar(rand(1:100), nsteps, true) == 1:nsteps+1 - @test Helpers.progress_bar(rand(1:100), nsteps, false) == 1:nsteps+1 - @test Helpers.progress_bar(0, nsteps, true) == 1:nsteps+1 - @test typeof(Helpers.progress_bar(0, nsteps, false)) == ProgressBar - @test length(Helpers.progress_bar(0, nsteps, false)) == nsteps + 1 + @test PeriLab.Solver.Helpers.progress_bar(rand(1:100), nsteps, true) == 1:nsteps+1 + @test PeriLab.Solver.Helpers.progress_bar(rand(1:100), nsteps, false) == 1:nsteps+1 + @test PeriLab.Solver.Helpers.progress_bar(0, nsteps, true) == 1:nsteps+1 + @test typeof(PeriLab.Solver.Helpers.progress_bar(0, nsteps, false)) == ProgressBar + @test length(PeriLab.Solver.Helpers.progress_bar(0, nsteps, false)) == nsteps + 1 end @testset "get_active_update_nodes" begin nnodes = 4 - test_Data_manager = Data_manager + test_Data_manager = PeriLab.Data_manager test_Data_manager.set_num_controller(nnodes) update_list = test_Data_manager.create_constant_node_field("Update List", Bool, 1, true) active = test_Data_manager.create_constant_node_field("Active List", Bool, 1, true) block_nodes = Dict(1 => [1, 2], 2 => [3, 4]) block = 1 - @test Helpers.get_active_update_nodes(active, update_list, block_nodes, block) == ([1, 2], [1, 2],) + @test PeriLab.Solver.Helpers.get_active_update_nodes(active, update_list, block_nodes, block) == ([1, 2], [1, 2],) block = 2 - @test Helpers.get_active_update_nodes(active, update_list, block_nodes, block) == ([3, 4], [3, 4]) + @test PeriLab.Solver.Helpers.get_active_update_nodes(active, update_list, block_nodes, block) == ([3, 4], [3, 4]) update_list[3] = false - @test Helpers.get_active_update_nodes(active, update_list, block_nodes, block) == ([3, 4], [4]) + @test PeriLab.Solver.Helpers.get_active_update_nodes(active, update_list, block_nodes, block) == ([3, 4], [4]) active[3] = false - @test Helpers.get_active_update_nodes(active, update_list, block_nodes, block) == ([4], [4]) + @test PeriLab.Solver.Helpers.get_active_update_nodes(active, update_list, block_nodes, block) == ([4], [4]) update_list[3] = true - @test Helpers.get_active_update_nodes(active, update_list, block_nodes, block) == ([4], [4]) + @test PeriLab.Solver.Helpers.get_active_update_nodes(active, update_list, block_nodes, block) == ([4], [4]) update_list[3] = false update_list[4] = false - @test Helpers.get_active_update_nodes(active, update_list, block_nodes, block) == ([4], []) + @test PeriLab.Solver.Helpers.get_active_update_nodes(active, update_list, block_nodes, block) == ([4], []) active[3] = false active[4] = false - @test Helpers.get_active_update_nodes(active, update_list, block_nodes, block) == ([], []) + @test PeriLab.Solver.Helpers.get_active_update_nodes(active, update_list, block_nodes, block) == ([], []) end \ No newline at end of file