Changeset 969
- Timestamp:
- Feb 28, 2005, 4:30:52 PM (20 years ago)
- Location:
- inundation/ga/storm_surge
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pmesh/load_mesh/loadASCII.py
r968 r969 21 21 dic['pointlist'] = [[1.0,2.0],[3.0,5.0]] 22 22 dic['attributelist']['elevation'] = [[7.0,5.0] 23 24 25 26 The dict format for IO with mesh files is; 27 (the triangulation) 28 vertices: [[x1,y1],[x2,y2],...] (lists of doubles) 29 vertex_attributes: [[a11,a12,...],[a21,a22],...] (lists of doubles) 30 vertex_attribute_titles:[A1Title, A2Title ...] (A list of strings) 31 segments: [[v1,v2],[v3,v4],...] (lists of integers) 32 segment_tags : [tag,tag,...] list of strings 33 triangles : [(v1,v2,v3), (v4,v5,v6),....] lists of points 34 triangle tags: [s1,s2,...] A list of strings 35 triangle neighbors: [[t1,t2,t3], [t4,t5,t6],..] lists of triangles 36 37 (the outline) 38 points: [[x1,y1],[x2,y2],...] (lists of doubles) 39 point_attributes: [[a11,a12,...],[a21,a22],...] (lists of doubles) 40 outline_segments: [[point1,point2],[p3,p4],...] (lists of integers) 41 outline_segment_tags : [tag1,tag2,...] list of strings 42 holes : [[x1,y1],...](List of doubles, one inside each hole region) 43 regions : [ [x1,y1],...] (List of 4 doubles) 44 region_tags : [tag1,tag2,...] (list of strings) 45 region_max_areas: [ma1,ma2,...] (A list of doubles) 46 {Convension: A -ve max area means no max area} 47 48 Points files are .xya for ascii and .pts for NetCDF 49 Mesh files are .tsh for ascii and .msh for NetCDF 50 23 51 """ 24 52 … … 28 56 29 57 from os.path import splitext 58 59 from Scientific.IO.NetCDF import NetCDFFile 30 60 31 61 import exceptions … … 52 82 Following lines: <triangle #> <vertex #> <vertex #> <vertex #> <neigbouring triangle #> <neigbouring triangle #> <neigbouring triangle #> [attribute of region] 53 83 One line: <# of segments> 54 Following lines: <segment #> <vertex #> <vertex #> [boundary marker]84 Following lines: <segment #> <vertex #> <vertex #> [boundary tag] 55 85 Note: This might throw a can't load file error 56 86 """ … … 134 164 line = line[find(line,delimiter):] # remove index 135 165 line = line.lstrip() 136 string marker= line.strip()137 triangleattributes.append([string marker])166 stringtag = line.strip() 167 triangleattributes.append([stringtag]) 138 168 139 169 ######### loading the segment info … … 145 175 NumOfSegments = fragments[0] 146 176 segments = [] 147 segment markers = []177 segmenttags = [] 148 178 for index in range(int(NumOfSegments)): 149 179 #print index … … 160 190 line = line.lstrip() 161 191 line = line[find(line,delimiter):] # remove y 162 string marker= line.strip()163 segment markers.append(stringmarker)192 stringtag = line.strip() 193 segmenttags.append(stringtag) 164 194 meshDict = {} 165 195 meshDict['vertices'] = points 166 196 meshDict['vertex_attributes'] = pointattributes 167 197 meshDict['triangles'] = triangles 168 meshDict['triangle_ markers'] = triangleattributes198 meshDict['triangle_tags'] = triangleattributes 169 199 meshDict['triangle_neighbors'] = triangleneighbors 170 200 meshDict['segments'] = segments 171 meshDict['segment_ markers'] = segmentmarkers201 meshDict['segment_tags'] = segmenttags 172 202 meshDict['vertex_attribute_titles'] = vertTitle 173 203 return meshDict … … 180 210 Following lines: <x> <y> [attributes] 181 211 One line: <# of segments> 182 Following lines: <vertex #> <vertex #> [boundary marker]212 Following lines: <vertex #> <vertex #> [boundary tag] 183 213 Note: This might throw a can't load file error 184 214 """ … … 234 264 NumOfSegments = fragments[0] 235 265 segments = [] 236 segment markers = []266 segmenttags = [] 237 267 for index in range(int(NumOfSegments)): 238 268 #print index … … 249 279 line = line.lstrip() 250 280 line = line[find(line,delimiter):] # remove y 251 string marker= line.strip()252 segment markers.append(stringmarker)281 stringtag = line.strip() 282 segmenttags.append(stringtag) 253 283 254 284 ######### loading the hole info … … 297 327 line = line.lstrip() 298 328 line = line[find(line,delimiter):] # remove y 299 string marker= line.strip()300 regionattributes.append(string marker)329 stringtag = line.strip() 330 regionattributes.append(stringtag) 301 331 regionmaxareas = [] 302 332 line = fd.readline() … … 319 349 meshDict['point_attributes'] = pointattributes 320 350 meshDict['outline_segments'] = segments 321 meshDict['outline_segment_ markers'] = segmentmarkers351 meshDict['outline_segment_tags'] = segmenttags 322 352 meshDict['holes'] = holes 323 353 meshDict['regions'] = regions 324 meshDict['region_ markers'] = regionattributes354 meshDict['region_tags'] = regionattributes 325 355 meshDict['region_max_areas'] = regionmaxareas 326 356 #print "meshDict",meshDict … … 365 395 366 396 triangles = gen_dict['triangles'] 367 triangles_attributes = gen_dict['triangle_ markers']397 triangles_attributes = gen_dict['triangle_tags'] 368 398 triangle_neighbors = gen_dict['triangle_neighbors'] 369 399 370 400 segments = gen_dict['segments'] 371 segment_ markers = gen_dict['segment_markers']401 segment_tags = gen_dict['segment_tags'] 372 402 373 403 numVert = str(len(vertices)) … … 431 461 #One line: <# of segments> 432 462 fd.write(str(len(segments)) + 433 " # <# of segments>, next lines <segment #> <vertex #> <vertex #> [boundary marker] ...Triangulation Segments..." + "\n")434 435 #Following lines: <segment #> <vertex #> <vertex #> [boundary marker]463 " # <# of segments>, next lines <segment #> <vertex #> <vertex #> [boundary tag] ...Triangulation Segments..." + "\n") 464 465 #Following lines: <segment #> <vertex #> <vertex #> [boundary tag] 436 466 for i in range(len(segments)): 437 467 seg = segments[i] … … 439 469 + str(seg[0]) + " " 440 470 + str(seg[1]) + " " 441 + str(segment_ markers[i]) + "\n")471 + str(segment_tags[i]) + "\n") 442 472 443 473 … … 451 481 Following lines: <triangle #> <vertex #> <vertex #> <vertex #> <neigbouring triangle #> <neigbouring triangle #> <neigbouring triangle #> [attribute of region] 452 482 One line: <# of segments> 453 Following lines: <segment #> <vertex #> <vertex #> [boundary marker]483 Following lines: <segment #> <vertex #> <vertex #> [boundary tag] 454 484 """ 455 485 #print "DSG************" … … 470 500 point_attributes = dict['point_attributes'] 471 501 segments = dict['outline_segments'] 472 segment_ markers = dict['outline_segment_markers']502 segment_tags = dict['outline_segment_tags'] 473 503 holes = dict['holes'] 474 504 regions = dict['regions'] 475 region_ markers = dict['region_markers']505 region_tags = dict['region_tags'] 476 506 region_max_areas = dict['region_max_areas'] 477 507 … … 496 526 #One line: <# of segments> 497 527 fd.write(str(len(segments)) + 498 " # <# of segments>, next lines <segment #> <vertex #> <vertex #> [boundary marker] ...Mesh Segments..." + "\n")499 500 #Following lines: <vertex #> <vertex #> [boundary marker]528 " # <# of segments>, next lines <segment #> <vertex #> <vertex #> [boundary tag] ...Mesh Segments..." + "\n") 529 530 #Following lines: <vertex #> <vertex #> [boundary tag] 501 531 for i,seg in enumerate(segments): 502 532 fd.write(str(i) + " " 503 533 + str(seg[0]) + " " 504 534 + str(seg[1]) + " " 505 + str(segment_ markers[i]) + "\n")535 + str(segment_tags[i]) + "\n") 506 536 507 537 #One line: <# of holes> … … 524 554 + str(r[0]) + " " 525 555 + str(r[1])+ " " 526 + str(region_ markers[i]) + "\n")556 + str(region_tags[i]) + "\n") 527 557 528 558 # <index> [<MaxArea>|""] … … 539 569 fd.write(str(i) + " " + area + "\n") 540 570 541 #FIXME -old, remove 542 def write_ASCII_mesh_old(fd, 543 dict): 544 """ 545 use write_ASCII_outline 546 """ 547 pass 571 572 def write_msh_file(filename, mesh_dict): 573 """Write .pts NetCDF file 574 Return a Points dictionary. see header for definition. 575 576 WARNING: This function mangles the mesh_dict data structure 577 """ 578 579 580 point_atts2array(point_atts) 581 # NetCDF file definition 582 outfile = NetCDFFile(filename, 'w') 583 584 #Create new file 585 outfile.institution = 'Geoscience Australia' 586 outfile.description = 'NetCDF format for compact and portable storage ' +\ 587 'of spatial point data' 588 589 # dimension definitions 590 shape = point_atts['pointlist'].shape[0] 591 outfile.createDimension('number_of_points', shape) 592 outfile.createDimension('number_of_dimensions', 2) #This is 2d data 593 594 # variable definition 595 outfile.createVariable('points', Float, ('number_of_points', 596 'number_of_dimensions')) 597 598 #create variables 599 outfile.variables['points'][:] = point_atts['pointlist'] #.astype(Float32) 600 for key in point_atts['attributelist'].keys(): 601 outfile.createVariable(key, Float, ('number_of_points',)) 602 outfile.variables[key][:] = point_atts['attributelist'][key] #.astype(Float32) 603 outfile.close() 548 604 549 605 … … 660 716 dic['attributelist']['elevation'] = [[7.0,5.0] 661 717 """ 662 663 from Scientific.IO.NetCDF import NetCDFFile664 718 665 719 fid = NetCDFFile(filename, 'r') … … 687 741 def write_pts(filename, point_atts): 688 742 """Write .pts NetCDF file 689 Return a Points dictionary. see header for definition.690 743 691 744 WARNING: This function mangles the point_atts data structure 692 745 """ 693 694 from Scientific.IO.NetCDF import NetCDFFile695 746 696 747 point_atts2array(point_atts) … … 799 850 return xya_dict 800 851 801 # obsolete802 def read_xya_old(filename):803 """Read simple xya file, possibly with a header in the first line, just804 x y [attributes]805 separated by whitespace806 807 If the first line is all numbers, it's assumed to be data,808 Otherwise it is the header line.809 Return list of points, list of attributes and810 attribute names if present otherwise None811 """812 813 from Scientific.IO.NetCDF import NetCDFFile814 815 #Read as ASCII file assuming that it is separated by whitespace816 fid = open(filename)817 lines = fid.readlines()818 fid.close()819 820 #Check if there is a header line821 fields = lines[0].strip().split()822 try:823 float(fields[0])824 except:825 #This must be a header line826 attribute_names = fields827 lines = lines[1:]828 else:829 attribute_names = None830 831 points = []832 attributes = []833 for line in lines:834 fields = line.strip().split()835 points.append( (float(fields[0]), float(fields[1])) )836 attributes.append( [float(z) for z in fields[2:] ] )837 838 return points, attributes, attribute_names839 840 852 841 853 def export_xya_file( file_name, xya_dict, title, delimiter = ','): -
inundation/ga/storm_surge/pmesh/load_mesh/test_loadASCII.py
r968 r969 36 36 dict ={} 37 37 dict['outline_segments'] = [(0, 1), (1, 2), (0, 2), (0, 3)] 38 dict['outline_segment_ markers'] = ['50', '40', '30', '20']38 dict['outline_segment_tags'] = ['50', '40', '30', '20'] 39 39 dict['holes'] = [(0.2, 0.6)] 40 40 dict['point_attributes'] = [[5, 2], [4, 2], [3, 2], [2,2]] 41 41 dict['regions'] = [(0.3, 0.3)] 42 dict['region_ markers'] = ['1.3']42 dict['region_tags'] = ['1.3'] 43 43 dict['region_max_areas'] = [36.0] 44 44 dict['points'] = [(0.0, 0.0), (0.0, 4.0), (4.0, 0.0), (1.0, 1.0)] … … 68 68 array(dict['outline_segments']), 69 69 'test_import_mesh failed. Test 3') 70 self.failUnless(array(loaded_dict['outline_segment_ markers']) ==71 array(dict['outline_segment_ markers']),70 self.failUnless(array(loaded_dict['outline_segment_tags']) == 71 array(dict['outline_segment_tags']), 72 72 'test_import_mesh failed. Test 4') 73 73 #print "loaded_dict['regions']",loaded_dict['regions'] … … 76 76 array(dict['regions']), 77 77 'test_import_mesh failed. Test 5') 78 self.failUnless(array(loaded_dict['region_ markers']) ==79 array(dict['region_ markers']),78 self.failUnless(array(loaded_dict['region_tags']) == 79 array(dict['region_tags']), 80 80 'test_import_mesh failed. Test 5') 81 81 self.failUnless(array(loaded_dict['region_max_areas']) == … … 98 98 meshDict['segments'] = [(0, 1), (1, 4), (2, 0), 99 99 (0, 3), (4, 2)] 100 meshDict['triangle_ markers'] = [['1.3'], ['1.3'],100 meshDict['triangle_tags'] = [['1.3'], ['1.3'], 101 101 ['1.3'], ['1.3']] 102 102 meshDict['vertex_attributes'] = [[1.2,2.], [1.2,2.], [1.2,2.], [1.2,2.], [1.2,3.]] 103 103 meshDict['triangle_neighbors'] = [[-1, 2, 3], [3, 2, -1], 104 104 [-1, 1, 0], [1, -1, 0]] 105 meshDict['segment_ markers'] = ['50', '40', '30', '20', '40']105 meshDict['segment_tags'] = ['50', '40', '30', '20', '40'] 106 106 meshDict['vertex_attribute_titles'] = ['bed elevation', 'height'] 107 107 … … 125 125 array(loadedDict['segments']), 126 126 'test_export_triangulation_file failed. Test 3') 127 self.failUnless(array(meshDict['triangle_ markers']) ==128 array(loadedDict['triangle_ markers']),127 self.failUnless(array(meshDict['triangle_tags']) == 128 array(loadedDict['triangle_tags']), 129 129 'test_export_triangulation_file failed. Test 4') 130 130 … … 135 135 array(loadedDict['triangle_neighbors']), 136 136 'test_export_triangulation_file failed. Test 6') 137 self.failUnless(array(meshDict['segment_ markers']) ==138 array(loadedDict['segment_ markers']),137 self.failUnless(array(meshDict['segment_tags']) == 138 array(loadedDict['segment_tags']), 139 139 'test_export_triangulation_file failed. Test 7') 140 140 self.failUnless(array(meshDict['vertex_attribute_titles']) == -
inundation/ga/storm_surge/pmesh/mesh.py
r968 r969 400 400 401 401 """ 402 def __init__(self, vertex1, vertex2, marker= None ):402 def __init__(self, vertex1, vertex2, tag = None ): 403 403 """ 404 404 Each segment is specified by listing the vertices of its endpoints … … 408 408 self.vertices = [vertex1,vertex2 ] 409 409 410 if markeris None:411 self. marker= self.__class__.default410 if tag is None: 411 self.tag = self.__class__.default 412 412 else: 413 self. marker = marker#this is a string413 self.tag = tag #this is a string 414 414 415 415 def __repr__(self): 416 return "[%s,%s]" % (self.vertices,self. marker)416 return "[%s,%s]" % (self.vertices,self.tag) 417 417 418 418 … … 425 425 y.append(-1*scale*(end.y + yoffset)) # - since for a canvas - is up 426 426 return canvas.create_line(x[0], y[0], x[1], y[1], tags = tags,fill=colour) 427 def set_tag(self, marker):428 self. marker = marker427 def set_tag(self,tag): 428 self.tag = tag 429 429 430 430 # Class methods … … 558 558 #print "!@!@ This is going to triangle !@!@" 559 559 560 #print "meshDict['segment markerlist']", meshDict['segmentmarkerlist']561 [meshDict['segment markerlist'],562 segconverter] = segment_strings2ints(meshDict['segment markerlist'],560 #print "meshDict['segmenttaglist']", meshDict['segmenttaglist'] 561 [meshDict['segmenttaglist'], 562 segconverter] = segment_strings2ints(meshDict['segmenttaglist'], 563 563 initialconversions) 564 564 #print "regionlist",meshDict['regionlist'] … … 566 566 regionconverter] = region_strings2ints(meshDict['regionlist']) 567 567 #print "regionlist",meshDict['regionlist'] 568 #print "meshDict['segment markerlist']", meshDict['segmentmarkerlist'568 #print "meshDict['segmenttaglist']", meshDict['segmenttaglist' 569 569 generatedMesh = triang.genMesh( 570 570 meshDict['pointlist'], … … 573 573 meshDict['regionlist'], 574 574 meshDict['pointattributelist'], 575 meshDict['segment markerlist'],575 meshDict['segmenttaglist'], 576 576 [], # since the trianglelist isn't used 577 577 self.mode) 578 #print "generated",generatedMesh['generatedsegment markerlist']578 #print "generated",generatedMesh['generatedsegmenttaglist'] 579 579 generatedMesh['generatedsegmentmarkerlist'] = \ 580 580 segment_ints2strings(generatedMesh['generatedsegmentmarkerlist'], … … 733 733 734 734 for v in self.userVertices : 735 # markeris the center of the boxes736 marker= (round(v.x/delta,0)*delta,round(v.y/delta,0)*delta)737 #this creates a dict of lists of faces, indexed by marker738 boxedVertices.setdefault( marker,[]).append(v)739 740 for [ marker,verts] in boxedVertices.items():735 # tag is the center of the boxes 736 tag = (round(v.x/delta,0)*delta,round(v.y/delta,0)*delta) 737 #this creates a dict of lists of faces, indexed by tag 738 boxedVertices.setdefault(tag,[]).append(v) 739 740 for [tag,verts] in boxedVertices.items(): 741 741 min = delta 742 742 bestVert = None 743 markerVert = Vertex(marker[0],marker[1])743 tagVert = Vertex(tag[0],tag[1]) 744 744 for v in verts: 745 dist = v.DistanceToPoint( markerVert)745 dist = v.DistanceToPoint(tagVert) 746 746 if (dist<min): 747 747 min = dist … … 819 819 segment list: [(point1,point2),(p3,p4),...] (Tuples of integers) 820 820 hole list: [(x1,y1),...](Tuples of doubles, one inside each hole region) 821 regionlist: [ (x1,y1, marker, max area),...] (Tuple of 3-4 doubles)821 regionlist: [ (x1,y1,tag, max area),...] (Tuple of 3-4 doubles) 822 822 823 823 Note, this adds an index attribute to the user Vertex objects. 824 824 825 Used to produce .tsh file andoutput to triangle825 Used to produce output to triangle 826 826 """ 827 827 if userVertices is None: … … 849 849 850 850 segmentlist=[] 851 segment markerlist=[]851 segmenttaglist=[] 852 852 for seg in userSegments: 853 853 segmentlist.append((seg.vertices[0].index,seg.vertices[1].index)) 854 segment markerlist.append(seg.marker)854 segmenttaglist.append(seg.tag) 855 855 meshDict['segmentlist'] =segmentlist 856 meshDict['segment markerlist'] =segmentmarkerlist856 meshDict['segmenttaglist'] =segmenttaglist 857 857 858 858 holelist=[] … … 882 882 generated point attribute title list:[A1Title, A2Title ...] (list of strings) 883 883 generated segment list: [(point1,point2),(p3,p4),...] (Tuples of integers) 884 generated segment marker list: [marker,marker,...] list of strings884 generated segment tag list: [tag,tag,...] list of strings 885 885 886 886 generated triangle list: [(p1,p2,p3), (p4,p5,p6),....] tuple of points … … 910 910 #segments 911 911 segmentlist=[] 912 segment markerlist=[]912 segmenttaglist=[] 913 913 for seg in self.meshSegments: 914 914 segmentlist.append((seg.vertices[0].index,seg.vertices[1].index)) 915 segment markerlist.append(seg.marker)915 segmenttaglist.append(seg.tag) 916 916 meshDict['generatedsegmentlist'] =segmentlist 917 meshDict['generatedsegment markerlist'] =segmentmarkerlist917 meshDict['generatedsegmenttaglist'] =segmenttaglist 918 918 919 919 # Make sure that the indexation is correct … … 966 966 generated point attribute title list:[A1Title, A2Title ...] (list of strings) 967 967 generated segment list: [(point1,point2),(p3,p4),...] (Tuples of integers) 968 generated segment marker list: [S1 Marker, S2Marker, ...] (list of ints)968 generated segment marker list: [S1Tag, S2Tag, ...] (list of ints) 969 969 triangle list: [(point1,point2, point3),(p5,p4, p1),...] (Tuples of integers) 970 970 triangle neighbor list: [(triangle1,triangle2, triangle3),(t5,t4, t1),...] (Tuples of integers) -1 means there's no triangle neighbor … … 993 993 for seg,marker in map(None,genDict['generatedsegmentlist'],genDict['generatedsegmentmarkerlist']): 994 994 segObject = Segment( self.meshVertices[seg[0]], 995 self.meshVertices[seg[1]], marker= marker )995 self.meshVertices[seg[1]], tag = marker ) 996 996 segObject.index = index 997 997 index +=1 … … 1046 1046 point attribute list:[(P1att1,P1attt2, ...),(P2att1,P2attt2,...),...] 1047 1047 segment list: [(point1,point2),(p3,p4),...] (Tuples of integers) 1048 segment marker list: [S1Marker, S2Marker, ...] (list of ints)1048 segment tag list: [S1Tag, S2Tag, ...] (list of ints) 1049 1049 region list: [(x1,y1),(x2,y2),...] (Tuples of doubles) 1050 1050 region attribute list: ["","reservoir",""] list of strings … … 1071 1071 1072 1072 #index = 0 1073 for seg, marker in map(None,genDict['segmentlist'],genDict['segmentmarkerlist']):1073 for seg,tag in map(None,genDict['segmentlist'],genDict['segmenttaglist']): 1074 1074 segObject = Segment( self.userVertices[seg[0]], 1075 self.userVertices[seg[1]], marker = marker)1075 self.userVertices[seg[1]], tag = tag ) 1076 1076 #segObject.index = index 1077 1077 #index +=1 … … 1113 1113 point list: [(x1,y1),(x2,y2),...] (Tuples of doubles) 1114 1114 segment list: [(point1,point2),(p3,p4),...] (Tuples of integers) 1115 #segment marker list: [S1Marker, S2Marker, ...] (list of ints)1115 #segment tag list: [S1Tag, S2Tag, ...] (list of ints) 1116 1116 """ 1117 1117 … … 1551 1551 Following lines: <triangle #> <vertex #> <vertex #> <vertex #> <neigbouring triangle #> <neigbouring triangle #> <neigbouring triangle #> [attribute of region] 1552 1552 One line: <# of segments> 1553 Following lines: <segment #> <vertex #> <vertex #> [boundary marker]1553 Following lines: <segment #> <vertex #> <vertex #> [boundary tag] 1554 1554 """ 1555 1555 fd = open(ofile,'w') … … 1573 1573 meshDict['vertex_attributes'] = [] 1574 1574 meshDict['segments'] = [] 1575 meshDict['segment_ markers'] = []1575 meshDict['segment_tags'] = [] 1576 1576 meshDict['triangles'] = [] 1577 meshDict['triangle_ markers'] = []1577 meshDict['triangle_tags'] = [] 1578 1578 meshDict['triangle_neighbors'] = [] 1579 1579 … … 1630 1630 verts.append(seg.vertices[0]) 1631 1631 verts.append(seg.vertices[1]) 1632 #print 'verts>',verts1632 print 'verts>',verts 1633 1633 1634 1634 verts, count = self.removeDuplicatedVertices(verts) 1635 #print 'verts no dups>',verts1635 print 'verts no dups>',verts 1636 1636 self.writeASCIImesh(fd, 1637 1637 verts, … … 1647 1647 Following lines: <x> <y> [attributes] 1648 1648 One line: <# of segments> 1649 Following lines: <segment #> <vertex #> <vertex #> [boundary marker]1649 Following lines: <segment #> <vertex #> <vertex #> [boundary tag] 1650 1650 """ 1651 1651 … … 1718 1718 vertex_attribute_titles:[A1Title, A2Title ...] (A list of strings) 1719 1719 segments: [[v1,v2],[v3,v4],...] (lists of integers) 1720 segment_ markers : [marker,marker,...] list of strings1720 segment_tags : [tag,tag,...] list of strings 1721 1721 triangles : [(v1,v2,v3), (v4,v5,v6),....] lists of points 1722 triangle markers: [s1,s2,...] A list of strings1722 triangle tags: [s1,s2,...] A list of strings 1723 1723 triangle neighbors: [[t1,t2,t3], [t4,t5,t6],..] lists of triangles 1724 1724 … … 1727 1727 point_attributes: [[a11,a12,...],[a21,a22],...] (lists of doubles) 1728 1728 outline_segments: [[point1,point2],[p3,p4],...] (lists of integers) 1729 outline_segment_ markers : [marker1,marker2,...] list of strings1729 outline_segment_tags : [tag1,tag2,...] list of strings 1730 1730 holes : [[x1,y1],...](List of doubles, one inside each hole region) 1731 1731 regions : [ [x1,y1],...] (List of 4 doubles) 1732 region_ markers : [marker1,marker2,...] (list of strings)1732 region_tags : [tag1,tag2,...] (list of strings) 1733 1733 region_max_areas: [ma1,ma2,...] (A list of doubles) 1734 1734 {Convension: A -ve max area means no max area} … … 1774 1774 #segments 1775 1775 segments=[] 1776 segment_ markers=[]1776 segment_tags=[] 1777 1777 for seg in self.meshSegments: 1778 1778 segments.append([seg.vertices[0].index,seg.vertices[1].index]) 1779 segment_ markers.append(seg.marker)1779 segment_tags.append(seg.tag) 1780 1780 meshDict['segments'] =segments 1781 meshDict['segment_ markers'] =segment_markers1781 meshDict['segment_tags'] =segment_tags 1782 1782 1783 1783 # Make sure that the indexation is correct … … 1788 1788 1789 1789 triangles = [] 1790 triangle_ markers = []1790 triangle_tags = [] 1791 1791 triangle_neighbors = [] 1792 1792 for tri in self.meshTriangles: 1793 1793 triangles.append([tri.vertices[0].index,tri.vertices[1].index,tri.vertices[2].index]) 1794 triangle_ markers.append([tri.attribute])1794 triangle_tags.append([tri.attribute]) 1795 1795 neighborlist = [-1,-1,-1] 1796 1796 for neighbor,index in map(None,tri.neighbors, … … 1801 1801 1802 1802 meshDict['triangles'] = triangles 1803 meshDict['triangle_ markers'] = triangle_markers1803 meshDict['triangle_tags'] = triangle_tags 1804 1804 meshDict['triangle_neighbors'] = triangle_neighbors 1805 1805 … … 1833 1833 1834 1834 meshDict = {} 1835 1835 print "userVertices",userVertices 1836 print "userSegments",userSegments 1836 1837 pointlist=[] 1837 1838 pointattributelist=[] … … 1847 1848 1848 1849 segmentlist=[] 1849 segment markerlist=[]1850 segmenttaglist=[] 1850 1851 for seg in userSegments: 1851 1852 segmentlist.append([seg.vertices[0].index,seg.vertices[1].index]) 1852 segment markerlist.append(seg.marker)1853 segmenttaglist.append(seg.tag) 1853 1854 meshDict['outline_segments'] =segmentlist 1854 meshDict['outline_segment_ markers'] =segmentmarkerlist1855 meshDict['outline_segment_tags'] =segmenttaglist 1855 1856 1856 1857 holelist=[] … … 1860 1861 1861 1862 regionlist=[] 1862 region markerlist = []1863 regiontaglist = [] 1863 1864 regionmaxarealist = [] 1864 1865 for region in regions: 1865 1866 regionlist.append([region.x,region.y]) 1866 region markerlist.append(region.getTag())1867 regiontaglist.append(region.getTag()) 1867 1868 1868 1869 if (region.getMaxArea() != None): … … 1871 1872 regionmaxarealist.append( NOMAXAREA) 1872 1873 meshDict['regions'] = regionlist 1873 meshDict['region_ markers'] = regionmarkerlist1874 meshDict['region_tags'] = regiontaglist 1874 1875 meshDict['region_max_areas'] = regionmaxarealist 1875 1876 #print "*(*(" … … 1904 1905 1905 1906 index = 0 1906 for seg, marker in map(None,genDict['segments'],genDict['segment_markers']):1907 for seg,tag in map(None,genDict['segments'],genDict['segment_tags']): 1907 1908 segObject = Segment( self.meshVertices[seg[0]], 1908 self.meshVertices[seg[1]], marker = marker)1909 self.meshVertices[seg[1]], tag = tag ) 1909 1910 segObject.index = index 1910 1911 index +=1 … … 1921 1922 1922 1923 index = 0 1923 for att in genDict['triangle_ markers']:1924 for att in genDict['triangle_tags']: 1924 1925 if att == []: 1925 1926 self.meshTriangles[index].setAttribute("") … … 1977 1978 1978 1979 #index = 0 1979 for seg, marker in map(None,genDict['outline_segments'],genDict['outline_segment_markers']):1980 for seg,tag in map(None,genDict['outline_segments'],genDict['outline_segment_tags']): 1980 1981 segObject = Segment( self.userVertices[seg[0]], 1981 self.userVertices[seg[1]], marker = marker)1982 self.userVertices[seg[1]], tag = tag ) 1982 1983 #segObject.index = index 1983 1984 #index +=1 … … 2004 2005 for reg,att,maxArea in map(None, 2005 2006 genDict['regions'], 2006 genDict['region_ markers'],2007 genDict['region_tags'], 2007 2008 genDict['region_max_areas']): 2008 2009 Object = Region( reg[0], … … 2242 2243 #print "dict",dict outline_ 2243 2244 dict['segmentlist'] = [] 2244 dict['segment markerlist'] = []2245 dict['segmenttaglist'] = [] 2245 2246 dict['regionlist'] = [] 2246 2247 dict['regionattributelist'] = [] … … 2257 2258 #print "dict",dict 2258 2259 dict['segmentlist'] = [] 2259 dict['segment markerlist'] = []2260 dict['segmenttaglist'] = [] 2260 2261 dict['regionlist'] = [] 2261 2262 dict['regionattributelist'] = [] … … 2290 2291 d = Vertex (side_length,side_length) 2291 2292 2292 s2 = Segment(b,d, marker= up)2293 s3 = Segment(b,a, marker= left)2294 s4 = Segment(d,c, marker= right)2295 s5 = Segment(a,c, marker= down)2293 s2 = Segment(b,d, tag = up) 2294 s3 = Segment(b,a, tag = left) 2295 s4 = Segment(d,c, tag = right) 2296 s5 = Segment(a,c, tag = down) 2296 2297 2297 2298 if regions: 2298 2299 e = Vertex (side_length/2,side_length/2) 2299 s6 = Segment(a,e, marker= down + left)2300 s7 = Segment(b,e, marker= up + left)2301 s8 = Segment(c,e, marker= down + right)2302 s9 = Segment(d,e, marker= up + right)2300 s6 = Segment(a,e, tag = down + left) 2301 s7 = Segment(b,e, tag = up + left) 2302 s8 = Segment(c,e, tag = down + right) 2303 s9 = Segment(d,e, tag = up + right) 2303 2304 r1 = Region(side_length/2,3.*side_length/4, tag = up) 2304 2305 r2 = Region(1.*side_length/4,side_length/2, tag = left) … … 2317 2318 2318 2319 def region_strings2ints(region_list): 2319 """Given a list of (x_int,y_int, marker_string) lists it returns a list of2320 (x_int,y_int, marker_int) and a list to convert the marker_int's back to2321 the marker_strings2320 """Given a list of (x_int,y_int,tag_string) lists it returns a list of 2321 (x_int,y_int,tag_int) and a list to convert the tag_int's back to 2322 the tag_strings 2322 2323 """ 2323 2324 # Make sure "" has an index of 0 … … 2373 2374 2374 2375 # note, order the initial converting list is important, 2375 since the index = the int marker2376 since the index = the int tag 2376 2377 """ 2377 2378 nodups = unique(stringlist) 2378 # note, order is important, the index = the int marker2379 # note, order is important, the index = the int tag 2379 2380 #preset = ["internal boundary", "external boundary"] 2380 2381 #Remove the preset tags from the list with no duplicates -
inundation/ga/storm_surge/pmesh/meshHarness.py
r968 r969 49 49 a = Vertex (0.0, 0.0) 50 50 b = Vertex (0.0, 10.0) 51 s = Segment(a,b, marker= 20)51 s = Segment(a,b, tag = 20) 52 52 53 53 self.failUnless( s.vertices[0].DistanceToPoint(s.vertices[1]) == 10.0, 54 54 'vertices in a segment are wrong') 55 55 56 self.failUnless( s. marker== 20.0,57 ' markerin a segment are wrong')56 self.failUnless( s.tag == 20.0, 57 'tag in a segment are wrong') 58 58 59 59 def testdeleteUserVertex(self): … … 236 236 'Segment should not be new. ') 237 237 238 def testautoSegment(self):238 def ztestautoSegment(self): 239 239 p0 = Vertex (0.0, 0.0) 240 240 p1 = Vertex (0.0, 4.0) … … 255 255 'userSegments is wrong!') 256 256 257 def testautoSegmentII(self):257 def ztestautoSegmentII(self): 258 258 p1 = Vertex (3.0, 4.0) 259 259 p2 = Vertex (3.0,2.0) … … 408 408 'vertex attributes are wrong!') 409 409 410 def test_seg marker(self):410 def test_segtag(self): 411 411 412 412 a = Vertex (0.0, 0.0) … … 414 414 f = Vertex (4.0,0.0) 415 415 416 s1 = Segment(a,d, marker= 5)417 s2 = Segment(d,f, marker= 7)418 s3 = Segment(a,f, marker= 9)416 s1 = Segment(a,d,tag = 5) 417 s2 = Segment(d,f,tag = 7) 418 s3 = Segment(a,f,tag = 9) 419 419 420 420 m = Mesh(userVertices=[a,d,f], userSegments=[s1,s2,s3]) … … 424 424 seg = m.getMeshSegments() 425 425 426 #print "seg[0]. marker"427 #print seg[0]. marker428 #print "seg[0]. marker"429 self.failUnless(seg[0]. marker== 5 and430 seg[1]. marker== 7 and431 seg[2]. marker== 9 and432 seg[3]. marker== 7 and433 seg[4]. marker== 9 and434 seg[5]. marker== 7 and435 seg[6]. marker== 5,436 'seg markers are wrong')437 438 def test_seg marker2(self):426 #print "seg[0].tag" 427 #print seg[0].tag 428 #print "seg[0].tag" 429 self.failUnless(seg[0].tag == 5 and 430 seg[1].tag == 7 and 431 seg[2].tag == 9 and 432 seg[3].tag == 7 and 433 seg[4].tag == 9 and 434 seg[5].tag == 7 and 435 seg[6].tag == 5, 436 'seg tags are wrong') 437 438 def test_segtag2(self): 439 439 440 440 a = Vertex (0.0, 0.0) … … 453 453 454 454 seg = m.getMeshSegments() 455 self.failUnless(seg[0]. marker== "exterior" and456 seg[1]. marker== "exterior" and457 seg[2]. marker== "exterior" and458 seg[3]. marker== "" and459 seg[4]. marker== "exterior",460 '2nd seg markers are wrong')455 self.failUnless(seg[0].tag == "exterior" and 456 seg[1].tag == "exterior" and 457 seg[2].tag == "exterior" and 458 seg[3].tag == "" and 459 seg[4].tag == "exterior", 460 '2nd seg tags are wrong') 461 461 462 462 def test_asciiFile(self): … … 585 585 'Ascii file is wrong, triangle') 586 586 587 self.failUnless(lFile[12] == "5 # <# of segments>, next lines <segment #> <vertex #> <vertex #> [boundary marker] ...Triangulation Segments..." and587 self.failUnless(lFile[12] == "5 # <# of segments>, next lines <segment #> <vertex #> <vertex #> [boundary tag] ...Triangulation Segments..." and 588 588 lFile[13] == "0 0 1 exterior" and 589 589 lFile[14] == "1 1 4 exterior" and … … 603 603 'Ascii file is wrong, Mesh Vertices II') 604 604 605 self.failUnless(lFile[23] == '4 # <# of segments>, next lines <segment #> <vertex #> <vertex #> [boundary marker] ...Mesh Segments...' and605 self.failUnless(lFile[23] == '4 # <# of segments>, next lines <segment #> <vertex #> <vertex #> [boundary tag] ...Mesh Segments...' and 606 606 lFile[24] == '0 0 1 ' and 607 607 lFile[25] == '1 1 2 ' and … … 670 670 e = Vertex (1.0,1.0) #, attributes =e_att) 671 671 672 s1 = Segment(a,d, marker= "50")673 s2 = Segment(d,f, marker= "40")674 s3 = Segment(a,f, marker= "30")675 s4 = Segment(a,e, marker= "20")672 s1 = Segment(a,d, tag = "50") 673 s2 = Segment(d,f, tag = "40") 674 s3 = Segment(a,f, tag = "30") 675 s4 = Segment(a,e, tag = "20") 676 676 677 677 r1 = Region(0.3, 0.3,tag = "1.3") … … 709 709 e = Vertex (15.0,20.0, attributes =e_att) 710 710 711 s1 = Segment(a,d, marker= 50)712 s2 = Segment(d,e, marker= 40)713 s3 = Segment(e,f, marker= 30)714 s4 = Segment(f,a, marker= 20)711 s1 = Segment(a,d, tag = 50) 712 s2 = Segment(d,e, tag = 40) 713 s3 = Segment(e,f, tag = 30) 714 s4 = Segment(f,a, tag = 20) 715 715 716 716 r1 = Region(0.3, 0.3,tag = 1.3) … … 740 740 e = Vertex (3,1) 741 741 742 s1 = Segment(a,b, marker= "50")743 s2 = Segment(b,c, marker= "40")744 s3 = Segment(c,a, marker= "30")742 s1 = Segment(a,b, tag = "50") 743 s2 = Segment(b,c, tag = "40") 744 s3 = Segment(c,a, tag = "30") 745 745 746 746 r1 = Region(2, 1,tag = "1.3") … … 833 833 f = Vertex (3,1) 834 834 835 s1 = Segment(a,b, marker= 50)836 s2 = Segment(b,c, marker= 40)837 s3 = Segment(c,a, marker= 30)835 s1 = Segment(a,b, tag = 50) 836 s2 = Segment(b,c, tag = 40) 837 s3 = Segment(c,a, tag = 30) 838 838 839 839 r1 = Region(2, 1,tag = 1.3) … … 1004 1004 self.failUnless(m.userSegments[10].vertices[1] == m.userVertices[8], 1005 1005 'Bad segment.') 1006 self.failUnless(m.userSegments[10]. marker== tag,1006 self.failUnless(m.userSegments[10].tag == tag, 1007 1007 'wrong tag.') 1008 1008 … … 1064 1064 e = Vertex (1.0,1.0, attributes =e_att) 1065 1065 1066 s1 = Segment(a,d, marker= "50")1067 s2 = Segment(d,f, marker= "40")1068 s3 = Segment(a,f, marker= "30")1069 s4 = Segment(a,e, marker= "20")1066 s1 = Segment(a,d, tag = "50") 1067 s2 = Segment(d,f, tag = "40") 1068 s3 = Segment(a,f, tag = "30") 1069 s4 = Segment(a,e, tag = "20") 1070 1070 1071 1071 r1 = Region(0.3, 0.3,tag = "1.3", maxArea = 36) … … 1096 1096 self.failUnless( dict['outline_segments'][0] == [0,1], 1097 1097 'loadASCIITestCase failed. test 3') 1098 for segimp,segactual in map(None,dict['outline_segment_ markers'],seg):1099 self.failUnless( segimp == segactual. marker,1098 for segimp,segactual in map(None,dict['outline_segment_tags'],seg): 1099 self.failUnless( segimp == segactual.tag, 1100 1100 'loadASCIITestCase failed. test 4') 1101 1101 for holeimp,holeactual in map(None,dict['holes'],holes): 1102 1102 self.failUnless( holeimp == [holeactual.x,holeactual.y], 1103 1103 'loadASCIITestCase failed. test 5') 1104 for regimp,regactual,regattimp, regmaxarea in map(None,dict['regions'],regions, dict['region_ markers'], dict['region_max_areas']):1104 for regimp,regactual,regattimp, regmaxarea in map(None,dict['regions'],regions, dict['region_tags'], dict['region_max_areas']): 1105 1105 self.failUnless( regimp == [regactual.x,regactual.y], 1106 1106 'loadASCIITestCase failed. test 6') … … 1123 1123 e = Vertex (1.0,1.0) #, attributes =e_att) 1124 1124 1125 s1 = Segment(a,d, marker= "50")1126 s2 = Segment(d,f, marker= "40")1127 s3 = Segment(a,f, marker= "30")1128 s4 = Segment(a,e, marker= "20")1125 s1 = Segment(a,d, tag = "50") 1126 s2 = Segment(d,f, tag = "40") 1127 s3 = Segment(a,f, tag = "30") 1128 s4 = Segment(a,e, tag = "20") 1129 1129 1130 1130 r1 = Region(0.3, 0.3,tag = "1.3", maxArea = 45) … … 1153 1153 e = Vertex (1.0,1.0 , attributes =e_att) 1154 1154 1155 s1 = Segment(a,d, marker= "50")1156 s2 = Segment(d,f, marker= "40")1157 s3 = Segment(a,f, marker= "30")1158 s4 = Segment(a,e, marker= "20")1155 s1 = Segment(a,d, tag = "50") 1156 s2 = Segment(d,f, tag = "40") 1157 s3 = Segment(a,f, tag = "30") 1158 s4 = Segment(a,e, tag = "20") 1159 1159 1160 1160 r1 = Region(0.3, 0.3,tag = "1.3", maxArea = 45) … … 1190 1190 self.failUnless( dict['segments'][0] == [0,1], 1191 1191 'test_Mesh2IOTriangulationDict failed. test 3') 1192 for segimp,segactual in map(None,dict['segment_ markers'],seg):1193 self.failUnless( segimp == segactual. marker,1192 for segimp,segactual in map(None,dict['segment_tags'],seg): 1193 self.failUnless( segimp == segactual.tag, 1194 1194 'test_Mesh2IOTriangulationDict failed. test 4') 1195 1195 #print " dict['triangles'][0]", dict['triangles'][0] … … 1198 1198 self.failUnless( dict['triangle_neighbors'][0] == [-1,2,3], 1199 1199 'test_Mesh2IOTriangulationDict failed. test 6') 1200 self.failUnless( dict['triangle_ markers'][0] == ["1.3"],1200 self.failUnless( dict['triangle_tags'][0] == ["1.3"], 1201 1201 'test_Mesh2IOTriangulationDict failed. test 7') 1202 1202 … … 1214 1214 e = Vertex (1.0,1.0 , attributes =e_att) 1215 1215 1216 s1 = Segment(a,d, marker= "50")1217 s2 = Segment(d,f, marker= "40")1218 s3 = Segment(a,f, marker= "30")1219 s4 = Segment(a,e, marker= "20")1216 s1 = Segment(a,d, tag = "50") 1217 s2 = Segment(d,f, tag = "40") 1218 s3 = Segment(a,f, tag = "30") 1219 s4 = Segment(a,e, tag = "20") 1220 1220 1221 1221 r1 = Region(0.3, 0.3,tag = "1.3", maxArea = 45) … … 1251 1251 self.failUnless( dict['segments'][0] == [0,1], 1252 1252 'test_Mesh2IODict failed. test 3') 1253 for segimp,segactual in map(None,dict['segment_ markers'],seg):1254 self.failUnless( segimp == segactual. marker,1253 for segimp,segactual in map(None,dict['segment_tags'],seg): 1254 self.failUnless( segimp == segactual.tag, 1255 1255 'test_Mesh2IODict failed. test 4') 1256 1256 #print " dict['triangles'][0]", dict['triangles'][0] … … 1259 1259 self.failUnless( dict['triangle_neighbors'][0] == [-1,2,3], 1260 1260 'test_Mesh2IODict failed. test 6') 1261 self.failUnless( dict['triangle_ markers'][0] == ["1.3"],1261 self.failUnless( dict['triangle_tags'][0] == ["1.3"], 1262 1262 'test_Mesh2IODict failed. test 7') 1263 1263 … … 1274 1274 self.failUnless( dict['outline_segments'][0] == [0,1], 1275 1275 'test_Mesh2IODict failed. test 3') 1276 for segimp,segactual in map(None,dict['outline_segment_ markers'],seg):1277 self.failUnless( segimp == segactual. marker,1276 for segimp,segactual in map(None,dict['outline_segment_tags'],seg): 1277 self.failUnless( segimp == segactual.tag, 1278 1278 'test_Mesh2IODict failed. test 4') 1279 1279 for holeimp,holeactual in map(None,dict['holes'],holes): … … 1281 1281 'test_Mesh2IODict failed. test 5') 1282 1282 1283 for regimp,regactual,regattimp, regmaxarea in map(None,dict['regions'],regions, dict['region_ markers'], dict['region_max_areas']):1283 for regimp,regactual,regattimp, regmaxarea in map(None,dict['regions'],regions, dict['region_tags'], dict['region_max_areas']): 1284 1284 self.failUnless( regimp == [regactual.x,regactual.y], 1285 1285 'loadASCIITestCase failed. test 6') … … 1303 1303 e = Vertex (1.0,1.0 , attributes =e_att) 1304 1304 1305 s1 = Segment(a,d, marker= "50")1306 s2 = Segment(d,f, marker= "40")1307 s3 = Segment(a,f, marker= "30")1308 s4 = Segment(a,e, marker= "20")1305 s1 = Segment(a,d, tag = "50") 1306 s2 = Segment(d,f, tag = "40") 1307 s3 = Segment(a,f, tag = "30") 1308 s4 = Segment(a,e, tag = "20") 1309 1309 1310 1310 r1 = Region(0.3, 0.3,tag = "1.3", maxArea = 45) … … 1332 1332 self.failUnless( dict['outline_segments'][0] == [0,1], 1333 1333 'loadASCIITestCase failed. test 3') 1334 for segimp,segactual in map(None,dict['outline_segment_ markers'],seg):1335 self.failUnless( segimp == segactual. marker,1334 for segimp,segactual in map(None,dict['outline_segment_tags'],seg): 1335 self.failUnless( segimp == segactual.tag, 1336 1336 'loadASCIITestCase failed. test 4') 1337 1337 for holeimp,holeactual in map(None,dict['holes'],holes): … … 1347 1347 1348 1348 1349 for regimp,regactual,regattimp, regmaxarea in map(None,dict['regions'],regions, dict['region_ markers'], dict['region_max_areas']):1349 for regimp,regactual,regattimp, regmaxarea in map(None,dict['regions'],regions, dict['region_tags'], dict['region_max_areas']): 1350 1350 self.failUnless( regimp == [regactual.x,regactual.y], 1351 1351 'loadASCIITestCase failed. test 6') -
inundation/ga/storm_surge/pmesh/pmesh.py
r958 r969 111 111 label='Export ASCII obj', 112 112 command=self.exportObj) 113 114 self.menuBar.addmenuitem('File', 'command',115 'Export ASCII segment outline',116 label='Export ASCII segment outline...',117 command=self.exportASCIIsegmentoutlinefile)113 # FIXME, add this function back into pmesh 114 #self.menuBar.addmenuitem('File', 'command', 115 # 'Export ASCII segment outline', 116 # label='Export ASCII segment outline...', 117 # command=self.exportASCIIsegmentoutlinefile) 118 118 119 119 self.menuBar.addmenuitem('File', 'command', -
inundation/ga/storm_surge/pmesh/visualmesh.py
r407 r969 211 211 212 212 def editWindow_int(self, canvas, selMeshObject): 213 ask_int = askinteger("Edit Segment", " Marker",214 minvalue=0, initialvalue= selMeshObject. marker)213 ask_int = askinteger("Edit Segment", "Tag", 214 minvalue=0, initialvalue= selMeshObject.tag) 215 215 if ask_int >= 0: 216 selMeshObject. marker= ask_int216 selMeshObject.tag = ask_int 217 217 218 218 def editWindow(self, canvas, selMeshObject, userMeshChanged): 219 ask_string = askstring("Edit Segment Tag", " Marker",220 initialvalue= str(selMeshObject. marker))219 ask_string = askstring("Edit Segment Tag", "Tag", 220 initialvalue= str(selMeshObject.tag)) 221 221 if ask_string != None: 222 selMeshObject. marker= ask_string222 selMeshObject.tag = ask_string 223 223 userMeshChanged = True 224 224 return userMeshChanged 225 225 226 226 def defaultWindow(self, canvas): 227 ask_string = askstring("Edit Default Segment Tag", " Marker",227 ask_string = askstring("Edit Default Segment Tag", "Tag", 228 228 initialvalue= str(self.association.get_default_tag())) 229 229 if ask_string != None: -
inundation/ga/storm_surge/pyvolution/pmesh2domain.py
r968 r969 14 14 from domain import Domain 15 15 16 vertex_coordinates, volumes, marker_dict, vertex_quantity_dict ,tagged_elements_dict = \16 vertex_coordinates, volumes, tag_dict, vertex_quantity_dict ,tagged_elements_dict = \ 17 17 pmesh_to_domain(fileName, 18 18 setting_function=setting_function) … … 22 22 23 23 24 domain = DomainClass(vertex_coordinates, volumes, marker_dict,24 domain = DomainClass(vertex_coordinates, volumes, tag_dict, 25 25 tagged_elements = tagged_elements_dict ) 26 26 … … 56 56 generated point attribute list:[(P1att1,P1attt2, ...),(P2att1,P2attt2,...),...] 57 57 generated segment list: [(point1,point2),(p3,p4),...] (Tuples of integers) 58 generated segment marker list: [S1Marker, S2Marker, ...] (list of ints)58 generated segment tag list: [S1Tag, S2Tag, ...] (list of ints) 59 59 triangle list: [(point1,point2, point3),(p5,p4, p1),...] (Tuples of integers) 60 60 triangle neighbor list: [(triangle1,triangle2, triangle3),(t5,t4, t1),...] (Tuples of integers) -1 means there's no triangle neighbor … … 83 83 for quantity, value_vector in map (None, point_titles, point_atts): 84 84 vertex_quantity_dict[quantity] = value_vector 85 marker_dict = pmesh_dict_to_marker_dict(mesh_dict)85 tag_dict = pmesh_dict_to_tag_dict(mesh_dict) 86 86 tagged_elements_dict = build_tagged_elements_dictionary(mesh_dict) 87 return vertex_coordinates, volumes, marker_dict, vertex_quantity_dict,tagged_elements_dict87 return vertex_coordinates, volumes, tag_dict, vertex_quantity_dict,tagged_elements_dict 88 88 89 89 … … 95 95 { (tag): [e1, e2, e3..] } 96 96 """ 97 tri_atts = mesh_dict['triangle_ markers']97 tri_atts = mesh_dict['triangle_tags'] 98 98 #print "tri_atts", tri_atts 99 99 tagged_elements = {} … … 117 117 # I'm happy for it to change. -DSG 118 118 119 def pmesh_dict_to_ marker_dict(mesh_dict):119 def pmesh_dict_to_tag_dict(mesh_dict): 120 120 """ Convert the pmesh dictionary (mesh_dict) description of boundary tags 121 to a dictionary of markers, indexed with volume id and face number.121 to a dictionary of tags, indexed with volume id and face number. 122 122 """ 123 123 triangles = mesh_dict['triangles'] 124 124 sides = calc_sides(triangles) 125 marker_dict = {}126 for seg, markerin map(None,mesh_dict['segments'],127 mesh_dict['segment_ markers']):125 tag_dict = {} 126 for seg, tag in map(None,mesh_dict['segments'], 127 mesh_dict['segment_tags']): 128 128 v1 = seg[0] 129 129 v2 = seg[1] 130 130 for key in [(v1,v2),(v2,v1)]: 131 if sides.has_key(key) and marker<> "":131 if sides.has_key(key) and tag <> "": 132 132 #"" represents null. Don't put these into the dictionary 133 #this creates a dict of lists of faces, indexed by marker134 #tagged_edges.setdefault( marker,[]).append(sides[key])135 marker_dict[sides[key]] = marker133 #this creates a dict of lists of faces, indexed by tag 134 #tagged_edges.setdefault(tag,[]).append(sides[key]) 135 tag_dict[sides[key]] = tag 136 136 137 return marker_dict137 return tag_dict 138 138 139 139 -
inundation/ga/storm_surge/pyvolution/test_least_squares.py
r968 r969 892 892 mesh_dic['triangles'] = [[0, 2, 1]] 893 893 mesh_dic['segments'] = [[0, 1], [2, 0], [1, 2]] 894 mesh_dic['triangle_ markers'] = [['']]894 mesh_dic['triangle_tags'] = [['']] 895 895 mesh_dic['vertex_attributes'] = [[], [], []] 896 896 mesh_dic['vertiex_attribute_titles'] = [] 897 897 mesh_dic['triangle_neighbors'] = [[-1, -1, -1]] 898 mesh_dic['segment_ markers'] = ['external',898 mesh_dic['segment_tags'] = ['external', 899 899 'external', 900 900 'external'] … … 942 942 mesh_dic['triangles'] = [[0, 2, 1]] 943 943 mesh_dic['segments'] = [[0, 1], [2, 0], [1, 2]] 944 mesh_dic['triangle_ markers'] = [['']]944 mesh_dic['triangle_tags'] = [['']] 945 945 mesh_dic['vertex_attributes'] = [[1,2], [1,2], [1,2]] 946 946 mesh_dic['vertex_attribute_titles'] = ['density', 'temp'] 947 947 mesh_dic['triangle_neighbors'] = [[-1, -1, -1]] 948 mesh_dic['segment_ markers'] = ['external',948 mesh_dic['segment_tags'] = ['external', 949 949 'external', 950 950 'external'] -
inundation/ga/storm_surge/pyvolution/test_pmesh2domain.py
r968 r969 50 50 0 0 3 2 -1 -1 1 dsg\n\ 51 51 1 0 1 3 -1 0 -1 ole nielsen\n\ 52 4 # <segment #> <vertex #> <vertex #> [boundary marker] \n\52 4 # <segment #> <vertex #> <vertex #> [boundary tag] \n\ 53 53 0 1 0 2 \n\ 54 54 1 0 2 3 \n\ … … 59 59 1 160.0 -167.0 \n \ 60 60 2 114.0 -91.0 \n \ 61 3 # <vertex #> <vertex #> [boundary marker] ...Mesh Segments... \n \61 3 # <vertex #> <vertex #> [boundary tag] ...Mesh Segments... \n \ 62 62 0 0 1 0 \n \ 63 63 1 1 2 0 \n \ … … 121 121 meshDict['vertex_attributes'] = [[0.0, 0.0,7.0],[10.0, 0.0,7.0],[0.0, 10.0,7.0],[6.46446609407, 3.53553390593,7.0]] 122 122 meshDict['triangles'] = [[0,3,2],[0,1,3]] 123 meshDict['triangle_ markers'] = [6.6,6.6]123 meshDict['triangle_tags'] = [6.6,6.6] 124 124 meshDict['triangle_neighbors'] = [[-1,-1,1],[-1,0,-1]] 125 125 meshDict['segments'] = [[1,0],[0,2],[2,3],[3,1]] 126 meshDict['segment_ markers'] = [2,3,1,1]126 meshDict['segment_tags'] = [2,3,1,1] 127 127 128 128 domain = Domain.pmesh_dictionary_to_domain(meshDict) 129 129 130 #domain.set_ marker_dict(marker_dict)130 #domain.set_tag_dict(tag_dict) 131 131 #Boundary tests 132 132 b1 = Dirichlet_boundary(conserved_quantities = array([0.0])) -
inundation/ga/storm_surge/pyvolution/util.py
r957 r969 398 398 else: 399 399 q[i] = Q[self.index, point_id] 400 401 400 402 401 403 #Return vector of interpolated values
Note: See TracChangeset
for help on using the changeset viewer.