1 public class SerialDelaunayRefinement {
2 public boolean isFirstRun;
3 public SerialDelaunayRefinement() {
7 public static void main(String args[]) {
8 SerialDelaunayRefinement sdr = new SerialDelaunayRefinement();
12 public void runMain(String args[]) {
14 //Numbers below are Long.Max_Value
15 long lasttime = 0x7fffffffffffffffL;
16 long mintime = 0x7fffffffffffffffL;
17 for (long run = 0; ((run < 3) || Math.abs(lasttime - runtime) * 64 > Math.min(lasttime, runtime)) && run < 7; run++) {
19 if (runtime < mintime) {
24 System.out.println("minimum runtime: " + mintime + " ms");
25 System.out.println("");
29 public long run(String args[]) {
32 System.out.println("Lonestar Benchmark Suite v2.1");
33 System.out.println("Copyright (C) 2007, 2008, 2009 The University of Texas at Austin");
34 System.out.println("http://iss.ices.utexas.edu/lonestar/");
36 System.out.println("application: Delaunay Mesh Refinement (serial version)");
37 System.out.println("Refines a Delaunay triangulation mesh such that no angle");
38 System.out.println("in the mesh is less than 30 degrees");
39 System.out.println("http://iss.ices.utexas.edu/lonestar/delaunayrefinement.html");
42 if (args.length < 1) {
43 System.out.println("Arguments: <input file> [verify]");
47 EdgeGraph mesh = new UndirectedEdgeGraph();
50 m.read(mesh, args[0]);
52 //treat LinkedList as a stack
53 // Stack worklist = new Stack();
54 LinkedList worklist = new LinkedList();
56 // worklist.addAll(Mesh.getBad(mesh));
57 HashMapIterator it = m.getBad(mesh).iterator();
58 while (it.hasNext()) {
59 worklist.push(it.next());
62 Cavity cavity = new Cavity(mesh);
64 System.out.println("configuration: " + mesh.getNumNodes() + " total triangles, " + worklist.size() + " bad triangles");
67 // long id = Time.getNewTimeId();
68 long startTime = System.currentTimeMillis();
69 while (!worklist.isEmpty()) {
70 Node bad_element = (Node) worklist.pop();
71 if (bad_element != null && mesh.containsNode(bad_element)) {
72 cavity.initialize(bad_element);
76 for (Iterator iterator = cavity.getPre().getNodes().iterator(); iterator.hasNext(); mesh.removeNode(node)) {
77 node = (Node) iterator.next();
80 for (Iterator iterator1 = cavity.getPost().getNodes().iterator(); iterator1.hasNext(); mesh.addNode(node)) {
81 node = (Node) iterator1.next();
85 for (Iterator iterator2 = cavity.getPost().getEdges().iterator(); iterator2.hasNext(); mesh.addEdge(edge)) {
86 edge = (Edge_d) iterator2.next();
89 // worklist.addAll(cavity.getPost().newBad(mesh));
90 it = cavity.getPost().newBad(mesh).iterator();
91 while (it.hasNext()) {
92 worklist.push((Node)it.next());
95 if (mesh.containsNode(bad_element)) {
96 worklist.push((Node) bad_element);
100 long time = System.currentTimeMillis() - startTime;
101 System.out.println("runtime: " + time + " ms");
102 if (isFirstRun && args.length > 1) {
109 public void verify(EdgeGraph result) {
110 //Put in cuz of static issues.
113 if (!m.verify(result)) {
114 // throw new IllegalStateException("refinement failed.");
115 System.out.println("Refinement Failed.");
119 int size = m.getBad(result).size();
121 System.out.println("refinement failed\nstill have "+size+" bad triangles left.\n");
124 System.out.println("OK");