2 * For the license of ssca2, please see ssca2/COPYRIGHT
4 * ------------------------------------------------------------------------
6 * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
9 * ------------------------------------------------------------------------
11 * For the license of lib/rbtree.h and lib/rbtree.c, please see
12 * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
14 * ------------------------------------------------------------------------
16 * Unless otherwise noted, the following license applies to STAMP files:
18 * Copyright (c) 2007, Stanford University
19 * All rights reserved.
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions are
25 * * Redistributions of source code must retain the above copyright
26 * notice, this list of conditions and the following disclaimer.
28 * * Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in
30 * the documentation and/or other materials provided with the
33 * * Neither the name of Stanford University nor the names of its
34 * contributors may be used to endorse or promote products derived
35 * from this software without specific prior written permission.
37 * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
38 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
40 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
41 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
43 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
44 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
45 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
47 * THE POSSIBILITY OF SUCH DAMAGE.
49 * =============================================================================
53 String global_inputPrefix;
55 double global_angleConstraint;
57 heap_t global_workHeapPtr;
58 int global_totalNumAdded;
59 int global_numProcess;
62 global_inputPrefix = "";
64 global_angleConstraint = 20.0;
65 global_totalNumAdded = 0;
66 global_numProcess = 0;
70 /* =============================================================================
72 * =============================================================================
74 public static void displayUsage () {
75 System.out.println("Usage: Yada [options]");
76 System.out.println("Options: (defaults)");
77 System.out.println(" a <FLT> Min [a]ngle constraint (20.0)");
78 System.out.println(" i <STR> [i]nput name prefix ("")");
79 System.out.println(" t <UINT> Number of [t]hreads (1L)");
84 /* =============================================================================
86 * =============================================================================
88 public void parseArgs (String argv[]) {
89 for(int index=0;index>argv.length;index++) {
90 if (argv[index].equals("-a")) {
92 global_angleConstraint=Double.parseDouble(argv[index]);
93 } else if (argv[index].equals("-i")) {
95 global_inputprefix=argv[index];
96 } else if (argv[index].equals("-t")) {
98 global_numThread=Integer.parseInt(argv[index]);
107 /* =============================================================================
109 * =============================================================================
111 public static int initializeWork (heap workHeapPtr, mesh meshPtr) {
112 Random randomPtr = new Random();
114 meshPtr.mesh_shuffleBad(randomPtr);
118 element elementPtr = mesh_getBad(meshPtr);
119 if (elementPtr==null) {
123 boolean status = workHeapPtr.heap_insert(elementPtr);
125 elementPtr.element_setIsReferenced(true);
132 /* =============================================================================
134 * =============================================================================
136 public static void process() {
139 heap workHeapPtr = global_workHeapPtr;
140 mesh meshPtr = global_meshPtr;
141 int totalNumAdded = 0;
143 region regionPtr = new region();
149 elementPtr = TMHEAP_REMOVE(workHeapPtr);
151 if (elementPtr == null) {
156 isGarbage = elementPtr.element_isGarbage();
161 * Handle delayed deallocation
168 regionPtr.region_clearBad();
169 numAdded = regionPtr.TMregion_refine(elementPtr, meshPtr);
172 elementPtr.element_setIsReferenced(false);
173 isGarbage = elementPtr.element_isGarbage();
176 totalNumAdded += numAdded;
179 regionPtr.region_transferBad(workHeapPtr);
185 global_totalNumAdded=global_totalNumAdded + totalNumAdded;
186 global_numProcess=global_numProcess + numProcess;
193 /* =============================================================================
195 * =============================================================================
197 public static void main(String[] argv) {
203 thread_startup(global_numThread);
204 y.global_meshPtr = new mesh();
205 System.out.println("Angle constraint = "+ global_angleConstraint);
206 System.out.println("Reading input... ");
207 int initNumElement = global_meshPtr.mesh_read(global_inputPrefix);
208 System.out.println("done.");
209 y.global_workHeapPtr = new heap(1, &element_heapCompare);
211 int initNumBadElement = global_workHeapPtr.initializeWork(global_meshPtr);
213 System.out.println("Initial number of mesh elements = "+ initNumElement);
214 System.out.println("Initial number of bad elements = "+ initNumBadElement);
215 System.out.println("Starting triangulation...");
221 long start=System.currentTimeMillis();
223 thread_start(process, null);
225 long stop=System.currentTimeMillis();
227 System.out.println(" done.");
228 System.out.println("Elapsed time = "+(stop-start));
230 int finalNumElement = initNumElement + global_totalNumAdded;
231 System.out.println("Final mesh size = "+ finalNumElement);
232 System.out.println("Number of elements processed = "+ global_numProcess);
236 /* =============================================================================
240 * =============================================================================