Files
JuliaFEM.jl/test/test_abaqus_reader.jl
T

84 lines
2.9 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-12-01 12:23:51 +02:00
#using JuliaFEM
2015-11-26 05:42:16 +02:00
using JuliaFEM.Test
2015-06-25 19:58:26 +03:00
2015-12-01 12:23:51 +02:00
using JuliaFEM.Preprocess: parse_abaqus, parse_section
2015-11-26 05:42:16 +02:00
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
2015-12-01 12:23:51 +02:00
@test length(model["elsets"]["BODY1"]) == 120
2015-11-26 05:42:16 +02:00
@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-12-01 12:23:51 +02:00
data = """*ELEMENT, TYPE=C3D10, ELSET=BEAM
2015-08-22 20:55:24 +03:00
1, 243, 240, 191, 117, 245, 242, 244,
1, 2, 196
2, 204, 199, 175, 130, 207, 208, 209,
3, 4, 176
"""
2015-12-01 12:23:51 +02:00
data = split(data, "\n")
model = Dict{AbstractString, Any}()
model["nsets"] = Dict{AbstractString, Vector{Int}}()
model["elsets"] = Dict{AbstractString, Vector{Int}}()
model["elements"] = Dict{Integer, Any}()
parse_section(model, data, :ELEMENT, 1, 5, Val{:ELEMENT})
2015-11-26 05:42:16 +02:00
@test length(model["elements"]) == 2
2015-12-01 12:23:51 +02:00
@test model["elements"][1]["connectivity"] == [243, 240, 191, 117, 245, 242, 244, 1, 2, 196]
@test model["elements"][2]["connectivity"] == [204, 199, 175, 130, 207, 208, 209, 3, 4, 176]
2015-11-26 05:42:16 +02:00
@test model["elsets"]["BEAM"] == [1, 2]
end
2015-12-01 12:23:51 +02:00
#function test_read_surface_set_section()
# data = """*SURFACE, TYPE=ELEMENT, NAME=LOAD
# 31429,S1
# 31481,S3
# """
# model = Dict{AbstractString, Any}()
# model["nsets"] = Dict{AbstractString, Vector{Int}}()
# model["elsets"] = Dict{AbstractString, Vector{Int}}()
# model["elements"] = Dict{Integer, Any}()
# parse_section(model, data, :SURFACE, 1, 3, Val{:SURFACE})
# @test model["surfaces"]["LOAD"] = [(31429,1), (31481,3)]
#
#end
2015-11-26 05:42:16 +02:00
function test_unknown_handler_warning_message()
2015-08-22 20:55:24 +03:00
fn = tempname()
fid = open(fn, "w")
2015-12-01 12:23:51 +02:00
testdata = """*ELEMENT2, TYPE=C3D10, ELSET=Body1
2015-08-22 20:55:24 +03:00
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-12-01 12:23:51 +02: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
2015-12-01 12:23:51 +02:00
end