From 64d0aea6312c39edec2933db7846c826a552aff9 Mon Sep 17 00:00:00 2001 From: Jukka Aho Date: Thu, 31 Dec 2015 07:39:24 +0200 Subject: [PATCH] added test for 2d weighted gap calculation --- test/test_mortar_2d_weighted_gap.jl | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/test_mortar_2d_weighted_gap.jl diff --git a/test/test_mortar_2d_weighted_gap.jl b/test/test_mortar_2d_weighted_gap.jl new file mode 100644 index 0000000..c7f23e4 --- /dev/null +++ b/test/test_mortar_2d_weighted_gap.jl @@ -0,0 +1,46 @@ +# This file is a part of JuliaFEM. +# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md + +using JuliaFEM.Test + +using JuliaFEM.Core: Node, Seg2, update!, calculate_normal_tangential_coordinates!, MortarProblem, assemble, calculate_nodal_vector + +macro debug(msg) + haskey(ENV, "DEBUG") || return + return msg +end + +@testset "calculate mortar matrices and weighted gap vector for 2d model" begin + nodes = Node[ + [1.0, 1.0], + [3.0, 1.0], + [2.0, 2.0], + [4.0, 4.0]] + sel = Seg2([1, 2]) + mel = Seg2([3, 4]) + update!([sel, mel], "geometry", nodes) + calculate_normal_tangential_coordinates!(sel, 0.0) + sel["master elements"] = [mel] + prob = MortarProblem("displacement", 2) + push!(prob, sel) + a = assemble(prob, 0.0) + C1 = full(a.C1) + D = C1[:, [1, 2, 3, 4]]*24 + M = C1[:, [5, 6, 7, 8]]*24 + X = calculate_nodal_vector("geometry", 2, [sel, mel], 0.0) + @debug begin + info("nodal vector") + dump(round(full(X), 3)) + end + g = -C1*X + g = full(g) + @debug begin + dump(round(D, 3)) + dump(round(M, 3)) + dump(round(g, 3)) + end + I = eye(2) + @test isapprox(D, [2*I 4*I; 4*I 14*I]) + @test isapprox(-M, [5*I 1*I; 13*I 5*I]) + @test isapprox(g, 1/6*[0, 2, 0, 7]) +end