a mini version of barnes hut
[IRC.git] / Robust / src / Tests / disjoint / bh-mini / test.java
1 ///////////////////////////////////
2 //
3 //  This tiny version of Barnes-Hut
4 //  might have enough of the elements
5 //  to exhibit the same reachability state
6 //  bug as the full benchmark, but wackily
7 //  it either analyzes longer than I'm
8 //  willing to wait (over an hour!) or
9 //  it exhausts the memory on dc-11.
10 //
11 ///////////////////////////////////
12
13
14 public class ArrayIndexedNode {
15   public ArrayIndexedNode[] neighbors;
16   public OctTreeNodeData data;
17 }
18
19 public class OctTreeNodeData {
20   public int z;
21 }
22
23 public class OctTreeLeafNodeData extends OctTreeNodeData {
24   public ArrayIndexedNode root;
25 }
26
27
28 public class ArrayIndexedGraph {
29   public ArrayIndexedNode createNode( OctTreeNodeData d ) {
30     ArrayIndexedNode node = disjoint AIN new ArrayIndexedNode();
31     node.data = d;
32     node.neighbors = new ArrayIndexedNode[1];
33     return node;
34   }
35 }
36
37
38 public class Test {
39
40   static public void main( String args[] ) {
41     innerMain( args.length );
42   }
43
44
45   static int numBodies = 3;
46
47
48   static public void innerMain( int x ) {
49
50  
51     OctTreeLeafNodeData bodies[] = new OctTreeLeafNodeData[numBodies];
52     for( int i = 0; i < numBodies; ++i ) {
53       bodies[i] = disjoint BODY new OctTreeLeafNodeData();
54       bodies[i].z = 0;
55     }
56
57     genreach b0;
58
59
60     for( int step = 0; step < 1; ++step ) {
61
62       genreach b1;
63
64       ArrayIndexedGraph octree = new ArrayIndexedGraph();
65
66       ArrayIndexedNode root = octree.createNode( new OctTreeNodeData() );
67
68       genreach b2;
69
70       for( int i = 0; i < numBodies; ++i ) {
71         insert( octree, root, bodies[i] );
72         bodies[i].root = root;
73       }
74
75       genreach b3;
76
77     }
78
79   }
80
81
82   static public void insert( ArrayIndexedGraph   octree,
83                              ArrayIndexedNode    root,
84                              OctTreeLeafNodeData b 
85                              ) {
86     ArrayIndexedNode newNode = octree.createNode( b );
87     root.neighbors[0] = newNode;
88     if( false ) {
89       insert( octree, newNode, b );
90     }
91   }
92 }