2015-08-31 20:15:28 +03:00
|
|
|
# This file is a part of JuliaFEM.
|
|
|
|
|
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
|
|
|
|
|
|
|
|
|
|
abstract Equation
|
|
|
|
|
|
2015-10-20 15:54:47 +03:00
|
|
|
function get_unknown_field_name(equation::Equation)
|
|
|
|
|
eqtype = typeof(equation)
|
|
|
|
|
error("define get_unknown_field_name for this equation type $eqtype")
|
|
|
|
|
end
|
|
|
|
|
|
2015-08-31 20:15:28 +03:00
|
|
|
|
2015-09-10 02:20:34 +03:00
|
|
|
has_lhs(eq::Equation) = false
|
2015-08-31 20:15:28 +03:00
|
|
|
get_lhs(eq::Equation, xi) = nothing
|
2015-09-10 02:20:34 +03:00
|
|
|
has_rhs(eq::Equation) = false
|
2015-08-31 20:15:28 +03:00
|
|
|
get_rhs(eq::Equation, xi) = nothing
|
|
|
|
|
get_element(eq::Equation) = eq.element
|
|
|
|
|
get_integration_points(eq::Equation) = eq.integration_points
|
2015-09-24 21:05:04 +03:00
|
|
|
|
2015-08-31 20:15:28 +03:00
|
|
|
# couple convenient functions -- could make weak form definition easier
|
2015-09-24 21:05:04 +03:00
|
|
|
get_connectivity(eq::Equation) = get_connectivity(get_element(eq))
|
2015-08-31 20:15:28 +03:00
|
|
|
get_basis(eq::Equation, ip::IntegrationPoint) = get_basis(get_element(eq), ip.xi)
|
|
|
|
|
get_dbasisdx(eq::Equation, ip::IntegrationPoint) = get_dbasisdx(get_element(eq), ip.xi)
|
2015-09-29 00:07:56 +03:00
|
|
|
interpolate(eq::Equation, field::Union{ASCIIString, Symbol}, ip::IntegrationPoint) = interpolate(get_element(el), field, ip.xi)
|
|
|
|
|
integrate_lhs(eq::Equation, t::Number) = has_lhs(eq) ? integrate(eq, get_lhs, t) : nothing
|
|
|
|
|
integrate_rhs(eq::Equation, t::Number) = has_rhs(eq) ? integrate(eq, get_rhs, t) : nothing
|
2015-10-09 01:44:08 +03:00
|
|
|
get_lhs(eq::Equation, t::Number) = has_lhs(eq) ? integrate(eq, get_lhs, t) : nothing
|
|
|
|
|
get_rhs(eq::Equation, t::Number) = has_rhs(eq) ? integrate(eq, get_rhs, t) : nothing
|
2015-08-31 20:15:28 +03:00
|
|
|
|
2015-09-24 21:05:04 +03:00
|
|
|
|
2015-08-31 20:15:28 +03:00
|
|
|
"""
|
|
|
|
|
Return determinant of Jacobian for numerical integration.
|
|
|
|
|
"""
|
2015-09-29 00:07:56 +03:00
|
|
|
function get_detJ(eq::Equation, ip::IntegrationPoint, t::Float64)
|
2015-08-31 20:15:28 +03:00
|
|
|
el = get_element(eq)
|
2015-09-29 00:07:56 +03:00
|
|
|
get_detJ(el, ip, t)
|
2015-08-31 20:15:28 +03:00
|
|
|
end
|
2015-09-29 00:07:56 +03:00
|
|
|
function get_detJ(el::Element, ip::IntegrationPoint, t::Float64)
|
|
|
|
|
get_detJ(el, ip.xi, t)
|
2015-08-31 20:15:28 +03:00
|
|
|
end
|
2015-09-29 00:07:56 +03:00
|
|
|
function get_detJ(el::Element, xi::Vector, t::Float64)
|
2015-10-09 01:44:08 +03:00
|
|
|
J = get_jacobian(el, xi, t)
|
2015-09-22 20:05:40 +03:00
|
|
|
s = size(J)
|
|
|
|
|
return s[1] == s[2] ? det(J) : norm(J)
|
2015-09-14 18:50:17 +03:00
|
|
|
end
|
2015-08-31 20:15:28 +03:00
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
Integrate f over element
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
eq::Equation
|
2015-09-14 16:15:36 +03:00
|
|
|
|
2015-08-31 20:15:28 +03:00
|
|
|
f::Function
|
|
|
|
|
Function to integrate
|
|
|
|
|
"""
|
2015-09-29 00:07:56 +03:00
|
|
|
function integrate(eq::Equation, f::Function, t::Float64)
|
2015-08-31 20:15:28 +03:00
|
|
|
target = []
|
|
|
|
|
for ip in get_integration_points(eq)
|
2015-09-29 00:07:56 +03:00
|
|
|
push!(target, ip.weight*f(eq, ip, t)*get_detJ(eq, ip, t))
|
2015-08-31 20:15:28 +03:00
|
|
|
end
|
|
|
|
|
return sum(target)
|
|
|
|
|
end
|
|
|
|
|
|
2015-09-14 16:15:36 +03:00
|
|
|
function get_global_dofs(eq::Equation)
|
|
|
|
|
eq.global_dofs
|
|
|
|
|
end
|
|
|
|
|
|
2015-09-24 21:05:04 +03:00
|
|
|
function set_global_dofs!(eq::Equation, dofs)
|
2015-09-14 16:15:36 +03:00
|
|
|
eq.global_dofs = dofs
|
|
|
|
|
end
|
|
|
|
|
|