Changeset 8616
- Timestamp:
- Nov 13, 2012, 9:11:35 PM (11 years ago)
- Location:
- trunk/anuga_core
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/mesh_factory_ext.c
r8551 r8616 118 118 } 119 119 120 free(vertices); 121 120 122 return Py_BuildValue("O", pyobj_boundary); 121 123 } -
trunk/anuga_core/source/anuga/structures/inlet.py
r8259 r8616 233 233 summed_volume = num.zeros_like(areas) 234 234 summed_volume[1:] = num.cumsum(summed_areas[:-1]*num.diff(stages[stages_order])) 235 236 # find the number of cells which will be filled 237 index = num.nonzero(summed_volume<=volume)[0][-1] 238 239 # calculate stage needed to fill chosen cells with given volume of water 240 depth = (volume - summed_volume[index])/summed_areas[index] 241 stages[stages_order[0:index+1]] = stages[stages_order[index]]+depth 242 243 self.set_stages(stages) 235 236 237 if volume>= 0.0 : 238 # find the number of cells which will be filled 239 #print summed_volume 240 #print summed_volume<=volume 241 242 #Test = summed_volume<=volume 243 244 #print num.any(Test) 245 #print num.nonzero(summed_volume<=volume) 246 #print num.nonzero(summed_volume<=volume)[0] 247 248 index = num.nonzero(summed_volume<=volume)[0][-1] 249 250 # calculate stage needed to fill chosen cells with given volume of water 251 depth = (volume - summed_volume[index])/summed_areas[index] 252 stages[stages_order[0:index+1]] = stages[stages_order[index]]+depth 253 254 else: 255 if summed_volume[-1]>= -volume : 256 depth = (summed_volume[-1] + volume)/summed_areas[-1] 257 stages[:] = depth 258 else: 259 #assert summed_volume[-1] >= -volume 260 import warnings 261 warnings.warn('summed_volume < volume to be extracted') 262 stages[:] = 0.0 263 264 self.set_stages(stages) 265 266 267 268 269 def set_stages_evenly_new(self,volume): 270 """ Distribute volume of water over 271 inlet exchange region so that stage is level 272 """ 273 # WARNING: requires synchronization, must be called by all procs associated 274 # with this inlet 275 276 centroid_coordinates = self.domain.get_full_centroid_coordinates(absolute=True) 277 areas = self.get_areas() 278 stages = self.get_stages() 279 280 stages_order = stages.argsort() 281 282 # PETE: send stages and areas, apply merging procedure 283 284 total_stages = len(stages) 285 286 287 s_areas = areas 288 s_stages = stages 289 s_stages_order = stages_order 290 291 292 pos = 0 293 summed_volume = 0. 294 summed_areas = 0. 295 prev_stage = 0. 296 num_stages = 0. 297 first = True 298 299 for i in self.procs: 300 pos[i] = 0 301 302 while num_stages < total_stages: 303 # Determine current minimum stage of all the processors in s_stages 304 num_stages = num_stages + 1 305 current_stage = num.finfo(num.float32).max 306 index = -1 307 308 309 if pos >= len(s_stages): 310 continue 311 312 if s_stages[s_stages_order[pos]] < current_stage: 313 current_stage = s_stages[i][s_stages_order[i][pos[i]]] 314 index = i 315 316 # If first iteration, then only update summed_areas, position, and prev|current stage 317 318 if first: 319 first = False 320 summed_areas = s_areas[index][s_stages_order[index][pos[index]]] 321 pos[index] = pos[index] + 1 322 prev_stage = current_stage 323 continue 324 325 assert index >= 0, "Index out of bounds" 326 327 # Update summed volume and summed areas 328 tmp_volume = summed_volume + (summed_areas * (current_stage - prev_stage)) 329 330 # Terminate if volume exceeded 331 if tmp_volume >= volume: 332 break 333 334 summed_areas = summed_areas + s_areas[index][s_stages_order[index][pos[index]]] 335 pos[index] = pos[index] + 1 336 summed_volume = tmp_volume 337 338 # Update position of index processor and current stage 339 prev_stage = current_stage 340 341 # Calculate new stage 342 new_stage = prev_stage + (volume - summed_volume) / summed_areas 343 344 345 # Update own depth 346 stages[stages_order[0:pos]] = new_stage 347 348 349 350 self.set_stages(stages) 351 352 stages = self.get_stages() 353 stages_order = stages.argsort() 354 244 355 245 356 def set_depths_evenly(self,volume): -
trunk/anuga_core/source/anuga/structures/inlet_operator.py
r8592 r8616 36 36 37 37 38 #print self.Q 39 38 40 self.enquiry_point = 0.5*(self.line[0] + self.line[1]) 39 41 self.outward_vector = self.line … … 59 61 Q2 = self.update_Q(t + timestep) 60 62 63 64 #print Q1,Q2 61 65 Q = 0.5*(Q1+Q2) 62 66 volume = Q*timestep 67 68 #print volume 63 69 64 70 #print Q, volume 71 72 # store last discharge 73 self.applied_Q = Q 65 74 66 75 msg = 'Requesting too much water to be removed from an inlet! \n' 67 76 msg += 'current_water_volume = %5.2e Increment volume = %5.2e' % (current_volume, volume) 68 assert current_volume + volume >= 0.0, msg 69 70 # store last discharge 71 self.applied_Q = Q 72 77 import warnings 78 if current_volume + volume < 0.0: 79 #warnings.warn(msg) 80 volume = -current_volume 81 self.applied_Q = volume/timestep 82 83 84 #print 'applied_Q', self.applied_Q 85 73 86 # Distribute volume so as to obtain flat surface 74 87 self.inlet.set_stages_evenly(volume) … … 76 89 # Distribute volume evenly over all cells 77 90 #self.inlet.set_depths_evenly(volume) 78 91 92 93 79 94 def update_Q(self, t): 80 95 """Allowing local modifications of Q … … 84 99 if callable(self.Q): 85 100 try: 86 Q = self.Q(t) [0]101 Q = self.Q(t) 87 102 except Modeltime_too_early, e: 88 103 raise Modeltime_too_early(e) -
trunk/anuga_core/source/anuga_parallel/run_sequential_dist_distribute_merimbula.py
r8606 r8616 35 35 36 36 37 from anuga_parallel.sequential_distribute import sequential_distribute 37 from anuga_parallel.sequential_distribute import sequential_distribute_dump 38 38 39 39 … … 95 95 96 96 if verbose: print 'DISTRIBUTING DOMAIN' 97 sequential_distribute (domain, 4, verbose=True)97 sequential_distribute_dump(domain, 4, verbose=True) 98 98 99 99 -
trunk/anuga_core/source/anuga_parallel/run_sequential_dist_evolve_merimbula.py
r8606 r8616 37 37 from anuga_parallel import distribute, myid, numprocs, finalize, barrier 38 38 39 from anuga_parallel.sequential_distribute import sequential_distribute_load 39 40 40 41 #-------------------------------------------------------------------------- 41 42 # Setup parameters 42 43 #-------------------------------------------------------------------------- 43 44 #mesh_filename = "merimbula_10785_1.tsh" ; x0 = 756000.0 ; x1 = 756500.0 45 mesh_filename = "merimbula_17156.tsh" ; x0 = 756000.0 ; x1 = 756500.0 46 #mesh_filename = "merimbula_43200_1.tsh" ; x0 = 756000.0 ; x1 = 756500.0 47 #mesh_filename = "test-100.tsh" ; x0 = 0.25 ; x1 = 0.5 48 #mesh_filename = "test-20.tsh" ; x0 = 250.0 ; x1 = 350.0 49 yieldstep = 50 44 yieldstep = 10 50 45 finaltime = 1500 51 46 verbose = True 52 47 53 #--------------------------------------------------------------------------54 # Setup procedures55 #--------------------------------------------------------------------------56 class Set_Stage:57 """Set an initial condition with constant water height, for x0<x<x158 """59 60 def __init__(self, x0=0.25, x1=0.5, h=1.0):61 self.x0 = x062 self.x1 = x163 self.h = h64 65 def __call__(self, x, y):66 return self.h*((x>self.x0)&(x<self.x1))+1.067 68 69 class Set_Elevation:70 """Set an elevation71 """72 73 def __init__(self, h=1.0):74 self.x0 = x075 self.x1 = x176 self.h = h77 78 def __call__(self, x, y):79 return x/self.h80 81 82 ##--------------------------------------------------------------------------83 ## Setup Domain only on processor 084 ##--------------------------------------------------------------------------85 #if myid == 0:86 # domain = create_domain_from_file(mesh_filename)87 # domain.set_quantity('stage', Set_Stage(x0, x1, 2.0))88 # #domain.set_datadir('.')89 # domain.set_name('merimbula_new')90 # domain.set_store(True)91 # #domain.set_quantity('elevation', Set_Elevation(500.0))92 #93 # #print domain.statistics()94 # #print domain.get_extent()95 # #print domain.get_extent(absolute=True)96 # #print domain.geo_reference97 #else:98 # domain = None99 #100 ##--------------------------------------------------------------------------101 ## Distribute sequential domain on processor 0 to other processors102 ##--------------------------------------------------------------------------103 #104 #if myid == 0 and verbose: print 'DISTRIBUTING DOMAIN'105 #domain = distribute(domain)106 48 107 49 108 50 #------------------------------------------------------------------------------- 109 # Read in cPickled parallel domains51 # Read in cPickled distribute mesh data 110 52 #------------------------------------------------------------------------------- 111 112 113 import cPickle 114 pickle_name = 'merimbula_new_P%g_%g.pickle'% (numprocs,myid) 115 f = file(pickle_name, 'rb') 116 domain = cPickle.load(f) 117 f.close() 53 domain = sequential_distribute_load(filename='merimbula_new', verbose = True) 118 54 119 55 #-------------------------------------------------------------------------- … … 122 58 #-------------------------------------------------------------------------- 123 59 124 domain.set_flow_algorithm(' 2_0')60 domain.set_flow_algorithm('tsunami') 125 61 126 #domain.smooth = False127 #domain.set_default_order(2)128 #domain.set_timestepping_method('rk2')129 #domain.set_CFL(0.7)130 #domain.set_beta(1.5)131 132 133 #for p in range(numprocs):134 # if myid == p:135 # print 'P%d'%p136 # print domain.get_extent()137 # print domain.get_extent(absolute=True)138 # print domain.geo_reference139 # print domain.s2p_map140 # print domain.p2s_map141 # print domain.tri_l2g142 # print domain.node_l2g143 # else:144 # pass145 #146 # barrier()147 62 148 63 … … 185 100 # Merge the individual sww files into one file 186 101 #-------------------------------------------------- 187 domain.sww_merge(delete_old=False) 102 103 104 188 105 189 106 finalize() -
trunk/anuga_core/validation_tests/Tests/Benchmarks/Okushiri/create_okushiri.py
r8529 r8616 28 28 29 29 30 base_resolution = 1 # Use this to coarsen or refine entire mesh.30 base_resolution = 0.25 # Use this to coarsen or refine entire mesh. 31 31 32 32 # Basic geometry and bounding polygon … … 165 165 166 166 if elevation_in_mesh is True: 167 from anuga.fit_interpolate.fit import fit_to_mesh_file 167 168 fit_to_mesh_file(project.mesh_filename, project.bathymetry_filename, 168 project.mesh_filename )169 project.mesh_filename, verbose = True) 169 170 170 171 171 172 #------------------------------------------------------------- 172 173 if __name__ == "__main__": 173 create_mesh( )174 create_mesh(elevation_in_mesh=True) 174 175 175 176 -
trunk/anuga_core/validation_tests/Tests/Benchmarks/Okushiri/run_okushiri.py
r8529 r8616 101 101 #------------------------------------------------------------- 102 102 if __name__ == "__main__": 103 main( )103 main(elevation_in_mesh=True)
Note: See TracChangeset
for help on using the changeset viewer.