Changeset 4899
- Timestamp:
- Dec 31, 2007, 7:53:02 AM (17 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/load_mesh/loadASCII.py
r4663 r4899 623 623 """ 624 624 625 # FIXME(Ole and John): We ran into a problem on Bogong (64 bit) where integers appeared as arrays. 626 # This may be similar to problem seen by Steve in changeset:2778 where he had to wrap them in int. 627 # Now we are trying with the native Integer format (Int == 'l' == Int64). However, that caused casting errors, when 64bit arrays 628 # are to be assigned to their NetCDF counterparts. It seems that the NetCDF arrays are 32bit even though they are created with 629 # the type Int64. Need to look at the NetCDF library in more detail. 625 # FIXME(Ole and John): We ran into a problem on Bogong (64 bit) 626 # where integers appeared as arrays. This may be similar to 627 # problem seen by Steve in changeset:2778 where he had to wrap 628 # them in int. Now we are trying with the native Integer format 629 # (Int == 'l' == Int64). However, that caused casting errors, when 630 # 64bit arrays are to be assigned to their NetCDF counterparts. It 631 # seems that the NetCDF arrays are 32bit even though they are 632 # created with the type Int64. Need to look at the NetCDF library 633 # in more detail. 630 634 631 635 IntType = Int32 … … 732 736 outfile.variables['triangles'][:] = mesh['triangles'] 733 737 outfile.variables['triangle_neighbors'][:] = mesh['triangle_neighbors'] 734 if (mesh['triangle_tags'].shape[1] > 0): 738 if mesh['triangle_tags'] is not None and \ 739 (mesh['triangle_tags'].shape[1] > 0): 735 740 outfile.createDimension('num_of_triangle_tag_chars', 736 741 mesh['triangle_tags'].shape[1]) -
anuga_core/source/anuga/load_mesh/test_loadASCII.py
r4165 r4899 275 275 export_mesh_file(fileName,dict) 276 276 loaded_dict = import_mesh_file(fileName) 277 dict = self.tri_dict 277 dict = self.tri_dict 278 278 self.check_mesh_dicts(loaded_dict,dict, 'test_read_write_msh_file6') 279 279 os.remove(fileName) … … 545 545 546 546 suite = unittest.makeSuite(loadASCIITestCase,'test') 547 #suite = unittest.makeSuite(loadASCIITestCase,'test_ writepts')548 runner = unittest.TextTestRunner() #verbosity= 0)547 #suite = unittest.makeSuite(loadASCIITestCase,'test_rs') 548 runner = unittest.TextTestRunner() #verbosity=2) 549 549 runner.run(suite) 550 550 -
anuga_core/source/anuga/mesh_engine/mesh_engine.py
r4898 r4899 5 5 from types import ListType, TupleType 6 6 7 import exceptions 8 9 class NoTrianglesError(exceptions.Exception): pass 7 10 import anuga.mesh_engine.mesh_engine_c_layer as triang 8 11 #import anuga.mesh_engine.list_dic as triang … … 130 133 pointatts,segatts, mode, segments.flat) 131 134 # the values as arrays 132 mesh_dict['trianglelist'] = trianglelist 133 mesh_dict['pointlist'] = pointlist 135 mesh_dict['generatedtrianglelist'] = trianglelist 136 mesh_dict['generatedpointlist'] = pointlist 137 #print "mesh engine mesh_dict['generatedpointlist']", mesh_dict['generatedpointlist'] 138 # WARNING - generatedpointmarkerlist IS UNTESTED 139 mesh_dict['generatedpointmarkerlist'] = pointmarkerlist 140 mesh_dict['generatedpointattributelist'] = pointattributelist 141 mesh_dict['generatedsegmentlist'] = segmentlist 142 mesh_dict['generatedsegmentmarkerlist'] = segmentmarkerlist 143 mesh_dict['generatedtriangleneighborlist'] = neighborlist 144 mesh_dict['qaz'] = 1 #debugging 134 145 135 # WARNING - pointmarkerlist IS UNTESTED 136 mesh_dict['pointmarkerlist'] = pointmarkerlist 137 mesh_dict['pointattributelist'] = pointattributelist 138 mesh_dict['triangleattributelist'] = triangleattributelist 139 mesh_dict['segmentlist'] = segmentlist 140 mesh_dict['segmentmarkerlist'] = segmentmarkerlist 141 mesh_dict['triangleneighborlist'] = neighborlist 142 mesh_dict['qaz'] = 1 #debugging 143 ##print "r_test", r_test 146 mesh_dict['triangleattributelist'] = triangleattributelist 147 #print "mesh eng generatedtrianglelist", trianglelist 148 #print "mesh eng mesh_dict['triangleattributelist'] ",mesh_dict['triangleattributelist'] 149 #print "mesh eng mesh_dict['generatedtriangleattributelist'] ", mesh_dict['generatedtriangleattributelist'] 150 151 if True: 152 mesh_dict['generatedtriangleattributelist'] = triangleattributelist 153 154 if mesh_dict['generatedtriangleattributelist'].shape[1] == 0: 155 mesh_dict['generatedtriangleattributelist'] = None 156 if trianglelist.shape[0] == 0: 157 # There are no triangles. 158 # this is used by urs_ungridded2sww 159 raise NoTrianglesError 160 #print "mesh eng mesh_dict['generatedtriangleattributelist'] ", mesh_dict['generatedtriangleattributelist'] 144 161 145 162 return mesh_dict -
anuga_core/source/anuga/mesh_engine/test_generate_mesh.py
r4898 r4899 527 527 528 528 529 def test_transition_to_arrays(self): 530 # segattlist = [] 531 points = [] 532 seglist = [] 533 holelist = [] 534 regionlist = [] 535 529 def dont_test_transition_to_arrays(self): 530 points = [] 531 seglist = [] 532 holelist = [] 533 regionlist = [] 536 534 points = [(0.0,0.0),(0.0,10.0),(3.0,0.0),(3.0,10.0)] 537 535 pointattlist = [] 538 536 # 5.0 is the region tag, 99.0 is the max area 539 # REgion tag isn't working though540 537 regionlist.append( [0.2,0.2,5.0,99.0] ) 541 538 seglist = [(0,1),(1,3),(3,2),(2,0)] … … 550 547 self.failUnless(data['generatedtrianglelist'] ==[(1, 0, 2), (2, 3, 1)], 551 548 'trianglelist is wrong!') 552 #print "data['generatedtrianglelist']",data['generatedtrianglelist']553 #print "data['trianglelist']", data['trianglelist']554 549 self.failUnless(data['generatedtrianglelist'] ==data['trianglelist'], 555 550 'trianglelist is wrong!') … … 585 580 data['triangleneighborlist'], 586 581 ' is wrong!') 587 582 583 def test_numeric_arrays(self): 584 points = [] 585 seglist = [] 586 holelist = [] 587 regionlist = [] 588 points = [(0.0,0.0),(0.0,10.0),(3.0,0.0),(3.0,10.0)] 589 pointattlist = [] 590 # 5.0 is the region tag, 99.0 is the max area 591 tri_tag = 123456.0 592 regionlist.append( [0.2,0.2, tri_tag,99.0] ) 593 seglist = [(0,1),(1,3),(3,2),(2,0)] 594 segattlist = [21,22,23,24] 595 #The 'A' has to be there to get the region marker stuff working 596 mode = "QzpnA" 597 #mode = "jQpznAa2000.1a" 598 data = generate_mesh(points,seglist,holelist,regionlist, 599 pointattlist,segattlist, mode, points) 600 #print "data", data 601 602 self.failUnless(data['generatedtrianglelist'] ==[(1, 0, 2), (2, 3, 1)], 603 'trianglelist is wrong!') 604 self.failUnless(data['generatedsegmentlist'] ==[(0, 1), (1, 3), 605 (3, 2), (2, 0)], 606 'segmentlist is wrong!') 607 self.failUnless(data['generatedpointlist'] ==[(0.0, 0.0), (0.0, 10.0), 608 (3.0, 0.0), (3.0, 10.0)], 609 ' is wrong!') 610 self.failUnless(data['generatedtriangleattributelist'] == [[tri_tag], 611 [tri_tag]], 612 ' is wrong!') 613 614 self.failUnless(data['generatedsegmentlist'] == seglist, 615 ' is wrong!') 616 self.failUnless(data['generatedsegmentmarkerlist'] == segattlist, 617 ' is wrong!') 618 # I copied these answers from the output, so bad test.. 619 self.failUnless(data['generatedtriangleneighborlist'] == \ 620 [(-1, 1, -1), (-1, 0, -1)], 621 ' is wrong!') 622 588 623 def test_pointattlist(self): 589 624 # segattlist = [] … … 604 639 [10],[10]], 605 640 ' is wrong!') 641 642 643 pointattlist = [[0.],[0.],[10.],[10.]] 644 mode = "Qzp" 645 data = generate_mesh(points,seglist,holelist,regionlist, 646 pointattlist,segattlist, mode, points) 647 self.failUnless(data['generatedpointattributelist'] == [[0.0],[0.0], 648 [10],[10]], 649 ' is wrong!') 650 pointattlist = [[0.,1],[0.,1],[10.,20],[10.,20]] 651 mode = "Qzp" 652 data = generate_mesh(points,seglist,holelist,regionlist, 653 pointattlist,segattlist, mode, points) 654 #print "data", data 655 self.failUnless(data['generatedpointattributelist'] == pointattlist, 656 ' is wrong!') 657 658 def dont_test_transition_pointattlist(self): 659 # segattlist = [] 660 points = [] 661 seglist = [] 662 holelist = [] 663 regionlist = [] 664 665 points = [(0.0,0.0),(0.0,4.0),(4.0,2.0),(2.0,0.0)] 666 pointattlist = [0.,0.,10.,10.] 667 regionlist.append( [0.2,0.2,2.1, 99.] ) 668 seglist = [(0,1),(1,2),(2,3),(3,0)] 669 segattlist = [11,12,13,14] 670 mode = "Qzp" 671 data = generate_mesh(points,seglist,holelist,regionlist, 672 pointattlist,segattlist, mode, points) 673 self.failUnless(data['generatedpointattributelist'] == [[0.0],[0.0], 674 [10],[10]], 675 ' is wrong!') 606 676 self.failUnless(data['generatedpointattributelist'] == \ 607 677 data['pointattributelist'], -
anuga_core/source/anuga/pmesh/mesh.py
r4898 r4899 25 25 26 26 27 class NoTrianglesError(exceptions.Exception): pass27 #class NoTrianglesError(exceptions.Exception): pass 28 28 29 29 #import load_mesh … … 1190 1190 #print "%%%%%%%%%%%%%%%%%%%%%%%%%%%generated",generatedMesh 1191 1191 generatedMesh['qaa'] = 1 1192 generatedMesh['generatedsegmentmarkerlist'] = \ 1193 segment_ints2strings(generatedMesh['generatedsegmentmarkerlist'], 1194 segconverter) 1192 if generatedMesh['generatedsegmentmarkerlist'] is not None: 1193 generatedMesh['generatedsegmentmarkerlist'] = \ 1194 segment_ints2strings(generatedMesh['generatedsegmentmarkerlist'], 1195 segconverter) 1195 1196 #print "processed gen",generatedMesh['generatedsegmentmarkerlist'] 1196 generatedMesh['generatedtriangleattributelist'] = \ 1197 region_ints2strings(generatedMesh['generatedtriangleattributelist'], 1197 #print "pmesh mesh generatedMesh['generatedtriangleattributelist']", generatedMesh['generatedtriangleattributelist'] 1198 if generatedMesh['generatedtriangleattributelist'] is not None: 1199 generatedMesh['generatedtriangleattributelist'] = \ 1200 region_ints2strings(generatedMesh['generatedtriangleattributelist'], 1198 1201 regionconverter) 1199 1202 1203 #print "pmesh mesh generatedMesh['generatedtriangleattributelist']", generatedMesh['generatedtriangleattributelist'] 1200 1204 #FIXME (DSG-DSG) move above section into generate_mesh.py 1201 1202 if len(generatedMesh['generatedpointattributelist'][0])==0:1205 1206 if generatedMesh['generatedpointattributelist'].shape[1] ==0: 1203 1207 self.attributeTitles = [] 1204 1208 generatedMesh['generatedpointattributetitlelist']= \ … … 1554 1558 self.meshTriangles.append(tObject) 1555 1559 1556 index = 0 1557 for att in genDict['generatedtriangleattributelist']: 1558 if att == []: 1559 self.meshTriangles[index].setAttribute("") 1560 else: 1561 self.meshTriangles[index].setAttribute(att[0]) 1562 index += 1 1560 if genDict['generatedtriangleattributelist'] is not None: 1561 index = 0 1562 for att in genDict['generatedtriangleattributelist']: 1563 if att == []: 1564 self.meshTriangles[index].setAttribute("") 1565 else: 1566 self.meshTriangles[index].setAttribute(att[0]) 1567 index += 1 1563 1568 1564 1569 index = 0 … … 3152 3157 """Reverses the transformation of region_strings2ints 3153 3158 """ 3154 if region_list == []: 3155 raise NoTrianglesError 3156 if region_list[0] != []: 3159 #print 'region_ints2strings region_list', region_list 3160 3161 returned_region_list = [] 3162 # may not need (not region_list[0] == []) 3163 # or region_list[0] == [0.0] 3164 if (not region_list[0] == []): # or region_list[0] == [0.0]: 3165 #print "in loop" 3157 3166 for i in xrange(len(region_list)): 3158 region_list[i] = [convertint2string[int(region_list[i][0])]] 3159 return region_list 3167 temp = region_list[i] 3168 returned_region_list.append([convertint2string[int(temp[0])]]) 3169 return returned_region_list 3160 3170 3161 3171 def segment_ints2strings(intlist, convertint2string): -
anuga_core/source/anuga/pmesh/test_mesh.py
r4888 r4899 418 418 m = Mesh(userVertices=[a,b,c,d,e,f,g], userSegments=[s1,s2,s3,s4,s5,s6,s7,s8,s9,s10], regions=[r1,r2,r3] ) 419 419 m.generateMesh("Q", maxArea = 2.1 ) 420 #print m420 421 421 Triangulation = m.getTriangulation() 422 422 #print Triangulation[0].attribute … … 1653 1653 self.failUnless( dict['triangle_neighbors'][0] == [-1,2,3], 1654 1654 'test_Mesh2IODict failed. test 6') 1655 #print "dict['triangle_tags'][0]", dict['triangle_tags'][0] 1655 1656 self.failUnless( dict['triangle_tags'][0] == "1.3", 1656 1657 'test_Mesh2IODict failed. test 7') … … 2356 2357 suite = unittest.makeSuite(meshTestCase,'test') 2357 2358 #suite = unittest.makeSuite(meshTestCase,'mode_string_float_problems') 2358 #suite = unittest.makeSuite(meshTestCase,'test_exportPointsFile') 2359 #suite = unittest.makeSuite(meshTestCase,'test_import_mesh') 2360 #suite = unittest.makeSuite(meshTestCase,'test_Mesh2IODict') 2359 2361 runner = unittest.TextTestRunner() # verbosity=2) 2360 2362 runner.run(suite) -
anuga_core/source/anuga/pmesh/test_mesh_interface.py
r3872 r4899 746 746 if __name__ == "__main__": 747 747 suite = unittest.makeSuite(TestCase,'test') 748 # suite = unittest.makeSuite(TestCase,'test_create_mesh_from_regions_interior_regions')748 #suite = unittest.makeSuite(TestCase,'test_create_mesh_from_regions4') 749 749 runner = unittest.TextTestRunner() #verbosity=2) 750 750 runner.run(suite) -
anuga_core/source/anuga/shallow_water/data_manager.py
r4868 r4899 4649 4649 +ve value in grid A and a -ve value in grid B. 4650 4650 """ 4651 from anuga.pmesh.mesh import Mesh, NoTrianglesError 4651 from anuga.mesh_engine.mesh_engine import NoTrianglesError 4652 from anuga.pmesh.mesh import Mesh 4652 4653 4653 4654 files_in = [basename_in + WAVEHEIGHT_MUX_LABEL, … … 4720 4721 4721 4722 points_utm=ensure_numeric(points_utm) 4722 #print "mesh_dic['generatedpointlist']", mesh_dic['generatedpointlist']4723 #print "points_utm", points_utm4724 4723 assert ensure_numeric(mesh_dic['generatedpointlist']) == \ 4725 4724 ensure_numeric(points_utm) -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r4868 r4899 7368 7368 suite = unittest.makeSuite(Test_Data_Manager,'test') 7369 7369 #suite = unittest.makeSuite(Test_Data_Manager,'test_urs_ungridded_holeII') 7370 #suite = unittest.makeSuite(Test_Data_Manager,'test_ sww_range')7370 #suite = unittest.makeSuite(Test_Data_Manager,'test_urs_ungridded_holeII') 7371 7371 7372 7372 … … 7379 7379 else: 7380 7380 pass 7381 runner = unittest.TextTestRunner() # verbosity=2)7381 runner = unittest.TextTestRunner() # verbosity=2) 7382 7382 runner.run(suite) 7383 7383
Note: See TracChangeset
for help on using the changeset viewer.