Files
JuliaFEM.jl/src/api_types.jl
T

147 lines
3.4 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 :: ASCIIString
value :: Any
end
type DirichletBC
set_name :: ASCIIString
value :: Any
end
typealias DisplacementBC DirichletBC
typealias TemperatureBC DirichletBC
typealias ForceBC NeumannBC
typealias HeatFluxBC NeumannBC
"""
"""
type Material
name :: ASCIIString
2015-12-12 15:22:31 +02:00
scalar_data :: Dict{ASCIIString, Any}
2015-12-01 16:03:23 +02:00
end
#Material(name, data) = Material(name, Dict(data))
2015-12-12 15:22:31 +02:00
Material(name) = Material(name, Dict{ASCIIString, Any}())
Material() = Material("", Dict{ASCIIString, 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
2015-12-01 16:03:23 +02:00
id :: Union{Integer, ASCIIString}
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, ASCIIString, Void}
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 :: ASCIIString
nodes :: Vector{Int64}
end
2015-12-01 16:03:23 +02:00
"""
"""
type ElementSet
name :: ASCIIString
2015-12-03 14:55:05 +02:00
elements :: Vector{Union{Int64, ASCIIString}}
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::ASCIIString, elements::Vector{Element}) =
ElementSet(name, map(x-> x.id, elements), Material())
ElementSet(name::ASCIIString, ids::Vector{Int64}) =
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
2015-12-03 14:55:05 +02:00
sets :: Vector{ASCIIString}
2015-12-01 16:03:23 +02:00
end
2015-12-04 08:27:59 +02:00
Simulation(a) = Simulation(a, NeumannBC[], DirichletBC[], nothing, ASCIIString[])
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
2015-12-03 14:55:05 +02:00
name :: ASCIIString
nodes :: Dict{Union{Int64, ASCIIString}}
2015-12-01 16:03:23 +02:00
elements :: Dict{Union{ASCIIString, Int64}, Element}
2015-12-03 14:55:05 +02:00
elsets :: Dict{ASCIIString, ElementSet}
nsets :: Dict{ASCIIString, NodeSet}
2015-12-04 08:27:59 +02:00
load_cases :: Dict{ASCIIString, Simulation}
2015-12-06 17:22:57 +02:00
renum_nodes :: Dict{Union{Int64, ASCIIString}, Int64}
2015-12-01 16:03:23 +02:00
#settings :: Dict{AbstractString, Real}
end
2015-12-03 15:39:02 +02:00
function Model(name::ASCIIString, abq_input::Dict)
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::ASCIIString) = Model(
name,
2015-12-03 14:55:05 +02:00
Dict{Union{Int64, ASCIIString}, Node}(),
Dict{Union{Int64, ASCIIString}, Element}(),
Dict{ASCIIString, NodeSet}(),
Dict{ASCIIString, ElementSet}(),
2015-12-04 08:27:59 +02:00
Dict{ASCIIString, Simulation}(),
2015-12-06 17:22:57 +02:00
Dict{Union{Int64, ASCIIString}, Int64}()
2015-12-01 16:03:23 +02:00
)
2015-12-03 14:55:05 +02:00
function Base.setindex!(dict::Dict{Union{ASCIIString, Int64}, Node},
vals::Vector{Float64}, idx::Union{ASCIIString, Int64})
dict[idx] = Node(idx, vals)
end