bug fixes
authorbdemsky <bdemsky>
Sun, 18 Oct 2009 10:53:59 +0000 (10:53 +0000)
committerbdemsky <bdemsky>
Sun, 18 Oct 2009 10:53:59 +0000 (10:53 +0000)
Robust/src/Benchmarks/SingleTM/Yada/bytereader.java
Robust/src/Benchmarks/SingleTM/Yada/element.java
Robust/src/Benchmarks/SingleTM/Yada/mesh.java
Robust/src/Benchmarks/SingleTM/Yada/yada.java

index 60f4f2f8f10ff8d5586626fc5e0bc026b83a5741..0f49ba327a6c3a3ba81e45a7adde56c6897f7cda 100644 (file)
@@ -54,6 +54,18 @@ public class bytereader {
   }
 
   private void getBytes() {
+    boolean searching=true;
+    while(searching) {
+      for(;pos<lastlocation;pos++) {
+       if (buffer[pos]!=' '&&buffer[pos]!='\n'&&buffer[pos]!='\t') {
+         searching=false;
+         break;
+       }
+      }
+      if (searching) {
+       readnewdata();
+      }
+    }
     start=pos;
     for(;pos<lastlocation;pos++) {
       if (buffer[pos]==' '||
@@ -71,16 +83,17 @@ public class bytereader {
     }
     readnewdata();
     start=lastlocation-start;
-    for(;true;pos++) {
+    for(;pos<lastlocation;pos++) {
       if (buffer[pos]==' '||
          buffer[pos]=='\n') {
+       end=pos+start;
+       start=0;
        pos++;
        skipline();
        return;
       }
       tmp[pos+start]=buffer[pos];
     }
-    end=pos+start;
   }
 
 }
\ No newline at end of file
index e2b22d9d417565211ebf8605cd12cd9260138fae..9cba4e8b9cdba5c5bac7798c14dfee8b0c2c2899 100644 (file)
@@ -181,7 +181,6 @@ public class element {
  */
   void calculateCircumCircle() {
     coordinate circumCenterPtr = this.circumCenter;
-
     yada.Assert(numCoordinate == 2 || numCoordinate == 3);
 
     if (numCoordinate == 2) {
@@ -322,11 +321,15 @@ int element_compare (element aElementPtr, element bElementPtr) {
 
   double angleConstraint;
   public element(coordinate[] coordinates, int numCoordinate, double angle) {
+    this.circumCenter=new coordinate();
     this.coordinates=new coordinate[3];
     this.midpoints=new coordinate[3]; /* midpoint of each edge */
     this.radii=new double[3];           /* half of edge length */
-
     this.edges=new edge[3];
+    for (int i = 0; i < 3; i++) {
+      this.midpoints[i] = new coordinate();
+      this.edges[i]=new edge();
+    }
     for (int i = 0; i < numCoordinate; i++) {
       this.coordinates[i] = coordinates[i];
     }
index 8374d80173968c2d757610e89ae8b307d41cae81..07eb1508e9c7909060a5cdd4fa4c521d2af360df 100644 (file)
@@ -227,10 +227,8 @@ boolean TMmesh_removeBoundary(edge boundaryPtr) {
  * =============================================================================
  */
 int mesh_read(String fileNamePrefix) {
-    char inputBuff[]=new char[256];
     int i;
     int numElement = 0;
-
     avltree edgeMapPtr = new avltree(0);
 
     /*
@@ -242,6 +240,7 @@ int mesh_read(String fileNamePrefix) {
     bytereader br=new bytereader(inputFile);
     int numEntry=br.getInt();
     int numDimension=br.getInt();
+    br.jumptonextline();
     yada.Assert(numDimension == 2); /* must be 2-D */
     int numCoordinate = numEntry + 1; /* numbering can start from 1 */
     coordinate coordinates[] = new coordinate[numCoordinate];
@@ -255,6 +254,7 @@ int mesh_read(String fileNamePrefix) {
       id=br.getInt();
       x=br.getDouble();
       y=br.getDouble();
+      br.jumptonextline();
       coordinates[id].x = x;
       coordinates[id].y = y;
     }
@@ -269,9 +269,11 @@ int mesh_read(String fileNamePrefix) {
     br=new bytereader(inputFile);
     numEntry=br.getInt();
     numDimension=br.getInt();
+    br.jumptonextline();
     yada.Assert(numEntry == 0); /* .node file used for vertices */
     yada.Assert(numDimension == 2); /* must be edge */
     numEntry=br.getInt();
+    br.jumptonextline();
     for (i = 0; i < numEntry; i++) {
       int id;
       int a;
@@ -280,6 +282,7 @@ int mesh_read(String fileNamePrefix) {
       id=br.getInt();
       a=br.getInt();
       b=br.getInt();
+      br.jumptonextline();
       yada.Assert(a >= 0 && a < numCoordinate);
       yada.Assert(b >= 0 && b < numCoordinate);
       insertCoordinates[0] = coordinates[a];
@@ -298,6 +301,7 @@ int mesh_read(String fileNamePrefix) {
     br=new bytereader(inputFile);
     numEntry=br.getInt();
     numDimension=br.getInt();
+    br.jumptonextline();
     yada.Assert(numDimension == 3); /* must be triangle */
     for (i = 0; i < numEntry; i++) {
       int id;
@@ -309,6 +313,7 @@ int mesh_read(String fileNamePrefix) {
       a=br.getInt();
       b=br.getInt();
       c=br.getInt();
+      br.jumptonextline();
       yada.Assert(a >= 0 && a < numCoordinate);
       yada.Assert(b >= 0 && b < numCoordinate);
       yada.Assert(c >= 0 && c < numCoordinate);
index acc36cc942338238808c8845e50884576f39902f..aa48155df34f97a94d6977faa63465a01cc9f4b1 100644 (file)
@@ -94,7 +94,7 @@ public class yada extends Thread {
  * =============================================================================
  */
   public void parseArgs (String argv[]) {
-    for(int index=0;index>argv.length;index++) {
+    for(int index=0;index<argv.length;index++) {
       if (argv[index].equals("-a")) {
        index++;
        global_angleConstraint=Double.parseDouble(argv[index]);
@@ -137,6 +137,11 @@ public class yada extends Thread {
   }
   
   public static void Assert(boolean status) {
+    if (!status) {
+      System.out.println("Failed assert");
+      int [] x=new int[1];
+      x[0]=3/0;
+    }
   }
 /* =============================================================================
  * process