code aster .med reader, notebook of 3d mortar.

This commit is contained in:
Jukka Aho
2015-12-14 02:09:33 +02:00
parent ccf32d5b76
commit 69bd7ce58c
13 changed files with 1286 additions and 85 deletions
+29 -5
View File
@@ -7,7 +7,8 @@ using JuliaFEM
using JuliaFEM.Test
using JuliaFEM.Core: Seg2, Quad4, Hex8, LinearElasticityProblem, get_connectivity,
assemble, PlaneStressLinearElasticityProblem
assemble, PlaneStressLinearElasticityProblem, DirichletProblem,
LinearSolver
using JuliaFEM.Preprocess: aster_parse_nodes
@@ -85,7 +86,7 @@ function test_continuum_elasticity_with_surface_load()
problem = LinearElasticityProblem()
push!(problem, element1)
push!(problem, element2)
#=
free_dofs = zeros(Bool, 8, 3)
x = 1
y = 2
@@ -107,15 +108,38 @@ function test_continuum_elasticity_with_surface_load()
# dump(reshape(f, 3, 8))
# info("initial stiffness matrix")
# dump(round(Int, K)[free_dofs, free_dofs])
u = zeros(3, 8)
u[free_dofs] = K[free_dofs, free_dofs] \ f[free_dofs]
info("result vector")
dump(u)
=#
dx = Quad4([1, 4, 8, 5])
dx["displacement 1"] = 0.0
dy = Quad4([1, 5, 6, 2])
dy["displacement 2"] = 0.0
dz = Quad4([1, 2, 3, 4])
dz["displacement 3"] = 0.0
bc = DirichletProblem("displacement", 3)
for el in [dx, dy, dz]
set_geometry!(el, nodes)
push!(bc, el)
end
solver = LinearSolver()
push!(solver, problem)
push!(solver, bc)
# solver.dump_matrices = true
# solver.name = "3d_hex8"
solver(0.0)
X = element1("geometry", [1.0, 1.0, 1.0], 0.0)
u = element1("displacement", [1.0, 1.0, 1.0], 0.0)
info("displacement at $X = $u")
# verified using Code Aster.
# 2015-12-12-continuum-elasticity/c3d_linear.*
@test isapprox(u[:,7], [2.77777777777778E-02, 2.77777777777778E-02, -1.11111111111111E-01])
# [1/36, 1/36, -1/9]
@test isapprox(u, [2.77777777777778E-02, 2.77777777777778E-02, -1.11111111111111E-01])
end
#test_continuum_elasticity_with_surface_load()
+70 -5
View File
@@ -16,7 +16,8 @@ using JuliaFEM.Core: create_auxiliary_plane, project_point_to_auxiliary_plane,
get_edge_intersections, get_points_inside_triangle,
clip_polygon, calculate_polygon_centerpoint,
project_point_from_plane_to_surface, assemble,
calculate_normal_tangential_coordinates!
calculate_normal_tangential_coordinates!,
is_point_inside_convex_polygon
function get_test_2d_model()
@@ -455,14 +456,38 @@ end
#test_get_points_inside_triangle()
function test_polygon_clipping()
function test_is_point_inside_convex_polygon()
X = Vector{Float64}[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]]
@test is_point_inside_convex_polygon([0.5, 0.5], X) == true
@test is_point_inside_convex_polygon([1.0, 0.5], X) == true
@test is_point_inside_convex_polygon([1.1, 0.5], X) == false
@test is_point_inside_convex_polygon([1.0, 1.0], X) == true
@test is_point_inside_convex_polygon([0.0, 0.3], X) == true
@test is_point_inside_convex_polygon([0.0, -0.000001], X) == false
end
function test_polygon_clipping_easy()
S = [0 0; 3 0; 0 3]'
M = [-1 1; 2 -1/2; 2 2]'
P, n = clip_polygon(S, M)
@test isapprox(P, [0.0 0.5; 1.0 0.0; 2.0 0.0; 2.0 1.0; 1.25 1.75; 0.0 4/3]')
@test isapprox(n, [1 0 1; 1 1 0; 0 1 1])
end
#test_polygon_clipping()
function test_polygon_clipping_no_clip()
# no clipping at all
S = [-0.125 0.125 0.125 -0.125
-0.125 -0.125 0.125 0.125]
M = [-0.291667 -0.625 -0.625 -0.291667
-0.208333 -0.208333 0.125 0.125 ]
P, n = clip_polygon(S, M)
# FIXME: check better.
@test isa(P, Void)
@test isa(n, Void)
end
#test_polygon_clipping_no_clip()
function test_calculate_polygon_centerpoint()
@@ -477,7 +502,7 @@ end
function test_assemble_3d_problem()
function test_assemble_3d_problem_tri3()
nodes = Vector{Float64}[
[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
@@ -533,7 +558,47 @@ function test_assemble_3d_problem()
@test isapprox(stiffness_matrix, B)
end
test_assemble_3d_problem()
#test_assemble_3d_problem_tri3()
function test_assemble_3d_problem_quad4()
nodes = Vector{Float64}[
[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[1.0, 1.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 0.1],
[1.0, 0.0, 0.1],
[1.0, 1.0, 0.1],
[0.0, 1.0, 0.1]]
#=
nodes = Vector{Float64}[
[-1.0, -1.0, 0.0],
[+1.0, -1.0, 0.0],
[+1.0, +1.0, 0.0],
[-1.0, +1.0, 0.0],
[-1.0, -1.0, 0.1],
[+1.0, -1.0, 0.1],
[+1.0, +1.0, 0.1],
[-1.0, +1.0, 0.1]]
=#
mel = Quad4([5, 6, 7, 8])
mel["geometry"] = Vector{Float64}[nodes[5], nodes[6], nodes[7], nodes[8]]
sel = Quad4([1, 2, 3, 4])
sel["geometry"] = Vector{Float64}[nodes[1], nodes[2], nodes[3], nodes[4]]
calculate_normal_tangential_coordinates!(sel, 0.0)
sel["master elements"] = Element[mel]
prob = MortarProblem("temperature", 1)
push!(prob, sel)
stiffness_matrix = full(assemble(prob, 0.0).stiffness_matrix)
info("stiffness matrix for this problem:\n$stiffness_matrix")
M = D = 1/36*[4 2 1 2; 2 4 2 1; 1 2 4 2; 2 1 2 4]
B = [D -M] # slave dofs are first in this.
info("expected matrix for this problem:\n$B")
@test isapprox(stiffness_matrix, B)
end
#test_assemble_3d_problem_quad4()
end