Files
JuliaFEM.jl/test/test_abaqus_reader.jl
T

66 lines
2.3 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-06-25 19:58:26 +03:00
using FactCheck
using Logging
@Logging.configure(level=INFO)
2015-08-22 20:55:24 +03:00
#using JuliaFEM.abaqus_reader: parse_abaqus, parse_element_section
include(Pkg.dir("JuliaFEM")*"/src/abaqus_reader.jl")
2015-06-25 19:58:26 +03:00
facts("test import abaqus model") do
2015-06-27 19:53:49 +03:00
# FIXME: get_test_data()
fid = open(Pkg.dir("JuliaFEM")*"/geometry/3d_beam/palkki.inp")
2015-06-25 19:58:26 +03:00
model = parse_abaqus(fid)
close(fid)
2015-08-22 20:55:24 +03:00
@fact length(model["nodes"]) --> 298
@fact length(model["elements"]) --> 120
@fact length(model["elsets"]["Body1"]) --> 120
@fact length(model["nsets"]["SUPPORT"]) --> 9
@fact length(model["nsets"]["LOAD"]) --> 9
@fact length(model["nsets"]["TOP"]) --> 83
2015-06-25 21:17:29 +03:00
end
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
facts("read element section") do
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()
header = Dict("section" => "ELEMENT", "options" => Dict("TYPE" => "C3D10", "ELSET" => "BEAM"))
parse_element_section(model, header, data)
@fact length(model["elements"]) --> 2
@fact model["elements"][1] --> [243, 240, 191, 117, 245, 242, 244, 1, 2, 196]
@fact model["elements"][2] --> [204, 199, 175, 130, 207, 208, 209, 3, 4, 176]
end
facts("test unknown handler warning message") do
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)
fid = open(fn)
model = parse_abaqus(fid)
close(fid)
# empty model expected, parser doesn't know what to do with unknown section
@fact length(model) --> 0
end