most important tests pass now

This commit is contained in:
Jukka Aho
2016-05-22 17:00:01 +03:00
parent d6dea85b9d
commit 24656eb243
9 changed files with 107 additions and 67 deletions
@@ -1,11 +1,10 @@
# 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.Test
using JuliaFEM.Preprocess: aster_create_elements, parse_aster_med_file
using JuliaFEM.Core: Problem, Elasticity, Dirichlet, Solver, update!
@testset "test 2d nonlinear elasticity with surface load" begin
meshfile = "/geometry/2d_block/BLOCK_1elem.med"
mesh = parse_aster_med_file(Pkg.dir("JuliaFEM")*meshfile)
@@ -0,0 +1,38 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
# http://ahojukka5.github.io/posts/finite-element-solution-for-one-element-problem/
using JuliaFEM
using JuliaFEM.Test
@testset "test 2d linear elasticity local matrices" begin
element = Element(Quad4)
element["geometry"] = Vector{Float64}[
[0.0, 0.0],
[1.0, 0.0],
[1.0, 1.0],
[0.0, 1.0]]
element["youngs modulus"] = 288.0
element["poissons ratio"] = 1/3
element["displacement load"] = DCTI([4.0, 8.0])
problem = Problem(Elasticity, "[0x1] x [0x1] block", 2)
problem.properties.formulation = :plane_stress
K, f = assemble(problem, element)
K_expected = [
144 54 -90 0 -72 -54 18 0
54 144 0 18 -54 -72 0 -90
-90 0 144 -54 18 0 -72 54
0 18 -54 144 0 -90 54 -72
-72 -54 18 0 144 54 -90 0
-54 -72 0 -90 54 144 0 18
18 0 -72 54 -90 0 144 -54
0 -90 54 -72 0 18 -54 144]
f_expected = [1, 2, 1, 2, 1, 2, 1, 2]
@test isapprox(K, K_expected)
@test isapprox(f, f_expected)
end
@@ -1,10 +1,9 @@
# 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
using JuliaFEM.Core: update!, Problem, Elasticity, Dirichlet, Solver, Node, Hex8, Quad4
@testset "test continuum 3d linear elasticity with surface load" begin
nodes = Dict{Int64, Node}(
1 => [0.0, 0.0, 0.0],
@@ -16,8 +15,8 @@ using JuliaFEM.Core: update!, Problem, Elasticity, Dirichlet, Solver, Node, Hex8
7 => [1.0, 1.0, 1.0],
8 => [0.0, 1.0, 1.0])
element1 = Hex8([1, 2, 3, 4, 5, 6, 7, 8])
element2 = Quad4([5, 6, 7, 8])
element1 = Element(Hex8, [1, 2, 3, 4, 5, 6, 7, 8])
element2 = Element(Quad4, [5, 6, 7, 8])
update!([element1, element2], "geometry", nodes)
update!([element1], "youngs modulus", 900.0)
update!([element1], "poissons ratio", 0.25)
@@ -28,9 +27,9 @@ using JuliaFEM.Core: update!, Problem, Elasticity, Dirichlet, Solver, Node, Hex8
push!(elasticity_problem, element1)
push!(elasticity_problem, element2)
symxy = Quad4([1, 2, 3, 4])
symxz = Quad4([1, 2, 6, 5])
symyz = Quad4([1, 4, 8, 5])
symxy = Element(Quad4, [1, 2, 3, 4])
symxz = Element(Quad4, [1, 2, 6, 5])
symyz = Element(Quad4, [1, 4, 8, 5])
update!([symxy, symxz, symyz], "geometry", nodes)
symxy["displacement 3"] = 0.0
symxz["displacement 2"] = 0.0
@@ -1,8 +1,8 @@
# 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
using JuliaFEM.Core: Node, update!, Quad4, Hex8, Problem, Elasticity, Solver, Dirichlet
@testset "test continuum nonlinear elasticity with surface load" begin
@@ -16,8 +16,8 @@ using JuliaFEM.Core: Node, update!, Quad4, Hex8, Problem, Elasticity, Solver, Di
7 => [1.0, 1.0, 1.0],
8 => [0.0, 1.0, 1.0])
element1 = Hex8([1, 2, 3, 4, 5, 6, 7, 8])
element2 = Quad4([5, 6, 7, 8])
element1 = Element(Hex8, [1, 2, 3, 4, 5, 6, 7, 8])
element2 = Element(Quad4, [5, 6, 7, 8])
update!([element1, element2], "geometry", nodes)
update!([element1], "youngs modulus", 900.0)
update!([element1], "poissons ratio", 0.25)
@@ -27,9 +27,9 @@ using JuliaFEM.Core: Node, update!, Quad4, Hex8, Problem, Elasticity, Solver, Di
push!(elasticity_problem, element1)
push!(elasticity_problem, element2)
symxy = Quad4([1, 2, 3, 4])
symxz = Quad4([1, 2, 6, 5])
symyz = Quad4([1, 4, 8, 5])
symxy = Element(Quad4, [1, 2, 3, 4])
symxz = Element(Quad4, [1, 2, 6, 5])
symyz = Element(Quad4, [1, 4, 8, 5])
update!([symxy, symxz, symyz], "geometry", nodes)
symxy["displacement 3"] = 0.0
symxz["displacement 2"] = 0.0
+5 -8
View File
@@ -4,9 +4,6 @@
using JuliaFEM
using JuliaFEM.Test
using JuliaFEM.Core: Quad4, Hex8, Elasticity, Dirichlet, Problem, Node, Solver
using JuliaFEM.Core: update!
@testset "test simple continuum block with surface traction" begin
nodes = Dict{Int64, Node}(
@@ -18,8 +15,8 @@ using JuliaFEM.Core: update!
6 => [1.0, 0.0, 1.0],
7 => [1.0, 1.0, 1.0],
8 => [0.0, 1.0, 1.0])
element1 = Hex8([1, 2, 3, 4, 5, 6, 7, 8])
element2 = Quad4([5, 6, 7, 8])
element1 = Element(Hex8, [1, 2, 3, 4, 5, 6, 7, 8])
element2 = Element(Quad4, [5, 6, 7, 8])
update!([element1, element2], "geometry", nodes)
update!(element1, "youngs modulus", 900.0)
update!(element1, "poissons ratio", 0.25)
@@ -56,11 +53,11 @@ using JuliaFEM.Core: update!
dump(u)
=#
dx = Quad4([1, 4, 8, 5])
dx = Element(Quad4, [1, 4, 8, 5])
dx["displacement 1"] = 0.0
dy = Quad4([1, 5, 6, 2])
dy = Element(Quad4, [1, 5, 6, 2])
dy["displacement 2"] = 0.0
dz = Quad4([1, 2, 3, 4])
dz = Element(Quad4, [1, 2, 3, 4])
dz["displacement 3"] = 0.0
bc = Problem(Dirichlet, "symmetries", 3, "displacement")
update!([dx, dy, dz], "geometry", nodes)