Changeset 969


Ignore:
Timestamp:
Feb 28, 2005, 4:30:52 PM (19 years ago)
Author:
duncan
Message:

for pmesh/loadmesh, changing markers to tags

Location:
inundation/ga/storm_surge
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pmesh/load_mesh/loadASCII.py

    r968 r969  
    2121    dic['pointlist'] = [[1.0,2.0],[3.0,5.0]]
    2222    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   
    2351"""
    2452
     
    2856
    2957from os.path import splitext
     58
     59from Scientific.IO.NetCDF import NetCDFFile
    3060   
    3161import exceptions
     
    5282    Following lines:  <triangle #> <vertex #>  <vertex #> <vertex #> <neigbouring triangle #> <neigbouring triangle #> <neigbouring triangle #> [attribute of region]
    5383    One line:  <# of segments>
    54     Following lines:  <segment #> <vertex #>  <vertex #> [boundary marker]
     84    Following lines:  <segment #> <vertex #>  <vertex #> [boundary tag]
    5585    Note: This might throw a can't load file error
    5686    """
     
    134164            line = line[find(line,delimiter):] # remove index
    135165            line = line.lstrip()
    136         stringmarker = line.strip()
    137         triangleattributes.append([stringmarker])
     166        stringtag = line.strip()
     167        triangleattributes.append([stringtag])
    138168       
    139169    ######### loading the segment info
     
    145175    NumOfSegments = fragments[0]
    146176    segments = []
    147     segmentmarkers = []
     177    segmenttags = []
    148178    for index in range(int(NumOfSegments)):       
    149179        #print index
     
    160190        line = line.lstrip()
    161191        line = line[find(line,delimiter):] # remove y
    162         stringmarker = line.strip()
    163         segmentmarkers.append(stringmarker)
     192        stringtag = line.strip()
     193        segmenttags.append(stringtag)
    164194    meshDict = {}
    165195    meshDict['vertices'] = points
    166196    meshDict['vertex_attributes'] = pointattributes
    167197    meshDict['triangles'] = triangles
    168     meshDict['triangle_markers'] = triangleattributes
     198    meshDict['triangle_tags'] = triangleattributes
    169199    meshDict['triangle_neighbors'] = triangleneighbors
    170200    meshDict['segments'] = segments
    171     meshDict['segment_markers'] = segmentmarkers
     201    meshDict['segment_tags'] = segmenttags
    172202    meshDict['vertex_attribute_titles'] = vertTitle
    173203    return meshDict
     
    180210    Following lines: <x> <y> [attributes]
    181211    One line:  <# of segments>
    182     Following lines:  <vertex #>  <vertex #> [boundary marker]
     212    Following lines:  <vertex #>  <vertex #> [boundary tag]
    183213    Note: This might throw a can't load file error
    184214    """
     
    234264        NumOfSegments = fragments[0]
    235265    segments = []
    236     segmentmarkers = []
     266    segmenttags = []
    237267    for index in range(int(NumOfSegments)): 
    238268        #print index
     
    249279        line = line.lstrip()
    250280        line = line[find(line,delimiter):] # remove y
    251         stringmarker = line.strip()
    252         segmentmarkers.append(stringmarker
     281        stringtag = line.strip()
     282        segmenttags.append(stringtag
    253283
    254284    ######### loading the hole info
     
    297327        line = line.lstrip()
    298328        line = line[find(line,delimiter):] # remove y
    299         stringmarker = line.strip()
    300         regionattributes.append(stringmarker)
     329        stringtag = line.strip()
     330        regionattributes.append(stringtag)
    301331    regionmaxareas = []
    302332    line = fd.readline()
     
    319349    meshDict['point_attributes'] = pointattributes
    320350    meshDict['outline_segments'] = segments
    321     meshDict['outline_segment_markers'] = segmentmarkers
     351    meshDict['outline_segment_tags'] = segmenttags
    322352    meshDict['holes'] = holes
    323353    meshDict['regions'] = regions
    324     meshDict['region_markers'] = regionattributes
     354    meshDict['region_tags'] = regionattributes
    325355    meshDict['region_max_areas'] = regionmaxareas
    326356    #print "meshDict",meshDict
     
    365395       
    366396    triangles = gen_dict['triangles']
    367     triangles_attributes = gen_dict['triangle_markers']
     397    triangles_attributes = gen_dict['triangle_tags']
    368398    triangle_neighbors = gen_dict['triangle_neighbors']
    369399       
    370400    segments = gen_dict['segments']
    371     segment_markers = gen_dict['segment_markers']
     401    segment_tags = gen_dict['segment_tags']
    372402     
    373403    numVert = str(len(vertices))
     
    431461    #One line:  <# of segments>
    432462    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]
    436466    for i in range(len(segments)):
    437467        seg = segments[i]
     
    439469                 + str(seg[0]) + " "
    440470                 + str(seg[1]) + " "
    441                  + str(segment_markers[i]) + "\n")
     471                 + str(segment_tags[i]) + "\n")
    442472
    443473
     
    451481    Following lines:  <triangle #> <vertex #>  <vertex #> <vertex #> <neigbouring triangle #> <neigbouring triangle #> <neigbouring triangle #> [attribute of region]
    452482    One line:  <# of segments>
    453     Following lines:  <segment #> <vertex #>  <vertex #> [boundary marker]
     483    Following lines:  <segment #> <vertex #>  <vertex #> [boundary tag]
    454484    """
    455485    #print "DSG************"
     
    470500    point_attributes = dict['point_attributes']
    471501    segments = dict['outline_segments']
    472     segment_markers = dict['outline_segment_markers']
     502    segment_tags = dict['outline_segment_tags']
    473503    holes = dict['holes']
    474504    regions = dict['regions']
    475     region_markers = dict['region_markers']
     505    region_tags = dict['region_tags']
    476506    region_max_areas = dict['region_max_areas']
    477507       
     
    496526    #One line:  <# of segments>
    497527    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]
    501531    for i,seg in enumerate(segments):
    502532        fd.write(str(i) + " "
    503533                 + str(seg[0]) + " "
    504534                 + str(seg[1]) + " "
    505                  + str(segment_markers[i]) + "\n")
     535                 + str(segment_tags[i]) + "\n")
    506536
    507537    #One line:  <# of holes>
     
    524554                 + str(r[0]) + " "
    525555                 + str(r[1])+ " "
    526                  + str(region_markers[i]) + "\n")
     556                 + str(region_tags[i]) + "\n")
    527557       
    528558    # <index> [<MaxArea>|""]
     
    539569        fd.write(str(i) + " " + area + "\n")
    540570
    541        #FIXME -old, remove
    542 def write_ASCII_mesh_old(fd,
    543                      dict):
    544     """
    545     use write_ASCII_outline
    546     """
    547     pass
     571
     572def 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()
    548604
    549605
     
    660716    dic['attributelist']['elevation'] = [[7.0,5.0]
    661717    """
    662    
    663     from Scientific.IO.NetCDF import NetCDFFile
    664718
    665719    fid = NetCDFFile(filename, 'r')
     
    687741def write_pts(filename, point_atts):
    688742    """Write .pts NetCDF file   
    689     Return a Points dictionary.  see header for definition.
    690743
    691744    WARNING: This function mangles the point_atts data structure
    692745    """
    693    
    694     from Scientific.IO.NetCDF import NetCDFFile
    695746   
    696747    point_atts2array(point_atts)
     
    799850    return xya_dict
    800851
    801 # obsolete
    802 def read_xya_old(filename):
    803     """Read simple xya file, possibly with a header in the first line, just
    804     x y [attributes]
    805     separated by whitespace
    806 
    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 and
    810     attribute names if present otherwise None
    811     """
    812    
    813     from Scientific.IO.NetCDF import NetCDFFile
    814 
    815     #Read as ASCII file assuming that it is separated by whitespace
    816     fid = open(filename)
    817     lines = fid.readlines()
    818     fid.close()
    819 
    820     #Check if there is a header line
    821     fields = lines[0].strip().split()
    822     try:
    823         float(fields[0])
    824     except:
    825         #This must be a header line
    826         attribute_names = fields
    827         lines = lines[1:]
    828     else:
    829         attribute_names = None
    830    
    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_names
    839    
    840852               
    841853def export_xya_file( file_name, xya_dict, title, delimiter = ','):
  • inundation/ga/storm_surge/pmesh/load_mesh/test_loadASCII.py

    r968 r969  
    3636        dict ={}
    3737        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']
    3939        dict['holes'] = [(0.2, 0.6)]
    4040        dict['point_attributes'] = [[5, 2], [4, 2], [3, 2], [2,2]]
    4141        dict['regions'] = [(0.3, 0.3)]
    42         dict['region_markers'] = ['1.3']
     42        dict['region_tags'] = ['1.3']
    4343        dict['region_max_areas'] = [36.0]
    4444        dict['points'] = [(0.0, 0.0), (0.0, 4.0), (4.0, 0.0), (1.0, 1.0)]
     
    6868                        array(dict['outline_segments']),
    6969                         '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']),
    7272                         'test_import_mesh failed. Test 4')
    7373        #print "loaded_dict['regions']",loaded_dict['regions']
     
    7676                        array(dict['regions']),
    7777                         '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']),
    8080                         'test_import_mesh failed. Test 5')
    8181        self.failUnless(array(loaded_dict['region_max_areas'])  ==
     
    9898        meshDict['segments'] = [(0, 1), (1, 4), (2, 0),
    9999                                            (0, 3), (4, 2)]
    100         meshDict['triangle_markers'] = [['1.3'], ['1.3'],
     100        meshDict['triangle_tags'] = [['1.3'], ['1.3'],
    101101                                                      ['1.3'], ['1.3']]
    102102        meshDict['vertex_attributes'] = [[1.2,2.], [1.2,2.], [1.2,2.], [1.2,2.], [1.2,3.]]
    103103        meshDict['triangle_neighbors'] = [[-1, 2, 3], [3, 2, -1],
    104104                                                     [-1, 1, 0], [1, -1, 0]]
    105         meshDict['segment_markers'] = ['50', '40', '30', '20', '40']
     105        meshDict['segment_tags'] = ['50', '40', '30', '20', '40']
    106106        meshDict['vertex_attribute_titles'] = ['bed elevation', 'height']
    107107       
     
    125125                        array(loadedDict['segments']),
    126126                         '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']),
    129129                         'test_export_triangulation_file failed. Test 4')
    130130       
     
    135135                        array(loadedDict['triangle_neighbors']),
    136136                         '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']),
    139139                         'test_export_triangulation_file failed. Test 7')
    140140        self.failUnless(array(meshDict['vertex_attribute_titles'])  ==
  • inundation/ga/storm_surge/pmesh/mesh.py

    r968 r969  
    400400   
    401401    """
    402     def __init__(self, vertex1, vertex2, marker = None ):
     402    def __init__(self, vertex1, vertex2, tag = None ):
    403403        """
    404404        Each segment is specified by listing the vertices of its endpoints
     
    408408        self.vertices = [vertex1,vertex2 ]
    409409       
    410         if marker is None:
    411             self.marker = self.__class__.default
     410        if tag is None:
     411            self.tag = self.__class__.default
    412412        else:
    413             self.marker = marker #this is a string
     413            self.tag = tag #this is a string
    414414       
    415415    def __repr__(self):
    416         return "[%s,%s]" % (self.vertices,self.marker)
     416        return "[%s,%s]" % (self.vertices,self.tag)
    417417           
    418418       
     
    425425            y.append(-1*scale*(end.y + yoffset))  # - since for a canvas - is up
    426426        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 = marker
     427    def set_tag(self,tag):
     428        self.tag = tag
    429429       
    430430    # Class methods
     
    558558        #print "!@!@ This is going to triangle   !@!@"
    559559
    560         #print "meshDict['segmentmarkerlist']", meshDict['segmentmarkerlist']
    561         [meshDict['segmentmarkerlist'],
    562          segconverter] =  segment_strings2ints(meshDict['segmentmarkerlist'],
     560        #print "meshDict['segmenttaglist']", meshDict['segmenttaglist']
     561        [meshDict['segmenttaglist'],
     562         segconverter] =  segment_strings2ints(meshDict['segmenttaglist'],
    563563                                             initialconversions)
    564564        #print "regionlist",meshDict['regionlist']
     
    566566         regionconverter] =  region_strings2ints(meshDict['regionlist'])
    567567        #print "regionlist",meshDict['regionlist']
    568         #print "meshDict['segmentmarkerlist']", meshDict['segmentmarkerlist'
     568        #print "meshDict['segmenttaglist']", meshDict['segmenttaglist'
    569569        generatedMesh = triang.genMesh(
    570570                              meshDict['pointlist'],
     
    573573                              meshDict['regionlist'],
    574574                              meshDict['pointattributelist'],
    575                               meshDict['segmentmarkerlist'],
     575                              meshDict['segmenttaglist'],
    576576                              [],  # since the trianglelist isn't used
    577577                              self.mode)
    578         #print "generated",generatedMesh['generatedsegmentmarkerlist']
     578        #print "generated",generatedMesh['generatedsegmenttaglist']
    579579        generatedMesh['generatedsegmentmarkerlist'] = \
    580580                     segment_ints2strings(generatedMesh['generatedsegmentmarkerlist'],
     
    733733       
    734734        for v in self.userVertices :
    735             # marker is the center of the boxes
    736             marker = (round(v.x/delta,0)*delta,round(v.y/delta,0)*delta)
    737             #this creates a dict of lists of faces, indexed by marker
    738             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():
    741741            min = delta
    742742            bestVert = None
    743             markerVert = Vertex(marker[0],marker[1])
     743            tagVert = Vertex(tag[0],tag[1])
    744744            for v in verts:
    745                 dist = v.DistanceToPoint(markerVert)
     745                dist = v.DistanceToPoint(tagVert)
    746746                if (dist<min):
    747747                    min = dist
     
    819819        segment list: [(point1,point2),(p3,p4),...] (Tuples of integers)
    820820        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)
    822822       
    823823        Note, this adds an index attribute to the user Vertex objects.
    824824
    825         Used to produce .tsh file and output to triangle
     825        Used to produce output to triangle
    826826        """
    827827        if userVertices is None:
     
    849849
    850850        segmentlist=[]
    851         segmentmarkerlist=[]
     851        segmenttaglist=[]
    852852        for seg in userSegments:
    853853            segmentlist.append((seg.vertices[0].index,seg.vertices[1].index))
    854             segmentmarkerlist.append(seg.marker)
     854            segmenttaglist.append(seg.tag)
    855855        meshDict['segmentlist'] =segmentlist
    856         meshDict['segmentmarkerlist'] =segmentmarkerlist
     856        meshDict['segmenttaglist'] =segmenttaglist
    857857       
    858858        holelist=[]
     
    882882        generated point attribute title list:[A1Title, A2Title ...] (list of strings)
    883883        generated segment list: [(point1,point2),(p3,p4),...] (Tuples of integers)
    884         generated segment marker list: [marker,marker,...] list of strings
     884        generated segment tag list: [tag,tag,...] list of strings
    885885
    886886        generated triangle list: [(p1,p2,p3), (p4,p5,p6),....] tuple of points
     
    910910        #segments
    911911        segmentlist=[]
    912         segmentmarkerlist=[]
     912        segmenttaglist=[]
    913913        for seg in self.meshSegments:
    914914            segmentlist.append((seg.vertices[0].index,seg.vertices[1].index))
    915             segmentmarkerlist.append(seg.marker)
     915            segmenttaglist.append(seg.tag)
    916916        meshDict['generatedsegmentlist'] =segmentlist
    917         meshDict['generatedsegmentmarkerlist'] =segmentmarkerlist
     917        meshDict['generatedsegmenttaglist'] =segmenttaglist
    918918
    919919        # Make sure that the indexation is correct
     
    966966        generated point attribute title list:[A1Title, A2Title ...] (list of strings)
    967967        generated segment list: [(point1,point2),(p3,p4),...] (Tuples of integers)
    968         generated segment marker list: [S1Marker, S2Marker, ...] (list of ints)
     968        generated segment marker list: [S1Tag, S2Tag, ...] (list of ints)
    969969        triangle list:  [(point1,point2, point3),(p5,p4, p1),...] (Tuples of integers)
    970970        triangle neighbor list: [(triangle1,triangle2, triangle3),(t5,t4, t1),...] (Tuples of integers) -1 means there's no triangle neighbor
     
    993993        for seg,marker in map(None,genDict['generatedsegmentlist'],genDict['generatedsegmentmarkerlist']):
    994994            segObject = Segment( self.meshVertices[seg[0]],
    995                            self.meshVertices[seg[1]], marker = marker )
     995                           self.meshVertices[seg[1]], tag = marker )
    996996            segObject.index = index
    997997            index +=1
     
    10461046        point attribute list:[(P1att1,P1attt2, ...),(P2att1,P2attt2,...),...]
    10471047        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)
    10491049        region list: [(x1,y1),(x2,y2),...] (Tuples of doubles)
    10501050        region attribute list: ["","reservoir",""] list of strings
     
    10711071
    10721072        #index = 0
    1073         for seg,marker in map(None,genDict['segmentlist'],genDict['segmentmarkerlist']):
     1073        for seg,tag in map(None,genDict['segmentlist'],genDict['segmenttaglist']):
    10741074            segObject = Segment( self.userVertices[seg[0]],
    1075                            self.userVertices[seg[1]], marker = marker )
     1075                           self.userVertices[seg[1]], tag = tag )
    10761076            #segObject.index = index
    10771077            #index +=1
     
    11131113        point list: [(x1,y1),(x2,y2),...] (Tuples of doubles) 
    11141114        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)
    11161116        """
    11171117
     
    15511551        Following lines:  <triangle #> <vertex #>  <vertex #> <vertex #> <neigbouring triangle #> <neigbouring triangle #> <neigbouring triangle #> [attribute of region]
    15521552        One line:  <# of segments>
    1553         Following lines:  <segment #> <vertex #>  <vertex #> [boundary marker]
     1553        Following lines:  <segment #> <vertex #>  <vertex #> [boundary tag]
    15541554        """
    15551555        fd = open(ofile,'w')
     
    15731573        meshDict['vertex_attributes'] = []
    15741574        meshDict['segments'] = []
    1575         meshDict['segment_markers'] = []
     1575        meshDict['segment_tags'] = []
    15761576        meshDict['triangles'] = []
    1577         meshDict['triangle_markers'] = []
     1577        meshDict['triangle_tags'] = []
    15781578        meshDict['triangle_neighbors'] = []
    15791579       
     
    16301630            verts.append(seg.vertices[0])
    16311631            verts.append(seg.vertices[1])
    1632         #print 'verts>',verts
     1632        print 'verts>',verts
    16331633
    16341634        verts, count = self.removeDuplicatedVertices(verts)
    1635         #print 'verts no dups>',verts
     1635        print 'verts no dups>',verts
    16361636        self.writeASCIImesh(fd,
    16371637                            verts,
     
    16471647        Following lines:  <x> <y> [attributes]
    16481648        One line:  <# of segments>
    1649         Following lines:  <segment #> <vertex #>  <vertex #> [boundary marker]
     1649        Following lines:  <segment #> <vertex #>  <vertex #> [boundary tag]
    16501650        """
    16511651       
     
    17181718        vertex_attribute_titles:[A1Title, A2Title ...] (A list of strings)
    17191719        segments: [[v1,v2],[v3,v4],...] (lists of integers)
    1720         segment_markers : [marker,marker,...] list of strings
     1720        segment_tags : [tag,tag,...] list of strings
    17211721        triangles : [(v1,v2,v3), (v4,v5,v6),....] lists of points
    1722         triangle markers: [s1,s2,...] A list of strings
     1722        triangle tags: [s1,s2,...] A list of strings
    17231723        triangle neighbors: [[t1,t2,t3], [t4,t5,t6],..] lists of triangles
    17241724       
     
    17271727        point_attributes: [[a11,a12,...],[a21,a22],...] (lists of doubles)
    17281728        outline_segments: [[point1,point2],[p3,p4],...] (lists of integers)
    1729         outline_segment_markers : [marker1,marker2,...] list of strings
     1729        outline_segment_tags : [tag1,tag2,...] list of strings
    17301730        holes : [[x1,y1],...](List of doubles, one inside each hole region)
    17311731        regions : [ [x1,y1],...] (List of 4 doubles)
    1732         region_markers : [marker1,marker2,...] (list of strings)
     1732        region_tags : [tag1,tag2,...] (list of strings)
    17331733        region_max_areas: [ma1,ma2,...] (A list of doubles)
    17341734        {Convension: A -ve max area means no max area}
     
    17741774        #segments
    17751775        segments=[]
    1776         segment_markers=[]
     1776        segment_tags=[]
    17771777        for seg in self.meshSegments:
    17781778            segments.append([seg.vertices[0].index,seg.vertices[1].index])
    1779             segment_markers.append(seg.marker)
     1779            segment_tags.append(seg.tag)
    17801780        meshDict['segments'] =segments
    1781         meshDict['segment_markers'] =segment_markers
     1781        meshDict['segment_tags'] =segment_tags
    17821782
    17831783        # Make sure that the indexation is correct
     
    17881788
    17891789        triangles = []
    1790         triangle_markers = []
     1790        triangle_tags = []
    17911791        triangle_neighbors = []
    17921792        for tri in self.meshTriangles: 
    17931793            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])
    17951795            neighborlist = [-1,-1,-1]
    17961796            for neighbor,index in map(None,tri.neighbors,
     
    18011801       
    18021802        meshDict['triangles'] = triangles
    1803         meshDict['triangle_markers'] = triangle_markers
     1803        meshDict['triangle_tags'] = triangle_tags
    18041804        meshDict['triangle_neighbors'] = triangle_neighbors
    18051805       
     
    18331833           
    18341834        meshDict = {}
    1835        
     1835        print "userVertices",userVertices
     1836        print "userSegments",userSegments
    18361837        pointlist=[]
    18371838        pointattributelist=[]
     
    18471848
    18481849        segmentlist=[]
    1849         segmentmarkerlist=[]
     1850        segmenttaglist=[]
    18501851        for seg in userSegments:
    18511852            segmentlist.append([seg.vertices[0].index,seg.vertices[1].index])
    1852             segmentmarkerlist.append(seg.marker)
     1853            segmenttaglist.append(seg.tag)
    18531854        meshDict['outline_segments'] =segmentlist
    1854         meshDict['outline_segment_markers'] =segmentmarkerlist
     1855        meshDict['outline_segment_tags'] =segmenttaglist
    18551856       
    18561857        holelist=[]
     
    18601861       
    18611862        regionlist=[]
    1862         regionmarkerlist = []
     1863        regiontaglist = []
    18631864        regionmaxarealist = []
    18641865        for region in regions:
    18651866            regionlist.append([region.x,region.y])
    1866             regionmarkerlist.append(region.getTag())
     1867            regiontaglist.append(region.getTag())
    18671868           
    18681869            if (region.getMaxArea() != None):
     
    18711872                regionmaxarealist.append( NOMAXAREA)
    18721873        meshDict['regions'] = regionlist
    1873         meshDict['region_markers'] = regionmarkerlist
     1874        meshDict['region_tags'] = regiontaglist
    18741875        meshDict['region_max_areas'] = regionmaxarealist
    18751876        #print "*(*("
     
    19041905
    19051906        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']):
    19071908            segObject = Segment( self.meshVertices[seg[0]],
    1908                            self.meshVertices[seg[1]], marker = marker )
     1909                           self.meshVertices[seg[1]], tag = tag )
    19091910            segObject.index = index
    19101911            index +=1
     
    19211922
    19221923        index = 0
    1923         for att in genDict['triangle_markers']:
     1924        for att in genDict['triangle_tags']:
    19241925            if att == []:
    19251926                self.meshTriangles[index].setAttribute("")
     
    19771978
    19781979        #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']):
    19801981            segObject = Segment( self.userVertices[seg[0]],
    1981                            self.userVertices[seg[1]], marker = marker )
     1982                           self.userVertices[seg[1]], tag = tag )
    19821983            #segObject.index = index
    19831984            #index +=1
     
    20042005        for reg,att,maxArea in map(None,
    20052006                                   genDict['regions'],
    2006                                    genDict['region_markers'],
     2007                                   genDict['region_tags'],
    20072008                                   genDict['region_max_areas']):
    20082009            Object = Region( reg[0],
     
    22422243        #print "dict",dict   outline_     
    22432244        dict['segmentlist'] = []
    2244         dict['segmentmarkerlist'] = []
     2245        dict['segmenttaglist'] = []
    22452246        dict['regionlist'] = []
    22462247        dict['regionattributelist'] = []
     
    22572258        #print "dict",dict     
    22582259        dict['segmentlist'] = []
    2259         dict['segmentmarkerlist'] = []
     2260        dict['segmenttaglist'] = []
    22602261        dict['regionlist'] = []
    22612262        dict['regionattributelist'] = []
     
    22902291        d = Vertex (side_length,side_length)
    22912292     
    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)
    22962297
    22972298        if regions:
    22982299            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)
    23032304            r1 = Region(side_length/2,3.*side_length/4, tag = up)
    23042305            r2 = Region(1.*side_length/4,side_length/2, tag = left)
     
    23172318
    23182319def region_strings2ints(region_list):
    2319     """Given a list of (x_int,y_int,marker_string) lists it returns a list of
    2320     (x_int,y_int,marker_int) and a list to convert the marker_int's back to
    2321     the marker_strings 
     2320    """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 
    23222323    """
    23232324    # Make sure "" has an index of 0
     
    23732374   
    23742375    # note, order the initial converting list is important,
    2375      since the index = the int marker
     2376     since the index = the int tag
    23762377    """
    23772378    nodups = unique(stringlist)
    2378     # note, order is important, the index = the int marker
     2379    # note, order is important, the index = the int tag
    23792380    #preset = ["internal boundary", "external boundary"]
    23802381    #Remove the preset tags from the list with no duplicates
  • inundation/ga/storm_surge/pmesh/meshHarness.py

    r968 r969  
    4949        a = Vertex (0.0, 0.0)
    5050        b = Vertex (0.0, 10.0)
    51         s = Segment(a,b, marker = 20)     
     51        s = Segment(a,b, tag = 20)     
    5252       
    5353        self.failUnless( s.vertices[0].DistanceToPoint(s.vertices[1]) == 10.0,
    5454                        'vertices in a segment are wrong')
    5555       
    56         self.failUnless( s.marker == 20.0,
    57                         'marker in a segment are wrong')
     56        self.failUnless( s.tag == 20.0,
     57                        'tag in a segment are wrong')
    5858
    5959    def testdeleteUserVertex(self):
     
    236236                        'Segment should not be new. ')
    237237       
    238     def testautoSegment(self):
     238    def ztestautoSegment(self):
    239239        p0 = Vertex (0.0, 0.0)
    240240        p1 = Vertex (0.0, 4.0)
     
    255255                        'userSegments is wrong!')
    256256     
    257     def testautoSegmentII(self):
     257    def ztestautoSegmentII(self):
    258258        p1 = Vertex (3.0, 4.0)
    259259        p2 = Vertex (3.0,2.0)
     
    408408                        'vertex attributes are wrong!')
    409409
    410     def test_segmarker(self):
     410    def test_segtag(self):
    411411   
    412412        a = Vertex (0.0, 0.0)
     
    414414        f = Vertex (4.0,0.0)
    415415   
    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)
    419419     
    420420        m = Mesh(userVertices=[a,d,f], userSegments=[s1,s2,s3])
     
    424424        seg = m.getMeshSegments()
    425425       
    426         #print "seg[0].marker"
    427         #print seg[0].marker
    428         #print "seg[0].marker"
    429         self.failUnless(seg[0].marker == 5 and
    430                         seg[1].marker == 7 and
    431                         seg[2].marker == 9 and
    432                         seg[3].marker == 7 and
    433                         seg[4].marker == 9 and
    434                         seg[5].marker == 7 and
    435                         seg[6].marker == 5,
    436                         'seg markers are wrong')
    437 
    438     def test_segmarker2(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):
    439439   
    440440        a = Vertex (0.0, 0.0)
     
    453453
    454454        seg = m.getMeshSegments()
    455         self.failUnless(seg[0].marker == "exterior" and
    456                         seg[1].marker == "exterior" and
    457                         seg[2].marker == "exterior" and
    458                         seg[3].marker == "" and
    459                         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')
    461461
    462462    def test_asciiFile(self):
     
    585585                        'Ascii file is wrong, triangle')
    586586
    587         self.failUnless(lFile[12] == "5 # <# of segments>, next lines <segment #> <vertex #>  <vertex #> [boundary marker] ...Triangulation Segments..." and
     587        self.failUnless(lFile[12] == "5 # <# of segments>, next lines <segment #> <vertex #>  <vertex #> [boundary tag] ...Triangulation Segments..." and
    588588                        lFile[13] == "0 0 1 exterior" and
    589589                        lFile[14] == "1 1 4 exterior" and
     
    603603                        'Ascii file is wrong, Mesh Vertices II')
    604604       
    605         self.failUnless(lFile[23] == '4 # <# of segments>, next lines <segment #> <vertex #>  <vertex #> [boundary marker] ...Mesh Segments...' and
     605        self.failUnless(lFile[23] == '4 # <# of segments>, next lines <segment #> <vertex #>  <vertex #> [boundary tag] ...Mesh Segments...' and
    606606                        lFile[24] == '0 0 1 ' and
    607607                        lFile[25] == '1 1 2 ' and
     
    670670        e = Vertex (1.0,1.0) #, attributes =e_att)
    671671   
    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")
    676676     
    677677        r1 = Region(0.3, 0.3,tag = "1.3")
     
    709709        e = Vertex (15.0,20.0, attributes =e_att)
    710710   
    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)
    715715     
    716716        r1 = Region(0.3, 0.3,tag = 1.3)
     
    740740        e = Vertex (3,1)
    741741     
    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")
    745745     
    746746        r1 = Region(2, 1,tag = "1.3")
     
    833833        f = Vertex (3,1)
    834834     
    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)
    838838     
    839839        r1 = Region(2, 1,tag = 1.3)
     
    10041004        self.failUnless(m.userSegments[10].vertices[1] == m.userVertices[8],
    10051005                        'Bad segment.')
    1006         self.failUnless(m.userSegments[10].marker == tag,
     1006        self.failUnless(m.userSegments[10].tag == tag,
    10071007                        'wrong tag.')
    10081008   
     
    10641064        e = Vertex (1.0,1.0, attributes =e_att)
    10651065   
    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")
    10701070     
    10711071        r1 = Region(0.3, 0.3,tag = "1.3", maxArea = 36)
     
    10961096        self.failUnless( dict['outline_segments'][0] == [0,1],
    10971097                        '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,
    11001100                        'loadASCIITestCase failed. test 4')
    11011101        for holeimp,holeactual in map(None,dict['holes'],holes):
    11021102            self.failUnless( holeimp == [holeactual.x,holeactual.y],
    11031103                        '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']):
    11051105            self.failUnless( regimp == [regactual.x,regactual.y],
    11061106                        'loadASCIITestCase failed. test 6')
     
    11231123        e = Vertex (1.0,1.0) #, attributes =e_att)
    11241124   
    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")
    11291129     
    11301130        r1 = Region(0.3, 0.3,tag = "1.3", maxArea = 45)
     
    11531153        e = Vertex (1.0,1.0 , attributes =e_att)
    11541154   
    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")
    11591159     
    11601160        r1 = Region(0.3, 0.3,tag = "1.3", maxArea = 45)
     
    11901190        self.failUnless( dict['segments'][0] == [0,1],
    11911191                        '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,
    11941194                        'test_Mesh2IOTriangulationDict failed. test 4')
    11951195        #print " dict['triangles'][0]", dict['triangles'][0]
     
    11981198        self.failUnless( dict['triangle_neighbors'][0] == [-1,2,3],
    11991199                        'test_Mesh2IOTriangulationDict failed. test 6')
    1200         self.failUnless( dict['triangle_markers'][0] == ["1.3"],
     1200        self.failUnless( dict['triangle_tags'][0] == ["1.3"],
    12011201                         'test_Mesh2IOTriangulationDict failed. test 7')
    12021202
     
    12141214        e = Vertex (1.0,1.0 , attributes =e_att)
    12151215   
    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")
    12201220     
    12211221        r1 = Region(0.3, 0.3,tag = "1.3", maxArea = 45)
     
    12511251        self.failUnless( dict['segments'][0] == [0,1],
    12521252                        '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,
    12551255                        'test_Mesh2IODict failed. test 4')
    12561256        #print " dict['triangles'][0]", dict['triangles'][0]
     
    12591259        self.failUnless( dict['triangle_neighbors'][0] == [-1,2,3],
    12601260                        'test_Mesh2IODict failed. test 6')
    1261         self.failUnless( dict['triangle_markers'][0] == ["1.3"],
     1261        self.failUnless( dict['triangle_tags'][0] == ["1.3"],
    12621262                         'test_Mesh2IODict failed. test 7')
    12631263
     
    12741274        self.failUnless( dict['outline_segments'][0] == [0,1],
    12751275                        '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,
    12781278                        'test_Mesh2IODict failed. test 4')
    12791279        for holeimp,holeactual in map(None,dict['holes'],holes):
     
    12811281                        'test_Mesh2IODict failed. test 5')
    12821282       
    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']):
    12841284            self.failUnless( regimp == [regactual.x,regactual.y],
    12851285                        'loadASCIITestCase failed. test 6')
     
    13031303        e = Vertex (1.0,1.0 , attributes =e_att)
    13041304   
    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")
    13091309     
    13101310        r1 = Region(0.3, 0.3,tag = "1.3", maxArea = 45)
     
    13321332        self.failUnless( dict['outline_segments'][0] == [0,1],
    13331333                        '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,
    13361336                        'loadASCIITestCase failed. test 4')
    13371337        for holeimp,holeactual in map(None,dict['holes'],holes):
     
    13471347
    13481348           
    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']):
    13501350            self.failUnless( regimp == [regactual.x,regactual.y],
    13511351                        'loadASCIITestCase failed. test 6')
  • inundation/ga/storm_surge/pmesh/pmesh.py

    r958 r969  
    111111                                 label='Export ASCII obj',
    112112                                 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)
    118118       
    119119        self.menuBar.addmenuitem('File', 'command',
  • inundation/ga/storm_surge/pmesh/visualmesh.py

    r407 r969  
    211211 
    212212    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)
    215215        if ask_int >= 0:
    216             selMeshObject.marker = ask_int
     216            selMeshObject.tag = ask_int
    217217           
    218218    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))
    221221        if ask_string != None:
    222             selMeshObject.marker = ask_string
     222            selMeshObject.tag = ask_string
    223223            userMeshChanged = True
    224224        return userMeshChanged
    225225   
    226226    def defaultWindow(self, canvas):
    227         ask_string = askstring("Edit Default Segment Tag", "Marker",
     227        ask_string = askstring("Edit Default Segment Tag", "Tag",
    228228                     initialvalue= str(self.association.get_default_tag()))
    229229        if ask_string != None:
  • inundation/ga/storm_surge/pyvolution/pmesh2domain.py

    r968 r969  
    1414    from domain import Domain
    1515
    16     vertex_coordinates, volumes, marker_dict, vertex_quantity_dict ,tagged_elements_dict = \
     16    vertex_coordinates, volumes, tag_dict, vertex_quantity_dict ,tagged_elements_dict = \
    1717                        pmesh_to_domain(fileName,
    1818                                                   setting_function=setting_function)
     
    2222
    2323   
    24     domain = DomainClass(vertex_coordinates, volumes, marker_dict,
     24    domain = DomainClass(vertex_coordinates, volumes, tag_dict,
    2525                         tagged_elements = tagged_elements_dict )
    2626
     
    5656    generated point attribute list:[(P1att1,P1attt2, ...),(P2att1,P2attt2,...),...]
    5757    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)
    5959    triangle list:  [(point1,point2, point3),(p5,p4, p1),...] (Tuples of integers)
    6060    triangle neighbor list: [(triangle1,triangle2, triangle3),(t5,t4, t1),...] (Tuples of integers) -1 means there's no triangle neighbor
     
    8383    for quantity, value_vector in map (None, point_titles, point_atts):
    8484        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)
    8686    tagged_elements_dict = build_tagged_elements_dictionary(mesh_dict)
    87     return vertex_coordinates, volumes, marker_dict, vertex_quantity_dict,tagged_elements_dict
     87    return vertex_coordinates, volumes, tag_dict, vertex_quantity_dict,tagged_elements_dict
    8888
    8989
     
    9595    { (tag): [e1, e2, e3..] }
    9696    """
    97     tri_atts = mesh_dict['triangle_markers']
     97    tri_atts = mesh_dict['triangle_tags']
    9898    #print "tri_atts", tri_atts
    9999    tagged_elements = {}
     
    117117# I'm happy for it to change. -DSG
    118118
    119 def pmesh_dict_to_marker_dict(mesh_dict):
     119def pmesh_dict_to_tag_dict(mesh_dict):
    120120    """ 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.
    122122    """
    123123    triangles = mesh_dict['triangles']
    124124    sides = calc_sides(triangles)
    125     marker_dict = {}
    126     for seg, marker in 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']):
    128128        v1 = seg[0]
    129129        v2 = seg[1]
    130130        for key in [(v1,v2),(v2,v1)]:
    131             if sides.has_key(key) and marker <> "":
     131            if sides.has_key(key) and tag <> "":
    132132                #"" represents null.  Don't put these into the dictionary
    133                 #this creates a dict of lists of faces, indexed by marker
    134                 #tagged_edges.setdefault(marker,[]).append(sides[key])
    135                 marker_dict[sides[key]] = marker
     133                #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
    136136
    137     return marker_dict
     137    return tag_dict
    138138
    139139   
  • inundation/ga/storm_surge/pyvolution/test_least_squares.py

    r968 r969  
    892892        mesh_dic['triangles'] =  [[0, 2, 1]]
    893893        mesh_dic['segments'] = [[0, 1], [2, 0], [1, 2]]
    894         mesh_dic['triangle_markers'] = [['']]
     894        mesh_dic['triangle_tags'] = [['']]
    895895        mesh_dic['vertex_attributes'] = [[], [], []]
    896896        mesh_dic['vertiex_attribute_titles'] = []
    897897        mesh_dic['triangle_neighbors'] = [[-1, -1, -1]]
    898         mesh_dic['segment_markers'] = ['external',
     898        mesh_dic['segment_tags'] = ['external',
    899899                                                  'external',
    900900                                                  'external']       
     
    942942        mesh_dic['triangles'] =  [[0, 2, 1]]
    943943        mesh_dic['segments'] = [[0, 1], [2, 0], [1, 2]]
    944         mesh_dic['triangle_markers'] = [['']]
     944        mesh_dic['triangle_tags'] = [['']]
    945945        mesh_dic['vertex_attributes'] = [[1,2], [1,2], [1,2]]
    946946        mesh_dic['vertex_attribute_titles'] = ['density', 'temp']
    947947        mesh_dic['triangle_neighbors'] = [[-1, -1, -1]]
    948         mesh_dic['segment_markers'] = ['external',
     948        mesh_dic['segment_tags'] = ['external',
    949949                                                  'external',
    950950                                                  'external']       
  • inundation/ga/storm_surge/pyvolution/test_pmesh2domain.py

    r968 r969  
    50500 0 3 2 -1  -1  1 dsg\n\
    51511 0 1 3 -1  0 -1   ole nielsen\n\
    52 4 # <segment #> <vertex #>  <vertex #> [boundary marker] \n\
     524 # <segment #> <vertex #>  <vertex #> [boundary tag] \n\
    53530 1 0 2 \n\
    54541 0 2 3 \n\
     
    59591 160.0 -167.0 \n \
    60602 114.0 -91.0 \n \
    61 3 # <vertex #>  <vertex #> [boundary marker] ...Mesh Segments... \n \
     613 # <vertex #>  <vertex #> [boundary tag] ...Mesh Segments... \n \
    62620 0 1 0 \n \
    63631 1 2 0 \n \
     
    121121         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]]
    122122         meshDict['triangles'] = [[0,3,2],[0,1,3]]
    123          meshDict['triangle_markers'] = [6.6,6.6]
     123         meshDict['triangle_tags'] = [6.6,6.6]
    124124         meshDict['triangle_neighbors'] = [[-1,-1,1],[-1,0,-1]]
    125125         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]
    127127       
    128128         domain = Domain.pmesh_dictionary_to_domain(meshDict)
    129129
    130          #domain.set_marker_dict(marker_dict)
     130         #domain.set_tag_dict(tag_dict)
    131131         #Boundary tests
    132132         b1 =  Dirichlet_boundary(conserved_quantities = array([0.0]))
  • inundation/ga/storm_surge/pyvolution/util.py

    r957 r969  
    398398            else:
    399399                q[i] = Q[self.index, point_id]
     400
     401
    400402
    401403        #Return vector of interpolated values
Note: See TracChangeset for help on using the changeset viewer.