Files
JuliaFEM.jl/test/test_abaqus_reader.jl
T

83 lines
2.6 KiB
Julia
Raw Normal View History

2015-06-25 21:17:29 +03:00
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
2015-11-26 05:42:16 +02:00
module AbaqusReaderTests
2015-06-25 19:58:26 +03:00
2015-11-26 05:42:16 +02:00
using JuliaFEM
using JuliaFEM.Test
2015-06-25 19:58:26 +03:00
2015-11-26 05:42:16 +02:00
using JuliaFEM: parse_abaqus, parse_element_section
function test_read_abaqus_model()
2015-06-27 19:53:49 +03:00
# FIXME: get_test_data()
2015-11-26 05:42:16 +02:00
model = open(parse_abaqus, Pkg.dir("JuliaFEM")*"/geometry/3d_beam/palkki.inp")
@test length(model["nodes"]) == 298
@test length(model["elements"]) == 120
@test length(model["elsets"]["Body1"]) == 120
@test length(model["nsets"]["SUPPORT"]) == 9
@test length(model["nsets"]["LOAD"]) == 9
@test length(model["nsets"]["TOP"]) == 83
2015-06-25 21:17:29 +03:00
end
2015-11-26 05:42:16 +02:00
#=
facts("test that reader throws error when dimension information of elemenet is missing") do
2015-08-22 20:55:24 +03:00
# *ELEMENT, TYPE=neverseenbefore, ELSET=Body1
data = """
1, 243, 240, 191, 117, 245, 242, 244,
1, 2, 196
"""
model = Dict()
header = Dict("section"=>"ELEMENT", "options" => Dict("TYPE" => "neverseenbefore", "ELSET"=>"Body1"))
@fact_throws parse_element_section(model, header, data)
end
2015-11-26 05:42:16 +02:00
=#
2015-08-22 20:55:24 +03:00
2015-11-26 05:42:16 +02:00
function test_read_element_section()
2015-08-22 20:55:24 +03:00
data = """
1, 243, 240, 191, 117, 245, 242, 244,
1, 2, 196
2, 204, 199, 175, 130, 207, 208, 209,
3, 4, 176
"""
model = Dict()
2015-11-26 05:42:16 +02:00
header = Dict(
"section" => "ELEMENT",
"options" => Dict("TYPE" => "C3D10", "ELSET" => "BEAM"))
2015-08-22 20:55:24 +03:00
parse_element_section(model, header, data)
2015-11-26 05:42:16 +02:00
@test length(model["elements"]) == 2
@test model["elements"][1] == [243, 240, 191, 117, 245, 242, 244, 1, 2, 196]
@test model["elements"][2] == [204, 199, 175, 130, 207, 208, 209, 3, 4, 176]
@test model["elsets"]["BEAM"] == [1, 2]
end
2015-11-26 05:42:16 +02:00
function test_read_surface_set_section()
data = """
31429,S1
31481,S3
"""
model = Dict()
header = Dict(
"section" => "SURFACE",
"options" => Dict("TYPE" => "ELEMENT", "NAME" => "LOAD"))
parse_surface_section(model, header, data)
@test model["surfaces"]["LOAD"] = [(31429,1), (31481,3)]
end
function test_unknown_handler_warning_message()
2015-08-22 20:55:24 +03:00
fn = tempname()
fid = open(fn, "w")
testdata = """
*ELEMENT2, TYPE=C3D10, ELSET=Body1
1, 243, 240, 191, 117, 245, 242, 244,
1, 2, 196
"""
write(fid, testdata)
close(fid)
2015-11-26 05:42:16 +02:00
model = open(parse_abaqus, fn)
2015-08-22 20:55:24 +03:00
# empty model expected, parser doesn't know what to do with unknown section
2015-11-26 05:42:16 +02:00
@test length(model) == 0
end
end