Files
JuliaFEM.jl/src/api_types.jl
T

147 lines
3.2 KiB
Julia
Raw Normal View History

2015-12-01 16:03:23 +02:00
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
2015-12-12 11:55:39 +02:00
2015-12-01 16:03:23 +02:00
type NeumannBC
set_name :: String
2015-12-01 16:03:23 +02:00
value :: Any
end
type DirichletBC
set_name :: String
2015-12-01 16:03:23 +02:00
value :: Any
end
typealias DisplacementBC DirichletBC
typealias TemperatureBC DirichletBC
typealias ForceBC NeumannBC
typealias HeatFluxBC NeumannBC
"""
"""
type Material
name :: String
scalar_data :: Dict{String, Any}
2015-12-01 16:03:23 +02:00
end
#Material(name, data) = Material(name, Dict(data))
Material(name) = Material(name, Dict{String, Any}())
Material() = Material("", Dict{String, Any}())
2015-12-01 16:03:23 +02:00
2015-12-12 15:22:31 +02:00
function Base.setindex!{T <: AbstractString }(material::Material, val, name::T)
2015-12-01 16:03:23 +02:00
material.scalar_data[name] = val
end
2015-12-03 14:55:05 +02:00
type Node
id :: Union{Integer, String}
2015-12-03 14:55:05 +02:00
coords :: Array{Float64, 1}
2015-12-01 16:03:23 +02:00
end
type Element
id :: Union{Integer, String, Void}
2015-12-01 16:03:23 +02:00
connectivity :: Vector{Int64}
element_type :: Symbol
2015-12-01 20:21:54 +02:00
results :: Any # Dict{}
material :: Any
2015-12-01 16:03:23 +02:00
end
2015-12-01 20:21:54 +02:00
Element(a, b, c) = Element(a, b, c, nothing, Material())
2015-12-01 16:03:23 +02:00
2015-12-03 14:55:05 +02:00
type NodeSet
name :: String
2015-12-03 14:55:05 +02:00
nodes :: Vector{Int64}
end
2015-12-01 16:03:23 +02:00
"""
"""
type ElementSet
name :: String
elements :: Vector{Union{Int64, String}}
2015-12-01 16:03:23 +02:00
material :: Material
2015-12-01 20:21:54 +02:00
end
2015-12-01 16:03:23 +02:00
ElementSet(name::String, elements::Vector{Element}) =
2015-12-01 16:03:23 +02:00
ElementSet(name, map(x-> x.id, elements), Material())
ElementSet(name::String, ids::Vector{Int64}) =
2015-12-01 16:03:23 +02:00
ElementSet(name, ids, Material())
2015-12-01 20:21:54 +02:00
"""
2015-12-04 08:27:59 +02:00
Simulation
2015-12-01 20:21:54 +02:00
"""
2015-12-04 08:27:59 +02:00
type Simulation
2015-12-01 20:21:54 +02:00
problem :: Symbol
neumann_boundary_conditions :: Vector{NeumannBC}
dirichlet_boundary_conditions :: Vector{DirichletBC}
2015-12-01 16:03:23 +02:00
solver
sets :: Vector{String}
2015-12-01 16:03:23 +02:00
end
Simulation(a) = Simulation(a, NeumannBC[], DirichletBC[], nothing, String[])
2015-12-01 20:21:54 +02:00
2015-12-01 16:03:23 +02:00
"""
2015-12-03 14:55:05 +02:00
Model type
Used for constructing the calculation model
2015-12-01 16:03:23 +02:00
"""
type Model
name :: String
nodes :: Dict{Union{Int64, String}}
elements :: Dict{Union{String, Int64}, Element}
elsets :: Dict{String, ElementSet}
nsets :: Dict{String, NodeSet}
load_cases :: Dict{String, Simulation}
renum_nodes :: Dict{Union{Int64, String}, Int64}
2015-12-01 16:03:23 +02:00
#settings :: Dict{AbstractString, Real}
end
function Model(name::String, abq_input::Dict)
2015-12-03 15:39:02 +02:00
model = Model(name)
nodes = abq_input["nodes"]
elements = abq_input["elements"]
element_sets = abq_input["elsets"]
node_sets = abq_input["nsets"]
for id in keys(nodes)
coords = nodes[id]
add_node!(model, id, coords)
end
for id in keys(elements)
data = elements[id]
eltype = data["type"]
conn = data["connectivity"]
# println(eltype, " ", conn)
add_element!(model, id, eltype, conn)
end
for name in keys(node_sets)
ids = node_sets[name]
add_node_set!(model, name, ids)
end
for name in keys(element_sets)
ids = element_sets[name]
add_element_set!(model, name, ids)
end
model
end
2015-12-01 16:03:23 +02:00
Model(name::String) = Model(
2015-12-01 16:03:23 +02:00
name,
Dict{Union{Int64, String}, Node}(),
Dict{Union{Int64, String}, Element}(),
Dict{String, NodeSet}(),
Dict{String, ElementSet}(),
Dict{String, Simulation}(),
Dict{Union{Int64, String}, Int64}()
2015-12-01 16:03:23 +02:00
)
function Base.setindex!(dict::Dict{Union{String, Int64}, Node},
vals::Vector{Float64}, idx::Union{String, Int64})
2015-12-03 14:55:05 +02:00
dict[idx] = Node(idx, vals)
end