Files
JuliaFEM.jl/test/test_elasticity_3d_unit_block.jl
T

71 lines
2.4 KiB
Julia
Raw Normal View History

2016-05-24 08:01:41 +03:00
# 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
2016-05-24 19:05:25 +03:00
using JuliaFEM.Postprocess
2016-05-24 08:01:41 +03:00
using JuliaFEM.Test
2016-07-03 21:16:03 +03:00
function calc_model(mesh_name; with_volume_load=false, debug_print=false)
2016-05-24 08:01:41 +03:00
meshfile = Pkg.dir("JuliaFEM")*"/geometry/3d_blocks/BLOCK.med"
2016-07-03 21:16:03 +03:00
mesh = aster_read_mesh(meshfile, mesh_name)
2016-05-24 08:01:41 +03:00
2016-07-03 21:16:03 +03:00
block = Problem(Elasticity, "BLOCK", 3)
2016-05-24 08:01:41 +03:00
block.properties.finite_strain = false
2016-06-19 20:01:37 +03:00
block.properties.geometric_stiffness = false
2016-07-03 21:16:03 +03:00
block.elements = create_elements(mesh, "BLOCK")
update!(block, "youngs modulus", 288.0)
update!(block, "poissons ratio", 1/3)
with_volume_load && update!(block, "displacement load 3", 576.0)
2016-05-24 08:01:41 +03:00
2016-07-03 21:16:03 +03:00
traction = Problem(Elasticity, "traction force", 3)
traction.properties.finite_strain = false
traction.properties.geometric_stiffness = false
traction.elements = create_elements(mesh, "LOAD")
2016-05-24 08:01:41 +03:00
update!(traction, "displacement traction force 3", 288.0)
bc = Problem(Dirichlet, "symmetry boundary condition", 3, "displacement")
2016-07-03 21:16:03 +03:00
symyz = create_elements(mesh, "SYMYZ")
symxz = create_elements(mesh, "SYMXZ")
symxy = create_elements(mesh, "SYMXY")
2016-05-24 08:01:41 +03:00
update!(symyz, "displacement 1", 0.0)
update!(symxz, "displacement 2", 0.0)
update!(symxy, "displacement 3", 0.0)
2016-07-03 21:16:03 +03:00
push!(bc, symyz, symxz, symxy)
2016-05-24 08:01:41 +03:00
2016-07-03 21:16:03 +03:00
solver = LinearSolver("Solver block problem")
push!(solver, block, traction, bc)
2016-05-24 08:01:41 +03:00
call(solver)
2016-07-03 21:16:03 +03:00
2016-05-24 08:01:41 +03:00
max_u = maximum(block.assembly.u)
nu = round(Int, length(block.assembly.u)/3)
u = reshape(block.assembly.u, 3, nu)
if debug_print
2016-06-19 20:01:37 +03:00
f = reshape(full(block.assembly.f), 3, nu)
dump(round(u', 5))
dump(round(f', 5))
info("max |u| = $max_u")
end
2016-05-24 19:05:25 +03:00
return block, u
2016-05-24 08:01:41 +03:00
end
@testset "test 3d block HEX8" begin
2016-07-03 21:16:03 +03:00
block, u = calc_model("BLOCK_HEX8"; with_volume_load=true)
@test isapprox(maximum(u), 2.0)
2016-05-24 19:05:25 +03:00
end
@testset "test 3d block TET4" begin
# block, u = calc_model("BLOCK_TET4", :TE4, :TR3; with_volume_load=true)
# @test isapprox(maximum(u), 2.1329516539440205)
2016-07-03 21:16:03 +03:00
block, u = calc_model("BLOCK_TET4"; with_volume_load=false)
@test isapprox(maximum(u), 1.0)
2016-05-24 19:05:25 +03:00
end
@testset "test 3d block TET10" begin
2016-07-03 21:16:03 +03:00
block, u = calc_model("BLOCK_TET10"; with_volume_load=false)
# @test isapprox(maximum(u), 2.13656216413056)
@test isapprox(maximum(u), 1.0)
2016-05-24 19:05:25 +03:00
end
2016-07-03 21:16:03 +03:00