Changeset 6085
- Timestamp:
- Dec 16, 2008, 5:04:35 PM (16 years ago)
- Location:
- anuga_work/development/river2d_integration
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/river2d_integration/Create_Domain_From_Pts_Vert.py
r6077 r6085 74 74 #------------------------------------------------------------------------------ 75 75 76 domain.set_quantity('stage', 1.0) 76 77 77 78 -
anuga_work/development/river2d_integration/River2Dcdg_ANUGAMesh.py
r6083 r6085 20 20 print "\nFILES are open ready for conversion....\n" 21 21 22 lines = infid.readlines() 22 23 23 linecounter =0 24 # Ignore all metadata prior to node information 25 for i, line in enumerate(lines): 26 if line.strip().startswith('Node #'): 27 # Found node information 28 break 29 30 24 31 reading_points = True 25 32 reading_vertices = False 26 33 last_point_index = 0 27 34 28 for line in infid.readlines(): 29 linecounter=linecounter+1 30 print 'line ',linecounter,reading_points, line.strip() 35 for L in lines[i+1:]: 36 line = L.strip() 31 37 32 raw_input("Press ENTER to exit.\n") 33 if linecounter < 35: 34 reading_vertices = False 35 reading_points = False 38 print line 39 40 if line == '': 36 41 continue 37 42 38 if line.st rip() == '':43 if line.startswith('Element Information'): 39 44 continue 40 41 if line.lower().startswith(' node #, coordinates'): 42 raw_input("Press ENTER to exit.\n") 43 reading_vertices = True 44 reading_points = True 45 continue 46 47 if line.lower().startswith(' element #, vtype, gtype, nodes'): 45 46 if line.startswith('Element #'): 48 47 reading_vertices = True 49 48 reading_points = False 50 49 continue 51 50 52 if line.lower().startswith(' boundary element #, vtype, gtype, nodes, boundary condition codes'): 51 if line.startswith('Boundary Element #'): 52 print 'Reached boundary info, not processing yet' 53 53 break 54 54 55 55 if reading_points is True: # Read Points 56 fields = line.split(' ') 56 fields = line.split() 57 58 #print fields, len(fields) 59 60 if len(fields) == 9: 61 # No single character flag 62 x_index = 1 63 elif len(fields) == 10: 64 # Single character flag used in in second column 65 x_index = 2 66 else: 67 print fields, len(fields) 68 raise Exception, 'Bad file format' 69 57 70 # Check that point indices are consecutive 58 71 s = fields[0] 59 print s60 72 index = int(s) 61 73 assert index-1 == last_point_index … … 63 75 64 76 # Get points 65 s = line[11:39] 66 fields = s.split(' ') 67 x=float(fields[0]) 68 y=float(fields[1]) 69 #z=float(fields[3]) # TODO: Get elevation data a separate list 77 x=float(fields[x_index]) 78 y=float(fields[x_index + 1]) 79 #z=float(fields[x_index + 2]) # TODO: Get elevation data a separate list 70 80 outfid1.write('%.3f, %.3f\n' % (x, y)) 71 81 72 82 elif reading_vertices is True: # Read Vertices 73 fields = line.split( ' ')83 fields = line.split() 74 84 75 85 # Create indices and make them start from 0 76 pt1=int( line[1:6]) - 177 pt2=int( line[10:16]) - 178 pt3=int( line[20:26]) - 186 pt1=int(fields[3]) - 1 87 pt2=int(fields[4]) - 1 88 pt3=int(fields[5]) - 1 79 89 outfid2.write('%d, %d, %d\n' % (pt1, pt2,pt3)) 80 90
Note: See TracChangeset
for help on using the changeset viewer.