Implement new function add_elements!

Add new elements to the problem.
This commit is contained in:
Rapo
2017-08-16 14:09:54 +03:00
committed by Jukka Aho
parent 8ca459fc3a
commit 683c0a03e6
3 changed files with 26 additions and 2 deletions
+1 -1
View File
@@ -78,7 +78,7 @@ export add!, SparseMatrixCOO, SparseVectorCOO, get_nonzero_rows, get_nonzero_col
include("problems.jl") # common problem routines
export Problem, AbstractProblem, FieldProblem, BoundaryProblem,
get_unknown_field_dimension, get_gdofs, Assembly,
get_parent_field_name, get_elements
get_parent_field_name, get_elements, add_elements!
include("problems_elasticity.jl")
export Elasticity
+12 -1
View File
@@ -8,7 +8,7 @@ abstract type MixedProblem<:AbstractProblem end
"""
General linearized problem to solve
(K₁+K₂)Δu + C1'*Δλ = f₁+f₂
(K₁+K₂)Δu + C1*Δλ = f₁+f₂
C2Δu + D*Δλ = g
"""
type Assembly
@@ -274,6 +274,17 @@ function update!{P<:BoundaryProblem}(problem::Problem{P}, assembly::Assembly, el
end
end
"""
add_elements!(problem::Problem, elements)
Add new elements into the problem.
"""
function add_elements!(problem::Problem, elements)
for element in elements
push!(problem.elements, element)
end
end
function get_elements(problem::Problem)
return problem.elements
end
+13
View File
@@ -0,0 +1,13 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
using JuliaFEM
using Base.Test
@testset "add elements to problem" begin
problem = Problem(Elasticity, "test", 2)
element = Element(Quad4, [1, 2, 3, 4])
elements = [element]
add_elements!(problem, elements)
@test problem.elements[1] == element
end