diff --git a/test/dg1dTests/src/test_tree.jl b/test/dg1dTests/src/test_tree.jl index 3a46a9c12059e4b03d55971a2e14a666faf51634..813392b5c03a91f6df5a72495774de6867eeac06 100644 --- a/test/dg1dTests/src/test_tree.jl +++ b/test/dg1dTests/src/test_tree.jl @@ -187,54 +187,58 @@ end @testset "Tree" begin - t1d = Tree1d(5) - t2d = Tree2d(5,6) - t3d = Tree3d(5,6,7) - - @test n_cells(t1d) == 5 - @test n_cells(t2d) == 5*6 - @test n_cells(t3d) == 5*6*7 - - # t1d = Tree1d(5, periodic=(true,)) - # t2d = Tree2d(5,6, periodic=(true,false)) - # t3d = Tree3d(5,6,7, periodic=(true,false,true)) - - # call show - println(t1d) - println(t2d) - println(t3d) - - # iterator interface - length_t1d = 0 - for c in t1d - length_t1d += 1 - end - @test length_t1d == n_cells(t1d) - - length_t2d = 0 - for c in t2d - length_t2d += 1 - end - @test length_t2d == n_cells(t2d) + for layout in [ :snake, :hilbert ] + + t1d = Tree1d(4, layout=layout) + t2d = Tree2d(2,4, layout=layout) + t3d = Tree3d(2,4,8, layout=layout) + + @test n_cells(t1d) == 4 + @test n_cells(t2d) == 2*4 + @test n_cells(t3d) == 2*4*8 + + # t1d = Tree1d(5, periodic=(true,)) + # t2d = Tree2d(5,6, periodic=(true,false)) + # t3d = Tree3d(5,6,7, periodic=(true,false,true)) + + # call show + println(t1d) + println(t2d) + println(t3d) + + # iterator interface + length_t1d = 0 + for c in t1d + length_t1d += 1 + end + @test length_t1d == n_cells(t1d) + + length_t2d = 0 + for c in t2d + length_t2d += 1 + end + @test length_t2d == n_cells(t2d) + + length_t3d = 0 + for c in t3d + length_t3d += 1 + end + @test length_t3d == n_cells(t3d) + + x_extends, y_extends, z_extends = (-2.0,2.0), (-10.0,0.0), (1.0,3.0) + boxes1d = place_boxes(t1d, x_extends) + boxes2d = place_boxes(t2d, x_extends, y_extends) + boxes3d = place_boxes(t3d, x_extends, y_extends, z_extends) + + # # TODO Visualize generated trees to check for correctness + # # TODO How to check if periodic boundaries are connected? + # # Perhaps also save is_boundarycell info and color boundary cells. + # # for (name, tree) in [ ("tree1d", t1d), ("tree2d", t2d), ("tree3d", t3d) ] + # # open(filename, "w") do file + # # writedlm(file, tree.coords) + # # end + # # end - length_t3d = 0 - for c in t3d - length_t3d += 1 end - @test length_t3d == n_cells(t3d) - - x_extends, y_extends, z_extends = (-2.0,2.0), (-10.0,0.0), (1.0,3.0) - boxes1d = place_boxes(t1d, x_extends) - boxes2d = place_boxes(t2d, x_extends, y_extends) - boxes3d = place_boxes(t3d, x_extends, y_extends, z_extends) - - # # TODO Visualize generated trees to check for correctness - # # TODO How to check if periodic boundaries are connected? - # # Perhaps also save is_boundarycell info and color boundary cells. - # # for (name, tree) in [ ("tree1d", t1d), ("tree2d", t2d), ("tree3d", t3d) ] - # # open(filename, "w") do file - # # writedlm(file, tree.coords) - # # end - # # end end