Boundary Conditions
This section describes the user facing API for boundary conditions along with the implementation details.
DirichletBC
We can set up dirichlet boundary conditions on a variable u and sideset sset_1 with a zero function as follows.
julia> using FiniteElementContainersjulia> bc_func(x, t) = 0.bc_func (generic function with 1 method)julia> bc = DirichletBC(:u, bc_func; sideset_name = :sset_1)DirichletBC{typeof(Main.bc_func)}(Main.bc_func, nothing, nothing, :sset_1, :u)
Internally this is eventually converted in a DirichletBCContainer
Dirichlet bcs can be setup on element blocks, nodesets, or sidesets. The appropriate keyword argument needs to be supplied with the DirichletBC constructor.
FiniteElementContainers.DirichletBC — Type
struct DirichletBC{F} <: FiniteElementContainers.AbstractDirichletBC{F}func::Anyblock_name::Union{Nothing, Symbol}nset_name::Union{Nothing, Symbol}sset_name::Union{Nothing, Symbol}var_name::Symbol
User facing API to define a DirichletBC`.
FiniteElementContainers.DirichletBC — Method
struct DirichletBC{F} <: FiniteElementContainers.AbstractDirichletBC{F}DirichletBC(
var_name::String,
func::Function;
block_name,
nodeset_name,
sideset_name
) -> DirichletBC{F} where F<:Function
func::Anyblock_name::Union{Nothing, Symbol}nset_name::Union{Nothing, Symbol}sset_name::Union{Nothing, Symbol}var_name::Symbol
FiniteElementContainers.DirichletBC — Method
struct DirichletBC{F} <: FiniteElementContainers.AbstractDirichletBC{F}DirichletBC(
var_name::Symbol,
func::Function;
block_name,
nodeset_name,
sideset_name
) -> DirichletBC{F} where F<:Function
func::Anyblock_name::Union{Nothing, Symbol}nset_name::Union{Nothing, Symbol}sset_name::Union{Nothing, Symbol}var_name::Symbol
FiniteElementContainers.DirichletBCContainer — Type
struct DirichletBCContainer{IV<:(AbstractVector{<:Integer}), RV<:(AbstractVector{<:Number})} <: FiniteElementContainers.AbstractBCContainerdofs::AbstractVector{<:Integer}nodes::AbstractVector{<:Integer}vals::AbstractVector{<:Number}vals_dot::AbstractVector{<:Number}vals_dot_dot::AbstractVector{<:Number}
Internal implementation of dirichlet BCs
FiniteElementContainers.DirichletBCContainer — Method
struct DirichletBCContainer{IV<:(AbstractVector{<:Integer}), RV<:(AbstractVector{<:Number})} <: FiniteElementContainers.AbstractBCContainerDirichletBCContainer(
mesh,
dof::DofManager,
dbc::DirichletBC
) -> FiniteElementContainers.DirichletBCContainer{Vector{Int64}, Vector{Float64}}
dofs::AbstractVector{<:Integer}nodes::AbstractVector{<:Integer}vals::AbstractVector{<:Number}vals_dot::AbstractVector{<:Number}vals_dot_dot::AbstractVector{<:Number}
FiniteElementContainers._update_bc_values! — Method
_update_bc_values!(
bc::FiniteElementContainers.DirichletBCContainer,
func,
X,
t,
backend::KernelAbstractions.Backend
)
GPU kernel wrapper for updating bc values based on the stored function
FiniteElementContainers._update_bc_values! — Method
_update_bc_values!(
bc::FiniteElementContainers.DirichletBCContainer,
func,
X,
t,
_::KernelAbstractions.CPU
)
CPU implementation for updating stored bc values based on the stored function
NeumannBC
We can setup Neumann bcs on a variable u and sideset sset_1 with a simple constant function as follows
julia> using FiniteElementContainersjulia> using StaticArraysjulia> bc_func(x, t) = SVector{1, Float64}(1.)bc_func (generic function with 1 method)julia> bc = NeumannBC(:u, :sset_1, bc_func)NeumannBC{typeof(Main.bc_func)}(Main.bc_func, :sset_1, :u)
Note that in comparison to the dirichlet bc example above, the function in this case returns a SVector of size 1. This will hold for any variable u that has a single dof. For vector variables, e.g. a traction vector in continuum mechanics, would need something like
julia> using FiniteElementContainersjulia> using StaticArraysjulia> ND = 22julia> bc_func(x, t) = SVector{ND, Float64}(1.)bc_func (generic function with 1 method)julia> bc = NeumannBC(:u, :sset_1, bc_func)NeumannBC{typeof(Main.bc_func)}(Main.bc_func, :sset_1, :u)
where ND is the number of dimensions.
FiniteElementContainers.NeumannBC — Type
struct NeumannBC{F} <: FiniteElementContainers.AbstractBC{F}func::Anysset_name::Symbolvar_name::Symbol
User facing API to define a NeumannBC`.
FiniteElementContainers.NeumannBC — Method
struct NeumannBC{F} <: FiniteElementContainers.AbstractBC{F}NeumannBC(
var_name::String,
sset_name::String,
func::Function
) -> NeumannBC{<:Function}
func::Anysset_name::Symbolvar_name::Symbol
FiniteElementContainers.NeumannBC — Method
struct NeumannBC{F} <: FiniteElementContainers.AbstractBC{F}NeumannBC(
var_name::Symbol,
sset_name::Symbol,
func::Function
) -> NeumannBC{<:Function}
func::Anysset_name::Symbolvar_name::Symbol
FiniteElementContainers.NeumannBCContainer — Type
struct NeumannBCContainer{IT<:Integer, IV<:AbstractArray{IT<:Integer, 1}, IM<:AbstractArray{IT<:Integer, 2}, RV<:(AbstractMatrix{<:Union{var"#s55", var"#s50"} where {var"#s55"<:Number, var"#s50"<:(StaticArraysCore.SVector)}}), C1, C2, RE<:ReferenceFiniteElements.ReferenceFE} <: FiniteElementContainers.AbstractBCContainerelement_conns::Anyelements::AbstractVector{IT} where IT<:Integerside_nodes::AbstractMatrix{IT} where IT<:Integersides::AbstractVector{IT} where IT<:Integersurface_conns::Anyref_fe::ReferenceFiniteElements.ReferenceFEvals::AbstractMatrix{<:Union{var"#s55", var"#s50"} where {var"#s55"<:Number, var"#s50"<:(StaticArraysCore.SVector)}}
Internal implementation of dirichlet BCs
PeriodicBC
Periodic boundary conditions are very much a work in progress. There is currently some machinary to implement a Lagrange multiplier approach.
Stay tuned.
Boundary Condition Implementation Details
FiniteElementContainers.AbstractBC — Type
abstract type AbstractBC{F<:Function}FiniteElementContainers.AbstractBCFunction — Type
abstract type AbstractBCFunction{F}FiniteElementContainers.BCBookKeeping — Type
struct BCBookKeeping{I<:Integer, V<:AbstractArray{I<:Integer, 1}, M<:AbstractArray{I<:Integer, 2}}blocks::AbstractVector{I} where I<:Integerdofs::AbstractVector{I} where I<:Integerelements::AbstractVector{I} where I<:Integernodes::AbstractVector{I} where I<:Integersides::AbstractVector{I} where I<:Integerside_nodes::AbstractMatrix{I} where I<:Integer
This struct is used to help with book keeping nodes, sides, etc. for all types of boundary conditions.
TODO need to add a domain ID for extending to Schwarz
FiniteElementContainers.BCBookKeeping — Method
BCBookKeeping(
mesh,
dof::DofManager,
var_name::Symbol;
block_name,
nset_name,
sset_name
)
FiniteElementContainers.update_bc_values! — Method
update_bc_values!(bcs, funcs, X, t)
Wrapper that is generic for all architectures to update bc values based on the stored function