2015-10-09 23:45:28 +03:00
|
|
|
# This file is a part of JuliaFEM.
|
|
|
|
|
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
|
|
|
|
|
|
|
|
|
|
# Dirichlet boundary conditions in weak form
|
|
|
|
|
|
|
|
|
|
abstract DirichletEquation <: Equation
|
|
|
|
|
|
2015-11-12 21:54:46 +02:00
|
|
|
function get_unknown_field_name(equation::DirichletEquation)
|
|
|
|
|
return "reaction force"
|
|
|
|
|
end
|
|
|
|
|
|
2015-10-09 23:45:28 +03:00
|
|
|
### Dirichlet problem + equations
|
|
|
|
|
|
|
|
|
|
type DirichletProblem <: BoundaryProblem
|
2015-10-27 06:37:58 +02:00
|
|
|
unknown_field_name :: ASCIIString
|
|
|
|
|
unknown_field_dimension :: Int
|
2015-11-12 07:16:25 +02:00
|
|
|
equations :: Vector{DirichletEquation}
|
2015-11-18 01:19:04 +02:00
|
|
|
# element_mapping :: Dict{DataType, DataType}
|
2015-10-27 06:37:58 +02:00
|
|
|
field_value :: Function
|
2015-10-09 23:45:28 +03:00
|
|
|
end
|
2015-10-27 06:37:58 +02:00
|
|
|
|
2015-11-12 07:16:25 +02:00
|
|
|
""" Initialize new Dirichlet boundary condition.
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
dimension
|
|
|
|
|
dimension of unknown field
|
|
|
|
|
field_value
|
|
|
|
|
boundary function
|
|
|
|
|
|
|
|
|
|
Examples
|
|
|
|
|
--------
|
|
|
|
|
|
|
|
|
|
Create u(X) = 0.0 boundary condition for three-dimensional elasticity problem:
|
|
|
|
|
|
|
|
|
|
>>> u(X) = [0.0, 0.0, 0.0]
|
|
|
|
|
>>> bc = DirichletProblem(3, u)
|
|
|
|
|
"""
|
2015-11-18 01:19:04 +02:00
|
|
|
function DirichletProblem(dimension::Int=1, field_value::Function=(X)->[0.0,0.0,0.0], equations=[])
|
|
|
|
|
# element_mapping = nothing
|
|
|
|
|
# if dimension == 1
|
|
|
|
|
# element_mapping = Dict(
|
|
|
|
|
# Seg2 => DBC2D2
|
|
|
|
|
# )
|
|
|
|
|
# end
|
|
|
|
|
DirichletProblem("reaction force", dimension, equations, field_value)
|
|
|
|
|
# DirichletProblem("reaction force", dimension, [], element_mapping, field_value)
|
2015-10-09 23:45:28 +03:00
|
|
|
end
|
|
|
|
|
|
2015-10-27 06:37:58 +02:00
|
|
|
""" Dirichlet boundary condition element for 2 node line segment """
|
2015-10-09 23:45:28 +03:00
|
|
|
type DBC2D2 <: DirichletEquation
|
|
|
|
|
element :: Seg2
|
2015-11-12 07:16:25 +02:00
|
|
|
integration_points :: Vector{IntegrationPoint}
|
2015-10-09 23:45:28 +03:00
|
|
|
end
|
2015-11-18 01:19:04 +02:00
|
|
|
|
|
|
|
|
function Base.size(equation::DBC2D2)
|
|
|
|
|
return (1, 2)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#function DBC2D2(element::Seg2)
|
|
|
|
|
function Base.convert(::Type{DirichletEquation}, element::Seg2)
|
|
|
|
|
integration_points = line3()
|
|
|
|
|
haskey(element, "reaction force") || (element["reaction force"] = zeros(1, 2))
|
2015-10-27 06:37:58 +02:00
|
|
|
DBC2D2(element, integration_points)
|
2015-10-09 23:45:28 +03:00
|
|
|
end
|
2015-11-18 01:19:04 +02:00
|
|
|
|
2015-10-27 06:37:58 +02:00
|
|
|
|
2015-11-12 21:54:46 +02:00
|
|
|
function assemble!(assembly::Assembly, equation::DirichletEquation, time::Number=0.0, problem=nothing)
|
|
|
|
|
gdofs = get_gdofs(equation)
|
2015-11-18 01:19:04 +02:00
|
|
|
# info("gdofs = $gdofs")
|
2015-10-27 06:37:58 +02:00
|
|
|
element = get_element(equation)
|
|
|
|
|
basis = get_basis(element)
|
|
|
|
|
detJ = det(basis)
|
|
|
|
|
for ip in get_integration_points(equation)
|
|
|
|
|
w = ip.weight * detJ(ip)
|
|
|
|
|
N = basis(ip, time)
|
2015-11-12 21:54:46 +02:00
|
|
|
add!(assembly.stiffness_matrix, gdofs, gdofs, w*N'*N)
|
2015-11-18 01:19:04 +02:00
|
|
|
# info("added $(w*N'*N)")
|
|
|
|
|
# if !isa(problem, Void)
|
|
|
|
|
# X = basis("geometry", ip, time)
|
|
|
|
|
# u = problem.field_value(X)[1:length(gdofs)]
|
|
|
|
|
# add!(assembly.force_vector, gdofs, w*N'*u)
|
|
|
|
|
# end
|
2015-10-27 06:37:58 +02:00
|
|
|
end
|
2015-11-18 01:19:04 +02:00
|
|
|
# info("assembly done")
|
2015-10-09 23:45:28 +03:00
|
|
|
end
|
|
|
|
|
|