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
|
|
|
|
|
|
|
|
|
|
|
|
# Heat problems
|
|
|
|
|
|
|
2015-10-28 04:29:14 +02:00
|
|
|
|
""" Heat equations.
|
|
|
|
|
|
|
|
|
|
|
|
Formulation
|
|
|
|
|
|
-----------
|
|
|
|
|
|
|
|
|
|
|
|
Field equation is:
|
|
|
|
|
|
|
|
|
|
|
|
ρc∂u/∂t = ∇⋅(k∇u) + f
|
|
|
|
|
|
|
|
|
|
|
|
Weak form is: find u∈U such that ∀v in V
|
|
|
|
|
|
|
|
|
|
|
|
∫k∇u∇v dx = ∫fv dx + ∫gv ds,
|
|
|
|
|
|
|
|
|
|
|
|
where
|
|
|
|
|
|
|
2016-06-17 02:10:17 +03:00
|
|
|
|
k = temperature thermal conductivity defined on volume elements
|
|
|
|
|
|
f = temperature load defined on volume elements
|
|
|
|
|
|
g = temperature flux defined on boundary elements
|
2015-10-28 04:29:14 +02:00
|
|
|
|
|
|
|
|
|
|
References
|
|
|
|
|
|
----------
|
|
|
|
|
|
https://en.wikipedia.org/wiki/Heat_equation
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
2016-06-17 02:10:17 +03:00
|
|
|
|
type Heat <: FieldProblem
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function get_unknown_field_name(problem::Problem{Heat})
|
|
|
|
|
|
return "temperature"
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function get_unknown_field_type(problem::Problem{Heat})
|
|
|
|
|
|
return Float64
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2016-06-08 23:42:36 +03:00
|
|
|
|
function assemble!(assembly::Assembly, problem::Problem{Heat}, element::Element, time=0.0)
|
|
|
|
|
|
gdofs = get_gdofs(problem, element)
|
2016-06-19 20:01:37 +03:00
|
|
|
|
field_name = get_unknown_field_name(problem)
|
|
|
|
|
|
nnodes = length(element)
|
|
|
|
|
|
K = zeros(nnodes, nnodes)
|
|
|
|
|
|
fq = zeros(nnodes)
|
2015-11-27 10:10:00 +02:00
|
|
|
|
for ip in get_integration_points(element)
|
2016-06-08 23:42:36 +03:00
|
|
|
|
detJ = element(ip, time, Val{:detJ})
|
|
|
|
|
|
w = ip.weight*detJ
|
2015-11-27 10:10:00 +02:00
|
|
|
|
N = element(ip, time)
|
2016-06-19 20:01:37 +03:00
|
|
|
|
if haskey(element, "$field_name thermal conductivity")
|
2016-06-08 23:42:36 +03:00
|
|
|
|
dN = element(ip, time, Val{:Grad})
|
2016-06-19 20:01:37 +03:00
|
|
|
|
k = element("$field_name thermal conductivity", ip, time)
|
|
|
|
|
|
K += w*k*dN'*dN
|
2015-10-28 04:29:14 +02:00
|
|
|
|
end
|
2016-06-19 20:01:37 +03:00
|
|
|
|
if haskey(element, "$field_name load")
|
|
|
|
|
|
f = element("$field_name load", ip, time)
|
|
|
|
|
|
fq += w*N'*f
|
2015-10-28 04:29:14 +02:00
|
|
|
|
end
|
2016-06-19 20:01:37 +03:00
|
|
|
|
if haskey(element, "$field_name flux")
|
|
|
|
|
|
g = element("$field_name flux", ip, time)
|
|
|
|
|
|
fq += w*N'*g
|
2015-10-28 04:29:14 +02:00
|
|
|
|
end
|
|
|
|
|
|
end
|
2016-06-19 20:01:37 +03:00
|
|
|
|
T = vec(element[field_name](time))
|
|
|
|
|
|
fq -= K*T
|
|
|
|
|
|
add!(assembly.K, gdofs, gdofs, K)
|
|
|
|
|
|
add!(assembly.f, gdofs, fq)
|
2015-10-28 04:29:14 +02:00
|
|
|
|
end
|
|
|
|
|
|
|