1 public class SerialDelaunayrefinement {
3 private static boolean isFirstRun = true;
5 public SerialDelaunayrefinement() {
8 public static void main(String args[]) {
10 //Numbers below are Long.Max_Value
11 long lasttime = 0x7fffffffffffffffL;
12 long mintime = 0x7fffffffffffffffL;
13 for (long run = 0; ((run < 3) || Math.abs(lasttime - runtime) * 64 > Math.min(lasttime, runtime)) && run < 7; run++) {
15 if (runtime < mintime) {
20 System.out.println("minimum runtime: " + mintime + " ms");
21 System.out.println("");
24 public static long run(String args[]) {
27 System.out.println("Lonestar Benchmark Suite v2.1");
28 System.out.println("Copyright (C) 2007, 2008, 2009 The University of Texas at Austin");
29 System.out.println("http://iss.ices.utexas.edu/lonestar/");
31 System.out.println("application: Delaunay Mesh Refinement (serial version)");
32 System.out.println("Refines a Delaunay triangulation mesh such that no angle");
33 System.out.println("in the mesh is less than 30 degrees");
34 System.out.println("http://iss.ices.utexas.edu/lonestar/delaunayrefinement.html");
37 if (args.length < 1) {
38 System.out.println("Arguments: <input file> [verify]");
42 EdgeGraph mesh = new UndirectedEdgeGraph();
45 m.read(mesh, args[0]);
47 Stack worklist = new Stack();
49 // worklist.addAll(Mesh.getBad(mesh));
50 HashMapIterator it = m.getBad(mesh).iterator();
51 while (it.hasNext()) {
52 worklist.push(it.next());
55 Cavity cavity = new Cavity(mesh);
57 System.err.println("configuration: " + mesh.getNumNodes() + " total triangles, " + worklist.size() + " bad triangles");
60 // long id = Time.getNewTimeId();
61 long startTime = System.currentTimeMillis();
62 while (!worklist.empty()) {
63 Node bad_element = (Node) worklist.pop();
64 if (bad_element != null && mesh.containsNode(bad_element)) {
65 cavity.initialize(bad_element);
69 for (Iterator iterator = cavity.getPre().getNodes().iterator(); iterator.hasNext(); mesh.removeNode(node)) {
70 node = (Node) iterator.next();
73 for (Iterator iterator1 = cavity.getPost().getNodes().iterator(); iterator1.hasNext(); mesh.addNode(node)) {
74 node = (Node) iterator1.next();
78 for (Iterator iterator2 = cavity.getPost().getEdges().iterator(); iterator2.hasNext(); mesh.addEdge(edge)) {
79 edge = (Edge_d) iterator2.next();
82 // worklist.addAll(cavity.getPost().newBad(mesh));
83 it = cavity.getPost().newBad(mesh).iterator();
84 while (it.hasNext()) {
85 worklist.push(it.next());
88 if (mesh.containsNode(bad_element)) {
89 worklist.push(bad_element);
93 long time = System.currentTimeMillis() - startTime;
94 System.out.println("runtime: " + time + " ms");
95 if (isFirstRun && args.length > 1) {
102 public static void verify(EdgeGraph result) {
103 if (!Mesh.verify(result)) {
104 // throw new IllegalStateException("refinement failed.");
105 System.out.println("Refinement Failed.");
109 int size = Mesh.getBad(result).size();
111 System.out.println("refinement failed\nstill have "+size+" bad triangles left.\n");
114 System.out.println("OK");