2 Lonestar Benchmark Suite for irregular applications that exhibit
3 amorphous data-parallelism.
5 Center for Grid and Distributed Computing
6 The University of Texas at Austin
8 Copyright (C) 2007, 2008, 2009 The University of Texas at Austin
10 Licensed under the Eclipse Public License, Version 1.0 (the "License");
11 you may not use this file except in compliance with the License.
12 You may obtain a copy of the License at
14 http://www.eclipse.org/legal/epl-v10.html
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
22 File: UndirectedEdgeGraph.java
26 public class SerialDelaunayRefinement {
27 public boolean isFirstRun;
28 public SerialDelaunayRefinement() {
32 public static void main(String args[]) {
33 SerialDelaunayRefinement sdr = new SerialDelaunayRefinement();
37 public void runMain(String args[]) {
39 //Numbers below are Long.Max_Value
40 long lasttime = 0x7fffffffffffffffL;
41 long mintime = 0x7fffffffffffffffL;
42 for (long run = 0; ((run < 3) || Math.abs(lasttime - runtime) * 64 > Math.min(lasttime, runtime)) && run < 7; run++) {
44 if (runtime < mintime) {
49 System.out.println("minimum runtime: " + mintime + " ms");
50 System.out.println("");
54 public long run(String args[]) {
57 System.out.println("Lonestar Benchmark Suite v2.1");
58 System.out.println("Copyright (C) 2007, 2008, 2009 The University of Texas at Austin");
59 System.out.println("http://iss.ices.utexas.edu/lonestar/");
61 System.out.println("application: Delaunay Mesh Refinement (serial version)");
62 System.out.println("Refines a Delaunay triangulation mesh such that no angle");
63 System.out.println("in the mesh is less than 30 degrees");
64 System.out.println("http://iss.ices.utexas.edu/lonestar/delaunayrefinement.html");
67 if (args.length < 1) {
68 System.out.println("Arguments: <input file> [verify]");
72 EdgeGraph mesh = new UndirectedEdgeGraph();
75 m.read(mesh, args[0]);
77 //treat LinkedList as a stack
78 // Stack worklist = new Stack();
79 LinkedList worklist = new LinkedList();
81 // worklist.addAll(Mesh.getBad(mesh));
82 HashMapIterator it = m.getBad(mesh).iterator();
83 while (it.hasNext()) {
84 worklist.add(it.next());
87 Cavity cavity = new Cavity(mesh);
89 System.out.println("configuration: " + mesh.getNumNodes() + " total triangles, " + worklist.size() + " bad triangles");
92 // long id = Time.getNewTimeId();
93 long startTime = System.currentTimeMillis();
94 while (!worklist.isEmpty()) {
95 Node bad_element = (Node) worklist.pop();
96 // System.out.println("Bad Node"+ ((Element)mesh.getNodeData(bad_element)).toString());
97 if (bad_element != null && mesh.containsNode(bad_element)) {
98 cavity.initialize(bad_element);
104 for (Iterator iterator = cavity.getPre().getNodes().iterator(); iterator.hasNext();) {
105 node = (Node) iterator.next();
106 mesh.removeNode(node);
110 for (Iterator iterator1 = cavity.getPost().getNodes().iterator(); iterator1.hasNext();) {
111 node = (Node) iterator1.next();
116 for (Iterator iterator2 = cavity.getPost().getEdges().iterator(); iterator2.hasNext();) {
117 edge = (Edge_d) iterator2.next();
121 // worklist.addAll(cavity.getPost().newBad(mesh));
122 it = cavity.getPost().newBad(mesh).iterator();
123 while (it.hasNext()) {
124 worklist.push((Node)it.next());
127 if (mesh.containsNode(bad_element)) {
128 worklist.push((Node) bad_element);
132 long time = System.currentTimeMillis() - startTime;
133 System.out.println("runtime: " + time + " ms");
134 //TODO note how we only verify on first run...
135 if (isFirstRun && args.length > 1) {
142 public void verify(EdgeGraph result) {
143 //Put in cuz of static issues.
145 if (!m.verify(result)) {
146 // throw new IllegalStateException("refinement failed.");
147 System.out.println("Refinement Failed.");
151 int size = m.getBad(result).size();
153 System.out.println("refinement failed\nstill have "+size+" bad triangles left.\n");
156 System.out.println("OK");