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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.