Changeset 389 for inundation
- Timestamp:
- Oct 12, 2004, 2:45:24 PM (20 years ago)
- Location:
- inundation/ga/storm_surge/pyvolution
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/domain.py
r278 r389 125 125 return q 126 126 127 128 def set_quantity_vertices_dict(self, quantity_dict): 129 """Set values for named quantities. 130 The index is the quantity 131 132 name: Name of quantity 133 X: Compatible list, Numeric array, const or function (see below) 134 135 The values will be stored in elements following their 136 internal ordering. 137 138 """ 139 for key in quantity_dict.keys(): 140 self.set_quantity(key,quantity_dict[key], location='vertices') 141 127 142 def set_quantity(self, name, X, location='vertices'): 128 143 """Set values for named quantity -
inundation/ga/storm_surge/pyvolution/interpolate_sww.py
r374 r389 116 116 volumes = fid.variables['volumes'][:] 117 117 time = fid.variables['time'][:] 118 stage = fid.variables['stage'][:,:] # 2D 118 stage = fid.variables['stage'][:,:] # 2D 119 119 120 120 fid.close() -
inundation/ga/storm_surge/pyvolution/least_squares.py
r374 r389 62 62 point_dict = load_xya_file(point_file) 63 63 point_coordinates = point_dict['pointlist'] 64 point_attributes = point_dict['pointattributelist']65 64 point_attributes = point_dict['pointattributelist'] 66 65 title_string = point_dict['title'] -
inundation/ga/storm_surge/pyvolution/pmesh2domain.py
r374 r389 8 8 9 9 10 def pmesh_to_domain (fileName,tags = None, setting_function = None):10 def pmesh_to_domain_instance(fileName, DomainClass,tags = None, setting_function = None): 11 11 """ 12 12 """ 13 #FIXME: The current design doesn't seem to accomadate tags and14 # setting_functionsbeing passed into the domain at this point.13 #FIXME: The current design doesn't seem to accomadate tags 14 # being passed into the domain at this point. 15 15 16 #FIXME: Plus the names of the functions are no longer appropriate,17 #since domain objects aren't being returned.18 19 16 import sys 20 from config import pmesh_filename 21 sys.path.append(pmesh_filename) 22 from load_mesh.loadASCII import import_trianglulation 17 from domain import Domain 23 18 24 try: 25 meshdic = import_trianglulation(fileName) 26 except IOError, e: 27 msg = 'Could not open file %s ' %fileName 28 raise IOError, msg 19 vertex_coordinates, volumes, marker_dict, vertex_quantity_dict = \ 20 pmesh_to_domain(fileName, 21 setting_function=setting_function) 22 23 assert issubclass(DomainClass, Domain), "DomainClass is not a subclass of Domain." 24 domain = DomainClass(vertex_coordinates, volumes, marker_dict) 29 25 30 31 return pmesh_dictionary_to_domain(meshdic, 32 setting_function = setting_function) 26 # set the water level to be the elevation 27 if vertex_quantity_dict.has_key('elevation') and not vertex_quantity_dict.has_key('level'): 28 vertex_quantity_dict['level'] = vertex_quantity_dict['elevation'] 29 domain.set_quantity_vertices_dict(vertex_quantity_dict) 30 #print "vertex_quantity_dict",vertex_quantity_dict 31 return domain 33 32 34 33 35 34 36 def pmesh_ dictionary_to_domain(meshdic, setting_function = None):35 def pmesh_to_domain(fileName, setting_function = None): 37 36 """ 38 37 convert a pmesh dictionary to a list of Volumes. 39 38 Also, return a list of triangles which have boundary tags 40 mesh dicstructure;39 mesh_dict structure; 41 40 generated point list: [(x1,y1),(x2,y2),...] (Tuples of doubles) 42 41 generated point attribute list:[(P1att1,P1attt2, ...),(P2att1,P2attt2,...),...] … … 47 46 triangle attribute list: [T1att, T2att, ...] (list of floats) 48 47 """ 49 50 vertex_coordinates = meshdic['generatedpointlist'] 51 volumes = meshdic['generatedtrianglelist'] 48 49 from Numeric import transpose 50 from load_mesh.loadASCII import mesh_file_to_mesh_dictionary 51 52 mesh_dict = mesh_file_to_mesh_dictionary(fileName) 53 #print "mesh_dict",mesh_dict 54 vertex_coordinates = mesh_dict['generatedpointlist'] 55 volumes = mesh_dict['generatedtrianglelist'] 52 56 53 57 #if setting_function: … … 55 59 # setting_function = [setting_function] 56 60 # for funct in setting_function: 57 # mesh dic = funct(meshdic, vertices = mesh_vertices,61 # mesh_dict = funct(mesh_dict, vertices = mesh_vertices, 58 62 # volumes = volumes) 59 60 marker_dict = pmesh_dict_to_marker_dict(volumes, meshdic, 63 64 65 vertex_quantity_dict = {} 66 point_atts = transpose(mesh_dict['generatedpointattributelist']) 67 point_titles = mesh_dict['generatedpointattributetitlelist'] 68 #print "point_titles",point_titles 69 for quantity, value_vector in map (None, point_titles, point_atts): 70 vertex_quantity_dict[quantity] = value_vector 71 marker_dict = pmesh_dict_to_marker_dict(volumes, mesh_dict, 61 72 vertex_coordinates) 62 63 return vertex_coordinates, volumes, marker_dict 73 74 return vertex_coordinates, volumes, marker_dict, vertex_quantity_dict 64 75 65 76 … … 75 86 76 87 77 def pmesh_dict_to_marker_dict(triangles,mesh dic,Vertices):78 """ Convert the pmesh dictionary (mesh dic) description of boundary tags88 def pmesh_dict_to_marker_dict(triangles,mesh_dict,Vertices): 89 """ Convert the pmesh dictionary (mesh_dict) description of boundary tags 79 90 to a dictionary of markers, indexed with volume id and face number. 80 91 """ 81 92 sides = calc_sides(triangles) 82 93 marker_dict = {} 83 for seg, marker in map(None,mesh dic['generatedsegmentlist'],84 mesh dic['generatedsegmentmarkerlist']):94 for seg, marker in map(None,mesh_dict['generatedsegmentlist'], 95 mesh_dict['generatedsegmentmarkerlist']): 85 96 v1 = seg[0] 86 97 v2 = seg[1] -
inundation/ga/storm_surge/pyvolution/quantity.py
r344 r389 56 56 def __len__(self): 57 57 return self.centroid_values.shape[0] 58 58 59 59 def interpolate(self): 60 60 """Compute interpolated values at edges and centroid … … 201 201 if len(values.shape) == 1: 202 202 #Values are being specified once for each unique vertex 203 msg = 'Number of values must ma ctnumber of vertices'203 msg = 'Number of values must match number of vertices' 204 204 assert values.shape[0] == self.domain.coordinates.shape[0], msg 205 205 … … 218 218 219 219 220 220 # FIXME have a get_vertex_values as well, so the 'level' quantity can be 221 # set, based on the elevation 221 222 def set_vertex_values(self, A): 222 223 """Set vertex values for all triangles based on input array A -
inundation/ga/storm_surge/pyvolution/run_tsh.py
r309 r389 16 16 17 17 from mesh_factory import rectangular 18 from pmesh2domain import pmesh_to_domain 18 from pmesh2domain import pmesh_to_domain, pmesh_to_domain_instance 19 19 20 20 from Numeric import array … … 30 30 31 31 print 'Creating domain from', filename 32 points, vertices, boundary = pmesh_to_domain(filename) 33 domain = Domain(points, vertices, boundary) 32 domain = pmesh_to_domain_instance(filename, Domain) 34 33 print "Number of triangles = ", len(domain) 35 34 … … 48 47 print 'Field values' 49 48 50 domain.set_quantity('elevation', W)49 #domain.set_quantity('elevation', W) 51 50 domain.set_quantity('friction', manning) 52 51 … … 73 72 74 73 #Set boundary conditions 75 domain.set_boundary({'left': Bw, '0': Br })74 domain.set_boundary({'left': Bw, '0': Br, '1':Bw, 'external':Br}) 76 75 76 77 print domain.quantities['elevation'].vertex_values 78 #print domain.quantities['level'].vertex_values 79 77 80 ###################### 78 81 #Initial condition 79 82 print 'Initial condition' 80 domain.set_quantity('level', Constant_height(W, 0.))83 #domain.set_quantity('level', Constant_height(W, 0.)) 81 84 domain.check_integrity() 82 85
Note: See TracChangeset
for help on using the changeset viewer.