Changeset 4131


Ignore:
Timestamp:
Jan 5, 2007, 2:30:04 PM (18 years ago)
Author:
nick
Message:

add "number_mesh_triangles" to polygon, given interior regions and bounding poly returns approx number of triangles in mesh

also
editted screen_catcher in util.py

Location:
anuga_core/source/anuga
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/util.py

    r4125 r4131  
    502502##################### end of obsolete stuff ? ############
    503503
    504 def start_screen_catcher(dirname, myid=0, numprocs=1):
     504def start_screen_catcher(dir_name, myid=0, numprocs=1):
    505505    """Used to store screen output and errors to file, if run on multiple
    506506    processes eachprocessor will have its own output and error file.
    507507    """
    508508
    509     dirname = dirname
    510     screen_output_name = dirname + "screen_output_%d_%d.txt" %(myid,numprocs)
    511     screen_error_name = dirname + "screen_error_%d_%d.txt" %(myid,numprocs)
    512 
     509    dir_name = dir_name
     510    if access(dir_name,F_OK) == 0:
     511        print 'Make directory %s' %dir_name
     512        mkdir (dir_name,0777)
     513    screen_output_name = dir_name + "screen_output_%d_%d.txt" %(myid,numprocs)
     514    screen_error_name = dir_name + "screen_error_%d_%d.txt" %(myid,numprocs)
     515   
    513516    #used to catch screen output to file
    514517    sys.stdout = Screen_Catcher(screen_output_name)
     
    522525    def __init__(self, filename):
    523526        self.filename = filename
     527 
    524528        if exists(self.filename)is True:
    525529            remove(self.filename)
  • anuga_core/source/anuga/utilities/polygon.py

    r4095 r4131  
    737737    FIXME: Add tests for this function
    738738    """
    739     import polygon_area
     739    from anuga.utilities.polygon import polygon_area
    740740   
    741741    # TO DO check if any of the regions fall inside one another
    742742    no_triangles = 0.0
    743743    area = polygon_area(bounding_poly)
     744#    print 'area of bounding_poly with res ',remainder_res,' is ', area/1000000.
    744745    for i,j in interior_regions:
    745746        this_area = polygon_area(i)
    746         no_triangles += this_area/j
     747        this_triangles = this_area/j
     748        no_triangles += this_triangles
    747749        area -= this_area
    748750        #convert to square Kms
    749         print 'area of ',j, this_area/1000000., area/1000000.
    750     no_triangles += area/remainder_res
     751        print 'area of',j, 'trigs', this_triangles, 'this area', this_area/1000000.
     752    bound_triangles = area/remainder_res
     753    no_triangles += bound_triangles
     754    print 'area of',remainder_res,'bound triangles:', bound_triangles, 'bound area:', area/1000000.
    751755    return int(no_triangles/0.7)
    752 
    753756
    754757
Note: See TracChangeset for help on using the changeset viewer.