Changeset 4916
- Timestamp:
- Jan 9, 2008, 12:15:17 PM (17 years ago)
- Location:
- anuga_core/source/anuga/mesh_engine
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/mesh_engine/mesh_engine.py
r4902 r4916 58 58 if pointatts is None or pointatts == []: 59 59 pointatts = [[] for x in range(points.shape[0])] 60 60 61 try: 61 62 # If Int is used, instead of Int32, it fails in Linux … … 69 70 if segatts is None or segatts == []: 70 71 segatts = [0 for x in range(segments.shape[0])] 72 71 73 try: 72 74 holes = ensure_numeric(holes, Float) … … 109 111 segment array.""" 110 112 raise ANUGAError, msg 111 112 113 113 114 #print "mode", mode … … 128 129 #print "pointatts", pointatts 129 130 #print "segatts", segatts 130 #XSprint "mode", mode 131 #print "yeah" 131 #print "mode", mode 132 #print "yeah" 133 # .copy() 132 134 trianglelist, pointlist, pointmarkerlist, pointattributelist, triangleattributelist, segmentlist, segmentmarkerlist, neighborlist = triang.genMesh(points,segments,holes,regions, 133 pointatts,segatts, mode , segments.flat)135 pointatts,segatts, mode) 134 136 mesh_dict = {} 135 137 # the values as arrays … … 145 147 mesh_dict['qaz'] = 1 #debugging 146 148 147 mesh_dict['triangleattributelist'] = triangleattributelist149 #mesh_dict['triangleattributelist'] = triangleattributelist 148 150 #print "mesh eng generatedtrianglelist", trianglelist 149 151 #print "mesh eng mesh_dict['triangleattributelist'] ",mesh_dict['triangleattributelist'] … … 157 159 if mesh_dict['generatedpointattributelist'].shape[1] == 0: 158 160 mesh_dict['generatedpointattributelist'] = None 161 162 if mesh_dict['generatedtriangleneighborlist'].shape[1] == 0: 163 mesh_dict['generatedtriangleneighborlist'] = None 164 159 165 if trianglelist.shape[0] == 0: 160 166 # There are no triangles. … … 162 168 raise NoTrianglesError 163 169 #print "mesh eng mesh_dict['generatedtriangleattributelist'] ", mesh_dict['generatedtriangleattributelist'] 164 170 a = mesh_dict['generatedtriangleattributelist'] 171 #print 'mesh_dict', mesh_dict 165 172 # the structure of generatedtriangleattributelist is an list of 166 173 # list of integers. It is transformed into a list of list of -
anuga_core/source/anuga/mesh_engine/mesh_engine_c_layer.c
r4915 r4916 62 62 //#define PY_ARRAY_UNIQUE_SYMBOL API_YEAH 63 63 64 //#define PY_ARRAY_UNIQUE_SYMBOL API_YEAH 65 64 #define PY_ARRAY_UNIQUE_SYMBOL API_YEAH 66 65 //#define NO_IMPORT_ARRAY 67 66 #include "Numeric/arrayobject.h" … … 117 116 char *mod; 118 117 119 if(!PyArg_ParseTuple(args,(char *)"OOOOOOO O",&pointlist,&seglist,&holelist,®ionlist,&pointattributelist,&segmarkerlist,&mode,&test)){118 if(!PyArg_ParseTuple(args,(char *)"OOOOOOO",&pointlist,&seglist,&holelist,®ionlist,&pointattributelist,&segmarkerlist,&mode)){ 120 119 return NULL; 121 120 } … … 128 127 /* Initialize and fill up region list */ 129 128 in.numberofregions = regionlist-> dimensions[0]; 129 130 130 in.regionlist = (double *) regionlist -> data; 131 131 … … 133 133 in.numberofsegments = seglist -> dimensions[0]; 134 134 in.segmentlist = (int *) seglist -> data; 135 /* in.segmentlist = (int *) test -> data; */136 135 in.segmentmarkerlist = (int *) segmarkerlist -> data; 136 //in.segmentmarkerlist = (int *) NULL; 137 137 138 138 /*Initialize triangles */ … … 141 141 in.numberoftriangleattributes = 0; 142 142 in.triangleattributelist = (REAL *)NULL; 143 in.trianglearealist = (REAL *)NULL; 144 in.neighborlist = (int *)NULL; 145 in.numberofcorners = 0; 143 146 144 147 /*Initialize holes */ … … 155 158 if (0 == pointattributelist -> dimensions[0]) { 156 159 in.numberofpointattributes = 0; 157 in.pointattributelist = NULL;160 in.pointattributelist = (double *) NULL; 158 161 } else { 159 162 if (0 == pointattributelist -> dimensions[1]) { 160 163 in.numberofpointattributes = 0; 161 in.pointattributelist = NULL;164 in.pointattributelist = (double *) NULL; 162 165 } else { 163 166 in.numberofpointattributes = pointattributelist -> dimensions[1]; … … 170 173 171 174 printf ("numberofpoints %i\n", in.numberofpoints); 175 printf ("numberofpointattributes %i\n", in.numberofpointattributes); 172 176 for(i = 0; i < in.numberofpoints; i++) { 173 177 printf("(%f,%f)\n",in.pointlist[i* 2+ 0],in.pointlist[i* 2+ 1]); 178 for(j = 0; j < in.numberofpointattributes; j++) { 179 printf("point att (%f)\n",in.pointattributelist[i* in.numberofpointattributes + j]); 180 } 181 174 182 } 175 183 176 184 printf ("numberofregions %i\n", in.numberofregions); 177 185 for(i = 0; i < in.numberofregions; i++) { 178 printf("(%f,%f)\n",in.regionlist[i* 2+ 0],in.regionlist[i* 2+ 1]); 186 printf("(%f,%f) ",in.regionlist[i* 4+ 0],in.regionlist[i* 4+ 1]); 187 printf("index %f Area %f\n",in.regionlist[i* 4+ 2],in.regionlist[i* 4+ 3]); 179 188 } 180 189 181 190 printf ("numberofsegments %i\n", in.numberofsegments); 182 191 for(i = 0; i < in.numberofsegments; i++) { 183 printf("(%i,%i)",in.segmentlist[i* 2+ 0],in.segmentlist[i* 2+ 1]); 192 printf("(%i,%i)\n",in.segmentlist[i* 2+ 0],in.segmentlist[i* 2+ 1]); 193 printf("Segment marker (%i)\n",in.segmentmarkerlist[i + 0]); 184 194 } 185 195 … … 194 204 printf("(%i,%i,%i)",in.trianglelist[i* 3+ 0],in.trianglelist[i* 3+ 1], in.trianglelist[i* 3+ 2]); 195 205 } 196 printf(" *** see ya world\n" ); */197 206 printf(" *** see ya world\n" ); 207 */ 198 208 /* set up the switch arguments to the triangulation routine */ 199 209 mod = PyString_AS_STRING(mode); … … 202 212 out.pointlist = (REAL *)NULL; 203 213 out.pointmarkerlist = (int *)NULL; 204 out.numberofpointattributes = in.numberofpointattributes;214 //out.numberofpointattributes = in.numberofpointattributes; 205 215 out.pointattributelist = (REAL *)NULL; 206 216 … … 220 230 221 231 222 /*printf("\n\nTriangulate input args: %s \n\n", mod); */223 232 triangulate(mod, &in, &out, (struct triangulateio *)NULL ); 224 233 225 234 226 227 /* printf(" *** back from triangulate\n" ); */ 235 228 236 /* 229 237 ------- Pass point numbers,coordinates and neighbors back to Python ------ … … 250 258 dimensions[0] = out.numberoftriangles; 251 259 dimensions[1] = 3; 252 gentrianglelist = (PyArrayObject *) PyArray_FromDims(2, 253 dimensions, 254 PyArray_INT); 255 gentrianglelist -> data = out.trianglelist; 256 257 /*gentrianglelist = PyArray_ContiguousFromObject(out.trianglelist, 258 PyArray_DOUBLE, 259 0, 260 */ 261 262 /*gentrianglelist = PyArray_FromDimsAndData(2, 260 gentrianglelist = (PyArrayObject *) PyArray_FromDimsAndData(2, 263 261 dimensions, 264 262 PyArray_INT, 265 ( int*) out.trianglelist);266 */263 (char*) out.trianglelist); 264 267 265 /* Add pointlist */ 268 266 dimensions[0] = out.numberofpoints; 269 267 dimensions[1] = 2; 270 271 /*genpointlist = (PyArrayObject *) PyArray_FromDims(2, 272 dimensions,273 PyArray_DOUBLE);274 */ 268 genpointlist = (PyArrayObject *) PyArray_FromDimsAndData(2, 269 dimensions, 270 PyArray_DOUBLE, 271 (char*) out.pointlist); 272 275 273 /* 276 274 (double*) genpointlist -> data = out.pointlist; 277 275 ((double*) genpointlist -> data) = out.pointlist; 278 276 ( genpointlist -> data) = (double*) out.pointlist; 277 genpointlist -> data = (double) out.pointlist; 279 278 280 279 */ 281 //genpointlist -> data = out.pointlist;282 283 284 genpointlist = PyArray_FromDimsAndData(2,285 dimensions,286 PyArray_DOUBLE,287 (char*) out.pointlist);288 289 290 280 291 281 /* Add point marker list */ 292 282 dimensions[0] = out.numberofpoints; 293 genpointmarkerlist = (PyArrayObject *) PyArray_FromDims (1,294 295 PyArray_INT);296 genpointmarkerlist -> data = out.pointmarkerlist;283 genpointmarkerlist = (PyArrayObject *) PyArray_FromDimsAndData(1, 284 dimensions, 285 PyArray_INT, 286 (char*) out.pointmarkerlist); 297 287 298 288 /* Add point attribute list */ 299 289 dimensions[0] = out.numberofpoints; 300 290 dimensions[1] = out.numberofpointattributes; 301 genpointattributelist = (PyArrayObject *) PyArray_FromDims (2,302 303 PyArray_DOUBLE);304 genpointattributelist -> data = out.pointattributelist; 291 genpointattributelist = (PyArrayObject *) PyArray_FromDimsAndData(2, 292 dimensions, 293 PyArray_DOUBLE, 294 (char*) out.pointattributelist); 305 295 306 296 … … 309 299 dimensions[0] = out.numberoftriangles; 310 300 dimensions[1] = out.numberoftriangleattributes; 311 gentriangleattributelist = (PyArrayObject *) PyArray_FromDims (2,312 313 PyArray_DOUBLE);314 gentriangleattributelist -> data = out.triangleattributelist;301 gentriangleattributelist = (PyArrayObject *) PyArray_FromDimsAndData(2, 302 dimensions, 303 PyArray_DOUBLE, 304 (char*)out.triangleattributelist); 315 305 316 306 /* Add segment list */ 317 307 dimensions[0] = out.numberofsegments; 318 308 dimensions[1] = 2; 319 gensegmentlist = (PyArrayObject *) PyArray_FromDims (2,309 gensegmentlist = (PyArrayObject *) PyArray_FromDimsAndData(2, 320 310 dimensions, 321 PyArray_INT );322 gensegmentlist -> data = out.segmentlist;311 PyArray_INT, 312 (char*)out.segmentlist); 323 313 324 314 325 315 /* Add segment marker list */ 326 316 dimensions[0] = out.numberofsegments; 327 gensegmentmarkerlist = (PyArrayObject *) PyArray_FromDims (1,328 329 PyArray_INT);330 gensegmentmarkerlist -> data = out.segmentmarkerlist;317 gensegmentmarkerlist = (PyArrayObject *) PyArray_FromDimsAndData(1, 318 dimensions, 319 PyArray_INT, 320 (char*)out.segmentmarkerlist); 331 321 332 322 /* Add triangle neighbor list */ 333 dimensions[0] = out.numberoftriangles; 334 dimensions[1] = 3; 335 genneighborlist = (PyArrayObject *) PyArray_FromDims(2, 336 dimensions, 337 PyArray_INT); 338 genneighborlist -> data = out.neighborlist; 339 323 if (out.neighborlist != NULL) { 324 dimensions[0] = out.numberoftriangles; 325 dimensions[1] = 3; 326 genneighborlist = (PyArrayObject *) PyArray_FromDimsAndData(2, 327 dimensions, 328 PyArray_INT, 329 (char*)out.neighborlist); 330 }else{ 331 dimensions[0] = 0; 332 dimensions[1] = 0; 333 genneighborlist = (PyArrayObject *) PyArray_FromDims(2, 334 dimensions, 335 PyArray_INT); 336 } 340 337 341 338 /* Add triangle neighbor list */ … … 356 353 */ 357 354 358 359 /* Free in/out structure memory */360 361 /* OUT */362 363 if(!out.pointlist){364 free(out.pointlist); out.pointlist=NULL;365 }366 if(!out.pointmarkerlist){367 free(out.pointmarkerlist); out.pointmarkerlist=NULL;368 }369 if(!out.pointattributelist){370 free(out.pointattributelist); out.pointattributelist=NULL;371 }372 if(!out.trianglelist){373 free(out.trianglelist); out.trianglelist=NULL;374 }375 if(!out.triangleattributelist){376 free(out.triangleattributelist); out.triangleattributelist=NULL;377 }378 if(!out.trianglearealist){379 free(out.trianglearealist); out.trianglearealist=NULL;380 }381 if(!out.neighborlist){382 free(out.neighborlist); out.neighborlist=NULL;383 }384 if(!out.segmentlist){385 free(out.segmentlist); out.segmentlist =NULL;386 }387 if(!out.segmentmarkerlist){388 free(out.segmentmarkerlist); out.segmentmarkerlist =NULL;389 }390 if(!out.edgelist){391 free(out.edgelist); out.edgelist=NULL;392 }393 if(!out.edgemarkerlist){394 free(out.edgemarkerlist); out.edgemarkerlist=NULL;395 }396 if(!out.holelist){397 free(out.holelist); out.holelist=NULL;398 }399 if(!out.regionlist){400 free(out.regionlist); out.regionlist=NULL;401 }402 355 403 356 /* R = Py_BuildValue((char *)"O", holder); */ … … 421 374 Py_DECREF(gensegmentmarkerlist); 422 375 Py_DECREF(genneighborlist); 376 377 378 /* Free in/out structure memory */ 379 /* OUT 380 381 if(!out.pointlist){ 382 free(out.pointlist); out.pointlist=NULL; 383 } 384 if(!out.pointmarkerlist){ 385 free(out.pointmarkerlist); out.pointmarkerlist=NULL; 386 } 387 if(!out.pointattributelist){ 388 free(out.pointattributelist); out.pointattributelist=NULL; 389 } 390 if(!in.pointattributelist){ 391 free(out.pointattributelist); out.pointattributelist=NULL; 392 } 393 if(!out.trianglelist){ 394 free(out.trianglelist); out.trianglelist=NULL; 395 } 396 if(!out.triangleattributelist){ 397 free(out.triangleattributelist); out.triangleattributelist=NULL; 398 } 399 if(!out.trianglearealist){ 400 free(out.trianglearealist); out.trianglearealist=NULL; 401 } 402 if(!out.neighborlist){ 403 free(out.neighborlist); out.neighborlist=NULL; 404 } 405 if(!out.segmentlist){ 406 free(out.segmentlist); out.segmentlist =NULL; 407 } 408 if(!out.segmentmarkerlist){ 409 free(out.segmentmarkerlist); out.segmentmarkerlist =NULL; 410 } 411 if(!out.edgelist){ 412 free(out.edgelist); out.edgelist=NULL; 413 } 414 if(!out.edgemarkerlist){ 415 free(out.edgemarkerlist); out.edgemarkerlist=NULL; 416 } 417 if(!out.holelist){ 418 free(out.holelist); out.holelist=NULL; 419 } 420 if(!out.regionlist){ 421 free(out.regionlist); out.regionlist=NULL; 422 } 423 */ 423 424 return R; 424 425 } -
anuga_core/source/anuga/mesh_engine/test_generate_mesh.py
r4899 r4916 355 355 356 356 def testrectangle_regionsII(self): 357 358 357 points = [] 359 358 seglist = [] … … 703 702 704 703 suite = unittest.makeSuite(triangTestCase,'test') 705 #suite = unittest.makeSuite(triangTestCase,'test_lone_verts4') 706 #suite = unittest.makeSuite(triangTestCase,'test_transition_to_arrays') 707 runner = unittest.TextTestRunner() #verbosity=2) 704 #suite = unittest.makeSuite(triangTestCase,'testrectangleIIb') 705 #suite = unittest.makeSuite(triangTestCase,'testsegmarker') 706 #suite = unittest.makeSuite(triangTestCase,'testrectangle_regionsII') 707 runner = unittest.TextTestRunner() #verbosity=2) 708 708 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.