Changeset 6077
- Timestamp:
- Dec 15, 2008, 4:56:07 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
r6075 r6077 33 33 34 34 # OLE How do I get the Domain Points to create a LIST of Points from the File ??? 35 35 import Numeric 36 36 37 37 #------------------------------------------------------------------------------ … … 39 39 #------------------------------------------------------------------------------ 40 40 41 points='ANUGA_MeshPts.csv' 42 vertices='ANUGA_MeshVertices.csv' 41 42 43 44 points=[] 45 fid = open('ANUGA_MeshPts.csv') 46 for lines in fid.readlines(): 47 if lines.strip() == '': continue 48 fields = lines.split(',') 49 x = float(fields[0]) 50 y = float(fields[1]) 51 points.append([x,y]) 52 fid.close() 53 54 vertices = [] 55 fid = open('ANUGA_MeshVertices.csv') 56 for lines in fid.readlines(): 57 if lines.strip() == '': continue 58 fields = lines.split(',') 59 i = int(fields[0]) 60 j = int(fields[1]) 61 k = int(fields[2]) 62 vertices.append([i,j,k]) 63 fid.close() 64 65 boundary=None # Deal with this later 66 67 #print points 68 #print vertices 43 69 domain = Domain(points, vertices, boundary) # Create domain 70 domain.check_integrity() 44 71 45 72 #------------------------------------------------------------------------------ … … 58 85 59 86 87 #------------------------------------------------------------------------------ 88 # BOUNDARY CONDITIONS 89 #------------------------------------------------------------------------------ 60 90 91 Br = Reflective_boundary(domain) 92 domain.set_boundary({'exterior': Br}) # Default tag 61 93 62 94 #------------------------------------------------------------------------------ … … 66 98 import time 67 99 t0 = time.time() 68 if answer2 == 1:69 for t in domain.evolve(yieldstep = 30, finaltime = 5000):70 domain.write_time()71 domain.write_boundary_statistics(tags='east', quantities='stage')72 if answer2 == 3:73 for t in domain.evolve(yieldstep = 30, finaltime = 3600):74 domain.write_time()75 domain.write_boundary_statistics(tags='east', quantities='stage')76 100 101 for t in domain.evolve(yieldstep = 10, finaltime = 100): 102 domain.write_time() 103 domain.write_boundary_statistics(quantities='stage') 77 104 78 print ' END OF RUN............'105 print 'That took', time.time() - t0, 'seconds' 79 106 -
anuga_work/development/river2d_integration/River2DMesh_ANUGAMesh.py
r6061 r6077 20 20 print "\nFILES are open ready for conversion....\n" 21 21 22 read pts=023 type=1 24 blank_line_count=022 reading_points = True 23 reading_vertices = False 24 last_point_index = 0 25 25 for line in infid.readlines(): 26 print 'line', line 26 print 'line', line.strip() 27 28 if line.strip() == '': 29 continue 27 30 28 #print 'type = ',type 29 if line.strip() == '': 30 #blank_line_count=blank_line_count+1 31 type=2 # blank line 31 if line.lower().startswith('no more nodes'): 32 reading_vertices = True 33 reading_points = False 32 34 continue 33 34 print 'readpts= %i, Type = %i Blank Line = %i'%(readpts, type, blank_line_count) 35 if readpts==0 and type==1: # Start to read Points 35 36 if line.lower().startswith('no more boundary segments'): 37 break 38 39 if reading_points is True: # Read Points 40 41 # Check that point indices are consecutive 42 s = line[:5] 43 index = int(s.strip()) 44 assert index-1 == last_point_index 45 last_point_index = index 46 47 # Get points 36 48 s = line[9:38] 37 49 fields = s.split(' ') 38 50 x=float(fields[0]) 39 51 y=float(fields[1]) 40 #z=float(fields[3]) 41 outfid1.write('%.3f,%.3f\n' %(x, y)) 42 elif readpts==1 and blank_line_count==2: # Start to read Vertices 52 #z=float(fields[3]) # TODO: Get elevation data a separate list 53 outfid1.write('%.3f, %.3f\n' % (x, y)) 54 55 elif reading_vertices is True: # Read Vertices 43 56 fields = line.split(' ') 44 pt1=int(line[1:6])45 pt2=int(line[10:16])46 pt3=int(line[20:26])47 outfid2.write('%i,%i,%i\n' %(pt1, pt2,pt3))48 57 49 if line=='no more boundary segments.': 50 print 'no more Vertices ALL DONE!!!!' 51 type=5 # End of File can stop processing 52 if line=='no more nodes.': 53 print 'no more nodes!!!!' 54 type=3 # End of Points 55 readpts=1 56 if line.strip() == '': 57 blank_line_count=blank_line_count+1 58 type=4 # blank line 59 readpts=1 58 # Create indices and make them start from 0 59 pt1=int(line[1:6]) - 1 60 pt2=int(line[10:16]) - 1 61 pt3=int(line[20:26]) - 1 62 outfid2.write('%d, %d, %d\n' % (pt1, pt2,pt3)) 63 60 64 61 65 outfid1.close() 62 66 outfid2.close() 63 67 print "\nConversion complete.\n" 64 raw_input("Press ENTER to exit.\n") 68
Note: See TracChangeset
for help on using the changeset viewer.