Changeset 4939


Ignore:
Timestamp:
Jan 15, 2008, 7:20:01 PM (16 years ago)
Author:
ole
Message:

Moved data_audit to utilities

Caching work on Joaquim Luis example

Files:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • anuga_work/development/joaqium_luis/run.py

    r4925 r4939  
    2828from anuga.abstract_2d_finite_volumes.util import file_function
    2929
     30from anuga.caching import cache
     31from anuga.utilities.polygon import read_polygon, plot_polygons, \
     32                                    polygon_area, is_inside_polygon
    3033
    3134#------------------------------------------------------------------------------
     
    3740    os.mkdir(scenario)
    3841basename = scenario + 'source'
     42
     43#------------------
     44# Initial condition
     45#------------------
     46tide = 0.0
     47
    3948
    4049#------------------------------------------------------------------------------
     
    4958meshname = 'bocarra.msh'
    5059
    51 # Create DEM from asc data
    52 #convert_dem_from_ascii2netcdf(dem_name, use_cache=True, verbose=True)
    5360
    54 # Create pts file for onshore DEM
    55 #dem2pts(dem_name, use_cache=True, verbose=True)
    56 
    57 from anuga.utilities.polygon import read_polygon, plot_polygons, \
    58                                     polygon_area, is_inside_polygon
    59 
    60 ###############################
    61 # Domain definitions
    62 ###############################
     61#---------
     62# Polygons
     63#---------
    6364
    6465# bounding polygon for study area
     
    6768print 'Area of bounding polygon in km?', polygon_area(bounding_polygon)/1000000.0
    6869
    69 ###############################
    70 # Interior region definitions
    71 ###############################
    72 
    7370# interior polygons
    7471#poly_midle = read_polygon('midle_rect.csv')
    7572poly_shallow = read_polygon('shallow.csv')
    7673
    77 #------------------------------------------------------------------------------
    78 # Create the triangular mesh based on overall clipping polygon with a tagged
    79 # boundary and interior regions defined in project.py along with
    80 # resolutions (maximal area of per triangle) for each polygon
    81 #------------------------------------------------------------------------------
    8274
     75#------------
     76# Resolutions
     77#------------
    8378remainder_res = 2000
    8479midle_res = 3500
    8580shallow_res = 100
    86 interior_regions = [[bounding_polygon, remainder_res], [poly_shallow, shallow_res]]
    87 #interior_regions = [[bounding_polygon, remainder_res], [poly_midle, midle_res], [poly_shallow, shallow_res]]
    8881
    89 create_mesh_from_regions(bounding_polygon,
    90                          boundary_tags={'west': [0],
    91                                         'north': [1],
    92                                         'east': [2],
    93                                         'south': [3]},
    94                          maximum_triangle_area=remainder_res,
    95                          filename=meshname,
    96                          interior_regions=interior_regions,
    97                          use_cache=True, verbose=True)
     82interior_regions = [[poly_shallow, shallow_res]]
    9883
    99 #------------------------------------------------------------------------------
    100 # Setup computational domain
    101 #------------------------------------------------------------------------------
     84def setup_domain(tide,
     85                 bounding_polygon,
     86                 remainder_res,                 
     87                 interior_regions,
     88                 mesh_filename,
     89                 points_filename):
     90    """Set up domain except boundary conditions
     91    This function is defined in order to cache it.
     92    """
    10293
    103 domain = Domain(meshname, use_cache=True, verbose=True)
    10494
    105 print 'Number of triangles = ', len(domain)
    106 print 'The extent is ', domain.get_extent()
    107 print domain.statistics()
    10895
    109 domain.set_name(basename)
    110 domain.set_datadir(scenario)
    111 domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
    112 #domain.set_quantities_to_be_stored('stage')
    113 domain.set_minimum_storable_height(0.05)
    11496
    115 #------------------------------------------------------------------------------
    116 # Setup initial conditions
    117 #------------------------------------------------------------------------------
    11897
    119 tide = 0.0
    120 domain.set_quantity('stage', tide)
    121 domain.set_quantity('friction', 0.025)
    122 domain.set_quantity('elevation', filename=dem_name + '.pts',
    123                     use_cache=True, verbose=True, alpha=0.1)
     98    create_mesh_from_regions(bounding_polygon,
     99                             boundary_tags={'west': [0],
     100                                            'north': [1],
     101                                            'east': [2],
     102                                            'south': [3]},
     103                             maximum_triangle_area=remainder_res,
     104                             filename=mesh_filename,
     105                             interior_regions=interior_regions,
     106                             use_cache=False,
     107                             verbose=True)
     108
     109    #--------------------------------------------------------------------------
     110    # Setup computational domain
     111    #--------------------------------------------------------------------------
     112
     113    domain = Domain(mesh_filename,
     114                    use_cache=False,
     115                    verbose=True)
     116
     117    print 'Number of triangles = ', len(domain)
     118    print 'The extent is ', domain.get_extent()
     119    print domain.statistics()
     120
     121    domain.set_name(basename)
     122    domain.set_datadir(scenario)
     123    domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
     124    domain.set_minimum_storable_height(0.05)
     125
     126    #--------------------------------------------------------------------------
     127    # Setup initial conditions
     128    #--------------------------------------------------------------------------
     129
     130    domain.set_quantity('stage', tide)
     131    domain.set_quantity('friction', 0.025)
     132    domain.set_quantity('elevation',
     133                        filename=points_filename,
     134                        use_cache=False,
     135                        verbose=True)
     136
     137    return domain
     138   
     139
     140#--------------------------------   
     141# Call (and cache) setup function
     142#--------------------------------   
     143
     144# Run set_up domain without caching
     145#domain = setup_domain(tide, bounding_polygon, poly_shallow,
     146#                      remainder_res, midle_res, shallow_res,
     147#                      meshname,
     148#                      dem_name + '.pts')
     149
     150# Run set_up domain with caching
     151domain = cache(setup_domain,
     152               (tide,
     153                bounding_polygon,
     154                remainder_res,
     155                interior_regions,
     156                meshname,
     157                dem_name + '.pts'),
     158               #dependencies =
     159               verbose=True)           
     160
     161
    124162
    125163#------------------------------------------------------------------------------
     
    127165#------------------------------------------------------------------------------
    128166
    129 # Create boundary function from timeseries provided in file
    130 #function1 = file_function('mareg.tms', domain, verbose=True)
    131 
    132 # Create and assign boundary objects
    133 #Bts1 = Transmissive_Momentum_Set_Stage_boundary(domain, function1)
    134 
    135167print 'Available boundary tags', domain.get_boundary_tags()
    136 #Bt = Transmissive_boundary(domain)    # Continue all values on boundary
    137168Br = Reflective_boundary(domain)
    138169Bd = Dirichlet_boundary([tide,0,0])
     
    140171                    use_cache=True, verbose=True)
    141172   
    142 #Boundary condition for sww feed at the east boundary
     173# Boundary condition for sww feed at the east boundary
    143174domain.set_boundary({'west': Bf,'south':Bf,'east': Br,'north': Br})
     175
    144176   
    145177#------------------------------------------------------------------------------
     
    153185from anuga.abstract_2d_finite_volumes.quantity import Quantity
    154186
    155 
    156 # save every 1 sec leading up to wave approaching land
     187# Save every 1 sec leading up to wave approaching land
    157188for t in domain.evolve(yieldstep = 10, finaltime = 90):
    158189    domain.write_time()
  • create_distribution.py

    r4931 r4939  
    2929from anuga.abstract_2d_finite_volumes.util import store_version_info
    3030from anuga.anuga_config import major_revision
     31
     32from anuga.utilities.data_audit import identify_data_files
    3133
    3234
     
    118120
    119121
    120 from data_audit import identify_data_files
    121122identify_data_files(distro_dir)
    122123
Note: See TracChangeset for help on using the changeset viewer.