Files
JuliaFEM.jl/test/test_global_assembly.jl
T

43 lines
1.3 KiB
Julia
Raw Normal View History

2015-10-28 04:29:14 +02:00
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
module AssemblyTests
2015-11-01 18:44:50 +02:00
using JuliaFEM.Test
2015-11-30 23:00:21 +02:00
using JuliaFEM.Core: Quad4, Seg2, FieldSet, Field, HeatProblem
using JuliaFEM.Core: Assembly, assemble!
2015-10-28 04:29:14 +02:00
2015-11-01 18:44:50 +02:00
"""assemble a simple two element problem and solve"""
function test_assembly()
info("create elements")
2015-10-28 04:29:14 +02:00
el1 = Quad4([1, 2, 3, 4])
el1["geometry"] = Vector[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]]
el1["temperature thermal conductivity"] = 6.0
el1["temperature load"] = 12.0
el1["density"] = 36.0
2015-10-28 04:29:14 +02:00
el2 = Seg2([1, 2])
el2["geometry"] = Vector[[0.0, 0.0], [1.0, 0.0]]
# Boundary load, linear ramp 0 -> 600 at time 0 -> 1
el2["temperature flux"] = ((0.0 => 0.0), (1.0 => 600.0))
info("element created")
2015-10-28 04:29:14 +02:00
problem = HeatProblem()
info("problem created. pushing elements")
2015-10-28 04:29:14 +02:00
push!(problem, el1)
push!(problem, el2)
info("creating assembly from equations")
assembly = Assembly()
assemble!(assembly, problem, 1.0)
info("solving")
2015-10-28 04:29:14 +02:00
free_dofs = [1, 2]
A = full(assembly.stiffness_matrix)[free_dofs, free_dofs]
b = full(assembly.force_vector)[free_dofs]
2015-10-28 04:29:14 +02:00
u = A \ b
info("solution u=$u")
@test isapprox(u, [101.0, 101.0])
2015-11-01 18:44:50 +02:00
end
2015-10-28 04:29:14 +02:00
end