Changeset 3931


Ignore:
Timestamp:
Nov 7, 2006, 2:47:20 PM (18 years ago)
Author:
nick
Message:

generic_boundary_conditions.py updated to allow caching and thinning of boundary sww file to reduce computation time
util.py now has start_screen_catcher and copy_code_files used for information management

Location:
anuga_core/source/anuga/abstract_2d_finite_volumes
Files:
3 edited

Legend:

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

    r3847 r3931  
    185185    # rather than File_boundary
    186186
    187     def __init__(self, filename, domain, verbose = False):
     187    def __init__(self, filename, domain, time_thinning=1,
     188                 use_cache=False, verbose=False):
    188189        import time
    189190        from Numeric import array, zeros, Float
     
    240241        self.F = file_function(filename, domain,
    241242                               interpolation_points=self.midpoint_coordinates,
    242                                verbose=verbose)
     243                           time_thinning=time_thinning,
     244                           use_cache=use_cache,
     245                           verbose=verbose)
    243246        self.domain = domain
    244247
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py

    r3563 r3931  
    11591159if __name__ == "__main__":
    11601160    suite = unittest.makeSuite(Test_Util,'test')
    1161     #suite = unittest.makeSuite(Test_Util,'test_apply')
     1161    #suite = unittest.makeSuite(Test_Util,'test_get_version_info')
    11621162    runner = unittest.TextTestRunner()
    11631163    runner.run(suite)
  • anuga_core/source/anuga/abstract_2d_finite_volumes/util.py

    r3910 r3931  
    66
    77import anuga.utilities.polygon
     8import sys
     9
     10from os import remove, mkdir, access, F_OK, sep
     11from os.path import exists
    812from warnings import warn
     13from shutil import copy
    914
    1015from anuga.geospatial_data.geospatial_data import ensure_absolute
    11 
    12 
    1316
    1417def file_function(filename,
     
    497500
    498501##################### end of obsolete stuff ? ############
    499 '''
    500 this simply catches the screen output and files it to a file
    501 '''
    502 from os import sep
    503 
    504 class Screen_Catcher:
    505 
     502
     503def start_screen_catcher(dirname, myid, numprocs):
     504    """Used to store screen output and errors to file, if run on multiple
     505    processes eachprocessor will have its own output and error file.
     506    """
     507
     508    dirname = dirname
     509    screen_output_name = dirname + "screen_output_%d_%d.txt" %(myid,numprocs)
     510    screen_error_name = dirname + "screen_error_%d_%d.txt" %(myid,numprocs)
     511
     512    #used to catch screen output to file
     513    sys.stdout = screen_catcher(screen_output_name)
     514    sys.stderr = screen_catcher(screen_error_name)
     515
     516class screen_catcher:
     517    """this simply catches the screen output and stores it to file defined by
     518    start_screen_catcher (above)
     519    """
     520   
    506521    def __init__(self, filename):
    507 #        self.data = ''
    508522        self.filename = filename
     523        if exists(self.filename)is True:
     524            remove(self.filename)
     525            print'Old existing file "%s" has been deleted' %(self.filename)
    509526
    510527    def write(self, stuff):
    511528        fid = open(self.filename, 'a')
    512 #        fid = open(self.filename, 'w')
    513 #        self.data = self.data + stuff
    514529        fid.write(stuff)
    515         fid.close()
    516        
     530
    517531def get_version_info():
    518532    """gets the version number of the SVN
     
    11491163   
    11501164    return texfile2, elev_output
     1165
     1166from os.path import basename
     1167
     1168def copy_code_files(dir_name, filename1, filename2):
     1169    """Copies "filename1" and "filename2" to "dir_name". Very useful for
     1170    information management """
     1171
     1172    if access(dir_name,F_OK) == 0:
     1173        print 'Make directory %s' %dir_name
     1174        mkdir (dir_name,0777)
     1175    copy(filename1, dir_name + sep + basename(filename1))
     1176    copy(filename2, dir_name + sep + basename(filename2))
     1177#    copy (__file__, project.output_run_time_dir + basename(__file__))
     1178    print 'Files %s and %s copied' %(filename1, filename2)
     1179
     1180
     1181
     1182
     1183
Note: See TracChangeset for help on using the changeset viewer.