Changeset 6077


Ignore:
Timestamp:
Dec 15, 2008, 4:56:07 PM (16 years ago)
Author:
ole
Message:

Some work on River2D integration - not working yet, mesh bungled.

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  
    3333
    3434# OLE How do I get the Domain Points to create a LIST of Points from the File ???
    35 
     35import Numeric
    3636
    3737#------------------------------------------------------------------------------
     
    3939#------------------------------------------------------------------------------
    4040
    41 points='ANUGA_MeshPts.csv'
    42 vertices='ANUGA_MeshVertices.csv'
     41
     42
     43
     44points=[]
     45fid = open('ANUGA_MeshPts.csv')
     46for 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])
     52fid.close()
     53
     54vertices = []
     55fid = open('ANUGA_MeshVertices.csv')   
     56for 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])
     63fid.close()
     64
     65boundary=None  # Deal with this later
     66
     67#print points
     68#print vertices
    4369domain = Domain(points, vertices, boundary) # Create domain
     70domain.check_integrity()
    4471
    4572#------------------------------------------------------------------------------
     
    5885
    5986
     87#------------------------------------------------------------------------------
     88#       BOUNDARY CONDITIONS
     89#------------------------------------------------------------------------------
    6090
     91Br = Reflective_boundary(domain)
     92domain.set_boundary({'exterior': Br})  # Default tag
    6193
    6294#------------------------------------------------------------------------------
     
    6698import time
    6799t0 = 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')       
    76100
     101for t in domain.evolve(yieldstep = 10, finaltime = 100):
     102    domain.write_time()
     103    domain.write_boundary_statistics(quantities='stage')     
    77104
    78 print 'END OF RUN............'                 
     105print 'That took', time.time() - t0, 'seconds'                 
    79106   
  • anuga_work/development/river2d_integration/River2DMesh_ANUGAMesh.py

    r6061 r6077  
    2020print "\nFILES are open ready for conversion....\n"
    2121
    22 readpts=0
    23 type=1
    24 blank_line_count=0
     22reading_points = True
     23reading_vertices = False
     24last_point_index = 0
    2525for line in infid.readlines():
    26     print 'line', line
     26    print 'line', line.strip()
     27   
     28    if line.strip() == '':
     29        continue
    2730
    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
    3234        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
    3648        s = line[9:38]
    3749        fields = s.split(' ')
    3850        x=float(fields[0])
    3951        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
    4356        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))
    4857
    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
    6064   
    6165outfid1.close()
    6266outfid2.close()
    6367print "\nConversion complete.\n"
    64 raw_input("Press ENTER to exit.\n")
     68
Note: See TracChangeset for help on using the changeset viewer.