Changeset 8610
- Timestamp:
- Nov 9, 2012, 4:46:46 PM (12 years ago)
- Location:
- trunk/anuga_core/source/anuga_parallel
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga_parallel/run_parallel_sw_rectangular_tsunami.py
r8585 r8610 55 55 #-------------------------------------------------------------------------- 56 56 if myid == 0: 57 length = 1.058 width = 1.057 length = 2.0 58 width = 2.0 59 59 dx = dy = 0.005 60 60 #dx = dy = 0.00125 -
trunk/anuga_core/source/anuga_parallel/run_sequential_dist_distribute_rectangular.py
r8609 r8610 16 16 import time 17 17 import sys 18 import numpy 18 19 19 20 … … 27 28 # Parallel interface 28 29 #--------------------------- 29 from anuga_parallel.sequential_distribute import sequential_distribute 30 from anuga_parallel.sequential_distribute import sequential_distribute_dump 30 31 31 32 … … 35 36 36 37 #-------------------------------------------------------------------------- 38 # Setup functions for topograpy etc 39 #-------------------------------------------------------------------------- 40 scale_me=1.0 41 42 def topography(x,y): 43 return (-x/2.0 +0.05*numpy.sin((x+y)*200.0))*scale_me 44 45 def stagefun(x,y): 46 stge=-0.2*scale_me #+0.01*(x>0.9) 47 #topo=topography(x,y) 48 return stge#*(stge>topo) + (topo)*(stge<=topo) 49 50 51 #-------------------------------------------------------------------------- 37 52 # Setup Domain only on processor 0 38 53 #-------------------------------------------------------------------------- 39 54 myid = 0 40 numprocs = 100 41 if myid == 0: 42 length = 2.0 43 width = 2.0 44 dx = dy = 0.005 # 640,000 45 dx = dy = 0.00125 46 #dx = dy = 0.5 47 domain = rectangular_cross_domain(int(length/dx), int(width/dy), 48 len1=length, len2=width, verbose=verbose) 55 numprocs = 4 49 56 50 57 51 print domain.number_of_global_triangles52 domain.set_store(True)53 domain.set_quantity('elevation', lambda x,y : -1.0-x )54 domain.set_quantity('stage', 1.0)55 domain.set_flow_algorithm('tsunami')56 domain.set_name('sw_rectangle')57 #domain.print_statistics()58 58 59 else: 60 domain = None 59 length = 2.0 60 width = 2.0 61 dx = dy = 0.005 # 640,000 62 dx = dy = 0.05 63 domain = rectangular_cross_domain(int(length/dx), int(width/dy), 64 len1=length, len2=width, verbose=verbose) 65 66 67 print domain.number_of_global_triangles 68 69 domain.set_store(True) 70 domain.set_flow_algorithm('tsunami') 71 domain.set_minimum_allowed_height(0.01) 72 domain.set_quantity('elevation',topography) # Use function for elevation 73 domain.get_quantity('elevation').smooth_vertex_values() 74 domain.set_quantity('friction',0.03) # Constant friction 75 domain.set_quantity('stage', stagefun) # Constant negative initial stage 76 domain.get_quantity('stage').smooth_vertex_values() 77 78 domain.set_name('sw_rectangle') 79 #domain.print_statistics() 80 61 81 62 82 t1 = time.time() … … 76 96 #domain = distribute(domain,verbose=verbose) 77 97 78 sequential_distribute (domain,numprocs, verbose = True)98 sequential_distribute_dump(domain, numprocs, verbose = True) 79 99 80 100 … … 84 104 print 'Distribute domain ',t2-t1 85 105 86 if myid == 0 : print 'after parallel domain'87 106 88 107 108 -
trunk/anuga_core/source/anuga_parallel/sequential_distribute.py
r8609 r8610 18 18 19 19 20 def sequential_distribute (domain, numprocs=1, verbose=False, debug=False, parameters = None):20 def sequential_distribute_dump(domain, numprocs=1, verbose=False, debug=False, parameters = None): 21 21 """ Distribute the domain, create parallel domain and pickle result 22 22 """ … … 122 122 123 123 124 args = [points, vertices, boundary]124 #args = [points, vertices, boundary] 125 125 126 126 kwargs = {'full_send_dict': full_send_dict, … … 139 139 'ghost_layer_width': ghost_layer_width} 140 140 141 parallel_domain = Parallel_domain(*args, **kwargs)141 # parallel_domain = Parallel_domain(points, vertices, boundary, **kwargs) 142 142 143 143 … … 146 146 # Transfer initial conditions to each subdomain 147 147 #------------------------------------------------------------------------ 148 for q in quantities:149 parallel_domain.set_quantity(q, quantities[q])148 # for q in quantities: 149 # parallel_domain.set_quantity(q, quantities[q]) 150 150 151 151 … … 153 153 # Transfer boundary conditions to each subdomain 154 154 #------------------------------------------------------------------------ 155 boundary_map['ghost'] = None # Add binding to ghost boundary156 parallel_domain.set_boundary(boundary_map)155 # boundary_map['ghost'] = None # Add binding to ghost boundary 156 # parallel_domain.set_boundary(boundary_map) 157 157 158 158 … … 160 160 # Transfer other attributes to each subdomain 161 161 #------------------------------------------------------------------------ 162 parallel_domain.set_name(domain_name)163 parallel_domain.set_datadir(domain_dir)164 parallel_domain.set_store(domain_store)165 parallel_domain.set_minimum_storable_height(domain_minimum_storable_height)166 parallel_domain.set_minimum_allowed_height(domain_minimum_allowed_height)167 parallel_domain.set_flow_algorithm(domain_flow_algorithm)168 parallel_domain.geo_reference = georef162 # parallel_domain.set_name(domain_name) 163 # parallel_domain.set_datadir(domain_dir) 164 # parallel_domain.set_store(domain_store) 165 # parallel_domain.set_minimum_storable_height(domain_minimum_storable_height) 166 # parallel_domain.set_minimum_allowed_height(domain_minimum_allowed_height) 167 # parallel_domain.set_flow_algorithm(domain_flow_algorithm) 168 # parallel_domain.geo_reference = georef 169 169 170 170 … … 173 173 # Now let's store the parallel_domain via cPickle 174 174 #----------------------------------------------------------------------- 175 # import cPickle 176 # pickle_name = domain_name + '_P%g_%g.pickle'% (numprocs,p) 177 # f = file(pickle_name, 'wb') 178 # cPickle.dump(parallel_domain, f, protocol=cPickle.HIGHEST_PROTOCOL) 179 # f.close() 180 181 182 #FIXME SR: Looks like we could reduce storage by a factor of 4 by just 183 # storing the data to create the parallel_domain instead of pickling 184 # a created domain 175 185 import cPickle 176 186 pickle_name = domain_name + '_P%g_%g.pickle'% (numprocs,p) 177 187 f = file(pickle_name, 'wb') 178 cPickle.dump(parallel_domain, f, protocol=cPickle.HIGHEST_PROTOCOL) 179 f.close() 180 181 #FIXME SR: Looks like we could reduce storage by a factor of 4 by just 182 # storing the data to create the parallel_domain instead of pickling 183 # a created domain 184 #pickle_name = 'test_P%g_%g.pickle'% (numprocs,p) 185 #f = file(pickle_name, 'wb') 186 #cPickle.dump( (args, kwargs, quantities), f, protocol=cPickle.HIGHEST_PROTOCOL) 187 #f.close() 188 tostore = (kwargs, points, vertices, boundary, quantities, boundary_map, domain_name, domain_dir, domain_store, domain_minimum_storable_height, \ 189 domain_minimum_allowed_height, domain_flow_algorithm, georef) 190 cPickle.dump( tostore, f, protocol=cPickle.HIGHEST_PROTOCOL) 188 191 189 192 return 190 193 191 194 195 def sequential_distribute_load(filename = 'domain', verbose = False): 196 197 198 from anuga_parallel import myid, numprocs 199 200 201 #--------------------------------------------------------------------------- 202 # Open pickle files 203 #--------------------------------------------------------------------------- 204 import cPickle 205 pickle_name = filename+'_P%g_%g.pickle'% (numprocs,myid) 206 f = file(pickle_name, 'rb') 207 kwargs, points, vertices, boundary, quantities, boundary_map, domain_name, domain_dir, domain_store, domain_minimum_storable_height, \ 208 domain_minimum_allowed_height, domain_flow_algorithm, georef = cPickle.load(f) 209 f.close() 210 211 #--------------------------------------------------------------------------- 212 # Create parallel domain 213 #--------------------------------------------------------------------------- 214 parallel_domain = Parallel_domain(points, vertices, boundary, **kwargs) 215 216 217 #------------------------------------------------------------------------ 218 # Copy in quantity data 219 #------------------------------------------------------------------------ 220 for q in quantities: 221 parallel_domain.set_quantity(q, quantities[q]) 222 223 224 #------------------------------------------------------------------------ 225 # Transfer boundary conditions to each subdomain 226 #------------------------------------------------------------------------ 227 boundary_map['ghost'] = None # Add binding to ghost boundary 228 parallel_domain.set_boundary(boundary_map) 229 230 231 #------------------------------------------------------------------------ 232 # Transfer other attributes to each subdomain 233 #------------------------------------------------------------------------ 234 parallel_domain.set_name(domain_name) 235 parallel_domain.set_datadir(domain_dir) 236 parallel_domain.set_store(domain_store) 237 parallel_domain.set_minimum_storable_height(domain_minimum_storable_height) 238 parallel_domain.set_minimum_allowed_height(domain_minimum_allowed_height) 239 parallel_domain.set_flow_algorithm(domain_flow_algorithm) 240 parallel_domain.geo_reference = georef 241 242 243 return parallel_domain 192 244 193 245 def extract_l2g_map(map):
Note: See TracChangeset
for help on using the changeset viewer.