dfj version of delaunay refinement executes the original algorithm with workers=1...
authorjjenista <jjenista>
Mon, 4 Apr 2011 18:29:21 +0000 (18:29 +0000)
committerjjenista <jjenista>
Mon, 4 Apr 2011 18:29:21 +0000 (18:29 +0000)
14 files changed:
Robust/src/Benchmarks/oooJava/DelaunayRefinement-orig-algo/GraphNode.java
Robust/src/Benchmarks/oooJava/DelaunayRefinement-orig-algo/Node.java
Robust/src/Benchmarks/oooJava/DelaunayRefinement-orig-algo/SerialDelaunayRefinement.java
Robust/src/Benchmarks/oooJava/DelaunayRefinement-orig-algo/Tuple.java
Robust/src/Benchmarks/oooJava/DelaunayRefinement-orig-algo/input/tiny.ele [new file with mode: 0644]
Robust/src/Benchmarks/oooJava/DelaunayRefinement-orig-algo/input/tiny.node [new file with mode: 0644]
Robust/src/Benchmarks/oooJava/DelaunayRefinement-orig-algo/input/tiny.poly [new file with mode: 0644]
Robust/src/Benchmarks/oooJava/DelaunayRefinement/Cavity.java
Robust/src/Benchmarks/oooJava/DelaunayRefinement/DirectedEdgeGraph.java
Robust/src/Benchmarks/oooJava/DelaunayRefinement/SerialDelaunayRefinement.java
Robust/src/Benchmarks/oooJava/DelaunayRefinement/Tuple.java
Robust/src/Benchmarks/oooJava/DelaunayRefinement/input/tiny.ele [new file with mode: 0644]
Robust/src/Benchmarks/oooJava/DelaunayRefinement/input/tiny.node [new file with mode: 0644]
Robust/src/Benchmarks/oooJava/DelaunayRefinement/input/tiny.poly [new file with mode: 0644]

index 755d453403ecc3c06aec0300075b0de058c755fd..2e00aa28bcd117e88a55d042175868b276f9f1b4 100644 (file)
@@ -16,14 +16,14 @@ public class GraphNode extends Node {
     outNeighbors = new Vector();
   }
 
     outNeighbors = new Vector();
   }
 
-//  public Object getData() {
-//    return getNodeData(this);
-//  }
-//
-//  public Object setData(Object n) {
-//    return setNodeData(this, n);
-//  }
-
+  //public Object getData() {
+  //  return getNodeData(this);
+  //}
+  //
+  //public Object setData(Object n) {
+  //  return setNodeData(this, n);
+  //}
+  
   public final boolean addInNeighbor(GraphNode n) {
     if (inNeighbors.contains(n)) {
       return false;
   public final boolean addInNeighbor(GraphNode n) {
     if (inNeighbors.contains(n)) {
       return false;
index 5f71f4f86aa7bad3112f8729ecb360ea4b390b1c..d2ac5391932d6212d36df2b7304c2483d1cefe2b 100644 (file)
@@ -1,7 +1,7 @@
-public class Node {
+abstract public class Node {
   
   //None of the program actually uses getData/setData so I use leave Node as a 
   //wrapper interface.
   
   //None of the program actually uses getData/setData so I use leave Node as a 
   //wrapper interface.
-//  public abstract Object getData();
-//  public abstract Object setData(Object obj);
+  //public abstract Object getData();
+  //public abstract Object setData(Object obj);
 }
 }
index d67103c8eaa7661516ead0fa3913e899ce158f45..a88d7e37958119ce4a0eec4a35c276e9a04a1edb 100644 (file)
@@ -44,6 +44,7 @@ public class SerialDelaunayRefinement {
       if (runtime < mintime) {
         mintime = runtime;
       }
       if (runtime < mintime) {
         mintime = runtime;
       }
+      //System.exit( 0 ); // GC STALLS FOREVER????
       System.gc();
     }
 
       System.gc();
     }
 
@@ -93,8 +94,13 @@ public class SerialDelaunayRefinement {
 
     System.gc();
 
 
     System.gc();
 
+    
+    int zzz = 0;
+    
+
 //    long id = Time.getNewTimeId();
     long startTime = System.currentTimeMillis();
 //    long id = Time.getNewTimeId();
     long startTime = System.currentTimeMillis();
+
     while (!worklist.isEmpty()) {
       Node bad_element = (Node) worklist.pop();
 //      System.out.println("Bad Node"+ ((Element)mesh.getNodeData(bad_element)).toString());
     while (!worklist.isEmpty()) {
       Node bad_element = (Node) worklist.pop();
 //      System.out.println("Bad Node"+ ((Element)mesh.getNodeData(bad_element)).toString());
@@ -102,23 +108,45 @@ public class SerialDelaunayRefinement {
         cavity.initialize(bad_element);
         cavity.build();
         cavity.update();
         cavity.initialize(bad_element);
         cavity.build();
         cavity.update();
+
+
+        //boolean printChange = true; //(zzz % 10 == 0);
         
         //remove old data
         
         //remove old data
+        //if( printChange ) {
+        //  System.out.println( "\n\n\nbad tri: "+mesh.getNodeData( bad_element ) );
+        //  System.out.println( "\npre nodes: " );
+        //}
         Node node;
         for (Iterator iterator = cavity.getPre().getNodes().iterator(); iterator.hasNext();) {
           node = (Node) iterator.next();
         Node node;
         for (Iterator iterator = cavity.getPre().getNodes().iterator(); iterator.hasNext();) {
           node = (Node) iterator.next();
+          //if( printChange ) {
+          //  System.out.println( "  "+mesh.getNodeData( node ) );
+          //}          
           mesh.removeNode(node);
         }
 
         //add new data
           mesh.removeNode(node);
         }
 
         //add new data
+        //if( printChange ) {
+        //  System.out.println( "post nodes: " );
+        //}
         for (Iterator iterator1 = cavity.getPost().getNodes().iterator(); iterator1.hasNext();) {
           node = (Node) iterator1.next();
         for (Iterator iterator1 = cavity.getPost().getNodes().iterator(); iterator1.hasNext();) {
           node = (Node) iterator1.next();
+          //if( printChange ) {
+          //  System.out.println( "  "+mesh.getNodeData( node ) );
+          //}          
           mesh.addNode(node);
         }
 
           mesh.addNode(node);
         }
 
+        //if( printChange ) {
+        //  System.out.println( "post edges: " );
+        //}
         Edge_d edge;
         for (Iterator iterator2 = cavity.getPost().getEdges().iterator(); iterator2.hasNext();) {
           edge = (Edge_d) iterator2.next();
         Edge_d edge;
         for (Iterator iterator2 = cavity.getPost().getEdges().iterator(); iterator2.hasNext();) {
           edge = (Edge_d) iterator2.next();
+          //if( printChange ) {
+          //  System.out.println( "  "+mesh.getEdgeData( edge ) );
+          //}          
           mesh.addEdge(edge);
         }
 
           mesh.addEdge(edge);
         }
 
@@ -131,7 +159,14 @@ public class SerialDelaunayRefinement {
         if (mesh.containsNode(bad_element)) {
           worklist.push((Node) bad_element);
         }
         if (mesh.containsNode(bad_element)) {
           worklist.push((Node) bad_element);
         }
+      } else {
+        //System.out.println( "\n\n\nthis tri no longer a concern: "+mesh.getNodeData( bad_element ) );
       }
       }
+
+      //++zzz;
+      //System.out.println( "\n\ntris="+mesh.getNumNodes()+
+      //                    " [wl="+worklist.size()+"]");
+      //if( zzz == 10 ) { System.exit( 0 ); }
     }
     long time = System.currentTimeMillis() - startTime;
     System.out.println("runtime: " + time + " ms");
     }
     long time = System.currentTimeMillis() - startTime;
     System.out.println("runtime: " + time + " ms");
index 29391115a63d4d8137ade1a32d3915dde4f1c211..24406031c7615613eb5e86b2bcc5e8b380e0dac9 100644 (file)
@@ -121,7 +121,15 @@ public class Tuple {
   }
 
   public String toString() {
   }
 
   public String toString() {
-    return new String("(" + coords[0] + ", " + coords[1] + ", " + coords[2] + ")");
+    //return new String("(" + coords[0] + ", " + coords[1] + ", " + coords[2] + ")");
+
+    String x = ""+coords[0];
+    x = x.substring( 0, 4 );
+
+    String y = ""+coords[1];
+    y = y.substring( 0, 4 );
+
+    return new String("("+x+", "+y+")");
   }
 
   public static int cmp(Tuple a, Tuple b) {
   }
 
   public static int cmp(Tuple a, Tuple b) {
diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement-orig-algo/input/tiny.ele b/Robust/src/Benchmarks/oooJava/DelaunayRefinement-orig-algo/input/tiny.ele
new file mode 100644 (file)
index 0000000..d9c5aea
--- /dev/null
@@ -0,0 +1,6 @@
+5
+0  0 1 3
+1  1 2 3
+2  2 3 5
+3  3 4 5
+4  0 3 4
diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement-orig-algo/input/tiny.node b/Robust/src/Benchmarks/oooJava/DelaunayRefinement-orig-algo/input/tiny.node
new file mode 100644 (file)
index 0000000..3b01700
--- /dev/null
@@ -0,0 +1,7 @@
+6
+0  1 1 0
+1  4 1 0
+2  7 2 0
+3  5 3 0
+4  0 9 0 //if you use this for point 4 it works fine: 2 6 0
+5  6 6 0
diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement-orig-algo/input/tiny.poly b/Robust/src/Benchmarks/oooJava/DelaunayRefinement-orig-algo/input/tiny.poly
new file mode 100644 (file)
index 0000000..bc45b3b
--- /dev/null
@@ -0,0 +1,7 @@
+ignored line
+5
+0  0 1
+1  1 2
+2  2 5
+3  5 4
+4  4 0
index b1b2b87355cc676d3ff2d0859c73ba573a9a5ec0..da6268b5a8f42097effe8ae4560081071040bc25 100644 (file)
@@ -55,39 +55,30 @@ public class Cavity {
   }
 
   private Edge_d getOpposite(Node node) {
   }
 
   private Edge_d getOpposite(Node node) {
-    Element element = (Element) getNodeData(node);
+    Element element = (Element) graph.getNodeData(node);
 
 
-    System.out.println( "\n  element="+element+" with obtuse="+element.getObtuse() );
+    // Don't think we'd run into it but..
+    // TODO check this.
+    // if(neighbors.size() != 3)
+    // throw new Error(String.format("neighbors %d", new Object[] {
+    // Integer.valueOf(neighbors.size())
+    // }));
 
 
-    int outNeiCnt = 0;
+    int cntOutNeighbors = 0;
 
 
-    for (Iterator iterator = getOutNeighbors(node); iterator.hasNext();) {
-      ++outNeiCnt;
+    for (Iterator iterator = graph.getOutNeighbors(node); iterator.hasNext();) {
+      ++cntOutNeighbors;
       Node neighbor = (Node) iterator.next();
       Node neighbor = (Node) iterator.next();
-      Edge_d edge = getEdge(node, neighbor);
-      ElementEdge edge_data = (ElementEdge) getEdgeData(edge);
-
-      System.out.println( "    is "+edge_data.getPoint(0)+" and "+edge_data.getPoint(1)+
-                          " opposite the obtuse?");
-
-      if (element.getObtuse().notEquals(edge_data.getPoint(0)) &&
-          element.getObtuse().notEquals(edge_data.getPoint(1))
-          )
+      Edge_d edge = graph.getEdge(node, neighbor);
+      ElementEdge edge_data = (ElementEdge) graph.getEdgeData(edge);
+      if (element.getObtuse().notEquals(edge_data.getPoint(0))
+          && element.getObtuse().notEquals(edge_data.getPoint(1)))
         return edge;
     }
 
         return edge;
     }
 
-    int inNeiCnt = 0;
-
-    for (Iterator iterator = ((EdgeGraphNode)node).getInNeighbors(); iterator.hasNext();) {
-      ++inNeiCnt;
-      Node neighbor = (Node) iterator.next();
-    }
-
-    if( outNeiCnt != 3 ) {
-      System.out.println( "Get opposite when "+outNeiCnt+" out-neighbors? in-nei="+inNeiCnt );
-    }
-    
     System.out.println("Error: \"Edge\" in Cavity.java getOpposite(Node)");
     System.out.println("Error: \"Edge\" in Cavity.java getOpposite(Node)");
+    System.out.println("  tri="+element+" has "+cntOutNeighbors+" out-neighbors");
+    System.out.println("  obtuse="+element.getObtuse());
     System.exit(-1);
     return null; // it's here so the compiler doesn't complain.
   }
     System.exit(-1);
     return null; // it's here so the compiler doesn't complain.
   }
index 8c4f59a9abc0a8089a2a49809a8397c89e2c0509..9252a22c5e1bbc87270f9dd53d9ff5b3f8e048b9 100644 (file)
@@ -59,26 +59,7 @@ public class DirectedEdgeGraph implements EdgeGraph {
         }
       }      
     }
         }
       }      
     }
-
-    System.out.println( "Graph has "+nodes.size()+" nodes currently." );
-  }
-
-//  // keep the nodes set up-to-date, but use AFTER...
-//  public void addNodeToAllNodesSet( Node n ) {
-//    if( !n.inGraph ) {
-//      System.out.println( "Error: adding a node NOT IN the graph to the all-nodes set!" );
-//      System.exit( -1 );
-//    }
-//    nodes.add( n );
-//  }
-//
-//  public void removeNodeFromAllNodesSet( Node n ) {
-//    if( n.inGraph ) {
-//      System.out.println( "Error: removing a node IN the graph from the all-nodes set!" );
-//      System.exit( -1 );
-//    }
-//    nodes.add( n );
-//  }
+  }
 
   // these are the normal methods for truly adding and removing nodes
   // from the graph, nodes know locally if they are in and out but they
 
   // these are the normal methods for truly adding and removing nodes
   // from the graph, nodes know locally if they are in and out but they
@@ -91,6 +72,7 @@ public class DirectedEdgeGraph implements EdgeGraph {
 
   public boolean removeNode(Node n) {
     boolean wasIn = n.inGraph;
 
   public boolean removeNode(Node n) {
     boolean wasIn = n.inGraph;
+    n.inGraph = false;
     removeConnectingEdges((EdgeGraphNode) n);
     return wasIn;
   }
     removeConnectingEdges((EdgeGraphNode) n);
     return wasIn;
   }
index f22ac8e3eef12af2834644a8db593a2ef22078da..c8f8fea18602ba7302731f4f015c254e0d3fc9e9 100644 (file)
@@ -104,6 +104,9 @@ public class SerialDelaunayRefinement {
     Cavity lastAppliedCavity = null;
 
 
     Cavity lastAppliedCavity = null;
 
 
+    int zzz = 0;
+
+
     long startTime = System.currentTimeMillis();
     while (!worklist.isEmpty()) {
 
     long startTime = System.currentTimeMillis();
     while (!worklist.isEmpty()) {
 
@@ -126,7 +129,8 @@ public class SerialDelaunayRefinement {
             nodeForBadTri.inGraph
             ) {
      
             nodeForBadTri.inGraph
             ) {
      
-          System.out.println( "computing a cavity..." );
+          //System.out.println( "computing a cavity for tri "+
+          //                    mesh.getNodeData( nodeForBadTri )+"..." );
      
           sese computeCavity {
             //takes < 1 sec 
      
           sese computeCavity {
             //takes < 1 sec 
@@ -144,7 +148,7 @@ public class SerialDelaunayRefinement {
             //Takes up a whooping 50% of computation time and changes NOTHING but cavity :D
             cavity.update();                    
           }
             //Takes up a whooping 50% of computation time and changes NOTHING but cavity :D
             cavity.update();                    
           }
-  
+          
           sese storeCavity {
             cavities[i] = cavity;
           }
           sese storeCavity {
             cavities[i] = cavity;
           }
@@ -175,32 +179,54 @@ public class SerialDelaunayRefinement {
             appliedCavity     = true;
             lastAppliedCavity = cavity;
 
             appliedCavity     = true;
             lastAppliedCavity = cavity;
 
+
+            //boolean printChange = true; //(zzz % 10 == 0);
+        
+
             //remove old data
             Node node;
             //remove old data
             Node node;
-    
+            //if( printChange ) {
+            //  System.out.println( "\n\n\nbad tri: "+mesh.getNodeData( nodeForBadTri ) );
+            //  System.out.println( "\npre nodes: " );
+            //}
             //Takes up 8.9% of runtime
             for (Iterator iterator = cavity.getPre().getNodes().iterator();
                  iterator.hasNext();) {
 
               node = (Node) iterator.next();
             //Takes up 8.9% of runtime
             for (Iterator iterator = cavity.getPre().getNodes().iterator();
                  iterator.hasNext();) {
 
               node = (Node) iterator.next();
+              //if( printChange ) {
+              //  System.out.println( "  "+mesh.getNodeData( node ) );
+              //}          
               mesh.removeNode(node);
             }
  
             //add new data
               mesh.removeNode(node);
             }
  
             //add new data
+            //if( printChange ) {
+            //  System.out.println( "post nodes: " );
+            //}
             //Takes up 1.7% of runtime
             for (Iterator iterator1 = cavity.getPost().getNodes().iterator(); 
                  iterator1.hasNext();) {
 
               node = (Node) iterator1.next();
             //Takes up 1.7% of runtime
             for (Iterator iterator1 = cavity.getPost().getNodes().iterator(); 
                  iterator1.hasNext();) {
 
               node = (Node) iterator1.next();
+              //if( printChange ) {
+              //  System.out.println( "  "+mesh.getNodeData( node ) );
+              //}          
               mesh.addNode(node);
             }
  
               mesh.addNode(node);
             }
  
+            //if( printChange ) {
+            //  System.out.println( "post edges: " );
+            //}
             //Takes up 7.8% of runtime
             Edge_d edge;
             for (Iterator iterator2 = cavity.getPost().getEdges().iterator();
                  iterator2.hasNext();) {
               
               edge = (Edge_d) iterator2.next();
             //Takes up 7.8% of runtime
             Edge_d edge;
             for (Iterator iterator2 = cavity.getPost().getEdges().iterator();
                  iterator2.hasNext();) {
               
               edge = (Edge_d) iterator2.next();
+              //if( printChange ) {
+              //  System.out.println( "  "+mesh.getEdgeData( edge ) );
+              //}                        
               mesh.addEdge(edge);
             }
           }
               mesh.addEdge(edge);
             }
           }
@@ -208,37 +234,54 @@ public class SerialDelaunayRefinement {
          
 
         sese scheduleMoreBad {
          
 
         sese scheduleMoreBad {
+
+          if( appliedCavity ) {
+            // we did apply the cavity, and we may 
+            // have introduced new bad triangles
+            HashMapIterator it2 = cavity.getPost().newBad(mesh).iterator();
+            while (it2.hasNext()) {
+              worklist.push((Node)it2.next());
+            }
+          }
+        
+          // the logic of having this out here seems wacky, and overconservative,
+          // but it matches the original algorithm and it works...
+          if( nodeForBadTri != null && mesh.containsNode( nodeForBadTri ) ) {
+            worklist.push( nodeForBadTri );
+          }
           
           
+          /*
           if( !appliedCavity ) {
 
             // if we couldn't even apply this cavity, just
             // throw it back on the worklist
             if( nodeForBadTri != null && nodeForBadTri.inGraph ) {
               worklist.push( nodeForBadTri );
           if( !appliedCavity ) {
 
             // if we couldn't even apply this cavity, just
             // throw it back on the worklist
             if( nodeForBadTri != null && nodeForBadTri.inGraph ) {
               worklist.push( nodeForBadTri );
+            } else {
+              System.out.println( "\n\n\nthis tri no longer a concern: "+
+                                  mesh.getNodeData( nodeForBadTri ) );
             }
 
           } else {
             }
 
           } else {
-            // otherwise we did apply the cavity, so repair the all-nodes set of the mesh
-            //Iterator itrPreNodes = cavity.getPre().getNodes().iterator();
-            //while( itrPreNodes.hasNext() ) {
-            //  System.out.println( "yere" );
-            //  mesh.removeNodeFromAllNodesSet( (Node)itrPreNodes.next() );
-            //  System.out.println( "yeres" );
-            //}
-            //Iterator itrPostNodes = cavity.getPost().getNodes().iterator();
-            //while( itrPostNodes.hasNext() ) {
-            //  mesh.addNodeToAllNodesSet( (Node)itrPostNodes.next() );
-            //}
-
+            // otherwise we did apply the cavity,
             // and we may have introduced new bad triangles
             HashMapIterator it2 = cavity.getPost().newBad(mesh).iterator();
             while (it2.hasNext()) {
               worklist.push((Node)it2.next());
             }
           }
             // and we may have introduced new bad triangles
             HashMapIterator it2 = cavity.getPost().newBad(mesh).iterator();
             while (it2.hasNext()) {
               worklist.push((Node)it2.next());
             }
           }
+          */
+
         } // end scheduleMoreBad
       } // end phase 3
 
         } // end scheduleMoreBad
       } // end phase 3
 
+      //++zzz;
+      //Node aNode = (Node)lastAppliedCavity.getPost().getNodes().iterator().next();      
+      //mesh.discoverAllNodes( aNode );
+      //System.out.println( "\n\ntris="+mesh.getNumNodes()+
+      //                    " [wl="+worklist.size()+"]");
+      //if( zzz == 10 ) { System.exit( 0 ); }
+
     } // end while( !worklist.isEmpty() )
 
     long time = System.currentTimeMillis() - startTime;
     } // end while( !worklist.isEmpty() )
 
     long time = System.currentTimeMillis() - startTime;
index 29391115a63d4d8137ade1a32d3915dde4f1c211..0e4ab8d17c59f27df20fa4a86de346d981e3ec9c 100644 (file)
@@ -120,8 +120,16 @@ public class Tuple {
     return 57.295779513082323D * Math.acos(d);
   }
 
     return 57.295779513082323D * Math.acos(d);
   }
 
-  public String toString() {
-    return new String("(" + coords[0] + ", " + coords[1] + ", " + coords[2] + ")");
+  public String toString() {    
+    //return new String("(" + coords[0] + ", " + coords[1] + ", " + coords[2] + ")");
+
+    String x = ""+coords[0];
+    x = x.substring( 0, 4 );
+
+    String y = ""+coords[1];
+    y = y.substring( 0, 4 );
+
+    return new String("("+x+", "+y+")");
   }
 
   public static int cmp(Tuple a, Tuple b) {
   }
 
   public static int cmp(Tuple a, Tuple b) {
diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/input/tiny.ele b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/input/tiny.ele
new file mode 100644 (file)
index 0000000..d9c5aea
--- /dev/null
@@ -0,0 +1,6 @@
+5
+0  0 1 3
+1  1 2 3
+2  2 3 5
+3  3 4 5
+4  0 3 4
diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/input/tiny.node b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/input/tiny.node
new file mode 100644 (file)
index 0000000..3b01700
--- /dev/null
@@ -0,0 +1,7 @@
+6
+0  1 1 0
+1  4 1 0
+2  7 2 0
+3  5 3 0
+4  0 9 0 //if you use this for point 4 it works fine: 2 6 0
+5  6 6 0
diff --git a/Robust/src/Benchmarks/oooJava/DelaunayRefinement/input/tiny.poly b/Robust/src/Benchmarks/oooJava/DelaunayRefinement/input/tiny.poly
new file mode 100644 (file)
index 0000000..bc45b3b
--- /dev/null
@@ -0,0 +1,7 @@
+ignored line
+5
+0  0 1
+1  1 2
+2  2 5
+3  5 4
+4  4 0