Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/PeriHub/PeriLab.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
JTHesse committed Aug 7, 2024
2 parents 1679a69 + bc68537 commit 598d2b3
Show file tree
Hide file tree
Showing 70 changed files with 1,044 additions and 702 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Dierckx = "39dd38d3-220a-591b-8e3c-4c3a8c710a94"
Exodus = "f57ae99e-f805-4780-bdca-96e224be1e5a"
FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Expand Down Expand Up @@ -42,7 +43,7 @@ AbaqusReader = "^0.2.6"
Aqua = "^0.8"
ArgParse = "^1"
CSV = "^0.10"
Combinatorics = "1"
Combinatorics = "^1"
DataFrames = "^1"
Dates = "^1"
Dierckx = "^0.5"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lib/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ set_rotation
set_element_rotation
switch_NP1_to_N
synch_manager
clear_data_manager
initialize_data
```

```@meta
Expand Down
4 changes: 3 additions & 1 deletion docs/src/lib/io_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ CurrentModule = PeriLab.IO.Geometry
```@docs
bond_geometry
shape_tensor
deformation_gradient
compute_deformation_gradient
compute_strain
rotation_tensor
```
Expand Down Expand Up @@ -152,6 +152,8 @@ matrix_style
progress_bar
get_fourth_order
find_inverse_bond_id
rotate
rotate_second_order_tensor
```

```@meta
Expand Down
2 changes: 0 additions & 2 deletions docs/src/lib/physics_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ Set_modules.PD_Solid_Elastic.Ordinary.compute_weighted_volume
Set_modules.PD_Solid_Elastic.Ordinary.compute_dilatation
Set_modules.Correspondence.zero_energy_mode_compensation
Set_modules.Correspondence.calculate_bond_force
Set_modules.Correspondence.rotate
Set_modules.Correspondence.rotate_second_order_tensor
Set_modules.Correspondence.Set_modules.Correspondence_Elastic.compute_stresses
Set_modules.Correspondence.Set_modules.Correspondence_Elastic.correspondence_name
Set_modules.Correspondence.Global_zero_energy_control.control_name
Expand Down
26 changes: 26 additions & 0 deletions src/Core/Influence_function.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-FileCopyrightText: 2023 Christian Willberg <[email protected]>, Jan-Timo Hesse <[email protected]>
#
# SPDX-License-Identifier: BSD-3-Clause

module Influence_function

function init_influence_function(nodes::Union{SubArray,Vector{Int64}}, datamanager::Module, params::Dict)

if !haskey(params, "Influence Function")
return datamanager
end
bond_length = datamanager.get_field("Bond Length")
omega = datamanager.get_field("Influence Function")
if params["Influence Function"] == "1/xi^2"
omega = influence_function_1_div_xi_squared(omega, nodes, bond_length)
end
return datamanager
end

function influence_function_1_div_xi_squared(omega, nodes, bond_length)
for iID in nodes
omega[iID][:] = 1 ./ (bond_length[iID][:] .* bond_length[iID][:])
end
return omega
end
end
6 changes: 5 additions & 1 deletion src/Core/Solver/Solver_control.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ include("Verlet.jl")
include("../BC_manager.jl")
include("../../MPI_communication/MPI_communication.jl")
include("../../FEM/FEM_Factory.jl")
include("../Influence_function.jl")

using .Physics
using .Boundary_conditions: init_BCs
using .Verlet
using .FEM
using .Influence_function
using TimerOutputs

export init
Expand Down Expand Up @@ -55,8 +57,10 @@ function init(params::Dict, datamanager::Module, to::TimerOutput)
horizon = set_horizon(params, block_nodes_with_neighbors, horizon) # includes the neighbors
fem_block = set_fem_block(params, block_nodes_with_neighbors, fem_block) # includes the neighbors
solver_options = get_solver_options(params)

datamanager.create_constant_bond_field("Influence Function", Float64, 1, 1)
for iblock in eachindex(block_nodes)
datamanager = Influence_function.init_influence_function(block_nodes[iblock], datamanager, params["Discretization"])
end
datamanager.create_bond_field("Bond Damage", Float64, 1, 1)
@debug "Read properties"
Physics.read_properties(params, datamanager, solver_options["Material Models"])
Expand Down
210 changes: 141 additions & 69 deletions src/Core/data_manager.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ export create_constant_bond_field
export create_constant_node_field
export create_node_field
export fem_active
export clear_data_manager
export initialize_data
export get_all_field_keys
export has_key
export get_accuracy_order
export get_block_list
export get_crit_values_matrix
export get_aniso_crit_values
Expand All @@ -39,6 +40,7 @@ export get_output_frequency
export get_rotation
export get_element_rotation
export init_property
export set_accuracy_order
export set_block_list
export set_crit_values_matrix
export set_aniso_crit_values
Expand All @@ -64,44 +66,132 @@ export synch_manager
##########################
# Variables
##########################
global nnodes::Int64 = 0
global num_controller::Int64 = 0
global num_responder::Int64 = 0
global num_elements::Int64 = 0
global nnsets::Int64 = 0
global dof::Int64 = 1
global fem_option = false
global block_list::Vector{Int64} = []
global nnodes::Int64
global num_controller::Int64
global num_responder::Int64
global num_elements::Int64
global nnsets::Int64
global dof::Int64
global fem_option::Bool
global block_list::Vector{Int64}
global distribution::Vector{Int64}
global crit_values_matrix::Array{Float64,3} = fill(-1, (1, 1, 1))
global crit_values_matrix::Array{Float64,3}
global aniso_crit_values::Dict{Int64,Vector{Float64}}
# global aniso_crit_values::Dict{Int64,String}
global properties::Dict{Int64,Dict{String,Any}} = Dict()
global properties::Dict{Int64,Dict{String,Any}}
global glob_to_loc::Dict{Int64,Int64}
global fields::Dict{DataType,Dict{String,Any}} = Dict(Int64 => Dict(), Float64 => Dict(), Bool => Dict())
global field_array_type::Dict{String,Dict{String,Any}} = Dict()
global field_types::Dict{String,DataType} = Dict()
global fields_to_synch::Dict{String,Any} = Dict()
global filedirectory = ""
global inverse_nlist::Vector{Dict{Int64,Int64}} = []
global model_modules::Dict{String,Module} = Dict()
global nsets::Dict{String,Vector{Int}} = Dict()
global fields::Dict{DataType,Dict{String,Any}}
global field_array_type::Dict{String,Dict{String,Any}}
global field_types::Dict{String,DataType}
global fields_to_synch::Dict{String,Any}
global filedirectory::String
global inverse_nlist::Vector{Dict{Int64,Int64}}
global model_modules::Dict{String,Module}
global nsets::Dict{String,Vector{Int}}
global overlap_map::Dict{Int64,Any}
global physics_options::Dict{String,Bool} = Dict("Deformed Bond Geometry" => true,
"Deformation Gradient" => false,
"Shape Tensor" => false,
"Bond Associated Deformation Gradient" => false,
"Rotation Matrix" => true)
global output_frequency::Vector{Dict} = []
global rank::Int64 = 0
global physics_options::Dict{String,Bool}
global output_frequency::Vector{Dict}
global accuracy_order::Int64
global rank::Int64
global commMPi::Any
global cancel::Bool = false
global max_rank::Int64 = 0
global silent::Bool = false
global rotation::Bool = false
global element_rotation::Bool = false
global cancel::Bool
global max_rank::Int64
global silent::Bool
global rotation::Bool
global element_rotation::Bool
##########################

"""
initialize_data()
Initialize all parameter in the datamanager and sets them to the default values.
"""
function initialize_data()
global nnodes
nnodes = 0
global num_controller
num_controller = 0
global num_responder
num_responder = 0
global num_elements
num_elements = 0
global nnsets
nnsets = 0
global dof
dof = 2
global fem_option
fem_option = false
global block_list
block_list = []
global distribution
distribution = []
global crit_values_matrix
crit_values_matrix = fill(-1, (1, 1, 1))
global aniso_crit_values
aniso_crit_values = Dict()
global properties
properties = Dict()
global glob_to_loc
glob_to_loc = Dict()
global fields
fields = Dict(Int64 => Dict(), Float64 => Dict(), Bool => Dict())
global field_array_type
field_array_type = Dict()
global field_types
field_types = Dict()
global fields_to_synch
fields_to_synch = Dict()
global filedirectory
filedirectory = ""
global inverse_nlist
inverser_nlist = []
global model_modules
model_modules = Dict()
global nsets
nsets = Dict()
global overlap_map
overlap_map = Dict()
global physics_options
physics_options = Dict("Deformed Bond Geometry" => true,
"Deformation Gradient" => false,
"Shape Tensor" => false,
"Bond Associated Deformation Gradient" => false)
global output_frequency
output_frequency = []
global accuracy_order
accuracy_order = 1
global rank
rank = 0
global cancel
cancel = false
global max_rank
max_rank = 0
global silent
silent = false
global rotation
rotation = false
global element_rotation
element_rotation = false

end
###################################





"""
get_accuracy_order()
Returns the accuracy order for the "bond associated correspondence" implementation.
# Arguments
- `value::Int64`: The value of the accuracy_order.
"""
function get_accuracy_order()
global accuracy_order
return accuracy_order
end

"""
get_comm()
Expand Down Expand Up @@ -398,43 +488,6 @@ function has_key(field_name::String)
return haskey(field_types, field_name)
end

"""
clear_data_manager()
Returns a list of all field keys.
"""
function clear_data_manager()
global field_types
global nsets
global nnsets
global physics_options
global filedirectory
global rotation
global element_rotation

field_types = Dict()
nsets = Dict()
nnsets = 0
physics_options = Dict("Deformed Bond Geometry" => true,
"Deformation Gradient" => false,
"Shape Tensor" => false,
"Bond Associated Deformation Gradient" => false)
filedirectory = ""
rotation = false
element_rotation = false

# global field_array_type
# global fields_to_synch
# global properties
# global fields
# global model_modules
# field_array_type = Dict()
# fields_to_synch = Dict()
# properties = Dict()
# fields = Dict()
# model_modules = Dict()
end

"""
get_block_list()
Expand Down Expand Up @@ -948,6 +1001,23 @@ function init_property()
return collect(keys(properties[block_list[1]]))
end

"""
set_accuracy_order(value::Int64)
Sets the accuracy order for the "bond associated correspondence" implementation.
# Arguments
- `value::Int64`: The value of the accuracy_order.
"""
function set_accuracy_order(value::Int64)
if value < 1
@error "Accuracy order must be greater than zero."
return nothing
end
global accuracy_order = value
end


"""
set_block_list(blocks::Union{SubArray,Vector{Int64}})
Expand Down Expand Up @@ -1196,6 +1266,8 @@ function set_physics_options(values::Dict{String,Bool})
global physics_options = values
end



"""
set_property(block_id, property, value_name, value)
Expand Down
6 changes: 3 additions & 3 deletions src/FEM/FEM_routines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ function calculate_FEM(datamanager::Module, elements::Union{SubArray,Vector{Int6

if rotation
#tbd
stress_N = rotate(nodes, dof, stress_N, rotation_tensor, false)
strain_increment = rotate(nodes, dof, strain_increment, rotation_tensor, false)
# stress_N = rotate(nodes, stress_N, rotation_tensor, false)
# strain_increment = rotate(nodes, strain_increment, rotation_tensor, false)
end

# in future this part must be changed -> using set Modules
Expand All @@ -67,7 +67,7 @@ function calculate_FEM(datamanager::Module, elements::Union{SubArray,Vector{Int6

if rotation
#tbd
stress_NP1 = rotate(nodes, dof, stress_NP1, rotation_tensor, true)
#stress_NP1 = rotate(nodes, stress_NP1, rotation_tensor, true)
end

force_densities[topo, :] -= reshape(B_matrix[id_el, id_int, :, :] * stress_NP1[id_el, id_int, :] .* det_jacobian[id_el, id_int], (dof, nnodes))'
Expand Down
2 changes: 1 addition & 1 deletion src/PeriLab.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function main(filename::String; output_dir::String="", dry_run::Bool=false, verb

Data_manager.set_silent(silent)
if !reload
Data_manager.clear_data_manager()
Data_manager.initialize_data()
else
@info "PeriLab started in the reload mode"
end
Expand Down
Loading

1 comment on commit 598d2b3

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/112744

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.2.0 -m "<description of version>" 598d2b3cc484f9848dabc66ff0e345b5fab22262
git push origin v1.2.0

Please sign in to comment.