protected Node centerNode;
protected Element centerElement;
protected int dim;
- protected LinkedList frontier = new LinkedList();
+ protected LinkedList frontier;
protected Subgraph pre = new Subgraph();
protected Subgraph post = new Subgraph();
private final EdgeGraph graph;
- protected HashSet connections = new HashSet();
+ protected HashSet connections;
public Cavity(EdgeGraph mesh) {
center = null;
graph = mesh;
+ connections = new HashSet();
+ frontier = new LinkedList();
}
public Subgraph getPre() {
public void initialize(Node node) {
pre.reset();
post.reset();
- connections.clear();
- frontier.clear();
+ connections = new HashSet();
+ frontier = new LinkedList();
centerNode = node;
for (centerElement = (Element) graph.getNodeData(centerNode); graph.containsNode(centerNode)
&& centerElement.isObtuse();) {
for (Iterator iterator = graph.getOutNeighbors(node); iterator.hasNext();) {
Node neighbor = (Node) iterator.next();
Edge_d edge = graph.getEdge(node, neighbor);
- Element.Edge edge_data = (Element.Edge) graph.getEdgeData(edge);
+ ElementEdge edge_data = (ElementEdge) graph.getEdgeData(edge);
if (element.getObtuse().notEquals(edge_data.getPoint(0))
&& element.getObtuse().notEquals(edge_data.getPoint(1)))
return edge;
Node ne_node;
for (Iterator iterator = connections.iterator(); iterator.hasNext(); post.addNode(ne_node)) {
Edge_d conn = (Edge_d) iterator.next();
- Element.Edge edge = (Element.Edge) graph.getEdgeData(conn);
+ ElementEdge edge = (ElementEdge) graph.getEdgeData(conn);
Element new_element = new Element(center, edge.getPoint(0), edge.getPoint(1));
ne_node = graph.createNode(new_element);
Node ne_connection;
ne_connection = graph.getSource(conn);
else
ne_connection = graph.getDest(conn);
- Element.Edge new_edge =
+ ElementEdge new_edge =
new_element.getRelatedEdge((Element) graph.getNodeData(ne_connection));
post.addEdge(graph.createEdge(ne_node, ne_connection, new_edge));
Node node = (Node) iterator1.next();
Element element = (Element) graph.getNodeData(node);
if (element.isRelated(new_element)) {
- Element.Edge ele_edge = new_element.getRelatedEdge(element);
+ ElementEdge ele_edge = new_element.getRelatedEdge(element);
post.addEdge(graph.createEdge(ne_node, node, ele_edge));
}
}
+++ /dev/null
-public interface Edge {
- public abstract Object getData();
- public abstract Object setData(Object obj);
-}
-public class EdgeGraphNode implements Node {\r
+public class EdgeGraphNode extends Node {\r
protected HashMap inEdges;\r
protected HashMap outEdges;\r
protected Object data;\r
-public interface Edge_d {
+public class Edge_d {
//None of the program actually uses getData/setData so I use leave Edge as a
//wrapper interface.
// public abstract Object getData();
private final int dim;
private final Tuple center;
private final double radius_squared;
- private static final double MINANGLE = 30D;
+ private final double MINANGLE = 30D;
public Element(Tuple a, Tuple b, Tuple c) {
dim = 3;
-public class GraphEdge implements Edge_d {\r
+public class GraphEdge extends Edge_d {\r
protected EdgeGraphNode src;\r
protected EdgeGraphNode dest;\r
protected Object d;\r
public class Mesh {
- protected static final HashMap edge_map = new HashMap();
+ protected HashMap edge_map;
public Mesh() {
+ edge_map = new HashMap();
}
- public static HashSet getBad(EdgeGraph mesh) {
+ public HashSet getBad(EdgeGraph mesh) {
HashSet ret = new HashSet();
for (Iterator iterator = mesh.iterator(); iterator.hasNext();) {
Node node = (Node) iterator.next();
return ret;
}
- private static FileInputStream getScanner(String filename) {
+ private FileInputStream getScanner(String filename) {
return new FileInputStream(filename);
}
return node;
}
- public static boolean verify(EdgeGraph mesh) {
+ public boolean verify(EdgeGraph mesh) {
for (Iterator iterator = mesh.iterator(); iterator.hasNext();) {
Node node = (Node) iterator.next();
Element element = (Element) mesh.getNodeData(node);
}
Node start = mesh.getRandom();
- Stack remaining = new Stack();
+// Stack remaining = new Stack();
+ LinkedList remaining = new LinkedList();
HashSet found = new HashSet();
remaining.push(start);
- while (!remaining.empty()) {
+ while (!remaining.isEmpty()) {
Node node = (Node) remaining.pop();
if (!found.contains(node)) {
found.add(node);
-public interface Node {
+public class Node {
//None of the program actually uses getData/setData so I use leave Node as a
//wrapper interface.
--- /dev/null
+public class SerialDelaunayRefinement {
+ public boolean isFirstRun;
+ public SerialDelaunayRefinement() {
+ isFirstRun = true;
+ }
+
+ public static void main(String args[]) {
+ SerialDelaunayRefinement sdr = new SerialDelaunayRefinement();
+ sdr.runMain(args);
+ }
+
+ public void runMain(String args[]) {
+ long runtime = 0;
+ //Numbers below are Long.Max_Value
+ long lasttime = 0x7fffffffffffffffL;
+ long mintime = 0x7fffffffffffffffL;
+ for (long run = 0; ((run < 3) || Math.abs(lasttime - runtime) * 64 > Math.min(lasttime, runtime)) && run < 7; run++) {
+ runtime = run(args);
+ if (runtime < mintime) {
+ mintime = runtime;
+ }
+ }
+
+ System.out.println("minimum runtime: " + mintime + " ms");
+ System.out.println("");
+ }
+
+
+ public long run(String args[]) {
+ if (isFirstRun) {
+ System.out.println();
+ System.out.println("Lonestar Benchmark Suite v2.1");
+ System.out.println("Copyright (C) 2007, 2008, 2009 The University of Texas at Austin");
+ System.out.println("http://iss.ices.utexas.edu/lonestar/");
+ System.out.println();
+ System.out.println("application: Delaunay Mesh Refinement (serial version)");
+ System.out.println("Refines a Delaunay triangulation mesh such that no angle");
+ System.out.println("in the mesh is less than 30 degrees");
+ System.out.println("http://iss.ices.utexas.edu/lonestar/delaunayrefinement.html");
+ System.out.println();
+ }
+ if (args.length < 1) {
+ System.out.println("Arguments: <input file> [verify]");
+ System.exit(-1);
+ }
+
+ EdgeGraph mesh = new UndirectedEdgeGraph();
+
+ Mesh m = new Mesh();
+ m.read(mesh, args[0]);
+
+ //treat LinkedList as a stack
+// Stack worklist = new Stack();
+ LinkedList worklist = new LinkedList();
+
+ // worklist.addAll(Mesh.getBad(mesh));
+ HashMapIterator it = m.getBad(mesh).iterator();
+ while (it.hasNext()) {
+ worklist.push(it.next());
+ }
+
+ Cavity cavity = new Cavity(mesh);
+ if (isFirstRun) {
+ System.out.println("configuration: " + mesh.getNumNodes() + " total triangles, " + worklist.size() + " bad triangles");
+ System.out.println();
+ }
+// long id = Time.getNewTimeId();
+ long startTime = System.currentTimeMillis();
+ while (!worklist.isEmpty()) {
+ Node bad_element = (Node) worklist.pop();
+ if (bad_element != null && mesh.containsNode(bad_element)) {
+ cavity.initialize(bad_element);
+ cavity.build();
+ cavity.update();
+ Node node;
+ for (Iterator iterator = cavity.getPre().getNodes().iterator(); iterator.hasNext(); mesh.removeNode(node)) {
+ node = (Node) iterator.next();
+ }
+
+ for (Iterator iterator1 = cavity.getPost().getNodes().iterator(); iterator1.hasNext(); mesh.addNode(node)) {
+ node = (Node) iterator1.next();
+ }
+
+ Edge_d edge;
+ for (Iterator iterator2 = cavity.getPost().getEdges().iterator(); iterator2.hasNext(); mesh.addEdge(edge)) {
+ edge = (Edge_d) iterator2.next();
+ }
+
+ // worklist.addAll(cavity.getPost().newBad(mesh));
+ it = cavity.getPost().newBad(mesh).iterator();
+ while (it.hasNext()) {
+ worklist.push((Node)it.next());
+ }
+
+ if (mesh.containsNode(bad_element)) {
+ worklist.push((Node) bad_element);
+ }
+ }
+ }
+ long time = System.currentTimeMillis() - startTime;
+ System.out.println("runtime: " + time + " ms");
+ if (isFirstRun && args.length > 1) {
+ verify(mesh);
+ }
+ isFirstRun = false;
+ return time;
+ }
+
+ public void verify(EdgeGraph result) {
+ //Put in cuz of static issues.
+ Mesh m = new Mesh();
+
+ if (!m.verify(result)) {
+// throw new IllegalStateException("refinement failed.");
+ System.out.println("Refinement Failed.");
+ System.exit(-1);
+ }
+
+ int size = m.getBad(result).size();
+ if (size != 0) {
+ System.out.println("refinement failed\nstill have "+size+" bad triangles left.\n");
+ System.exit(-1);
+ } else {
+ System.out.println("OK");
+ return;
+ }
+ }
+}
+++ /dev/null
-public class SerialDelaunayrefinement {
-
- private static boolean isFirstRun = true;
-
- public SerialDelaunayrefinement() {
- }
-
- public static void main(String args[]) {
- long runtime = 0;
- //Numbers below are Long.Max_Value
- long lasttime = 0x7fffffffffffffffL;
- long mintime = 0x7fffffffffffffffL;
- for (long run = 0; ((run < 3) || Math.abs(lasttime - runtime) * 64 > Math.min(lasttime, runtime)) && run < 7; run++) {
- runtime = run(args);
- if (runtime < mintime) {
- mintime = runtime;
- }
- }
-
- System.out.println("minimum runtime: " + mintime + " ms");
- System.out.println("");
- }
-
- public static long run(String args[]) {
- if (isFirstRun) {
- System.out.println();
- System.out.println("Lonestar Benchmark Suite v2.1");
- System.out.println("Copyright (C) 2007, 2008, 2009 The University of Texas at Austin");
- System.out.println("http://iss.ices.utexas.edu/lonestar/");
- System.out.println();
- System.out.println("application: Delaunay Mesh Refinement (serial version)");
- System.out.println("Refines a Delaunay triangulation mesh such that no angle");
- System.out.println("in the mesh is less than 30 degrees");
- System.out.println("http://iss.ices.utexas.edu/lonestar/delaunayrefinement.html");
- System.out.println();
- }
- if (args.length < 1) {
- System.out.println("Arguments: <input file> [verify]");
- System.exit(-1);
- }
-
- EdgeGraph mesh = new UndirectedEdgeGraph();
-
- Mesh m = new Mesh();
- m.read(mesh, args[0]);
-
- Stack worklist = new Stack();
-
- // worklist.addAll(Mesh.getBad(mesh));
- HashMapIterator it = m.getBad(mesh).iterator();
- while (it.hasNext()) {
- worklist.push(it.next());
- }
-
- Cavity cavity = new Cavity(mesh);
- if (isFirstRun) {
- System.err.println("configuration: " + mesh.getNumNodes() + " total triangles, " + worklist.size() + " bad triangles");
- System.out.println();
- }
-// long id = Time.getNewTimeId();
- long startTime = System.currentTimeMillis();
- while (!worklist.empty()) {
- Node bad_element = (Node) worklist.pop();
- if (bad_element != null && mesh.containsNode(bad_element)) {
- cavity.initialize(bad_element);
- cavity.build();
- cavity.update();
- Node node;
- for (Iterator iterator = cavity.getPre().getNodes().iterator(); iterator.hasNext(); mesh.removeNode(node)) {
- node = (Node) iterator.next();
- }
-
- for (Iterator iterator1 = cavity.getPost().getNodes().iterator(); iterator1.hasNext(); mesh.addNode(node)) {
- node = (Node) iterator1.next();
- }
-
- Edge_d edge;
- for (Iterator iterator2 = cavity.getPost().getEdges().iterator(); iterator2.hasNext(); mesh.addEdge(edge)) {
- edge = (Edge_d) iterator2.next();
- }
-
- // worklist.addAll(cavity.getPost().newBad(mesh));
- it = cavity.getPost().newBad(mesh).iterator();
- while (it.hasNext()) {
- worklist.push(it.next());
- }
-
- if (mesh.containsNode(bad_element)) {
- worklist.push(bad_element);
- }
- }
- }
- long time = System.currentTimeMillis() - startTime;
- System.out.println("runtime: " + time + " ms");
- if (isFirstRun && args.length > 1) {
- verify(mesh);
- }
- isFirstRun = false;
- return time;
- }
-
- public static void verify(EdgeGraph result) {
- if (!Mesh.verify(result)) {
-// throw new IllegalStateException("refinement failed.");
- System.out.println("Refinement Failed.");
- System.exit(-1);
- }
-
- int size = Mesh.getBad(result).size();
- if (size != 0) {
- System.out.println("refinement failed\nstill have "+size+" bad triangles left.\n");
- System.exit(-1);
- } else {
- System.out.println("OK");
- return;
- }
- }
-}
-PROGRAM=DelaunayRefinement
+PROGRAM=SerialDelaunayRefinement
-SOURCE_FILES=SerialDelaunayrefinement.java
+SOURCE_FILES=SerialDelaunayRefinement.java
NUM_OOO_WORKERS=24
NUM_RCR_WORKERS=23
--- /dev/null
+./SerialDelaunayRefinements.bin ./input/large.2 true