diff --git a/src/Compute/compute_global_values.jl b/src/Compute/compute_global_values.jl index 6b9803ce4..c75f4c3e6 100644 --- a/src/Compute/compute_global_values.jl +++ b/src/Compute/compute_global_values.jl @@ -3,7 +3,7 @@ # SPDX-License-Identifier: BSD-3-Clause """ - calculate_nodelist(datamanager::Module, field_key::String, dof::Union{Int64,Vector{Int64}}, calculation_type::String, node_set::Vector{Int64}) + calculate_nodelist(datamanager::Module, field_key::String, dof::Union{Int64,Vector{Int64}}, calculation_type::String, local_nodes::Vector{Int64}) Calculate the global value of a field for a given set of nodes. @@ -12,7 +12,7 @@ Calculate the global value of a field for a given set of nodes. - `field_key::String`: Field key. - `dof::Union{Int64,Vector{Int64}}`: Degree of freedom - `calculation_type::String`: Calculation type. -- `node_set::Vector{Int64}`: Node set. +- `local_nodes::Vector{Int64}`: Node set. # Returns - `value::Vector`: Global value. - `nnodes::Int64`: Number of nodes. @@ -22,7 +22,7 @@ function calculate_nodelist( field_key::String, dof::Union{Int64,Vector{Int64}}, calculation_type::String, - node_set::Union{Int64,Vector{Int64}}, + local_nodes::Union{Int64,Vector{Int64}}, ) # get block_nodes # check NP1 @@ -35,37 +35,36 @@ function calculate_nodelist( end field = datamanager.get_field(field_key) field_type = datamanager.get_field_type(field_key) - node_list = datamanager.get_local_nodes(node_set) if calculation_type == "Sum" - if length(node_list) == 0 + if length(local_nodes) == 0 value = field_type(0) else - value = global_value_sum(field, dof, node_list) + value = global_value_sum(field, dof, local_nodes) end elseif calculation_type == "Maximum" - if length(node_list) == 0 + if length(local_nodes) == 0 value = typemin(field_type) else - value = global_value_max(field, dof, node_list) + value = global_value_max(field, dof, local_nodes) end elseif calculation_type == "Minimum" - if length(node_list) == 0 + if length(local_nodes) == 0 value = typemax(field_type) else - value = global_value_min(field, dof, node_list) + value = global_value_min(field, dof, local_nodes) end elseif calculation_type == "Average" - if length(node_list) == 0 + if length(local_nodes) == 0 value = field_type(0) else - value = global_value_avg(field, dof, node_list) + value = global_value_avg(field, dof, local_nodes) end else @warn "Unknown calculation type $calculation_type" return nothing end - return value, Int64(length(node_list)) + return value, Int64(length(local_nodes)) end """ diff --git a/src/IO/IO.jl b/src/IO/IO.jl index b10b36c7c..81d9bf915 100644 --- a/src/IO/IO.jl +++ b/src/IO/IO.jl @@ -665,8 +665,9 @@ function get_global_values(output::Dict, datamanager::Module) calculate_block(datamanager, fieldname, dof, calculation_type, block_id) elseif compute_class == "Node_Set_Data" node_set = output[varname]["nodeset"] + node_list = datamanager.get_local_nodes(node_set) global_value, nnodes = - calculate_nodelist(datamanager, fieldname, dof, calculation_type, node_set) + calculate_nodelist(datamanager, fieldname, dof, calculation_type, node_list) end if datamanager.get_max_rank() > 1 global_value = diff --git a/test/unit_tests/Compute/ut_compute_global_values.jl b/test/unit_tests/Compute/ut_compute_global_values.jl index afbb462d3..462fc1075 100644 --- a/test/unit_tests/Compute/ut_compute_global_values.jl +++ b/test/unit_tests/Compute/ut_compute_global_values.jl @@ -46,10 +46,10 @@ include("../../../src/Compute/compute_global_values.jl") test_data_manager.set_glob_to_loc(Dict(1 => 1, 2 => 2)) nodes = Vector{Int64}(3:4) - @test calculate_nodelist(test_data_manager, "Disp", 1, "Sum", nodes) == (0, 0) - @test calculate_nodelist(test_data_manager, "Disp", 1, "Average", nodes) == (0, 0) - @test calculate_nodelist(test_data_manager, "Disp", 1, "Minimum", nodes) == (Inf, 0) - @test calculate_nodelist(test_data_manager, "Disp", 1, "Maximum", nodes) == (-Inf, 0) + @test calculate_nodelist(test_data_manager, "Disp", 1, "Sum", nodes) == (7, 2) + @test calculate_nodelist(test_data_manager, "Disp", 1, "Average", nodes) == (3.5, 2) + @test calculate_nodelist(test_data_manager, "Disp", 1, "Minimum", nodes) == (3, 2) + @test calculate_nodelist(test_data_manager, "Disp", 1, "Maximum", nodes) == (4, 2) matrix = test_data_manager.create_constant_node_field("Matrix", Float64, "Matrix", 3) matrix[:, 1, 2] .= 4