Changeset 8944
- Timestamp:
- Jul 5, 2013, 10:04:02 PM (12 years ago)
- Location:
- trunk/anuga_core/source
- Files:
-
- 11 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py
r8828 r8944 173 173 174 174 for name in self.evolved_quantities: 175 self.quantities[name] = Quantity(self )175 self.quantities[name] = Quantity(self, name=name) 176 176 for name in self.other_quantities: 177 self.quantities[name] = Quantity(self )177 self.quantities[name] = Quantity(self, name=name) 178 178 179 179 # Create an empty list for forcing terms … … 317 317 self.timestep = 0.0 318 318 self.flux_timestep = 0.0 319 self.evolved_called = False 319 320 320 321 self.last_walltime = walltime() … … 1349 1350 return self.simulation_name 1350 1351 1351 def set_name(self, name ):1352 def set_name(self, name=None, timestamp=False): 1352 1353 """Assign a name to this simulation. 1353 1354 This will be used to identify the output sww file. 1354 """ 1355 1355 Without parameters the name will be derived from the script file, 1356 ie run_simulation.py -> output_run_simulation.sww 1357 """ 1358 1359 import os 1360 import inspect 1361 1362 if name is None: 1363 frame = inspect.currentframe() 1364 script_name = inspect.getouterframes(frame)[1][1] 1365 name = 'output_'+os.path.splitext(script_name)[0] 1366 1356 1367 # remove any '.sww' end 1357 1368 if name.endswith('.sww'): 1358 1369 name = name[:-4] 1370 1371 1372 from time import localtime, strftime, gmtime 1373 time = strftime('%Y%m%d_%H%M%S',localtime()) 1374 1375 if timestamp: 1376 name = name+'_'+time 1359 1377 1360 1378 self.simulation_name = name … … 1396 1414 1397 1415 1398 # Proc 0 gathers full and ghost nodes from self and other processors1416 # Gather full and ghost nodes 1399 1417 fx = vertices[full_mask,0] 1400 1418 fy = vertices[full_mask,1] … … 1466 1484 % self.get_boundary_tags()) 1467 1485 assert hasattr(self, 'boundary_objects'), msg 1468 1486 1487 1488 if self.evolved_called: 1489 skip_initial_step = True 1490 1491 self.evolved_called = True 1492 1493 # We assume evolve has already been called so we should now 1494 # set starttime to match actual time 1495 if skip_initial_step: 1496 self.set_starttime(self.get_time()) 1497 1498 1499 # This can happen on the first call to evolve 1469 1500 if self.get_time() != self.get_starttime(): 1470 1501 self.set_time(self.get_starttime()) … … 1477 1508 self._order_ = self.default_order 1478 1509 1479 assert finaltime >= self.get_starttime(), 'finaltime is less than starttime!' 1510 1480 1511 1481 1512 if finaltime is not None and duration is not None: … … 1487 1518 if duration is not None: 1488 1519 self.finaltime = self.starttime + float(duration) 1520 1521 assert self.finaltime >= self.get_starttime(), 'finaltime is less than starttime!' 1489 1522 1490 1523 N = len(self) # Number of triangles -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
r8930 r8944 33 33 class Quantity: 34 34 35 def __init__(self, domain, vertex_values=None): 35 36 counter = 0 37 38 def __init__(self, domain, vertex_values=None, name=None): 36 39 from anuga.abstract_2d_finite_volumes.generic_domain \ 37 40 import Generic_Domain … … 85 88 86 89 self.set_beta(1.0) 90 91 # Keep count of quantities 92 Quantity.counter += 1 93 94 self.set_name(name) 95 96 97 98 99 87 100 88 101 ############################################################################ … … 248 261 self.centroid_values[:] = num.maximum(self.centroid_values, Q.centroid_values) 249 262 263 return self 264 250 265 251 266 … … 273 288 self.centroid_values[:] = num.minimum(self.centroid_values, Q.centroid_values) 274 289 275 290 return self 276 291 277 292 … … 279 294 # Setters/Getters 280 295 ############################################################################ 281 296 297 def save_centroid_data_to_csv(self,filename=None): 298 299 300 #FIXME SR: Should add code to deal with parallel 301 302 c_v = self.centroid_values.reshape((-1,1)) 303 c_x = self.domain.centroid_coordinates[:,0].reshape((-1,1)) 304 c_y = self.domain.centroid_coordinates[:,1].reshape((-1,1)) 305 306 import numpy 307 308 c_xyv = numpy.hstack((c_x, c_y, c_v)) 309 310 if filename is None: 311 filename = self.name+'_centroid_data.csv' 312 313 numpy.savetxt(filename, c_xyv, delimiter=',', fmt = ['%.15e', '%.15e', '%.15e' ]) 314 315 316 317 def plot_quantity(self, filename=None, show=True): 318 319 X, Y, A, V = self.get_vertex_values(smooth=True) 320 321 import matplotlib.pyplot as plt 322 import numpy as np 323 324 325 plt.tripcolor(X, Y, V, A) 326 plt.colorbar() 327 328 if filename is None: 329 filename = self.name+'.png' 330 331 plt.savefig(filename) 332 333 if show: 334 plt.show() 335 336 337 338 339 def set_name(self, name=None): 340 341 if name is not None: 342 self.name = name 343 else: 344 self.name = 'quantity_%g' % Quantity.counter 345 346 347 348 def get_name(self): 349 350 return self.name 351 352 282 353 def set_beta(self, beta): 283 354 """Set default beta value for limiting """ … … 1300 1371 self._set_vertex_values(vertex_list, A) 1301 1372 1373 1374 1302 1375 # Note Padarn 27/11/12: 1303 1376 # This function has been changed and now uses an external c function -
trunk/anuga_core/source/anuga/operators/collect_max_stage_operator.py
r8939 r8944 35 35 # Setup a quantity to store max_stage 36 36 #------------------------------------------ 37 self.max_stage = Quantity(domain )37 self.max_stage = Quantity(domain, name = 'max_stage') 38 38 self.max_stage.set_values(-1.0e+100) 39 39 … … 50 50 """ 51 51 52 self.max_stage.maximum(self.stage) #=self.max_stage.maximum(self.stage) 53 #self.max_stage=self.max_stage.maximum(self.stage) 52 self.max_stage.maximum(self.stage) 54 53 55 54 … … 73 72 74 73 74 def save_centroid_data_to_csv(self, filename=None): 75 76 self.max_stage.save_centroid_data_to_csv(filename) 77 78 79 def plot_quantity(self, filename=None, show=True): 80 81 self.max_stage.plot_quantity(filename=filename, show=show) 82 83 84 85 -
trunk/anuga_core/source/anuga/operators/erosion_operators.py
r8574 r8944 12 12 import numpy as num 13 13 from anuga.geometry.polygon import inside_polygon 14 from anuga import indent 15 16 from anuga import Domain 17 from anuga import Quantity 14 18 from anuga.operators.base_operator import Operator 15 from anuga import indent16 17 18 class Erosion_operator(Operator ):19 from anuga.operators.region import Region 20 21 22 class Erosion_operator(Operator, Region): 19 23 """ 20 24 Simple erosion operator in a region (careful to maintain continuitiy of elevation) … … 32 36 base=0.0, 33 37 indices=None, 38 polygon=None, 39 center=None, 40 radius=None, 34 41 description = None, 35 42 label = None, … … 40 47 Operator.__init__(self, domain, description, label, logging, verbose) 41 48 49 50 51 Region.__init__(self, domain, 52 indices=indices, 53 polygon=polygon, 54 center=center, 55 radius=radius, 56 verbose=verbose) 57 42 58 #------------------------------------------ 43 59 # Local variables … … 45 61 self.threshold = threshold 46 62 self.base = base 47 self.indices = indices 63 48 64 49 65 #------------------------------------------ … … 409 425 verbose=False): 410 426 411 assert center is not None412 assert radius is not None413 414 415 # Determine indices in update region416 N = domain.get_number_of_triangles()417 points = domain.get_centroid_coordinates(absolute=True)418 419 420 indices = []421 422 c = center423 r = radius424 425 self.center = center426 self.radius = radius427 428 intersect = False429 for k in range(N):430 x, y = points[k,:] # Centroid431 432 if ((x-c[0])**2+(y-c[1])**2) < r**2:433 intersect = True434 indices.append(k)435 436 437 msg = 'No centroids intersect circle center'+str(center)+' radius '+str(radius)438 assert intersect, msg439 440 441 442 443 # It is possible that circle doesn't intersect with mesh (as can happen444 # for parallel runs445 427 446 428 … … 449 431 threshold, 450 432 base, 451 indices=indices, 433 center=center, 434 radius=radius, 452 435 verbose=verbose) 453 436 … … 472 455 473 456 474 # Determine indices in update region475 N = domain.get_number_of_triangles()476 points = domain.get_centroid_coordinates(absolute=True)477 478 479 indices = inside_polygon(points, polygon)480 self.polygon = polygon481 482 # It is possible that circle doesn't intersect with mesh (as can happen483 # for parallel runs484 485 486 457 Erosion_operator.__init__(self, 487 458 domain, 488 459 threshold=threshold, 489 460 base=base, 490 indices=indices,461 polygon=polygon, 491 462 verbose=verbose) 463 464 465 492 466 493 467 -
trunk/anuga_core/source/anuga/operators/rate_operators.py
r8879 r8944 10 10 11 11 12 from anuga import Domain 13 from anuga import Quantity 12 14 13 from anuga import indent 15 14 import numpy as num 16 15 from warnings import warn 17 16 import anuga.utilities.log as log 18 19 17 from anuga.geometry.polygon import inside_polygon 20 18 21 from anuga.operators.base_operator import Operator 19 22 20 from anuga.fit_interpolate.interpolate import Modeltime_too_early, \ 23 21 Modeltime_too_late 24 22 from anuga.utilities.function_utils import evaluate_temporal_function 25 23 26 27 class Rate_operator(Operator): 24 from anuga import Domain 25 from anuga import Quantity 26 from anuga.operators.base_operator import Operator 27 from anuga.operators.region import Region 28 29 class Rate_operator(Operator,Region): 28 30 """ 29 31 Add water at certain rate (ms^{-1} = vol/Area/sec) over a … … 43 45 factor=1.0, 44 46 indices=None, 47 polygon=None, 48 center=None, 49 radius=None, 45 50 default_rate=None, 46 51 description = None, … … 52 57 Operator.__init__(self, domain, description, label, logging, verbose) 53 58 59 60 Region.__init__(self, domain, 61 indices=indices, 62 polygon=polygon, 63 center=center, 64 radius=radius, 65 verbose=verbose) 66 67 54 68 #------------------------------------------ 55 69 # Local variables 56 70 #------------------------------------------ 57 self.indices = indices58 71 self.factor = factor 59 72 … … 131 144 132 145 rate = evaluate_temporal_function(self.rate, t, default_right_value=self.default_rate) 133 # if self.rate_callable:134 # try:135 # rate = self.rate(t)136 # except Modeltime_too_early, e:137 # raise Modeltime_too_early(e)138 # except Modeltime_too_late, e:139 # if self.default_rate is None:140 # msg = '%s: ANUGA is trying to run longer than specified data.\n' %str(e)141 # msg += 'You can specify keyword argument default_rate in the '142 # msg += 'rate operator to tell it what to do in the absence of time data.'143 # raise Modeltime_too_late(msg)144 # else:145 # # Pass control to default rate function146 # rate = self.default_rate(t)147 #148 # if self.default_rate_invoked is False:149 # # Issue warning the first time150 # msg = ('\n%s'151 # 'Instead I will use the default rate: %s\n'152 # 'Note: Further warnings will be supressed'153 # % (str(e), self.default_rate(t)))154 # warn(msg)155 #156 # # FIXME (Ole): Replace this crude flag with157 # # Python's ability to print warnings only once.158 # # See http://docs.python.org/lib/warning-filter.html159 # self.default_rate_invoked = True160 # else:161 # rate = self.rate162 163 146 164 147 if rate is None: … … 190 173 assert x is not None 191 174 assert y is not None 192 #print x.shape,y.shape 175 193 176 assert isinstance(t, (int, float)) 194 177 assert len(x) == len(y) … … 362 345 verbose=False): 363 346 364 assert center is not None365 assert radius is not None366 367 368 # Determine indices in update region369 N = domain.get_number_of_triangles()370 points = domain.get_centroid_coordinates(absolute=True)371 372 373 indices = []374 375 c = center376 r = radius377 378 for k in range(N):379 x, y = points[k,:] # Centroid380 381 if ((x-c[0])**2+(y-c[1])**2) < r**2:382 indices.append(k)383 384 385 # It is possible that circle doesn't intersect with mesh (as can happen386 # for parallel runs387 388 347 389 348 Rate_operator.__init__(self, … … 391 350 rate=rate, 392 351 factor=factor, 393 indices=indices, 352 center=center, 353 radius=radius, 394 354 default_rate=default_rate, 395 355 verbose=verbose) 396 356 397 398 self.center = center399 self.radius = radius400 357 401 358 … … 421 378 verbose=False): 422 379 423 assert polygon is not None424 425 426 # Determine indices in update region427 N = domain.get_number_of_triangles()428 points = domain.get_centroid_coordinates(absolute=True)429 430 431 indices = inside_polygon(points, polygon)432 self.polygon = polygon433 434 435 # It is possible that circle doesn't intersect with mesh (as can happen436 # for parallel runs437 438 380 439 381 Rate_operator.__init__(self, … … 441 383 rate=rate, 442 384 factor=factor, 443 indices=indices,385 polygon=polygon, 444 386 default_rate=default_rate, 445 387 verbose=verbose) 388 446 389 447 390 -
trunk/anuga_core/source/anuga/operators/run_change_elevation.py
r8480 r8944 7 7 # Import necessary modules 8 8 #------------------------------------------------------------------------------ 9 import numpy 9 10 from anuga import rectangular_cross 10 11 from anuga import Domain … … 23 24 len1=length, len2=width) 24 25 domain = Domain(points, vertices, boundary) 25 domain.set_name( 'change_elevation') # Output name26 domain.set_name() 26 27 print domain.statistics() 27 28 domain.set_quantities_to_be_stored({'elevation': 2, 28 'stage': 2}) 29 'stage': 2, 30 'xmomentum': 2, 31 'ymomentum': 2}) 29 32 30 33 #------------------------------------------------------------------------------ … … 36 39 z = -x/100 37 40 38 N = len(x) 39 for i in range(N): 40 # Step 41 if 2 < x[i] < 4: 42 z[i] += 0.4 - 0.05*y[i] 43 44 # Permanent pole 45 #if (x[i] - 8)**2 + (y[i] - 2)**2 < 0.4**2: 46 # z[i] += 1 41 # Step 42 id = (2 < x) & (x < 4) 43 z[id] += 0.4 - 0.05*y[id] 47 44 48 45 49 # Dam 50 if 12 < x[i] < 13: 51 z[i] += 0.4 46 # Permanent pole 47 #id = (x - 8)**2 + (y - 2)**2 < 0.4**2 48 #z[id] += 1 49 50 51 # Dam 52 id = (12 < x) & (x < 13) 53 z[id] += 0.4 54 52 55 53 56 … … 58 61 59 62 z = -x/100 60 61 N = len(x) 62 for i in range(N): 63 # Step 64 if 2 < x[i] < 4: 65 z[i] += 0.4 - 0.05*y[i] 66 67 # Permanent pole 68 #if (x[i] - 8)**2 + (y[i] - 2)**2 < 0.4**2: 69 # z[i] += 1 63 64 # Step 65 id = (2 < x) & (x < 4) 66 z[id] += 0.4 - 0.05*y[id] 70 67 71 68 72 # Dam73 if 12 < x[i] < 13 and y[i] > 3.0:74 z[i] += 0.469 # Permanent pole 70 #id = (x - 8)**2 + (y - 2)**2 < 0.4**2 71 #z[id] += 1 75 72 76 if 12 < x[i] < 13 and y[i] < 2.0: 77 z[i] += 0.4 73 # Dam with hole 74 id = (12 < x) & (x < 13) and (y > 3.0) 75 z[id] += 0.4 76 77 id = (12 < x) & (x < 13) and (y < 2.0) 78 z[id] += 0.4 79 78 80 79 81 return z … … 97 99 #------------------------------------------------------------------------------ 98 100 99 #from anuga.operators.set_elevation_operators import Circular_set_elevation_operator 100 101 #op1 = Circular_set_elevation_operator(domain, elevation=pole, radius=0.5, center = (12.0,3.0)) 101 from anuga.operators.set_elevation import Set_elevation 102 op1 = Set_elevation(domain, elevation=lambda x,y : -x/100, radius=1.0, center = (12.5,3.0)) 102 103 103 104 104 dam_break = False105 #dam_break = False 105 106 106 107 for t in domain.evolve(yieldstep=0.1, finaltime=30.0): … … 108 109 domain.print_operator_timestepping_statistics() 109 110 110 if t >= 10 and not dam_break:111 if numpy.allclose(t, 10.0): 111 112 print 'changing elevation' 112 domain.set_quantity('elevation', topography_dam_break) 113 dam_break = True 113 op1() 114 114 115 115 … … 117 117 118 118 119 -
trunk/anuga_core/source/anuga/operators/run_collect_max_stage_operator.py
r8936 r8944 19 19 20 20 21 22 #-------------------------------------------------------------------------------23 # Copy scripts to time stamped output directory and capture screen24 # output to file25 #-------------------------------------------------------------------------------26 #time = strftime('%Y%m%d_%H%M%S',localtime())27 28 #output_dir = 'dam_break_'+time29 output_file = 'dam_break'30 31 #anuga.copy_code_files(output_dir,__file__)32 #start_screen_catcher(output_dir+'_')33 34 35 21 #------------------------------------------------------------------------------ 36 22 # Setup domain … … 45 31 domain = anuga.rectangular_cross_domain(int(L/dx), int(W/dy), L, W, (0.0, -W/2)) 46 32 47 domain.set_name( output_file)33 domain.set_name() # based on script name 48 34 49 35 #------------------------------------------------------------------------------ 50 36 # Setup Algorithm 51 37 #------------------------------------------------------------------------------ 52 domain.set_timestepping_method('rk2') 53 domain.set_default_order(2) 54 domain.set_beta(1.7) 55 56 #------------------------------------------------------------------------------ 57 # Setup Kinematic Viscosity Operator 58 #------------------------------------------------------------------------------ 59 domain.set_use_kinematic_viscosity(True) 38 domain.set_flow_algorithm('2_0') 60 39 61 40 #------------------------------------------------------------------------------ … … 76 55 domain.set_quantity('friction', 0.0) 77 56 domain.add_quantity('stage', height) 57 78 58 #----------------------------------------------------------------------------- 79 59 # Setup boundary conditions … … 89 69 90 70 91 ##===============================================================================92 #from anuga.visualiser import RealtimeVisualiser93 #vis = RealtimeVisualiser(domain)94 #vis.render_quantity_height("stage", zScale = 50000/(h0-h1), dynamic=True)95 #vis.colour_height_quantity("stage",96 ## (lambda q: numpy.sqrt( (q["xvelocity"]**2 ) + (q['yvelocity']**2 )), 0.0, 10.0) )97 # (lambda q: q["yvelocity"], -10.0, 10.0) )98 #vis.start()99 ##===============================================================================100 71 101 72 #----------------------------------------------------------------------------- 73 # Setup operators that will be applied each inner timestep 74 #------------------------------------------------------------------------------ 102 75 from anuga.operators.collect_max_stage_operator import Collect_max_stage_operator 103 76 max_operator = Collect_max_stage_operator(domain) … … 106 79 # Evolve system through time 107 80 #------------------------------------------------------------------------------ 108 109 81 for t in domain.evolve(yieldstep = 100.0, finaltime = 60*60.): 110 82 #print domain.timestepping_statistics(track_speeds=True) … … 112 84 domain.print_operator_timestepping_statistics() 113 85 114 #vis.update() 86 87 88 # save the max_stage centroid data to a text file 89 max_operator.save_centroid_data_to_csv() 90 91 max_operator.plot_quantity() 115 92 116 93 117 94 118 #print max_operator.max_stage.centroid_values119 95 120 c_v = max_operator.max_stage.centroid_values.flatten()121 c_x = domain.centroid_coordinates[:,0].flatten()122 c_y = domain.centroid_coordinates[:,1].flatten()123 124 import numpy125 126 numpy.savetxt('max_stage.txt', c_v)127 128 #test against know data129 130 #vis.evolveFinished()131 -
trunk/anuga_core/source/anuga/operators/run_polygon_erosion.py
r8506 r8944 112 112 length = 24. 113 113 width = 5. 114 dx = dy = 0. 1#.1 # Resolution: Length of subdivisions on both axes114 dx = dy = 0.2 #.1 # Resolution: Length of subdivisions on both axes 115 115 116 116 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), 117 117 len1=length, len2=width) 118 118 domain = Domain(points, vertices, boundary) 119 domain.set_name( 'polygon_erosion') # Output name119 domain.set_name() # Output name based on script 120 120 print domain.statistics() 121 121 domain.set_quantities_to_be_stored({'elevation': 2, -
trunk/anuga_core/source/anuga/operators/run_rate_operator.py
r8477 r8944 12 12 from anuga import Dirichlet_boundary 13 13 from anuga import Time_boundary 14 import os 14 15 15 16 … … 24 25 len1=length, len2=width) 25 26 domain = Domain(points, vertices, boundary) 26 domain.set_name( 'rate_polygon') # Output name27 domain.set_name() # Output name based on script name. You can add timestamp=True 27 28 print domain.statistics() 28 29 … … 36 37 z = -x/100 37 38 38 N = len(x) 39 for i in range(N): 40 # Step 41 if 2 < x[i] < 4: 42 z[i] += 0.4 - 0.05*y[i] 43 44 # Permanent pole 45 #if (x[i] - 8)**2 + (y[i] - 2)**2 < 0.4**2: 46 # z[i] += 1 39 # Step 40 id = (2 < x) & (x < 4) 41 z[id] += 0.4 - 0.05*y[id] 47 42 48 43 49 # # Dam 50 # if 12 < x[i] < 13 and y[i] > 3.0: 51 # z[i] += 0.4 52 # 53 # if 12 < x[i] < 13 and y[i] < 2.0: 54 # z[i] += 0.4 44 # Permanent pole 45 #id = (x - 8)**2 + (y - 2)**2 < 0.4**2 46 #z[id] += 1 55 47 56 48 57 # # Dam 58 # if 12 < x[i] < 13: 59 # z[i] += 0.4 49 # Dam 50 #id = (12 < x) & (x < 13) 51 #z[id] += 0.4 52 53 60 54 61 55 … … 68 62 """ 69 63 70 71 z = 0.0*x 72 64 z = 0.0*x 73 65 74 66 if t<10.0: … … 76 68 77 69 78 N = len(x) 79 for i in range(N): 80 # Pole 1 81 if (x[i] - 12)**2 + (y[i] - 3)**2 < 0.4**2: 82 z[i] += 0.1 70 # Pole 1 71 id = (x - 12)**2 + (y - 3)**2 < 0.4**2 72 z[id] += 0.1 83 73 84 for i in range(N): 85 # Pole 2 86 if (x[i] - 14)**2 + (y[i] - 2)**2 < 0.4**2: 87 z[i] += 0.05 74 75 # Pole 2 76 id = (x - 14)**2 + (y - 2)**2 < 0.4**2 77 z[id] += 0.05 78 88 79 89 80 return z … … 119 110 polygon2 = [ [12.0, 2.0], [13.0, 2.0], [13.0, 3.0], [12.0, 3.0] ] 120 111 121 from anuga.operators.rate_operators import Polygonal_rate_operator 122 from anuga.operators.rate_operators import Circular_rate_operator 112 from anuga.operators.rate_operators import Rate_operator 123 113 124 op1 = Polygonal_rate_operator(domain, rate=10.0, polygon=polygon2)125 op2 = Circular_rate_operator(domain, rate=10.0, radius=0.5, center=(10.0, 3.0))114 op1 = Rate_operator(domain, rate=lambda t: 10.0 if (t>=0.0) else 0.0, polygon=polygon2) 115 op2 = Rate_operator(domain, rate=lambda t: 10.0 if (t>=0.0) else 0.0, radius=0.5, center=(10.0, 3.0)) 126 116 127 117 128 for t in domain.evolve(yieldstep=0.1, finaltime=40.0): 118 domain.set_starttime(-0.1) 119 for t in domain.evolve(yieldstep=0.01, finaltime=0.0): 120 domain.print_timestepping_statistics() 121 domain.print_operator_timestepping_statistics() 122 123 stage = domain.get_quantity('stage') 124 elev = domain.get_quantity('elevation') 125 height = stage - elev 126 127 print 'integral = ', height.get_integral() 128 129 130 for t in domain.evolve(yieldstep=0.1, duration=5.0): 131 129 132 domain.print_timestepping_statistics() 130 133 domain.print_operator_timestepping_statistics() -
trunk/anuga_core/source/anuga/operators/run_rate_spatial_operator.py
r8871 r8944 27 27 len1=length, len2=width) 28 28 domain = Domain(points, vertices, boundary) 29 domain.set_name( 'output_rate_spatial_operator') # Output name29 domain.set_name() # Output name based on script 30 30 print domain.statistics() 31 31 … … 119 119 polygon2 = [ [12.0, 2.0], [13.0, 2.0], [13.0, 3.0], [12.0, 3.0] ] 120 120 121 from anuga.operators.rate_operators import Polygonal_rate_operator 122 from anuga.operators.rate_operators import Circular_rate_operator 121 123 122 from anuga.operators.rate_operators import Rate_operator 124 123 125 op1 = Polygonal_rate_operator(domain, rate=10.0, polygon=polygon2)124 op1 = Rate_operator(domain, rate=10.0, polygon=polygon2) 126 125 127 126 area1 = numpy.sum(domain.areas[op1.indices]) … … 129 128 print 'op1 Q ',Q1 130 129 131 op2 = Circular_rate_operator(domain, rate=10.0, radius=0.5, center=(10.0, 3.0))130 op2 = Rate_operator(domain, rate=10.0, radius=0.5, center=(10.0, 3.0)) 132 131 133 132 area2 = numpy.sum(domain.areas[op2.indices]) … … 141 140 abd t a scalar 142 141 """ 143 if t<= 5.0:142 if t<=4.0: 144 143 return (x+y) 145 144 else: … … 160 159 accum = 0.0 161 160 yieldstep = 0.1 162 finaltime = 40.0161 finaltime = 5.0 163 162 for t in domain.evolve(yieldstep=yieldstep, finaltime=finaltime): 164 163 domain.print_timestepping_statistics() -
trunk/anuga_core/source/anuga/utilities/log.py
r8427 r8944 64 64 65 65 # The default name of the file to log to. 66 67 66 68 log_filename = os.path.join('.', 'anuga.log') 67 69 -
trunk/anuga_core/source/anuga_validation_tests/case_studies/patong/run_model.py
r8922 r8944 43 43 44 44 # Tell log module to store log file in output dir 45 log.log_filename = os.path.join(project.output_run, 'anuga .log')45 log.log_filename = os.path.join(project.output_run, 'anuga_P_%g.log'%myid) 46 46 47 47 if(myid==0): … … 221 221 ## conflated in the code 222 222 ## 223 ## Skip over the first 6000 seconds 224 #for t in domain.evolve(yieldstep=2000, 225 # finaltime=6000): 226 # log.critical(domain.timestepping_statistics()) 227 # log.critical(domain.boundary_statistics(tags='ocean')) 228 # 229 ## Start detailed model 230 #for t in domain.evolve(yieldstep=project.yieldstep, 231 # finaltime=project.finaltime, 232 # skip_initial_step=True): 233 # log.critical(domain.timestepping_statistics()) 234 # log.critical(domain.boundary_statistics(tags='ocean')) 223 ## Skip over the first 60 seconds 224 for t in domain.evolve(yieldstep=2, 225 duration=60): 226 log.critical(domain.timestepping_statistics()) 227 log.critical(domain.boundary_statistics(tags='ocean')) 235 228 236 229 … … 239 232 import time 240 233 time.sleep(myid) 241 print 'Processor ', myid , ' : ', project.yieldstep, domain.flow_algorithm 234 print 'Processor ', myid , ' : ', project.yieldstep, domain.flow_algorithm 242 235 barrier() 243 236 print 'project.yieldstep', project.yieldstep 237 # Start detailed model 244 238 for t in domain.evolve(yieldstep=project.yieldstep, 245 239 finaltime=project.finaltime): … … 250 244 print 'Processor ', myid, ' project.yieldstep ', project.yieldstep 251 245 246 252 247 ## Final print out 253 248 barrier()
Note: See TracChangeset
for help on using the changeset viewer.