xdmf test

This commit is contained in:
Jukka Aho
2015-06-20 21:47:54 +03:00
parent 362774b08b
commit a961a1f48b
2 changed files with 35 additions and 0 deletions
+2
View File
@@ -125,6 +125,8 @@ test_get_element()
include("test_xdfm.jl")
# write your own tests here
# @test 1 == JuliaFEM.test()
# @test_approx_eq 1.0 1.0
+33
View File
@@ -0,0 +1,33 @@
using JuliaFEM
using Base.Test
function test_write_to_xdfm()
m = new_model()
nodes = Dict(1 => [0.0, 0.0, 0.0],
2 => [1.0, 0.0, 0.0],
3 => [0.0, 1.0, 0.0],
4 => [0.0, 0.0, 1.0])
add_nodes(m, nodes)
el1 = Dict("element_type" => 0x6, "node_ids" => [1, 2, 3, 4])
elements = [el1]
add_elements(elements)
# create new field "temperature" for nodal points
f = new_field(m.nodes, "temperature")
f[1] = 0.1
f[2] = 0.2
f[3] = 0.3
# do NOT write to fourth node.
# export model to xdmf
fn = tempname()
println("temp file: ", fn)
time = 123
write_xdmf(m, fn, time; fields = ["temperature"])
d = h5open(fn)
@test d[123]["temperature"][:] = [0.1, 0.2, 0.3]
end
test_write_to_xdfm()