mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-09-22 02:40:51 +00:00
all tests pass now
This commit is contained in:
@@ -6,75 +6,37 @@ using JuliaFEM.Preprocess
|
||||
using JuliaFEM.Postprocess
|
||||
using JuliaFEM.Test
|
||||
|
||||
function get_model(fn, vol, sur; with_volume_load=false)
|
||||
function calc_model(mesh_name; with_volume_load=false, debug_print=false)
|
||||
meshfile = Pkg.dir("JuliaFEM")*"/geometry/3d_blocks/BLOCK.med"
|
||||
mesh = parse_aster_med_file(meshfile, fn)
|
||||
mesh = aster_read_mesh(meshfile, mesh_name)
|
||||
|
||||
block = Problem(Elasticity, fn, 3)
|
||||
block = Problem(Elasticity, "BLOCK", 3)
|
||||
block.properties.finite_strain = false
|
||||
block.properties.geometric_stiffness = false
|
||||
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)
|
||||
|
||||
elements = aster_create_elements(mesh, :BLOCK, vol)
|
||||
update!(elements, "youngs modulus", 288.0)
|
||||
update!(elements, "poissons ratio", 1/3)
|
||||
if with_volume_load
|
||||
update!(elements, "displacement load 3", 576.0)
|
||||
end
|
||||
push!(block, elements...)
|
||||
|
||||
traction = aster_create_elements(mesh, :LOAD, sur)
|
||||
traction = Problem(Elasticity, "traction force", 3)
|
||||
traction.properties.finite_strain = false
|
||||
traction.properties.geometric_stiffness = false
|
||||
traction.elements = create_elements(mesh, "LOAD")
|
||||
update!(traction, "displacement traction force 3", 288.0)
|
||||
push!(block, traction...)
|
||||
|
||||
bc = Problem(Dirichlet, "symmetry boundary condition", 3, "displacement")
|
||||
# bc.properties.formulation = :incremental
|
||||
symyz = aster_create_elements(mesh, :SYMYZ, sur)
|
||||
symxz = aster_create_elements(mesh, :SYMXZ, sur)
|
||||
symxy = aster_create_elements(mesh, :SYMXY, sur)
|
||||
symyz = create_elements(mesh, "SYMYZ")
|
||||
symxz = create_elements(mesh, "SYMXZ")
|
||||
symxy = create_elements(mesh, "SYMXY")
|
||||
update!(symyz, "displacement 1", 0.0)
|
||||
update!(symxz, "displacement 2", 0.0)
|
||||
update!(symxy, "displacement 3", 0.0)
|
||||
push!(bc, symyz..., symxz..., symxy...)
|
||||
return block, bc, elements, traction, symyz, symxz, symxy
|
||||
end
|
||||
push!(bc, symyz, symxz, symxy)
|
||||
|
||||
function calc_size(elements, dim; debug_print=false)
|
||||
A = 0.0
|
||||
for element in elements
|
||||
Ael = 0.0
|
||||
size(element, 1) == dim || continue
|
||||
for ip in get_integration_points(element)
|
||||
detJ = element(ip, 0.0, Val{:detJ})
|
||||
Ael += ip.weight*detJ
|
||||
end
|
||||
if debug_print
|
||||
for (i, X) in enumerate(element["geometry"](0.0))
|
||||
info("$i : $X")
|
||||
end
|
||||
info("Area / volume: $Ael")
|
||||
end
|
||||
A += Ael
|
||||
end
|
||||
return A
|
||||
end
|
||||
|
||||
function calc_model(model, volume_element, surface_element; with_volume_load=false, debug_print=false)
|
||||
block, bc, elements, traction, symyz, symxz, symxy = get_model(model, volume_element, surface_element; with_volume_load=with_volume_load)
|
||||
V = calc_size(block.elements, 3)
|
||||
A = calc_size(bc.elements, 2)
|
||||
At = calc_size(traction, 2)
|
||||
if debug_print
|
||||
info("volume of block: $V")
|
||||
info("area of boundary condition: $A")
|
||||
info("area of load surface: $At")
|
||||
end
|
||||
@test isapprox(V, 1.0)
|
||||
@test isapprox(At, 1.0)
|
||||
@test isapprox(A, 3.0)
|
||||
solver = Solver("solver block problem")
|
||||
#solver.is_linear_system = true
|
||||
push!(solver, block, bc)
|
||||
solver = LinearSolver("Solver block problem")
|
||||
push!(solver, block, traction, bc)
|
||||
call(solver)
|
||||
|
||||
max_u = maximum(block.assembly.u)
|
||||
nu = round(Int, length(block.assembly.u)/3)
|
||||
u = reshape(block.assembly.u, 3, nu)
|
||||
@@ -89,19 +51,20 @@ end
|
||||
|
||||
|
||||
@testset "test 3d block HEX8" begin
|
||||
block, u = calc_model("BLOCK_HEX8", :HE8, :QU4; with_volume_load=true)
|
||||
block, u = calc_model("BLOCK_HEX8"; with_volume_load=true)
|
||||
@test isapprox(maximum(u), 2.0)
|
||||
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)
|
||||
block, u = calc_model("BLOCK_TET4", :TE4, :TR3; with_volume_load=false)
|
||||
block, u = calc_model("BLOCK_TET4"; with_volume_load=false)
|
||||
@test isapprox(maximum(u), 1.0)
|
||||
end
|
||||
|
||||
@testset "test 3d block TET10" begin
|
||||
block, u = calc_model("BLOCK_TET10", :T10, :TR6; with_volume_load=false)
|
||||
block, u = calc_model("BLOCK_TET10"; with_volume_load=false)
|
||||
# @test isapprox(maximum(u), 2.13656216413056)
|
||||
@test isapprox(maximum(u), 1.0)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user