Ignore:
Timestamp:
Oct 18, 2004, 1:53:59 PM (20 years ago)
Author:
duncan
Message:

added element tags to Domain

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/pmesh2domain.py

    r389 r415  
    88
    99
    10 def pmesh_to_domain_instance(fileName, DomainClass,tags = None, setting_function = None):
     10def pmesh_to_domain_instance(fileName, DomainClass, setting_function = None):
    1111    """
    1212    """
    13     #FIXME:  The current design doesn't seem to accomadate tags
    14     #  being passed into the domain at this point.
    15 
    1613    import sys
    1714    from domain import Domain
    1815
    19     vertex_coordinates, volumes, marker_dict, vertex_quantity_dict = \
     16    vertex_coordinates, volumes, marker_dict, vertex_quantity_dict ,tagged_elements_dict = \
    2017                        pmesh_to_domain(fileName,
    2118                                                   setting_function=setting_function)
    2219       
    2320    assert issubclass(DomainClass, Domain), "DomainClass is not a subclass of Domain."
    24     domain = DomainClass(vertex_coordinates, volumes, marker_dict)
     21    domain = DomainClass(vertex_coordinates, volumes, marker_dict,
     22                         tagged_elements = tagged_elements_dict )
    2523
    2624    # set the water level to be the elevation
     
    4442    triangle list:  [(point1,point2, point3),(p5,p4, p1),...] (Tuples of integers)
    4543    triangle neighbor list: [(triangle1,triangle2, triangle3),(t5,t4, t1),...] (Tuples of integers) -1 means there's no triangle neighbor
    46     triangle attribute list: [T1att, T2att, ...] (list of floats)
     44    triangle attribute list: [T1att, T2att, ...] (list of strings)
    4745    """
    4846   
     
    6967    for quantity, value_vector in map (None, point_titles, point_atts):
    7068        vertex_quantity_dict[quantity] = value_vector
    71     marker_dict = pmesh_dict_to_marker_dict(volumes, mesh_dict,
    72                                             vertex_coordinates)
    73    
    74     return vertex_coordinates, volumes, marker_dict, vertex_quantity_dict
     69    marker_dict = pmesh_dict_to_marker_dict(mesh_dict)
     70    tagged_elements_dict = build_tagged_elements_dictionary(mesh_dict)
     71    return vertex_coordinates, volumes, marker_dict, vertex_quantity_dict,tagged_elements_dict
    7572
    7673
    7774
     75def build_tagged_elements_dictionary(mesh_dict):
     76    """Build the dictionary of element tags.
     77    tagged_elements is a dictionary of element arrays,
     78    keyed by tag:
     79    { (tag): [e1, e2, e3..] }
     80    """
     81    tri_atts = mesh_dict['generatedtriangleattributelist']
     82    #print "tri_atts", tri_atts
     83    tagged_elements = {}
     84    for tri_att_index in range(len(tri_atts)):
     85        tagged_elements.setdefault(tri_atts[tri_att_index][0],[]).append(tri_att_index)
     86    #print "DSG pm2do tagged_elements", tagged_elements
     87    return tagged_elements
    7888
    7989#FIXME: The issue is whether this format should be stored in the tsh file
     
    8595#using netCDF.
    8696
    87    
    88 def pmesh_dict_to_marker_dict(triangles,mesh_dict,Vertices):
     97def pmesh_dict_to_marker_dict(mesh_dict):
    8998    """ Convert the pmesh dictionary (mesh_dict) description of boundary tags
    9099    to a dictionary of markers, indexed with volume id and face number.
    91100    """
     101    triangles = mesh_dict['generatedtrianglelist']
    92102    sides = calc_sides(triangles)
    93103    marker_dict = {}
Note: See TracChangeset for help on using the changeset viewer.