Skip to content

Commit

Permalink
Parse lower/mixed case input files
Browse files Browse the repository at this point in the history
Abaqus input files are case insensitive.

Previously, the element type (e.g. C3D4 == c3d4)
and the NSET and ELSET options were not recognized
if lower or mixed case.

Note: Boundary conditions and loads are read verbatim
(i.e. symbols :P or :p are created for pressure loads
depending on the case used in the input file)
which may cause confusion.
  • Loading branch information
benzwick committed May 13, 2019
1 parent 49a46b1 commit 099547a
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/parse_mesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function parse_section(model, lines, ::Symbol, idx_start, idx_end, ::Type{Val{:E
regexp = r"TYPE=([\w\-\_]+)"i
m = match(regexp, definition)
m == nothing && error("Could not match regexp $regexp to line $definition")
element_type = m[1]
element_type = uppercase(m[1])
eltype_sym = Symbol(element_type)
eltype_nodes = element_has_nodes(Val{eltype_sym})
element_type = element_has_type(Val{eltype_sym})
Expand Down Expand Up @@ -172,8 +172,8 @@ end
function parse_section(model, lines, key, idx_start, idx_end, ::Union{Type{Val{:NSET}},
Type{Val{:ELSET}}})
data = Integer[]
set_regex_string = Dict(:NSET => r"NSET=([\w\-\_]+)",
:ELSET => r"ELSET=([\w\-\_]+)" )
set_regex_string = Dict(:NSET => r"NSET=([\w\-\_]+)"i,
:ELSET => r"ELSET=([\w\-\_]+)"i)
selected_set = key == :NSET ? "node_sets" : "element_sets"
definition = lines[idx_start]
regex_string = set_regex_string[key]
Expand Down
39 changes: 39 additions & 0 deletions test/test_parse_model_mixed_case.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/AbaqusReader.jl/blob/master/LICENSE

using AbaqusReader: abaqus_read_model
using AbaqusReader: parse_keyword

datadir = first(splitext(basename(@__FILE__)))

@testset "parse abaqus inp file to AbaqusModel" begin
fn = joinpath(datadir, "cube_tet4_mixed_case.inp")
model = abaqus_read_model(fn)

@test length(model.properties) == 1
section = first(model.properties)
@test section.element_set == :Cube
@test section.material_name == :Mat

@test haskey(model.materials, :Mat)
material = model.materials[:Mat]
@test isapprox(first(material.properties).E, 208.0e3)

@test length(model.steps) == 1
step = first(model.steps)
@test length(step.boundary_conditions) == 2

bc = step.boundary_conditions[1]
@test bc.data[1] == [:Sym23, 1]
@test bc.data[2] == [:Sym13, 2]

load = step.boundary_conditions[2]
@test load.data[1] == [:Load, :p, 1.00000]
end

@testset "parse keyword" begin
k = parse_keyword("*SURFACE, NAME=TIE, SURFACE TO SURFACE")
@test k.options[1] == ("NAME" => "TIE")
@test k.options[2] == "SURFACE TO SURFACE"
@test_throws(Exception, parse_keyword("*SURFACE, MOI=HEI=EI"))
end
61 changes: 61 additions & 0 deletions test/test_parse_model_mixed_case/cube_tet4_mixed_case.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
*Node, Nset=Nall
1, 4.07417, 3.51532, 4.43035
2, 6.24583, 4.69753, 6.40067
3,1.0e1,10.00000,0.00000
4, 1.0E1, 0.00000, 0.00000
5, 0.00000, 0.00000, 0.00000
6, 0.00000, 10.00000, 0.00000
7, 0.00000, 10.00000, 10.00000
8, 0.00000, 0.00000, 10.00000
9, 100.0e-1,10.00000,10.00000
10,100.0E-1,0.00000,10.00000
*Element, Type=C3d4, Elset=Cube
1, 8, 10, 1, 2
2, 4, 1, 10, 2
3, 3, 9, 7, 2
4, 3, 5, 4, 1
5, 8, 7, 2, 1
6, 5, 6, 8, 1
7, 7, 6, 1, 8
8, 7, 9, 8, 2
9, 5, 8, 10, 1
10, 3, 6, 5, 1
11, 4, 10, 9, 2
12, 1, 7, 2, 3
13, 3, 4, 9, 2
14, 3, 1, 4, 2
15, 4, 5, 10, 1
16, 8, 9, 10, 2
17, 3, 6, 1, 7
*Solid Section, Elset=Cube, Material=Mat
*Material, Name=Mat
*Elastic
2.08000e+005, 3.00000e-001
*Nset, Nset=Sym12
5, 6, 3, 4,
*Nset, Nset=Sym23
5, 6, 7, 8,
*Nset, Nset=Sym13
5, 10, 8, 4,
*Surface, Type=Element, Name=Load
16, S1
8, S1
*Surface, Name=Order , Type=Element
16, S1
8, S1
*Boundary
Sym12, 3
*Step
*Static
*Boundary
Sym23, 1
Sym13, 2
*Dsload
Load, p, 1.00000
*Node File
Coord
u
*Node Print
Coord
u
*End Step

0 comments on commit 099547a

Please sign in to comment.