Skip to content

Commit

Permalink
refac
Browse files Browse the repository at this point in the history
  • Loading branch information
JTHesse committed Aug 21, 2024
1 parent 28569e2 commit 51e4385
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 30 deletions.
10 changes: 8 additions & 2 deletions src/Core/data_manager.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,10 @@ Sets the damage models globally.
- `value`: The value to set as the damage models.
"""
function set_damage_models(value)
global damage_models = value
global damage_models
if !(value in damage_models)
push!(damage_models, value)
end
end

"""
Expand All @@ -1525,7 +1528,10 @@ Sets the material models globally.
- `value`: The value to set as the material models.
"""
function set_material_models(value)
global material_models = value
global material_models
if !(value in material_models)
push!(material_models, value)
end
end

"""
Expand Down
20 changes: 3 additions & 17 deletions src/MPI_communication/MPI_communication.jl
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,7 @@ function synch_controller_bonds_to_responder_flattened(
continue
end
if !isempty(overlapnodes[rank+1][jcore]["Controller"])
send_indices = overlapnodes[rank+1][jcore]["Controller"]
# send_msg = array[overlapnodes[rank+1][jcore]["Controller"]]
# send_msg = vcat(send_msg...)
@views send_indices = overlapnodes[rank+1][jcore]["Controller"]
# @debug "Sending $rank -> $(jcore-1)"
MPI.Isend(
vcat([reshape(array[i], :, 1) for i in send_indices]...),
Expand All @@ -326,25 +324,13 @@ function synch_controller_bonds_to_responder_flattened(
)
end
if !isempty(overlapnodes[rank+1][jcore]["Responder"])
recv_indices = overlapnodes[rank+1][jcore]["Responder"]
@views recv_indices = overlapnodes[rank+1][jcore]["Responder"]
row_nums = [length(subarr) for subarr in array[recv_indices]]
recv_msg = zeros(sum(row_nums))
@views recv_msg = zeros(sum(row_nums))
# @debug "Receiving $(jcore-1) -> $rank"
MPI.Recv!(recv_msg, comm; source = jcore - 1, tag = 0)
recv_msg = split_vector(recv_msg, row_nums, dof)
array[recv_indices] .= recv_msg
# if dof == 1
# array[recv_indices] .= recv_msg
# else
# array[recv_indices] .= recv_msg
# end
# recv_msg = similar(array[recv_indices])
# row_starts = cumsum([size(array[i], 1) for i in recv_indices])
# row_starts = [0; row_starts[1:end-1]]
# MPI.Recv!(recv_msg, comm, source=jcore - 1, tag=0)
# for (i, idx) in enumerate(recv_indices)
# array[idx] .= recv_msg[row_starts[i]+1:row_starts[i]+size(array[idx], 1), :]
# end
end
end
return array
Expand Down
1 change: 1 addition & 0 deletions src/Models/Damage/Damage_Factory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ function init_damage_model(
end
datamanager.set_model_module(model_param["Damage Model"], mod)
datamanager = mod.init_damage_model(datamanager, nodes, model_param, block)
datamanager.set_damage_models(model_param["Damage Model"])
datamanager = Damage.init_interface_crit_values(datamanager, model_param, block)
datamanager = Damage.init_aniso_crit_values(datamanager, model_param, block)
return datamanager
Expand Down
1 change: 1 addition & 0 deletions src/Models/Material/Material_Factory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ function init_material_model(
end
datamanager.set_model_module(material_model, mod)
datamanager = mod.init_material_model(datamanager, nodes, model_param)
datamanager.set_material_models(material_model)
end
#TODO in extra function
# nlist = datamanager.get_nlist()
Expand Down
11 changes: 0 additions & 11 deletions src/Models/Model_Factory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -392,18 +392,12 @@ function init_models(
@info "Init damage models"
@timeit to "damage_model_fields" datamanager =
Damage.init_damage_model_fields(datamanager, params)
damage_models = []
for block in eachindex(block_nodes)
if datamanager.check_property(block, "Damage Model")
push!(
damage_models,
datamanager.get_property(block, "Damage Model", "Damage Model"),
)
@timeit to "init damage model" datamanager =
Damage.init_damage_model(datamanager, block_nodes[block], block)
end
end
datamanager.set_damage_models(unique(damage_models))
end
if solver_options["Material Models"]
@info "Init material models"
Expand All @@ -412,15 +406,10 @@ function init_models(
material_models = []
for block in eachindex(block_nodes)
if datamanager.check_property(block, "Material Model")
push!(
material_models,
datamanager.get_property(block, "Material Model", "Material Model"),
)
@timeit to "init material" datamanager =
Material.init_material_model(datamanager, block_nodes[block], block)
end
end
datamanager.set_material_models(unique(material_models))
end
if solver_options["Calculate Cauchy"] | solver_options["Calculate von Mises"]
datamanager.create_node_field("Cauchy Stress", Float64, "Matrix", dof)
Expand Down

0 comments on commit 51e4385

Please sign in to comment.