Adding functionality to api

This commit is contained in:
Olli Väinölä
2015-11-29 14:38:04 +02:00
parent c71c40b952
commit ecfa1fdc41
2 changed files with 64 additions and 32 deletions
+8 -19
View File
@@ -10,19 +10,6 @@ global ABQ_ELTYPE_HAS_NODES = Dict(
)
type AbaqusModel
nodes::Array{INode, 1}
elements::Array{IElement, 1}
node_sets::Array{INodeSet, 1}
element_sets::Array{IElementSet, 1}
end
AbaqusModel() = AbaqusModel(INode[],
IElement[],
INodeSet[],
IElementSet[])
"""
"""
function empty_or_comment_line(line)
@@ -44,7 +31,7 @@ function parse_nodes(model, lines, key, idx_start, idx_end)
m = matchall(r"[-0-9.]+", line)
node_id = parse(Int, m[1])
coords = float(m[2:end])
node = INode(node_id, coords)
node = jNode(node_id, coords)
push!(model.nodes, node)
end
end
@@ -71,11 +58,11 @@ end
"""
"""
function parse_elements(model, lines, key, idx_start, idx_end)
info("Parsing elements")
definition = uppercase(lines[idx_start])
element_type = regex_match(r"TYPE=([\w\-\_]+)", definition, 1)
eltype_sym = symbol(element_type)
eltype_nodes = ABQ_ELTYPE_HAS_NODES[eltype_sym]
info("Parsing elements. Type: $(element_type)")
list_iterator = consumeList(lines, idx_start+1, idx_end)
line = consume(list_iterator)
while line != nothing
@@ -84,7 +71,7 @@ function parse_elements(model, lines, key, idx_start, idx_end)
if !(empty_or_comment_line(line))
id = numbers[1]
connectivity = numbers[2:end]
element = IElement(id, connectivity, element_type)
element = jElement(id, connectivity, element_type)
while length(element.connectivity) != eltype_nodes
@assert length(element.connectivity) < eltype_nodes
line = consume(list_iterator)
@@ -92,6 +79,7 @@ function parse_elements(model, lines, key, idx_start, idx_end)
numbers = map(x-> parse(Int, x), arr_num_as_str)
map(x->push!(element.connectivity, x), numbers)
end
push!(model.elements, element)
end
line = consume(list_iterator)
end
@@ -105,7 +93,7 @@ function parse_set(model, lines, key, idx_start, idx_end)
definition = uppercase(lines[idx_start])
regex_string = set_regex_string[key]
set_name = regex_match(regex_string, definition, 1)
info("Creating set $set_name")
info("Creating $(lowercase(string(key))) $set_name")
data = Integer[]
if endswith(strip(definition), "GENERATE")
line = lines[idx_start + 1]
@@ -122,8 +110,9 @@ function parse_set(model, lines, key, idx_start, idx_end)
end
end
end
selected_set = key == :NSET ? INodeSet : IElementSet
selected_set = key == :NSET ? jNodeSet : jElementSet
set_alloc = selected_set(set_name, data)
model.sets[set_name] = set_alloc
end
#
@@ -149,7 +138,7 @@ end
"""
"""
function parse_abaqus(fid::IOStream)
model = AbaqusModel()
model = jModel()
lines = readlines(fid)
info("Registered handlers: $(keys(parse_section))")
keyword_indexes = find_keywords(lines)
+56 -13
View File
@@ -1,34 +1,77 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
abstract calculation_model
abstract JuliaFEMModel
type Model <: calculation_model
jotain
type jMaterial
name :: AbstractString
scalar_data :: Dict{AbstractString, Float64}
owners :: Vector
end
type INode{T<:Real}
type jNode{T<:Real}
id::Integer
coords::Array{T, 1}
end
type IElement{T<:Real}
type jElement{T<:Real}
id::Integer
connectivity::Array{T, 1}
element_type::AbstractString
# fields :: Dict{AbstractString, Field}
end
# IElement(id, conn, eltype) = IElement(id, conn, eltype, Dict())
type INodeSet
type jNodeSet
name::AbstractString
node_ids::Array{Integer, 1}
end
type IElementSet
name::AbstractString
element_ids::Array{Integer, 1}
type jElementSet
name :: AbstractString
element_ids :: Array{Integer, 1}
end
type jProblem
problem_type :: Symbol
boundary_conditions :: Array{Dict{ASCIIString, Any}, 1}
end
jProblem(a, b) = jProblem(symbol(a), b)
type jModel <: JuliaFEMModel
nodes :: Vector{jNode}
elements :: Vector{jElement}
sets :: Dict{AbstractString, Union{jNodeSet, jElementSet}}
material :: Dict{AbstractString, jMaterial}
problems :: Array{jProblem}
settings :: Dict{AbstractString, Real}
end
jModel() = jModel(jNode[],
jElement[],
Dict{AbstractString, Union{jNodeSet, jElementSet}}(),
Dict{AbstractString, jMaterial}(),
jProblem[],
Dict{AbstractString, Real}()
)
function build_core_model()
end
function build_core_elements()
end
function set_core_element_material()
end
function create_problems()
end
function add_problems!()
end