frictionless 2d contact

This commit is contained in:
Jukka Aho
2015-12-23 17:39:53 +02:00
parent 5426e47a26
commit a608a580fa
6 changed files with 1586 additions and 38 deletions
+69 -27
View File
@@ -4,64 +4,106 @@
module TestDirichletBoundaryCondition
using JuliaFEM.Test
using JuliaFEM.Core: Tri3, Seg2, DirichletProblem, Assembly, assemble
using JuliaFEM.Core: Tri3, Seg2, DirichletProblem, Assembly, assemble, Node,
BiorthogonalBasis
function test_dirichlet_problem_1_dim()
@testset "test dirichlet boundary conditions" begin
@testset "dirichlet problem in 1 dimension" begin
element = Seg2([1, 2])
element["geometry"] = Vector[[1.0, 1.0], [0.0, 1.0]]
element["geometry"] = Node[[1.0, 1.0], [0.0, 1.0]]
element["temperature"] = 0.0
problem = DirichletProblem("temperature", 1)
push!(problem, element)
assembly = assemble(problem, 0.0)
A = full(assembly.stiffness_matrix)
b = full(assembly.force_vector)
@test isapprox(A, 1/6*[2 1; 1 2])
@test isapprox(b, [0.0, 0.0])
C1 = full(assembly.C1)
C2 = full(assembly.C2)
g = full(assembly.g)
@test isapprox(C1, C2)
@test isapprox(C1, 1/6*[2 1; 1 2])
@test isapprox(g, [0.0, 0.0])
end
function test_dirichlet_problem_2_dim()
@testset "dirichlet problem in 2 dimensions" begin
element = Seg2([1, 2])
element["geometry"] = Vector[[1.0, 1.0], [0.0, 1.0]]
element["geometry"] = Node[[1.0, 1.0], [0.0, 1.0]]
element["displacement"] = 0.0
problem = DirichletProblem("displacement", 2)
push!(problem, element)
assembly = assemble(problem, 0.0)
A = full(assembly.stiffness_matrix)
b = full(assembly.force_vector)
A_expected = 1/6*[2 0 1 0; 0 2 0 1; 1 0 2 0; 0 1 0 2]
@test isapprox(A, A_expected)
@test isapprox(b, [0.0, 0.0, 0.0, 0.0])
C1 = full(assembly.C1)
C2 = full(assembly.C2)
g = full(assembly.g)
@test isapprox(C1, C2)
C1_expected = 1/6*[2 0 1 0; 0 2 0 1; 1 0 2 0; 0 1 0 2]
@test isapprox(C1, C1_expected)
@test isapprox(g, [0.0, 0.0, 0.0, 0.0])
end
function test_dirichlet_problem_2_dim_single_dof_fixed()
@testset "dirichlet problem in 2 dimensions, with 1 dof fixed" begin
element = Seg2([1, 2])
element["geometry"] = Vector[[1.0, 1.0], [0.0, 1.0]]
element["geometry"] = Node[[1.0, 1.0], [0.0, 1.0]]
element["displacement 2"] = 0.0
problem = DirichletProblem("displacement", 2)
push!(problem, element)
assembly = assemble(problem, 0.0)
A = full(assembly.stiffness_matrix)
b = full(assembly.force_vector)
info(b)
info("A = \n$A")
A_expected = 1/6*[
C1 = full(assembly.C1)
C2 = full(assembly.C2)
g = full(assembly.g)
@test isapprox(C1, C2)
C1_expected = 1/6*[
0 0 0 0
0 2 0 1
0 0 0 0
0 1 0 2]
@test isapprox(A, A_expected)
@test isapprox(b, [0.0, 0.0, 0.0, 0.0])
@test isapprox(C1, C1_expected)
@test isapprox(g, [0.0, 0.0, 0.0, 0.0])
end
function test_dirichlet_surface_tri3()
@testset "dirichlet problem using tri3 surface element" begin
elem = Tri3([1, 2, 3])
elem["geometry"] = Vector{Float64}[[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]]
elem["geometry"] = Node[[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]
elem["temperature"] = 0.0
prob = DirichletProblem("temperature", 1)
push!(prob, elem)
ass = assemble(prob, 0.0)
k = full(ass.stiffness_matrix)
@test isapprox(k, 1/24*[2 1 1; 1 2 1; 1 1 2])
C1 = full(ass.C1)
C2 = full(ass.C2)
@test isapprox(C1, C2)
@test isapprox(C1, 1/24*[2 1 1; 1 2 1; 1 1 2])
end
@testset "dirichlet problem using biorthogonal basis" begin
elem = Tri3([1, 2, 3])
elem["geometry"] = Node[[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]
elem["displacement 1"] = 1.0
prob = DirichletProblem("displacement", 3; basis=BiorthogonalBasis)
push!(prob, elem)
ass = assemble(prob, 0.0)
C1 = full(ass.C1, 9, 9)
C2 = full(ass.C2, 9, 9)
D = full(ass.D, 9, 9)
g = full(ass.g, 9, 1)
C1_expected = eye(9)*1.0/6.0
g_expected = zeros(9)
g_expected[1] = g_expected[4] = g_expected[7] = 1.0/6.0
C2_expected = zeros(9, 9)
D_expected = zeros(9, 9)
C2_expected[1, 1] = 1.0/6.0
D_expected[2, 2] = 1.0/6.0
D_expected[3, 3] = 1.0/6.0
C2_expected[4, 4] = 1.0/6.0
D_expected[5, 5] = 1.0/6.0
D_expected[6, 6] = 1.0/6.0
C2_expected[7, 7] = 1.0/6.0
D_expected[8, 8] = 1.0/6.0
D_expected[9, 9] = 1.0/6.0
@test isapprox(C1, C1_expected)
@test isapprox(C2, C2_expected)
@test isapprox(D, D_expected)
@test isapprox(g, g_expected)
end
end
end