Changeset 7276 for anuga_core/source/anuga/mesh_engine
- Timestamp:
- Jun 30, 2009, 2:07:41 PM (16 years ago)
- Location:
- anuga_core/source/anuga/mesh_engine
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/mesh_engine/mesh_engine.py
r6155 r7276 11 11 #import anuga.mesh_engine.list_dic as triang 12 12 13 import Numericas num13 import numpy as num 14 14 15 15 from anuga.utilities.numerical_tools import ensure_numeric … … 46 46 47 47 try: 48 points = ensure_numeric(points, num. Float)48 points = ensure_numeric(points, num.float) 49 49 except ValueError: 50 50 msg = 'ERROR: Inconsistent points array.' … … 60 60 61 61 try: 62 # If Int is used, instead of Int32, it fails in Linux63 segments = ensure_numeric(segments, num. Int32)62 # If num.int is used, instead of num.int32, it fails in Linux 63 segments = ensure_numeric(segments, num.int32) 64 64 65 65 except ValueError: … … 72 72 73 73 try: 74 holes = ensure_numeric(holes, num. Float)74 holes = ensure_numeric(holes, num.float) 75 75 except ValueError: 76 76 msg = 'ERROR: Inconsistent holess array.' … … 80 80 regions = add_area_tag(regions) 81 81 try: 82 regions = ensure_numeric(regions, num. Float)82 regions = ensure_numeric(regions, num.float) 83 83 except (ValueError, TypeError): 84 84 msg = 'ERROR: Inconsistent regions array.' … … 90 90 91 91 try: 92 pointatts = ensure_numeric(pointatts, num. Float)92 pointatts = ensure_numeric(pointatts, num.float) 93 93 except (ValueError, TypeError): 94 94 msg = 'ERROR: Inconsistent point attributes array.' … … 103 103 104 104 try: 105 segatts = ensure_numeric(segatts, num. Int32)105 segatts = ensure_numeric(segatts, num.int32) 106 106 except ValueError: 107 107 msg = 'ERROR: Inconsistent point attributes array.' -
anuga_core/source/anuga/mesh_engine/mesh_engine_c_layer.c
r4917 r7276 8 8 9 9 This code interfaces pmesh directly with "triangle", a general 10 purpose triangulation code. In doing so, Python Numeric data structures10 purpose triangulation code. In doing so, Python numeric data structures 11 11 are passed to C for use by "triangle" and the results are then 12 12 converted back. This was accomplished using the Python/C API. … … 60 60 #include "Python.h" 61 61 62 #include "util_ext.h" 63 #include "numpy_shim.h" 64 65 62 66 //#define PY_ARRAY_UNIQUE_SYMBOL API_YEAH 63 67 64 68 #define PY_ARRAY_UNIQUE_SYMBOL API_YEAH 65 69 //#define NO_IMPORT_ARRAY 66 #include " Numeric/arrayobject.h"70 #include "numpy/arrayobject.h" 67 71 #include <sys/types.h> 68 72 … … 119 123 return NULL; 120 124 } 125 126 // check that numpy array objects arrays are C contiguous memory 127 CHECK_C_CONTIG(pointlist); 128 CHECK_C_CONTIG(seglist); 129 CHECK_C_CONTIG(holelist); 130 CHECK_C_CONTIG(regionlist); 131 CHECK_C_CONTIG(pointattributelist); 132 CHECK_C_CONTIG(segmarkerlist); 121 133 122 134 /* Initialize points */ … … 245 257 abs quantity_ext.c compute_gradients 246 258 247 PyArray_FromDims allolws you to create a Numeric array with unitialized data.259 PyArray_FromDims allolws you to create a numeric array with unitialized data. 248 260 The first argument is the size of the second argument ( 249 261 the dimensions array). … … 258 270 dimensions[0] = out.numberoftriangles; 259 271 dimensions[1] = 3; 260 gentrianglelist = (PyArrayObject *) PyArray_FromDimsAndData(2,272 gentrianglelist = (PyArrayObject *) anuga_FromDimsAndData(2, 261 273 dimensions, 262 274 PyArray_INT, … … 266 278 dimensions[0] = out.numberofpoints; 267 279 dimensions[1] = 2; 268 genpointlist = (PyArrayObject *) PyArray_FromDimsAndData(2,280 genpointlist = (PyArrayObject *) anuga_FromDimsAndData(2, 269 281 dimensions, 270 282 PyArray_DOUBLE, … … 274 286 /* Add point marker list */ 275 287 dimensions[0] = out.numberofpoints; 276 genpointmarkerlist = (PyArrayObject *) PyArray_FromDimsAndData(1,288 genpointmarkerlist = (PyArrayObject *) anuga_FromDimsAndData(1, 277 289 dimensions, 278 290 PyArray_INT, … … 282 294 dimensions[0] = out.numberofpoints; 283 295 dimensions[1] = out.numberofpointattributes; 284 genpointattributelist = (PyArrayObject *) PyArray_FromDimsAndData(2,296 genpointattributelist = (PyArrayObject *) anuga_FromDimsAndData(2, 285 297 dimensions, 286 298 PyArray_DOUBLE, … … 292 304 dimensions[0] = out.numberoftriangles; 293 305 dimensions[1] = out.numberoftriangleattributes; 294 gentriangleattributelist = (PyArrayObject *) PyArray_FromDimsAndData(2,306 gentriangleattributelist = (PyArrayObject *) anuga_FromDimsAndData(2, 295 307 dimensions, 296 308 PyArray_DOUBLE, … … 300 312 dimensions[0] = out.numberofsegments; 301 313 dimensions[1] = 2; 302 gensegmentlist = (PyArrayObject *) PyArray_FromDimsAndData(2,314 gensegmentlist = (PyArrayObject *) anuga_FromDimsAndData(2, 303 315 dimensions, 304 316 PyArray_INT, … … 308 320 /* Add segment marker list */ 309 321 dimensions[0] = out.numberofsegments; 310 gensegmentmarkerlist = (PyArrayObject *) PyArray_FromDimsAndData(1,322 gensegmentmarkerlist = (PyArrayObject *) anuga_FromDimsAndData(1, 311 323 dimensions, 312 324 PyArray_INT, … … 317 329 dimensions[0] = out.numberoftriangles; 318 330 dimensions[1] = 3; 319 genneighborlist = (PyArrayObject *) PyArray_FromDimsAndData(2,331 genneighborlist = (PyArrayObject *) anuga_FromDimsAndData(2, 320 332 dimensions, 321 333 PyArray_INT, … … 324 336 dimensions[0] = 0; 325 337 dimensions[1] = 0; 326 genneighborlist = (PyArrayObject *) PyArray_FromDims(2,327 328 338 genneighborlist = (PyArrayObject *) anuga_FromDims(2, 339 dimensions, 340 PyArray_INT); 329 341 } 330 342 … … 351 363 352 364 353 /* These memory blocks are passed into Numeric arrays365 /* These memory blocks are passed into numeric arrays 354 366 so don't free them */ 355 367 /* -
anuga_core/source/anuga/mesh_engine/test_all.py
r4898 r7276 76 76 return unittest.TestSuite(map(load, modules)) 77 77 78 78 79 if __name__ == '__main__': 79 80 suite = regressionTest() -
anuga_core/source/anuga/mesh_engine/test_generate_mesh.py
r6174 r7276 12 12 from anuga.mesh_engine.mesh_engine import generate_mesh 13 13 14 import Numericas num14 import numpy as num 15 15 16 16 from anuga.utilities.numerical_tools import ensure_numeric … … 43 43 pointattlist,segattlist, mode, points) 44 44 45 correct = num.array([(1, 0, 2), (2, 3, 1)] , num.Int) #array default#45 correct = num.array([(1, 0, 2), (2, 3, 1)]) 46 46 self.failUnless(num.alltrue(data['generatedtrianglelist'].flat == \ 47 47 correct.flat), 48 48 'trianglelist is wrong!') 49 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)] , num.Int) #array default#49 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)]) 50 50 self.failUnless(num.alltrue(data['generatedsegmentlist'].flat == \ 51 51 correct.flat), … … 74 74 data = generate_mesh(points,seglist,holelist,regionlist, 75 75 pointattlist,segattlist, mode, points) 76 correct = num.array([(1, 0, 2), (2, 3, 1)] , num.Int) #array default#76 correct = num.array([(1, 0, 2), (2, 3, 1)]) 77 77 self.failUnless(num.alltrue(data['generatedtrianglelist'].flat == \ 78 78 correct.flat), 79 79 'trianglelist is wrong!') 80 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)] , num.Int) #array default#80 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)]) 81 81 self.failUnless(num.alltrue(data['generatedsegmentlist'].flat == \ 82 82 correct.flat), … … 154 154 pointattlist,segattlist, mode, points) 155 155 156 correct = num.array([(1, 0, 2), (2, 3, 1)] , num.Int) #array default#156 correct = num.array([(1, 0, 2), (2, 3, 1)]) 157 157 self.failUnless(num.alltrue(data['generatedtrianglelist'].flat == \ 158 158 correct.flat), 159 159 'trianglelist is wrong!') 160 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)] , num.Int) #array default#160 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)]) 161 161 self.failUnless(num.alltrue(data['generatedsegmentlist'].flat == \ 162 162 correct.flat), … … 170 170 171 171 self.failUnless(num.alltrue(data['generatedsegmentmarkerlist'] == \ 172 num.array([1,2,3,4] , num.Int)), #array default#172 num.array([1,2,3,4])), 173 173 'Failed!') 174 174 … … 388 388 389 389 390 correct = num.array([(1, 0, 2), (2, 3, 1)] , num.Int) #array default#390 correct = num.array([(1, 0, 2), (2, 3, 1)]) 391 391 self.failUnless(num.alltrue(data['generatedtrianglelist'].flat == \ 392 392 correct.flat), 393 393 'trianglelist is wrong!') 394 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)] , num.Int) #array default#394 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)]) 395 395 self.failUnless(num.alltrue(data['generatedsegmentlist'].flat == \ 396 396 correct.flat), … … 407 407 correct.flat), 408 408 'Failed') 409 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)] , num.Int) #array default#409 correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)]) 410 410 self.failUnless(num.alltrue(data['generatedsegmentlist'].flat == \ 411 411 correct.flat), 412 412 'Failed!') 413 413 414 correct = num.array(segattlist, num. Int) #array default#414 correct = num.array(segattlist, num.int) 415 415 self.failUnless(num.allclose(data['generatedsegmentmarkerlist'].flat, 416 416 correct.flat), … … 418 418 419 419 # I copied these answers from the output, so bad test.. 420 correct = num.array([(-1, 1, -1), (-1, 0, -1)] , num.Int) #array default#420 correct = num.array([(-1, 1, -1), (-1, 0, -1)]) 421 421 self.failUnless(num.alltrue(data['generatedtriangleneighborlist'].flat == \ 422 422 correct.flat), … … 463 463 correct.flat), 464 464 'Failed') 465 465 466 466 467 if __name__ == "__main__": 467 468 468 suite = unittest.makeSuite(triangTestCase,'test') 469 #suite = unittest.makeSuite(triangTestCase,'testrectangleIIb')470 #suite = unittest.makeSuite(triangTestCase,'testsegmarker')471 #suite = unittest.makeSuite(triangTestCase,'testrectangle_regionsII')472 469 runner = unittest.TextTestRunner() #verbosity=2) 473 470 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.