Skip to content

Commit 4380c39

Browse files
authored
Implement reading of B33 elements (#42)
* Parse beam B33 topology. * Modify regexp to handle lowercase definition line. * Fix incorrect comparison by length of `has_set_def`.
1 parent 852392b commit 4380c39

4 files changed

Lines changed: 36 additions & 3 deletions

File tree

src/parse_mesh.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ element_has_type(::Type{Val{:T2D2}}) = :Seg2
3232
element_has_nodes(::Type{Val{:T3D2}}) = 2
3333
element_has_type(::Type{Val{:T3D2}}) = :Seg2
3434

35+
element_has_nodes(::Type{Val{:B33}}) = 2
36+
element_has_type(::Type{Val{:B33}}) = :Seg2
37+
3538
"""Checks for a comment or empty line
3639
3740
Function return true, if line starts with comment character "**"
@@ -73,7 +76,7 @@ end
7376
"""
7477
function add_set!(model, definition, model_key, abaqus_key, ids)
7578
has_set_def = parse_definition(definition)
76-
if length(has_set_def) != 0
79+
if haskey(has_set_def, "elset")
7780
set_name = has_set_def[abaqus_key]
7881
@info("Adding $abaqus_key: $set_name")
7982
model[model_key][set_name] = ids
@@ -133,11 +136,14 @@ If elset definition exists, also adds the set to model.
133136
function parse_section(model, lines, ::Symbol, idx_start, idx_end, ::Type{Val{:ELEMENT}})
134137
ids = Integer[]
135138
definition = lines[idx_start]
136-
element_type = regex_match(r"TYPE=([\w\-\_]+)", definition, 1)
139+
regexp = r"TYPE=([\w\-\_]+)"i
140+
m = match(regexp, definition)
141+
m == nothing && error("Could not match regexp $regexp to line $definition")
142+
element_type = m[1]
137143
eltype_sym = Symbol(element_type)
138144
eltype_nodes = element_has_nodes(Val{eltype_sym})
139145
element_type = element_has_type(Val{eltype_sym})
140-
@info("Parsing elements. Type: $(element_type)")
146+
@info("Parsing elements. Type: $(m[1]). Topology: $(element_type)")
141147
list_iterator = consumeList(lines, idx_start+1, idx_end)
142148
line = list_iterator()
143149
while line != nothing

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ include("../docs/make.jl")
1212
@testset "test_create_surface_elements" begin include("test_create_surface_elements.jl") end
1313
@testset "test_download" begin include("test_download.jl") end
1414
@testset "test_parse_t2d2" begin include("test_parse_t2d2.jl") end
15+
@testset "test_parse_beams" begin include("test_parse_beams.jl") end
1516
end
1617

1718
include("../docs/deploy.jl")

test/test_parse_beams.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file is a part of JuliaFEM.
2+
# License is MIT: see https://github.com/JuliaFEM/AbaqusReader.jl/blob/master/LICENSE
3+
4+
using AbaqusReader: abaqus_read_mesh
5+
using Test
6+
7+
datadir = first(splitext(basename(@__FILE__)))
8+
filename = joinpath(datadir, "mesh.inp")
9+
mesh = abaqus_read_mesh(filename)
10+
@test length(mesh["elements"]) == 7

test/test_parse_beams/mesh.inp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
*Node
2+
1, 240., 1090., 147.5
3+
74, 244.285721, 1114.28577, 173.357147
4+
75, 248.571426, 1138.57141, 199.214279
5+
76, 252.857147, 1162.85718, 225.071426
6+
77, 257.142853, 1187.14282, 250.928574
7+
78, 261.428558, 1211.42859, 276.785706
8+
79, 265.714294, 1235.71423, 302.642853
9+
*Element, type=B33
10+
1, 1, 74
11+
2, 74, 75
12+
3, 75, 76
13+
4, 76, 77
14+
5, 77, 78
15+
6, 78, 79
16+
7, 79, 2

0 commit comments

Comments
 (0)