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 global_workHeapPtr;
58 int global_totalNumAdded;
59 int global_numProcess;
63 global_inputPrefix = "";
65 global_angleConstraint = 20.0;
66 global_totalNumAdded = 0;
67 global_numProcess = 0;
70 public yada(mesh meshptr, heap heapptr, double angle, global g) {
71 global_meshPtr=meshptr;
72 global_workHeapPtr=heapptr;
73 global_angleConstraint=angle;
78 /* =============================================================================
80 * =============================================================================
82 public static void displayUsage () {
83 System.out.println("Usage: Yada [options]");
84 System.out.println("Options: (defaults)");
85 System.out.println(" a <FLT> Min [a]ngle constraint (20.0)");
86 System.out.println(" i <STR> [i]nput name prefix (\"\")");
87 System.out.println(" t <UINT> Number of [t]hreads (1L)");
92 /* =============================================================================
94 * =============================================================================
96 public void parseArgs (String argv[]) {
97 for(int index=0;index>argv.length;index++) {
98 if (argv[index].equals("-a")) {
100 global_angleConstraint=Double.parseDouble(argv[index]);
101 } else if (argv[index].equals("-i")) {
103 global_inputprefix=argv[index];
104 } else if (argv[index].equals("-t")) {
106 global_numThread=Integer.parseInt(argv[index]);
115 /* =============================================================================
117 * =============================================================================
119 public static int initializeWork (heap workHeapPtr, mesh meshPtr) {
120 Random randomPtr = new Random();
122 meshPtr.mesh_shuffleBad(randomPtr);
126 element elementPtr = mesh_getBad(meshPtr);
127 if (elementPtr==null) {
131 boolean status = workHeapPtr.heap_insert(elementPtr);
133 elementPtr.element_setIsReferenced(true);
139 public static void Assert(boolean status) {
141 /* =============================================================================
143 * =============================================================================
145 public static void process() {
146 heap workHeapPtr = global_workHeapPtr;
147 mesh meshPtr = global_meshPtr;
148 int totalNumAdded = 0;
150 region regionPtr = new region();
151 yada.Assert(regionPtr);
156 elementPtr = (element) workHeapPtr.heap_remove();
158 if (elementPtr == null) {
163 isGarbage = elementPtr.element_isGarbage();
168 * Handle delayed deallocation
175 regionPtr.region_clearBad();
176 numAdded = regionPtr.TMregion_refine(elementPtr, meshPtr);
179 elementPtr.element_setIsReferenced(false);
180 isGarbage = elementPtr.element_isGarbage();
183 totalNumAdded += numAdded;
186 regionPtr.region_transferBad(workHeapPtr);
192 global.global_totalNumAdded=global.global_totalNumAdded + totalNumAdded;
193 global.global_numProcess=global.global_numProcess + numProcess;
198 Barrier.enterBarrier();
200 Barrier.enterBarrier();
203 /* =============================================================================
205 * =============================================================================
207 public static void main(String[] argv) {
212 global g=new global();
215 Barrier.setBarrier(y.global_numThread);
216 y.global_meshPtr = new mesh();
217 System.out.println("Angle constraint = "+ y.global_angleConstraint);
218 System.out.println("Reading input... ");
219 int initNumElement = y.global_meshPtr.mesh_read(global_inputPrefix);
220 System.out.println("done.");
221 y.global_workHeapPtr = new heap(1);
223 for(int i=1;i<global_numThread;i++) {
224 yada ychild=new yada(y.global_meshPtr, y.global_angleConstraint, y.global_angleConstraint, g);
228 int initNumBadElement = y.global_workHeapPtr.initializeWork(y.global_meshPtr);
230 System.out.println("Initial number of mesh elements = "+ initNumElement);
231 System.out.println("Initial number of bad elements = "+ initNumBadElement);
232 System.out.println("Starting triangulation...");
238 long start=System.currentTimeMillis();
240 long stop=System.currentTimeMillis();
242 System.out.println(" done.");
243 System.out.println("Elapsed time = "+(stop-start));
245 int finalNumElement = initNumElement + y.global.global_totalNumAdded;
246 System.out.println("Final mesh size = "+ finalNumElement);
247 System.out.println("Number of elements processed = "+ y.global.global_numProcess);
251 /* =============================================================================
255 * =============================================================================