Changeset 3905


Ignore:
Timestamp:
Nov 1, 2006, 5:01:22 PM (16 years ago)
Author:
nick
Message:

this should be a working version of the parallel code

Location:
anuga_work/production/dampier_2006
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/production/dampier_2006/build_dampier.py

    r3877 r3905  
    6969#-------------------------------------------------------------------------------
    7070
     71'''
    7172# topography directory filenames
    7273onshore_dir_name = project.onshore_dir_name
     
    138139    mkdir (project.topographies_time_dir)
    139140G.export_points_file(project.combined_time_dir_name + '.pts')
    140 
     141'''
    141142#-------------------------------------------------------------------------
    142143# Convert URS to SWW file for boundary conditions
     
    149150print 'minlat=project.north_boundary, maxlat=project.south_boundary',project.north_boundary, project.south_boundary
    150151print 'minlon= project.west_boundary, maxlon=project.east_boundary',project.west_boundary, project.east_boundary
     152print ' maxlon=project.east',project.east
     153
     154#import sys; sys.exit()
    151155
    152156if access(project.boundaries_time_dir,F_OK) == 0:
    153157    mkdir (project.boundaries_time_dir)
     158'''
    154159urs2sww(boundaries_in_dir_name,basename_out= project.boundaries_time_dir_name,
    155160        minlat=project.south_boundary, maxlat=project.north_boundary,
     
    157162        mint=0, maxt= 35000,
    158163        verbose='true')
     164
     165
     166urs2sww(boundaries_in_dir_name, basename_out= project.boundaries_time_dir_name,
     167#        minlat=project.south, maxlat=project.north,
     168#        minlon= project.west, maxlon=project.east,
     169        minlat=project.south_boundary, maxlat=project.north_boundary,
     170        minlon= project.east_boundary, maxlon=project.west_boundary,
     171        mint=0, maxt= 35000,
     172        verbose='true')
    159173'''
    160174from caching import cache
     
    163177       project.boundaries_time_dir_name),
    164178      {'verbose': True,
    165        'minlat': project.south_boundary,
    166        'maxlat': project.north_boundary,
    167        'minlon': project.west_boundary,
    168        'maxlon': project.east_boundary,
     179#       'minlat': project.south_boundary,
     180#       'maxlat': project.north_boundary,
     181#       'minlon': project.west_boundary,
     182#       'maxlon': project.east_boundary,
     183#       'minlat': project.south,
     184#       'maxlat': project.north,
     185#       'minlon': project.west,
     186#       'maxlon': project.east,
    169187       'mint': 0, 'maxt': 35000,
    170188#       'origin': domain.geo_reference.get_origin(),
     
    175193       )
    176194#       dependencies = source_dir + project.boundary_basename + '.sww')
    177 '''        
    178 
    179 
    180 
    181 
    182 
    183 
    184 
    185 
     195   
     196
     197
     198
     199
     200
     201
     202
     203
  • anuga_work/production/dampier_2006/project.py

    r3885 r3905  
    1010     convert_from_latlon_to_utm
    1111
    12 from time import localtime, strftime, gmtime
     12from time import localtime, strftime, gmtime, ctime
    1313from anuga.geospatial_data.geospatial_data import *
     14from anuga.utilities.polygon import read_polygon, plot_polygons, polygon_area
    1415
    1516# file and system info
     
    3536
    3637#mesh_name = 'elevation50m'
    37 boundaries_name = 'dampier'
     38boundaries_name = 'dampier1'
    3839boundaries_source = 'mag_9_corrected'
     40#boundaries_source = 'test'
    3941
    4042tide = 2.4
     43#tide = 0.0
    4144
    4245# topography file names
     
    7679time = strftime('%Y%m%d_%H%M%S',localtime()) #gets time for new dir
    7780gtime = strftime('%Y%m%d_%H%M%S',gmtime()) #gets time for new dir
     81#cctime = strftime('%Y%m%d_%H%M%S',ctime()) #gets time for new dir
    7882build_time = time+'_build'
    7983run_time = time+'_run'
    8084
    8185print 'gtime: ', gtime
     86#print 'ctime: ', cctime
    8287
    8388output_build_time_dir = home+sep+state+sep+scenario_datas_name+sep+'anuga'+sep+'outputs'+sep+build_time+sep
     
    8691boundaries_dir = home+sep+state+sep+scenario_datas_name+sep+'anuga'+sep+'boundaries'+sep
    8792boundaries_time_dir = home+sep+state+sep+scenario_datas_name+sep+'anuga'+sep+'boundaries'+sep+build_time+sep
     93meshes_time_dir = meshes_dir+build_time+sep
    8894
    8995#ideas
     
    117123
    118124meshes_dir_name = meshes_dir + scenario_name
    119 
     125meshes_time_dir_name = meshes_time_dir + scenario_name
    120126#output_build_time_dir_name = output_build_time_dir + scenario_name  #Used by post processing
    121127output_run_time_dir_name = output_run_time_dir + scenario_name  #Used by post processing
     
    136142
    137143#only used to clip boundary condition
    138 north_boundary = north + 0.02
    139 south_boundary = south - 0.02
    140 west_boundary = west - 0.02
    141 east_boundary = east + 0.02
     144#north_boundary = north + 0.02
     145#south_boundary = south - 0.02
     146#west_boundary = west - 0.02
     147#east_boundary = east + 0.02
     148
     149south_boundary = degminsec2decimal_degrees(-21,0,0)
     150#north_boundary = degminsec2decimal_degrees(-19,00,0)
     151north_boundary = degminsec2decimal_degrees(-20,10,0)
     152#west_boundary = degminsec2decimal_degrees(116,0,0)
     153#east_boundary = degminsec2decimal_degrees(118,00,0)
     154west_boundary = degminsec2decimal_degrees(116,10,0)
     155east_boundary = degminsec2decimal_degrees(117,15,0)
    142156
    143157
     
    153167
    154168bounding_polygon, zone =\
    155                   convert_from_latlon_to_utm([p0, p1, p2, p3, p4,
    156                                               p5, p6, p7, p8])
     169                  convert_from_latlon_to_utm([p0, p1, p2, p3, p4,p5, p6, p7, p8])
     170#bounding_polygon, zone =\
     171#                  convert_from_latlon_to_utm([p1, p2, p3, p4, p5, p6, p7])
    157172refzone = zone
    158 
    159173
    160174#Interior regions
     
    177191n_min_area = 7719000
    178192n_max_area = 7725000
     193
     194poly_facility = read_polygon(polygons_dir+'facility.csv')
     195
     196poly_pipeline = read_polygon(polygons_dir+'pipeline.csv')
    179197
    180198#Interior regions
  • anuga_work/production/dampier_2006/run_dampier.py

    r3885 r3905  
    3434from anuga.geospatial_data.geospatial_data import *
    3535from anuga.abstract_2d_finite_volumes.util import Screen_Catcher
    36 from anuga_parallel.parallel_api import distribute, numprocs, myid
     36from anuga_parallel.parallel_api import distribute, numprocs, myid, barrier
    3737
    3838# Application specific imports
    3939import project                 # Definition of file names and polygons
    4040
    41 
    42 
    4341#------------------------------------------------------------------------------
    4442# Copy scripts to time stamped output directory and capture screen
     
    4846# filenames
    4947
    50 build_time = '20061029_231935_build_tide_24'
     48#build_time = '20061029_231935_build_tide_24'
     49build_time = '20061030_165746_build_tide_24'
     50#build_time = '20061025_153643_build_basic'
     51
    5152boundaries_name = project.boundaries_name
    52 meshes_dir_name = project.meshes_dir_name+'.msh'
     53meshes_time_dir_name = project.meshes_time_dir_name+'.msh'
    5354#source_dir = project.boundarydir
    54 boundaries_time_dir_name = project.boundaries_dir + build_time + sep + boundaries_name
     55#boundaries_time_dir_name = project.boundaries_dir + build_time + sep + boundaries_name
     56boundaries_time_dir_name = project.boundaries_time_dir_name
     57tide = project.tide
    5558
    5659# # creates copy of code in output dir if dir doesn't exist
     
    6366    copy (__file__, project.output_run_time_dir + basename(__file__))
    6467    print 'project.output_run_time_dir',project.output_run_time_dir
    65 
     68barrier()
    6669#normal screen output is stored in
    6770screen_output_name = project.output_run_time_dir + "screen_output_%d_%d.txt" %(myid,numprocs)
     
    7376
    7477print 'USER: ', project.user
    75 
    7678
    7779#--------------------------------------------------------------------------
     
    8284#--------------------------------------------------------------------------
    8385
    84 interior_regions = [#[project.karratha_polygon, 25000],
    85                     [project.cipma_polygon, 50000]]   
    86 
    87 print 'start create mesh from regions'
    88 meshes_dir_name = project.meshes_dir_name + '.msh'
    89 create_mesh_from_regions(project.bounding_polygon,
     86if myid == 0:
     87    if access(project.meshes_time_dir,F_OK) == 0:
     88        mkdir(project.meshes_time_dir)
     89    print 'start create mesh from regions'
     90    interior_regions = [#[project.karratha_polygon, 25000],
     91#                    [project.cipma_polygon, 1000],
     92                    [project.poly_pipeline, 1000],
     93                    [project.poly_facility, 10000]]   
     94#    meshes_dir_name = project.meshes_dir_name + '.msh'
     95
     96    create_mesh_from_regions(project.bounding_polygon,
    9097                         boundary_tags={'back': [7, 8], 'side': [0, 6],
    9198                                        'ocean': [1, 2, 3, 4, 5]},
    92                          maximum_triangle_area=300000,
     99                         maximum_triangle_area=100000,
    93100                         interior_regions=interior_regions,
    94                          filename=meshes_dir_name,
     101                         filename=meshes_time_dir_name,
    95102                         use_cache=True,
    96103                         verbose=True)
    97104
     105# to sync all processors are ready
     106barrier()
     107
    98108#-------------------------------------------------------------------------
    99109# Setup computational domain
    100110#-------------------------------------------------------------------------
    101111print 'Setup computational domain'
    102 domain = Domain(meshes_dir_name, use_cache=True, verbose=True)
     112domain = Domain(meshes_time_dir_name, use_cache=True, verbose=True)
    103113print domain.statistics()
    104114
     115
     116
     117print 'starting to create boundary conditions'
     118boundaries_in_dir_name = project.boundaries_in_dir_name
     119
     120from anuga.shallow_water.data_manager import urs2sww, ferret2sww
     121
     122print 'maxlat=project.south_boundary, minlat=project.north_boundary', project.south_boundary,project.north_boundary
     123print 'minlon= project.west_boundary, maxlon=project.east_boundary',project.west_boundary, project.east_boundary
     124print ' maxlon=project.east',project.east
     125
     126print 'origin: domain.geo_reference.get_origin()',domain.geo_reference.get_origin()
     127
     128#import sys; sys.exit()
     129
     130if access(project.boundaries_time_dir,F_OK) == 0:
     131    mkdir (project.boundaries_time_dir)
     132# put above distribute
     133from caching import cache
     134cache(ferret2sww,
     135      (boundaries_in_dir_name,
     136       boundaries_time_dir_name),
     137      {'verbose': True,
     138       'minlat': project.south_boundary,
     139       'maxlat': project.north_boundary,
     140       'minlon': project.west_boundary,
     141       'maxlon': project.east_boundary,
     142#       'minlat': project.south,
     143#       'maxlat': project.north,
     144#       'minlon': project.west,
     145#       'maxlon': project.east,
     146       'mint': 0, 'maxt': 35000,
     147       'origin': domain.geo_reference.get_origin(),
     148       'mean_stage': project.tide,
     149#       'zscale': 1,                 #Enhance tsunami
     150       'fail_on_NaN': False},
     151       verbose = True,
     152       )
     153
     154
     155
    105156#-------------------------------------------------------------------------
    106157# Setup initial conditions
    107158#-------------------------------------------------------------------------
    108 tide = project.tide
     159print 'Setup initial conditions'
     160
    109161domain.set_quantity('stage', tide)
    110162domain.set_quantity('friction', 0.0)
    111163#combined_time_dir_name = project.topographies_dir+build_time+project.combined_name
     164print 'Start Set quantity'
     165
    112166domain.set_quantity('elevation',
    113167                    filename = project.topographies_dir + build_time + sep + project.combined_name + '.pts',
     
    115169                    verbose = True,
    116170                    alpha = 0.1)
     171#domain.set_quantity('elevation', -50)
     172print 'Finished Set quantity'
     173
     174
    117175
    118176#------------------------------------------------------
     
    135193# Setup boundary conditions
    136194#-------------------------------------------------------------------------
    137 
    138 
    139195print 'Available boundary tags', domain.get_boundary_tags()
    140196
    141 
     197print 'Reading Boundary file'
     198#boundariesname = project.boundaries_dir + '20061101_003322_build'+sep+boundaries_name
     199#print'boundariesname',boundariesname
    142200Bf = File_boundary(boundaries_time_dir_name + '.sww',
    143                    domain, verbose = True)
     201
     202#Bf = File_boundary(boundariesname + '.sww',
     203                   domain, time_thinning=20, use_cache=True, verbose=True)
     204
     205print 'finished reading boundary file'
     206
    144207Br = Reflective_boundary(domain)
    145208Bd = Dirichlet_boundary([tide,0,0])
     209
     210print'set_boundary'
    146211domain.set_boundary({'back': Br,
    147212                     'side': Bd,
    148213                     'ocean': Bf})
     214print'finish set boundary'
     215
    149216
    150217#----------------------------------------------------------------------------
    151218# Evolve system through time
    152219#----------------------------------------------------------------------------
    153 import time
     220
    154221t0 = time.time()
    155222
    156 for t in domain.evolve(yieldstep = 120, finaltime = 28800):
     223for t in domain.evolve(yieldstep = 60, finaltime = 28800):
     224#for t in domain.evolve(yieldstep = 120, finaltime = 28800):
    157225    domain.write_time()
    158     domain.write_boundary_statistics(tags = 'ocean')     
     226#    domain.write_boundary_statistics(tags = 'ocean')     
    159227   
    160228print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracChangeset for help on using the changeset viewer.