Skip to content

Commit

Permalink
Merge pull request #39 from sandialabs/swap_bc_types
Browse files Browse the repository at this point in the history
Adding option to swap Neumann and Dirichlet BCs for Schwarz non-overlapping coupling and contact
  • Loading branch information
ikalash authored Jan 23, 2025
2 parents 363b0f2 + eab1d74 commit 342211e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
2 changes: 2 additions & 0 deletions examples/nonoverlap/static-same-time-step/cuboid-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ boundary conditions:
source: cuboid-2.yaml
source block: coarse
source side set: ssz-
default BC type: Neumann
swap BC types: false
solver:
type: Hessian minimizer
step: full Newton
Expand Down
2 changes: 2 additions & 0 deletions examples/nonoverlap/static-same-time-step/cuboid-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ boundary conditions:
source: cuboid-1.yaml
source block: fine
source side set: ssz+
default BC type: Neumann
swap BC types: false
solver:
type: Hessian minimizer
step: full Newton
Expand Down
35 changes: 32 additions & 3 deletions src/ics_bcs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ function SMContactSchwarzBC(
coupled_side_set_id = side_set_id_from_name(coupled_side_set_name, coupled_mesh)
is_dirichlet = true
transfer_operator = Matrix{Float64}(undef, 0, 0)
swap_bcs = false
if haskey(bc_params, "swap BC types") == true
swap_bcs = bc_params["swap BC types"]
end
SMContactSchwarzBC(
side_set_name,
side_set_id,
Expand All @@ -97,6 +101,7 @@ function SMContactSchwarzBC(
coupled_side_set_id,
is_dirichlet,
transfer_operator,
swap_bcs
)
end

Expand All @@ -107,7 +112,8 @@ function SMNonOverlapSchwarzBC(side_set_id::Int64,
coupled_subsim::Simulation,
subsim::Simulation,
coupled_side_set_id::Int64,
is_dirichlet::Bool)
is_dirichlet::Bool,
swap_bcs::Bool)
transfer_operator = Matrix{Float64}(undef, 0, 0)
return SMNonOverlapSchwarzBC(side_set_id,
side_set_node_indices,
Expand All @@ -117,6 +123,7 @@ function SMNonOverlapSchwarzBC(side_set_id::Int64,
subsim,
coupled_side_set_id,
is_dirichlet,
swap_bcs,
transfer_operator)
end

Expand Down Expand Up @@ -159,6 +166,7 @@ function SMCouplingSchwarzBC(
push!(interpolation_function_values, N)
end
is_dirichlet = true
swap_bcs = false
if bc_type == "Schwarz overlap"
SMOverlapSchwarzBC(
side_set_name,
Expand All @@ -167,9 +175,23 @@ function SMCouplingSchwarzBC(
interpolation_function_values,
coupled_subsim,
subsim,
is_dirichlet
is_dirichlet,
swap_bcs
)
elseif bc_type == "Schwarz nonoverlap"
if haskey(bc_params, "default BC type") == true
default_bc_type = bc_params["default BC type"]
if default_bc_type == "Dirichlet"
is_dirichlet = true
elseif default_bc_type == "Neumann"
is_dirichlet = false
else
error("Invalid string for 'default BC type'! Valid options are 'Dirichlet' and 'Neumann'")
end
end
if haskey(bc_params, "swap BC types") == true
swap_bcs = bc_params["swap BC types"]
end
SMNonOverlapSchwarzBC(
side_set_id,
side_set_node_indices,
Expand All @@ -178,7 +200,8 @@ function SMCouplingSchwarzBC(
coupled_subsim,
subsim,
coupled_side_set_id,
is_dirichlet
is_dirichlet,
swap_bcs
)
else
error("Unknown boundary condition type : ", bc_type)
Expand Down Expand Up @@ -342,6 +365,9 @@ function apply_bc_detail(model::SolidMechanics, bc::SMContactSchwarzBC)
else
apply_sm_schwarz_contact_neumann(model, bc)
end
if (bc.swap_bcs == true)
bc.is_dirichlet = !bc.is_dirichlet
end
end

function apply_bc_detail(model::SolidMechanics, bc::CouplingSchwarzBoundaryCondition)
Expand All @@ -350,6 +376,9 @@ function apply_bc_detail(model::SolidMechanics, bc::CouplingSchwarzBoundaryCondi
else
apply_sm_schwarz_coupling_neumann(model, bc)
end
if (bc.swap_bcs == true)
bc.is_dirichlet = !bc.is_dirichlet
end
end

function apply_bc_detail(model::LinearOpInfRom, bc::CouplingSchwarzBoundaryCondition)
Expand Down
3 changes: 3 additions & 0 deletions src/ics_bcs_def.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ mutable struct SMContactSchwarzBC <: ContactSchwarzBoundaryCondition
coupled_side_set_id::Int64
is_dirichlet::Bool
transfer_operator::Matrix{Float64}
swap_bcs::Bool
end

mutable struct SMOverlapSchwarzBC <: OverlapSchwarzBoundaryCondition
Expand All @@ -66,6 +67,7 @@ mutable struct SMOverlapSchwarzBC <: OverlapSchwarzBoundaryCondition
coupled_subsim::Simulation
subsim::Simulation
is_dirichlet::Bool
swap_bcs::Bool
end

mutable struct SMNonOverlapSchwarzBC <: NonOverlapSchwarzBoundaryCondition
Expand All @@ -77,5 +79,6 @@ mutable struct SMNonOverlapSchwarzBC <: NonOverlapSchwarzBoundaryCondition
subsim::Simulation
coupled_side_set_id::Int64
is_dirichlet::Bool
swap_bcs::Bool
transfer_operator::Matrix{Float64}
end

0 comments on commit 342211e

Please sign in to comment.