mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-09-28 04:35:08 +00:00
removed Equation type from code
This commit is contained in:
+22
-63
@@ -1,77 +1,36 @@
|
||||
# This file is a part of JuliaFEM.
|
||||
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
|
||||
|
||||
abstract Problem
|
||||
abstract BoundaryProblem <: Problem
|
||||
abstract FieldProblem <: Problem
|
||||
abstract AbstractProblem
|
||||
|
||||
""" Return all equations beloging to this problem. """
|
||||
function get_equations(problem::Problem)
|
||||
problem.equations
|
||||
type Problem{T<:AbstractProblem}
|
||||
dim :: Int
|
||||
elements :: Vector{Element}
|
||||
end
|
||||
|
||||
type BoundaryProblem{T<:AbstractProblem}
|
||||
parent_field_name :: ASCIIString
|
||||
parent_field_dim :: Int
|
||||
dim :: Int
|
||||
elements :: Vector{Element}
|
||||
end
|
||||
|
||||
typealias AllProblems Union{Problem, BoundaryProblem}
|
||||
|
||||
function get_elements(problem::AllProblems)
|
||||
return problem.elements
|
||||
end
|
||||
|
||||
""" Return the dimension of the unknown field of this problem. """
|
||||
function get_unknown_field_dimension(problem::Problem)
|
||||
problem.unknown_field_dimension
|
||||
return problem.dim
|
||||
end
|
||||
|
||||
""" Return the name of the unknown field of this problem. """
|
||||
function get_unknown_field_name(problem::Problem)
|
||||
problem.unknown_field_name
|
||||
function get_unknown_field_name{P<:AbstractProblem}(problem::Problem{P})
|
||||
return get_unknown_field_name(P)
|
||||
end
|
||||
|
||||
"""
|
||||
Add new equation to problem.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
problem
|
||||
element
|
||||
|
||||
Notes
|
||||
-----
|
||||
Equation is automatically created during process based on problem
|
||||
element -> equation mapping and element type.
|
||||
"""
|
||||
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)
|
||||
function Base.push!(problem::AllProblems, element::Element)
|
||||
push!(problem.elements, element)
|
||||
end
|
||||
|
||||
"""
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user