modal solver + tie contact works now. dirichlet boundary and mpcs are eliminated properly before solution to get reduced system

This commit is contained in:
Jukka Aho
2016-06-22 01:39:28 +03:00
parent 8bd32cbeca
commit 6d3e33c3ff
14 changed files with 887 additions and 120 deletions
@@ -18,7 +18,7 @@ using JuliaFEM.Test
block.elements = create_elements(mesh, "BLOCK")
update!(block.elements, "youngs modulus", 288.0)
update!(block.elements, "poissons ratio", 1/3)
# update!(block.elements, "displacement load 2", 576.0)
update!(block.elements, "displacement load 2", 576.0)
traction = create_elements(mesh, "TOP")
update!(traction, "displacement traction force 2", 288.0)
+76
View File
@@ -42,3 +42,79 @@ using JuliaFEM.Test
call(s1; debug=true)
@test isapprox(s1.properties.eigvals, [5/3, 2/3])
end
@testset "test poisson problem modal analysis without tie" begin
X = Dict{Int64, Vector{Float64}}(
1 => [0.0, 0.0],
2 => [1.0, 0.0],
3 => [1.0, 3.0],
4 => [0.0, 3.0],
5 => [0.0, 3.0],
6 => [1.0, 3.0],
7 => [1.0, 9.0],
8 => [0.0, 9.0])
T = Dict{Int64, Float64}()
for i=1:8
T[i] = 0.0
end
el1 = Element(Quad4, [1, 2, 3, 4])
el2 = Element(Quad4, [4, 3, 7, 8])
el3 = Element(Seg2, [1, 2])
el4 = Element(Seg2, [7, 8])
update!([el1, el2, el3, el4], "geometry", X)
update!([el1, el2], "density", 6.0)
update!([el1, el2], "temperature thermal conductivity", 36.0)
update!([el1, el2], "temperature", T)
update!([el3, el4], "temperature 1", 0.0)
p1 = Problem(Heat, "combined body", 1)
p2 = Problem(Dirichlet, "fixed ends", 1, "temperature")
push!(p1, el1, el2)
push!(p2, el3, el4)
solver = Solver(Modal)
push!(solver, p1, p2)
call(solver)
@test isapprox(solver.properties.eigvals[1], 1.0)
end
@testset "test poisson modal problem with mesh tie" begin
X = Dict{Int64, Vector{Float64}}(
1 => [0.0, 0.0],
2 => [1.0, 0.0],
3 => [1.0, 3.0],
4 => [0.0, 3.0],
5 => [0.0, 3.0],
6 => [1.0, 3.0],
7 => [1.0, 9.0],
8 => [0.0, 9.0])
T = Dict{Int64, Float64}()
for i=1:8
T[i] = 0.0
end
el1 = Element(Quad4, [1, 2, 3, 4])
el2 = Element(Quad4, [5, 6, 7, 8])
el3 = Element(Seg2, [1, 2])
el4 = Element(Seg2, [7, 8])
el5 = Element(Seg2, [3, 4])
el6 = Element(Seg2, [5, 6])
update!([el1, el2, el3, el4, el5, el6], "geometry", X)
update!([el1, el2], "temperature", T)
update!([el1, el2], "density", 6.0)
update!([el1, el2], "temperature thermal conductivity", 36.0)
update!([el3, el4], "temperature 1", 0.0)
update!(el5, "master elements", [el6])
p1 = Problem(Heat, "body 1", 1)
p2 = Problem(Heat, "body 2", 1)
p3 = Problem(Dirichlet, "fixed ends", 1, "temperature")
p4 = Problem(Mortar, "interface between bodies", 1, "temperature")
p4.properties.dimension = 1
push!(p1, el1)
push!(p2, el2)
push!(p3, el3, el4)
push!(p4, el5, el6)
solver = Solver(Modal)
push!(solver, p1, p2, p3, p4)
call(solver)
@test isapprox(solver.properties.eigvals[1], 1.0)
end
+119
View File
@@ -0,0 +1,119 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
using JuliaFEM
using JuliaFEM.Preprocess
using JuliaFEM.Postprocess
using JuliaFEM.Test
function get_test_model()
X = Dict{Int64, Vector{Float64}}(
1 => [0.0, 0.0],
2 => [1.0, 0.0],
3 => [1.0, 0.5],
4 => [0.0, 0.5],
5 => [0.0, 0.6],
6 => [1.0, 0.6],
7 => [1.0, 1.1],
8 => [0.0, 1.1])
el1 = Element(Quad4, [1, 2, 3, 4])
el2 = Element(Quad4, [5, 6, 7, 8])
el3 = Element(Seg2, [1, 2])
el4 = Element(Seg2, [7, 8])
el5 = Element(Seg2, [4, 3])
el6 = Element(Seg2, [5, 6])
update!([el1, el2, el3, el4, el5, el6], "geometry", X)
update!([el1, el2], "youngs modulus", 96.0)
update!([el1, el2], "poissons ratio", 1/3)
update!([el3], "displacement 1", 0.0)
update!([el3], "displacement 2", 0.0)
update!([el4], "displacement 1", 0.0)
update!([el4], "displacement 2", 0.0)
update!(el6, "master elements", [el5])
p1 = Problem(Elasticity, "body1", 2)
p2 = Problem(Elasticity, "body2", 2)
p3 = Problem(Dirichlet, "fixed", 2, "displacement")
p4 = Problem(Mortar, "interface", 2, "displacement")
push!(p1, el1)
push!(p2, el2)
push!(p3, el3, el4)
push!(p4, el5, el6)
return p1, p2, p3, p4
end
@testset "test adjust setting in 2d tie contact" begin
p1, p2, p3, p4 = get_test_model()
p1.properties.formulation = :plane_stress
p2.properties.formulation = :plane_stress
p4.properties.dimension = 1
p4.properties.adjust = true
p4.properties.rotate_normals = false
solver = Solver(Nonlinear)
push!(solver, p1, p2, p3, p4)
call(solver)
el5 = p4.elements[1]
u = el5("displacement", [0.0], 0.0)
info("u = $u")
@test isapprox(u, [0.0, 0.05])
end
@testset "test that interface transfers constant field without error" begin
meshfile = Pkg.dir("JuliaFEM") * "/test/testdata/block_2d.med"
mesh = aster_read_mesh(meshfile)
upper = Problem(Heat, "upper", 1)
upper.elements = create_elements(mesh, "UPPER")
update!(upper.elements, "temperature thermal conductivity", 1.0)
lower = Problem(Heat, "lower", 1)
lower.elements = create_elements(mesh, "LOWER")
update!(lower.elements, "temperature thermal conductivity", 1.0)
bc_upper = Problem(Dirichlet, "upper boundary", 1, "temperature")
bc_upper.elements = create_elements(mesh, "UPPER_TOP")
update!(bc_upper.elements, "temperature 1", 0.0)
bc_lower = Problem(Dirichlet, "lower boundary", 1, "temperature")
bc_lower.elements = create_elements(mesh, "LOWER_BOTTOM")
update!(bc_lower.elements, "temperature 1", 1.0)
interface = Problem(Mortar, "interface between upper and lower block", 1, "temperature")
interface_slave_elements = create_elements(mesh, "LOWER_TOP")
interface_master_elements = create_elements(mesh, "UPPER_BOTTOM")
update!(interface_slave_elements, "master elements", interface_master_elements)
interface.elements = [interface_master_elements; interface_slave_elements]
interface.properties.dimension = 1
solver = Solver()
push!(solver, upper, lower, bc_upper, bc_lower, interface)
call(solver)
node_ids, temperature = get_nodal_vector(interface.elements, "temperature", 0.0)
T = [t[1] for t in temperature]
minT = minimum(T)
maxT = maximum(T)
info("minT = $minT, maxT = $maxT")
@test isapprox(minT, 0.5)
@test isapprox(maxT, 0.5)
end
#=
@testset "expect clear error when trying to solve 2d model in 3d setting" begin
p1, p2, p3, p4 = get_test_model()
# p1.properties.formulation = :plane_stress
# p2.properties.formulation = :plane_stress
p4.properties.adjust = true
p4.properties.rotate_normals = false
solver = Solver(Nonlinear)
solver.properties.linear_system_solver = :DirectLinearSolver_UMFPACK
push!(solver, p1, p2, p3, p4)
call(solver)
el5 = p4.elements[1]
u = el5("displacement", [0.0], 0.0)
info("u = $u")
@test isapprox(u, [0.0, 0.05])
end
=#
+47
View File
@@ -0,0 +1,47 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
using JuliaFEM
using JuliaFEM.Preprocess
using JuliaFEM.Postprocess
using JuliaFEM.Test
@testset "test that interface transfers constant field without error" begin
meshfile = Pkg.dir("JuliaFEM") * "/test/testdata/block_3d.med"
mesh = aster_read_mesh(meshfile)
upper = Problem(Heat, "upper", 1)
upper.elements = create_elements(mesh, "UPPER")
update!(upper.elements, "temperature thermal conductivity", 1.0)
lower = Problem(Heat, "lower", 1)
lower.elements = create_elements(mesh, "LOWER")
update!(lower.elements, "temperature thermal conductivity", 1.0)
bc_upper = Problem(Dirichlet, "upper boundary", 1, "temperature")
bc_upper.elements = create_elements(mesh, "UPPER_TOP")
update!(bc_upper.elements, "temperature 1", 0.0)
bc_lower = Problem(Dirichlet, "lower boundary", 1, "temperature")
bc_lower.elements = create_elements(mesh, "LOWER_BOTTOM")
update!(bc_lower.elements, "temperature 1", 1.0)
interface = Problem(Mortar, "interface between upper and lower block", 1, "temperature")
interface_slave_elements = create_elements(mesh, "LOWER_TOP")
interface_master_elements = create_elements(mesh, "UPPER_BOTTOM")
update!(interface_slave_elements, "master elements", interface_master_elements)
interface.elements = [interface_master_elements; interface_slave_elements]
interface.properties.dimension = 2
solver = Solver()
solver.properties.linear_system_solver = :DirectLinearSolver_UMFPACK
push!(solver, upper, lower, bc_upper, bc_lower, interface)
call(solver)
node_ids, temperature = get_nodal_vector(interface.elements, "temperature", 0.0)
T = [t[1] for t in temperature]
minT = minimum(T)
maxT = maximum(T)
info("minT = $minT, maxT = $maxT")
@test isapprox(minT, 0.5)
@test isapprox(maxT, 0.5)
end
+41
View File
@@ -0,0 +1,41 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
using JuliaFEM
using JuliaFEM.Test
@testset "polygon clip case 1" begin
S = Vector[
[0.375, 0.0, 0.5],
[0.6, 0.0, 0.5],
[0.5, 0.25, 0.5]]
M = Vector[
[0.50, 0.0, 0.5],
[0.25, 0.0, 0.5],
[0.375, 0.25, 0.5]]
n0 = [0.0, 0.0, 1.0]
P = get_polygon_clip(S, M, n0)
P_expected = Vector{Float64}[
[0.500, 0.0, 0.5],
[0.375, 0.0, 0.5],
[0.4375, 0.125, 0.5]]
@test length(P) == length(P_expected)
for (Pi, Pj) in zip(P, P_expected)
@test isapprox(Pi, Pj)
end
end
@testset "polygon clip case 2" begin
S = Vector[
[0.25, 0.0, 0.5],
[0.75, 0.0, 0.5],
[0.50, 0.25, 0.5]]
M = Vector[
[0.50, 0.0, 0.5],
[0.25, 0.0, 0.5],
[0.375, 0.25, 0.5]]
n0 = [0.0, 0.0, 1.0]
P = get_polygon_clip(S, M, n0)
@test length(P) == 3
end
+32
View File
@@ -0,0 +1,32 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
using JuliaFEM
using JuliaFEM.Test
@testset "test projection" begin
C = [
2.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0
1.0 2.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 2.0 1.0 -1.0 -2.0 0.0 0.0
0.0 0.0 1.0 2.0 -2.0 -1.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0]
g = [3.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
P, h = create_projection(sparse(C), g)
P_expected = [
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0
0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0]
h_expected = [1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
@test isapprox(full(P), P_expected)
@test isapprox(full(h), h_expected)
end