testing api

This commit is contained in:
Olli Väinölä
2015-11-30 20:03:28 +02:00
parent f2325c25ab
commit 608dcae3f0
2 changed files with 46 additions and 21 deletions
+16 -11
View File
@@ -56,15 +56,10 @@ Set of nodes. Holds name and the ids
"""
type NodeSet
name :: AbstractString
node_ids :: Array{Integer, 1}
node_ids :: Array{Integer, 1}
end
#julia> type myn
# arr :: Array{Integer, 1}
# finder :: Dict{Integer, Integer}
# end
#
#julia> myn(arr::Array{Int64, 1}) = myn(arr, Dict(zip(arr, collect(1:length(arr)))))
# NodeSet(arr::Array{Int64, 1}) = myn(arr, Dict(zip(arr, collect(1:length(arr)))))
"""
@@ -171,14 +166,24 @@ end
"""
"""
function add_element!(model::Model, element::Element)
push!(model.elements, element)
function push!(model::Model, element::Element...)
push!(model.elements, element...)
end
"""
"""
function add_node!(model::Model, node::Node)
push!(model.nodes, node)
function push!(model::Model, elements::Vector{Element})
push!(model.element, elements...)
end
"""
"""
function push!(model::Model, node::Node...)
push!(model.nodes, node...)
end
function push!(model::Model, nodes::Vector{Node})
push!(mode, nodes...)
end
"""
+30 -10
View File
@@ -15,29 +15,49 @@ function test_basic()
n2 = Node(2, [1.0, 0.0])
n3 = Node(3, [1.0, 1.0])
n4 = Node(4, [0.0, 1.0])
push!(model, n1, n2, n3, n4)
# create elements
e1 = Element{Quad4}([n1, n2, n3, n4])
e2 = Element{Seg2}([n1, n2])
# element set
elset = ElementSet("body", e1, e2)
elset2 = ElementSet("boundary", e2)
push!(model, elset, elset2)
# material properties
material = Material("my material")
material["temperature thermal conductivity"] = 6.0
material["density"] = 36.0
set_material!(model, material, "Es")
# create element set body
body = ElementSet("body")
push!(body, e1, e2)
# add element set to model
add_element_set(model, body)
# assign material to elements in element set body
set_material(model, material, body)
# Create problem
field_problem = HeatProblem()
# boundary conditions
bc = DirichletBC("body", "temperature" => 0.0)
# bc = DirichletBC("Es", 0.0)
ne = NeumannBC("boundary", "temperature flux" => ((0.0 => 0.0),
(1.0=>600.0)))
# LoadCase
case = LoadCase("Heat problem")
push!(case, field_problem)
push!(case, bc, ne)
# Get solver
solver = LinearSolver
push!(case, solver)
# add case
push!(model, case)
# Solve problem
solve!(model, 1.0, "Heat problem")
xi = [0.0, -1.0]
T = el1("temperature", xi, 1.0)
# T = model("temperature", [0.5, 0.0], 1)
end
end