Files
JuliaFEM.jl/test/test_api.jl
T

84 lines
2.4 KiB
Julia
Raw Normal View History

2015-11-30 19:11:00 +02:00
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
module APITests
2015-12-01 20:21:54 +02:00
using JuliaFEM.Test
2015-12-01 16:03:23 +02:00
using JuliaFEM.Preprocess: parse_abaqus
using JuliaFEM.API: Model, Element, ElementSet, Material, LoadCase,
2015-12-01 20:21:54 +02:00
DirichletBC, NeumannBC, add_boundary_condition!, add_solver!, add_material!
2015-12-01 16:03:23 +02:00
using JuliaFEM.Interfaces: solve!
2015-11-30 19:11:00 +02:00
function test_basic()
# basic workflow, copied from test_solver.jl
2015-12-01 16:03:23 +02:00
model = Model("Piston Calculation")
2015-11-30 19:11:00 +02:00
2015-11-30 21:50:09 +02:00
model.nodes[1] = [0.0, 0.0]
model.nodes[2] = [1.0, 0.0]
model.nodes[3] = [1.0, 1.0]
model.nodes[4] = [0.0, 1.0]
2015-11-30 20:03:28 +02:00
2015-11-30 19:11:00 +02:00
# create elements
2015-12-01 16:03:23 +02:00
e1 = Element(1, [1, 2, 3, 4], :Quad4)
e2 = Element(2, [1, 2], :Seg2)
2015-12-01 20:21:54 +02:00
e3 = Element(3, [3, 4], :Seg2)
2015-12-01 16:03:23 +02:00
model.elements[1] = e1
model.elements[2] = e2
2015-12-01 20:21:54 +02:00
model.elements[3] = e3
2015-12-01 16:03:23 +02:00
2015-11-30 19:11:00 +02:00
2015-11-30 20:03:28 +02:00
# element set
2015-12-01 16:03:23 +02:00
elset = ElementSet("body", [e1, e2])
2015-12-01 20:21:54 +02:00
elset2 = ElementSet("heat_flux", [e2])
elset3 = ElementSet("constant_temp", [e3])
elset4 = ElementSet("set_material", [e1])
2015-12-01 16:03:23 +02:00
model.elsets["body"] = elset
2015-12-01 20:21:54 +02:00
model.elsets["heat_flux"] = elset2
model.elsets["constant_temp"] = elset3
model.elsets["set_material"] = elset4
2015-11-30 20:03:28 +02:00
2015-11-30 19:11:00 +02:00
# material properties
2015-12-01 16:03:23 +02:00
material = Material("MatMat")
material["temperature thermal conductivity"] = 6.0
material["density"] = 36.0
2015-12-01 20:21:54 +02:00
add_material!(model, "set_material", material)
2015-11-30 19:11:00 +02:00
2015-11-30 20:03:28 +02:00
# Create problem
2015-12-01 20:21:54 +02:00
field_problem = LoadCase(:HeatProblem)
field_problem.sets = "body"
2015-11-30 19:11:00 +02:00
# boundary conditions
2015-12-01 20:21:54 +02:00
bc = DirichletBC("constant_temp", "temperature" => 0.0)
ne = NeumannBC("heat_flux", "temperature flux" => ((0.0 => 0.0),
(1.0 => 600.0)))
2015-11-30 20:03:28 +02:00
# LoadCase
2015-12-01 16:03:23 +02:00
add_boundary_condition!(field_problem, bc)
add_boundary_condition!(field_problem, ne)
2015-11-30 20:03:28 +02:00
# Get solver
2015-12-01 16:03:23 +02:00
add_solver!(field_problem, :LinearSolver)
2015-11-30 20:03:28 +02:00
# add case
2015-12-01 16:03:23 +02:00
model.load_cases["Heat problem"] = field_problem
2015-11-30 20:03:28 +02:00
# Solve problem
2015-12-01 20:21:54 +02:00
solve!(model, "Heat problem", 1.0)
xi = [0.0, -1.0]
T = model.elements[1].results("temperature", xi, 1.0)
X = model.elements[2].results("geometry", xi, 1.0)
info("Temperature at point X = $X is T = $T")
@test isapprox(T, 100.0)
2015-11-30 19:11:00 +02:00
end
2015-12-01 16:03:23 +02:00
function test_piston_8789()
abaqus_input = open(parse_abaqus, "../geometry/piston/piston_8789_P1.inp")
model = Model("Piston Calculation", abaqus_input)
end
2015-11-30 21:50:09 +02:00
test_basic()
2015-11-30 19:11:00 +02:00
end