2015-09-24 21:05:04 +03:00
|
|
|
|
# This file is a part of JuliaFEM.
|
|
|
|
|
|
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
|
|
|
|
|
|
|
|
|
|
|
|
abstract Problem
|
2015-10-09 23:45:28 +03:00
|
|
|
|
abstract BoundaryProblem <: Problem
|
|
|
|
|
|
abstract FieldProblem <: Problem
|
2015-09-24 21:05:04 +03:00
|
|
|
|
|
2015-10-28 04:29:14 +02:00
|
|
|
|
""" Return all equations beloging to this problem. """
|
2015-10-27 06:37:58 +02:00
|
|
|
|
function get_equations(problem::Problem)
|
|
|
|
|
|
problem.equations
|
2015-10-20 15:54:47 +03:00
|
|
|
|
end
|
2015-09-24 21:05:04 +03:00
|
|
|
|
|
2015-10-28 04:29:14 +02:00
|
|
|
|
""" Return the dimension of the unknown field of this problem. """
|
2015-10-27 06:37:58 +02:00
|
|
|
|
function get_unknown_field_dimension(problem::Problem)
|
|
|
|
|
|
problem.unknown_field_dimension
|
2015-09-24 21:05:04 +03:00
|
|
|
|
end
|
|
|
|
|
|
|
2015-10-28 04:29:14 +02:00
|
|
|
|
""" Return the name of the unknown field of this problem. """
|
2015-10-27 06:37:58 +02:00
|
|
|
|
function get_unknown_field_name(problem::Problem)
|
|
|
|
|
|
problem.unknown_field_name
|
2015-09-24 21:05:04 +03:00
|
|
|
|
end
|
|
|
|
|
|
|
2015-10-28 04:29:14 +02:00
|
|
|
|
"""
|
|
|
|
|
|
Add new equation to problem.
|
|
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
|
----------
|
|
|
|
|
|
problem
|
|
|
|
|
|
element
|
|
|
|
|
|
|
|
|
|
|
|
Notes
|
|
|
|
|
|
-----
|
|
|
|
|
|
Equation is automatically created during process based on problem
|
|
|
|
|
|
element -> equation mapping and element type.
|
|
|
|
|
|
"""
|
2015-11-18 01:19:04 +02:00
|
|
|
|
function Base.push!(problem::Problem, element::Element, args...)
|
|
|
|
|
|
# element_type = typeof(element)
|
|
|
|
|
|
# equation_type = problem.element_mapping[element_type]
|
|
|
|
|
|
# push!(problem.equations, equation_type(element, args...))
|
|
|
|
|
|
push!(problem.equations, element)
|
2015-10-09 23:45:28 +03:00
|
|
|
|
end
|
|
|
|
|
|
|
2015-10-28 04:29:14 +02:00
|
|
|
|
"""
|
|
|
|
|
|
Return the size of the problem, i.e.
|
|
|
|
|
|
maximum number of connectivity × unknown field dimension.
|
|
|
|
|
|
"""
|
|
|
|
|
|
function Base.size(problem::Problem)
|
|
|
|
|
|
mc = 0
|
|
|
|
|
|
for equation in get_equations(problem)
|
|
|
|
|
|
element = get_element(equation)
|
|
|
|
|
|
mc = max(mc, get_connectivity(element)...)
|
|
|
|
|
|
end
|
|
|
|
|
|
dim = get_unknown_field_dimension(problem)
|
|
|
|
|
|
return (dim, dim*mc)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
""" Assign new equation mapping to problem for some element.
|
|
|
|
|
|
|
|
|
|
|
|
Examples
|
|
|
|
|
|
--------
|
|
|
|
|
|
>>> p = PlaneHeatProblem()
|
|
|
|
|
|
>>> p[Seg2] = DC2D2
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
function Base.setindex!(problem::Problem, equation, element)
|
|
|
|
|
|
problem.element_mapping[element] = equation
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
""" Return global degrees of freedom of element in matrix level. """
|
|
|
|
|
|
function get_gdofs(problem::Problem, equation::Equation)
|
|
|
|
|
|
dim = get_unknown_field_dimension(problem)
|
|
|
|
|
|
element = get_element(equation)
|
|
|
|
|
|
conn = get_connectivity(element)
|
|
|
|
|
|
gdofs = vec(vcat([dim*conn'-i for i=dim-1:-1:0]...))
|
|
|
|
|
|
return gdofs
|
|
|
|
|
|
end
|
|
|
|
|
|
|