diff --git a/src/JuliaFEM.jl b/src/JuliaFEM.jl index e424d04..8ea8c97 100644 --- a/src/JuliaFEM.jl +++ b/src/JuliaFEM.jl @@ -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 diff --git a/src/problems.jl b/src/problems.jl index facdf64..3bfce2c 100644 --- a/src/problems.jl +++ b/src/problems.jl @@ -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 diff --git a/test/test_add_elements.jl b/test/test_add_elements.jl new file mode 100644 index 0000000..10ee53d --- /dev/null +++ b/test/test_add_elements.jl @@ -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