Skip to content

Commit

Permalink
Merge pull request #48 from brianphung/schwarz_inclined_contact
Browse files Browse the repository at this point in the history
Implicit Dynamics Inclined Schwarz Contact Bugfix + Tests
  • Loading branch information
lxmota authored Feb 6, 2025
2 parents 060269f + b423f3b commit 13203f9
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 51 deletions.
7 changes: 5 additions & 2 deletions src/ics_bcs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ function apply_bc(model::SolidMechanics, bc::SMDirichletInclined)
model.acceleration[:, node_index] = original_acceleration
# Inclined support is only applied in local X
model.free_dofs[3*node_index-2] = false
model.free_dofs[3*node_index-1] = true
model.free_dofs[3*node_index] = true

global_base = 3 * (node_index - 1) # Block index in global stiffness
model.global_transform[global_base+1:global_base+3, global_base+1:global_base+3] = bc.rotation_matrix
Expand Down Expand Up @@ -678,8 +680,9 @@ function apply_sm_schwarz_contact_dirichlet(model::SolidMechanics, bc::SMContact
model.acceleration[:, node_index],
closest_normal,
)
dof_index = [3 * node_index - 2]
model.free_dofs[dof_index] .= false
model.free_dofs[[3 * node_index - 2]] .= false
model.free_dofs[[3 * node_index - 1]] .= true
model.free_dofs[[3 * node_index]] .= true
global_base = 3 * (node_index - 1) # Block index in global stiffness
model.global_transform[global_base+1:global_base+3, global_base+1:global_base+3] = bc.rotation_matrix
end
Expand Down
98 changes: 49 additions & 49 deletions test/schwarz-contact-dynamic-cubes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,58 +62,58 @@ using YAML

end

# @testset "schwarz-contact-inclined-implicit-cubes" begin
@testset "schwarz-contact-inclined-implicit-cubes" begin

# model_fine = nothing
# model_coarse = nothing
model_fine = nothing
model_coarse = nothing

# angles = [ 0.0, 22.5, 45, 90 ]
# for (i, angle_deg) in enumerate(angles)
# cp("../examples/contact/implicit-dynamic/inclined-cubes/cubes-test$i.yaml", "cubes-test$i.yaml", force=true)
# cp("../examples/contact/implicit-dynamic/inclined-cubes/cube-test$i-1.yaml", "cube-test$i-1.yaml", force=true)
# cp("../examples/contact/implicit-dynamic/inclined-cubes/cube-test$i-2.yaml", "cube-test$i-2.yaml", force=true)
# cp("../examples/contact/implicit-dynamic/inclined-cubes/cube-test$i-1.g", "cube-test$i-1.g", force=true)
# cp("../examples/contact/implicit-dynamic/inclined-cubes/cube-test$i-2.g", "cube-test$i-2.g", force=true)
# input_file = "cubes-test$i.yaml"
# params = YAML.load_file(input_file; dicttype=Dict{String,Any})
# params["initial time"] = -1.0e-06
# params["final time"] = 1.0e-3
# sim = Norma.run(params, input_file)
# subsim_temp = sim.subsims
# model_fine_temp = subsim_temp[1].model.current
# model_coarse_temp = subsim_temp[2].model.current
angles = [ 0.0, 22.5, 45, 90 ]
for (i, angle_deg) in enumerate(angles)
cp("../examples/contact/implicit-dynamic/inclined-cubes/cubes-test$i.yaml", "cubes-test$i.yaml", force=true)
cp("../examples/contact/implicit-dynamic/inclined-cubes/cube-test$i-1.yaml", "cube-test$i-1.yaml", force=true)
cp("../examples/contact/implicit-dynamic/inclined-cubes/cube-test$i-2.yaml", "cube-test$i-2.yaml", force=true)
cp("../examples/contact/implicit-dynamic/inclined-cubes/cube-test$i-1.g", "cube-test$i-1.g", force=true)
cp("../examples/contact/implicit-dynamic/inclined-cubes/cube-test$i-2.g", "cube-test$i-2.g", force=true)
input_file = "cubes-test$i.yaml"
params = YAML.load_file(input_file; dicttype=Dict{String,Any})
params["initial time"] = -1.0e-06
params["final time"] = 1.0e-3
sim = Norma.run(params, input_file)
subsim_temp = sim.subsims
model_fine_temp = subsim_temp[1].model.current
model_coarse_temp = subsim_temp[2].model.current

# rm("cubes-test$i.yaml")
# rm("cube-test$i-1.yaml")
# rm("cube-test$i-2.yaml")
# rm("cube-test$i-1.g")
# rm("cube-test$i-2.g")
# rm("cube-test$i-1.e")
# rm("cube-test$i-2.e")
rm("cubes-test$i.yaml")
rm("cube-test$i-1.yaml")
rm("cube-test$i-2.yaml")
rm("cube-test$i-1.g")
rm("cube-test$i-2.g")
rm("cube-test$i-1.e")
rm("cube-test$i-2.e")

# if ( i == 1 )
# model_fine = model_fine_temp
# model_coarse = model_coarse_temp
# else
# # Rotate these displacements about z
# angle = angle_deg * π / 180
# c = cos(angle)
# s = sin(angle)
# local_rotation_matrix = [ c s 0; -s c 0 ; 0 0 1]
# model_fine_rotated = zeros((3,68))
# model_coarse_rotated = zeros((3,27))
# for i in range(1,68)
# base = (i-1)*(3) + 1
# model_fine_rotated[:, i] = local_rotation_matrix * model_fine_temp[:, i]
# end
# for i in range(1,27)
# base = (i-1)*(3) + 1
# model_coarse_rotated[:, i] = local_rotation_matrix * model_coarse_temp[:, i]
# end
if ( i == 1 )
model_fine = model_fine_temp
model_coarse = model_coarse_temp
else
# Rotate these displacements about z
angle = angle_deg * π / 180
c = cos(angle)
s = sin(angle)
local_rotation_matrix = [ c s 0; -s c 0 ; 0 0 1]
model_fine_rotated = zeros((3,68))
model_coarse_rotated = zeros((3,27))
for i in range(1,68)
base = (i-1)*(3) + 1
model_fine_rotated[:, i] = local_rotation_matrix * model_fine_temp[:, i]
end
for i in range(1,27)
base = (i-1)*(3) + 1
model_coarse_rotated[:, i] = local_rotation_matrix * model_coarse_temp[:, i]
end

# @test model_fine_rotated ≈ model_fine rtol=2e-4
# @test model_coarse_rotated ≈ model_coarse rtol=2e-4
# end
# end
@test model_fine_rotated model_fine rtol=2e-4
@test model_coarse_rotated model_coarse rtol=2e-4
end
end

# end
end

0 comments on commit 13203f9

Please sign in to comment.