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
CWillberg committed Nov 7, 2024
2 parents 99feafe + 5c5faf9 commit b721122
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 43 deletions.
6 changes: 3 additions & 3 deletions src/IO/mesh_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,12 @@ function get_bond_geometry(datamanager::Module)
undeformed_bond = datamanager.create_constant_bond_field("Bond Geometry", Float64, dof)
undeformed_bond_length =
datamanager.create_constant_bond_field("Bond Length", Float64, 1)
Geometry.bond_geometry(
Geometry.bond_geometry!(
undeformed_bond,
undeformed_bond_length,
Vector{Int64}(1:nnodes),
nlist,
coor,
undeformed_bond,
undeformed_bond_length,
)
return datamanager
end
Expand Down
8 changes: 7 additions & 1 deletion src/Models/Pre_calculation/bond_deformation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ function compute(
deformed_coor = datamanager.get_field("Deformed Coordinates", "NP1")
deformed_bond = datamanager.get_field("Deformed Bond Geometry", "NP1")
deformed_bond_length = datamanager.get_field("Deformed Bond Length", "NP1")
Geometry.bond_geometry(nodes, nlist, deformed_coor, deformed_bond, deformed_bond_length)
Geometry.bond_geometry!(
deformed_bond,
deformed_bond_length,
nodes,
nlist,
deformed_coor,
)
return datamanager
end

Expand Down
24 changes: 12 additions & 12 deletions src/Support/geometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ using StaticArrays
using Rotations
include("helpers.jl")
using .Helpers: invert, smat, mat_mul_transpose_mat!
export bond_geometry
export bond_geometry!
export compute_shape_tensors!
export compute_deformation_gradients!


"""
bond_geometry(nodes::Union{SubArray,Vector{Int64}}, nlist, coor, undeformed_bond, undeformed_bond_length)
bond_geometry!(nodes::Union{SubArray,Vector{Int64}}, nlist, coor, undeformed_bond, undeformed_bond_length)
Calculate bond geometries between nodes based on their coordinates.
Expand Down Expand Up @@ -46,12 +46,12 @@ Calculate bond geometries between nodes based on their coordinates.
undeformed_bond(nodes, dof, nlist, coor, undeformed_bond)
"""

function bond_geometry(
function bond_geometry!(
undeformed_bond::Vector{Vector{Vector{Float64}}},
undeformed_bond_length::Vector{Vector{Float64}},
nodes::Union{SubArray,Vector{Int64}},
nlist::Vector{Vector{Int64}},
coor::Union{SubArray,Matrix{Float64},Matrix{Int64}},
undeformed_bond::Vector{Vector{Vector{Float64}}},
undeformed_bond_length::Vector{Vector{Float64}},
)

for iID in nodes
Expand Down Expand Up @@ -141,7 +141,7 @@ function compute_shape_tensors!(
volume,
omega[iID],
bond_damage[iID],
mapreduce(permutedims, vcat, undeformed_bond[iID]),
undeformed_bond[iID],
nlist,
iID,
)
Expand Down Expand Up @@ -180,8 +180,8 @@ function compute_shape_tensor!(
Cmn = zero(eltype(shape_tensor))
@inbounds @fastmath for k axes(undeformed_bond, 1)
Cmn +=
undeformed_bond[k, m] *
undeformed_bond[k, n] *
undeformed_bond[k][m] *
undeformed_bond[k][n] *
volume[nlist[iID][k]] *
omega[k] *
bond_damage[k]
Expand Down Expand Up @@ -271,8 +271,8 @@ function compute_deformation_gradients!(
compute_deformation_gradient!(
temp,
bond_damage[iID],
mapreduce(permutedims, vcat, deformed_bond[iID]),
mapreduce(permutedims, vcat, undeformed_bond[iID]),
deformed_bond[iID],
undeformed_bond[iID],
volume,
omega[iID],
nlist,
Expand Down Expand Up @@ -300,8 +300,8 @@ function compute_deformation_gradient!(
Cmn = zero(eltype(deformation_gradient))
@inbounds @fastmath for k axes(undeformed_bond, 1)
Cmn +=
deformed_bond[k, m] *
undeformed_bond[k, n] *
deformed_bond[k][m] *
undeformed_bond[k][n] *
volume[nlist[iID][k]] *
omega[k] *
bond_damage[k]
Expand Down
6 changes: 3 additions & 3 deletions test/unit_tests/Core/Solver/ut_Verlet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ volume = [0.5, 0.5, 0.5, 0.5, 0.5]
density = [1e-6, 1e-6, 3e-6, 3e-6, 1e-6]
horizon = [3.1, 3.1, 3.1, 3.1, 3.1]

PeriLab.IO.Geometry.bond_geometry(
PeriLab.IO.Geometry.bond_geometry!(
undeformed_bond,
undeformed_bond_length,
Vector(1:nnodes),
nlist,
coor,
undeformed_bond,
undeformed_bond_length,
)

blocks = [1, 1, 2, 2, 1]
Expand Down
6 changes: 3 additions & 3 deletions test/unit_tests/IO/ut_mesh_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -529,12 +529,12 @@ end
test_data_manager.create_constant_bond_field("Bond Geometry", Float64, dof)
undeformed_bond_length =
test_data_manager.create_constant_bond_field("Bond Length", Float64, 1)
PeriLab.IO.Geometry.bond_geometry(
PeriLab.IO.Geometry.bond_geometry!(
undeformed_bond,
undeformed_bond_length,
Vector(1:nnodes),
nlist,
coor,
undeformed_bond,
undeformed_bond_length,
)

@test undeformed_bond[1][1][1] == 1
Expand Down
42 changes: 21 additions & 21 deletions test/unit_tests/Support/ut_geometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ end
@test undeformed_bond[1][2][2] == 0
@test undeformed_bond_length[1][2] == 1

PeriLab.IO.Geometry.bond_geometry(
PeriLab.IO.Geometry.bond_geometry!(
undeformed_bond,
undeformed_bond_length,
Vector(1:nnodes),
nlist,
coor,
undeformed_bond,
undeformed_bond_length,
)

@test undeformed_bond[1][1][1] == 0.5
Expand All @@ -174,12 +174,12 @@ end
@test undeformed_bond[4][1][1] == 0.5
@test undeformed_bond[4][1][2] == -0.5
@test undeformed_bond_length[4][1] / sqrt(1.25) - 1 < 1e-8
PeriLab.IO.Geometry.bond_geometry(
PeriLab.IO.Geometry.bond_geometry!(
undeformed_bond,
undeformed_bond_length,
Vector(1:nnodes),
nlist,
coor,
undeformed_bond,
undeformed_bond_length,
)
# test if a sum exists or not
@test undeformed_bond[1][1][1] == 0.5
Expand Down Expand Up @@ -216,12 +216,12 @@ end
end
end

PeriLab.IO.Geometry.bond_geometry(
PeriLab.IO.Geometry.bond_geometry!(
undeformed_bond,
undeformed_bond_length,
Vector(1:nnodes),
nlist,
coor,
undeformed_bond,
undeformed_bond_length,
)
end

Expand Down Expand Up @@ -305,12 +305,12 @@ end
coor[4, 1] = 1
coor[4, 2] = 0.5

PeriLab.IO.Geometry.bond_geometry(
PeriLab.IO.Geometry.bond_geometry!(
undeformed_bond,
undeformed_bond_length,
Vector(1:nnodes),
nlist,
coor,
undeformed_bond,
undeformed_bond_length,
)
PeriLab.IO.Geometry.compute_shape_tensors!(
shape_tensor,
Expand Down Expand Up @@ -348,12 +348,12 @@ end
deformed_coor[2, 1] = 0.25
deformed_coor[4, 1] = 0.25

PeriLab.IO.Geometry.bond_geometry(
PeriLab.IO.Geometry.bond_geometry!(
deformed_bond,
deformed_bond_length,
Vector(1:nnodes),
nlist,
deformed_coor,
deformed_bond,
deformed_bond_length,
)
PeriLab.IO.Geometry.compute_deformation_gradients!(
deformation_gradient,
Expand Down Expand Up @@ -382,12 +382,12 @@ end
deformed_coor[3, 2] = 1.5
deformed_coor[4, 2] = 1.5

PeriLab.IO.Geometry.bond_geometry(
PeriLab.IO.Geometry.bond_geometry!(
deformed_bond,
deformed_bond_length,
Vector(1:nnodes),
nlist,
deformed_coor,
deformed_bond,
deformed_bond_length,
)
PeriLab.IO.Geometry.compute_deformation_gradients!(
deformation_gradient,
Expand Down Expand Up @@ -420,12 +420,12 @@ end
deformed_coor[4, 1] = 1.5
deformed_coor[4, 2] = 0.5

PeriLab.IO.Geometry.bond_geometry(
PeriLab.IO.Geometry.bond_geometry!(
deformed_bond,
deformed_bond_length,
Vector(1:nnodes),
nlist,
deformed_coor,
deformed_bond,
deformed_bond_length,
)
PeriLab.IO.Geometry.compute_deformation_gradients!(
deformation_gradient,
Expand Down

0 comments on commit b721122

Please sign in to comment.