Changeset 5741
- Timestamp:
- Sep 5, 2008, 9:16:45 PM (17 years ago)
- Location:
- anuga_work/development
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/anuga_1d/config.py
r5740 r5741 11 11 12 12 min_timestep = 1.0e-6 #Should be computed based on geometry 13 max_timestep = 1000 13 max_timestep = 1.0e3 14 max_smallsteps = 50 # Max number of degenerate steps allowed b4 trying first order 14 15 #This is how: 15 16 #Define maximal possible speed in open water v_max, e.g. 500m/s (soundspeed?) -
anuga_work/development/anuga_1d/dam_h_elevation.py
r5738 r5741 1 1 import os 2 2 from math import sqrt, sin, cos, pi, exp 3 from shallow_water_domain import *3 from shallow_water_domain_new import * 4 4 from Numeric import zeros, Float 5 5 #from analytic_dam_sudi import AnalyticDam … … 42 42 43 43 domain.default_order = 2 44 domain.default_time_order = 1 44 domain.set_timestepping_method('euler') 45 #domain.default_time_order = 2 45 46 domain.cfl = 1.0 46 47 domain.limiter = "vanleer" -
anuga_work/development/anuga_1d/domain.py
r5740 r5741 724 724 #-------------------------- 725 725 726 def evolve(self, yieldstep = None, finaltime = None, duration = None, 726 def evolve(self, yieldstep = None, 727 finaltime = None, 728 duration = None, 727 729 skip_initial_step = False): 728 730 """Evolve model through time starting from self.starttime. … … 759 761 760 762 from config import min_timestep, max_timestep, epsilon 761 762 print 'yieldstep', yieldstep763 print 'duration', duration764 763 765 764 # FIXME: Maybe lump into a larger check prior to evolving … … 1388 1387 def update_timestep(self, yieldstep, finaltime): 1389 1388 1390 from config import min_timestep 1389 from config import min_timestep, max_timestep 1391 1390 1392 1391 # self.timestep is calculated from speed of characteristics 1393 1392 # Apply CFL condition here 1394 timestep = self.CFL*self.timestep1393 timestep = min(self.CFL*self.flux_timestep, max_timestep) 1395 1394 1396 1395 #Record maximal and minimal values of timestep for reporting … … 1459 1458 1460 1459 #def update_conserved_quantities(self): 1461 def update_conserved_quantities(self ,timestep):1460 def update_conserved_quantities(self): 1462 1461 """Update vectors of conserved quantities using previously 1463 1462 computed fluxes specified forcing functions. … … 1469 1468 d = len(self.conserved_quantities) 1470 1469 1471 #timestep = self.timestep1470 timestep = self.timestep 1472 1471 1473 1472 #Compute forcing terms 1474 #self.compute_forcing_terms()1473 self.compute_forcing_terms() 1475 1474 1476 1475 #Update conserved_quantities … … 1479 1478 Q.update(timestep) 1480 1479 1481 #Clean up 1482 #Note that Q.explicit_update is reset by compute_fluxes 1483 1484 #MH090605 commented out the following since semi_implicit_update is now re-initialized 1485 #at the end of the _update function in quantity_ext.c (This is called by the 1486 #preceeding Q.update(timestep) statement above). 1487 #For run_profile.py with N=128, the time of update_conserved_quantities is cut from 14.00 secs 1488 #to 8.35 secs 1489 1490 #Q.semi_implicit_update[:] = 0.0 1480 1491 1481 1492 1482 if __name__ == "__main__": -
anuga_work/development/anuga_1d/quantity.py
r5738 r5741 861 861 #backup_centroid_values(self) 862 862 N = self.domain.number_of_elements 863 for i in range( self.N):864 quantity.centroid_backup_values[i] = quantity.centroid_values[i]863 for i in range(N): 864 self.centroid_backup_values[i] = self.centroid_values[i] 865 865 866 866 def saxpy_centroid_values(self,a,b): … … 869 869 #saxpy_centroid_values(self,a,b) 870 870 N = self.domain.number_of_elements 871 for i in range( self.N):872 quantity.centroid_backup_values[i] = a*quantity.centroid_values[i] + b*quantity.centroid_backup_values[i]871 for i in range(N): 872 self.centroid_backup_values[i] = a*self.centroid_values[i] + b*self.centroid_backup_values[i] 873 873 874 874 class Conserved_quantity(Quantity): -
anuga_work/development/anuga_1d/shallow_water_domain.py
r5740 r5741 575 575 #print "flux cell",k,flux[0] 576 576 577 domain. timestep = timestep577 domain.flux_timestep = timestep 578 578 #print domain.quantities['stage'].centroid_values 579 579 … … 652 652 from comp_flux_ext import compute_fluxes_ext 653 653 654 domain. timestep = compute_fluxes_ext(timestep,654 domain.flux_timestep = compute_fluxes_ext(timestep, 655 655 epsilon, 656 656 g, … … 685 685 from comp_flux_ext import compute_fluxes_ext_short 686 686 687 domain. timestep = compute_fluxes_ext_short(timestep,domain,stage,xmom,bed)687 domain.flux_timestep = compute_fluxes_ext_short(timestep,domain,stage,xmom,bed) 688 688 689 689 -
anuga_work/development/anuga_1d/shallow_water_domain_new.py
r5737 r5741 165 165 distribute_to_vertices_and_edges(self) 166 166 167 def evolve(self, yieldstep = None, finaltime = None, 167 def evolve(self, yieldstep = None, 168 finaltime = None, 169 duration = None, 168 170 skip_initial_step = False): 169 171 """Specialisation of basic evolve method from parent class … … 172 174 self.distribute_to_vertices_and_edges() 173 175 174 for t in Generic_Domain.evolve(self, yieldstep, finaltime, 176 for t in Generic_Domain.evolve(self, yieldstep, finaltime, duration, 175 177 skip_initial_step): 176 178 #Pass control on to outer loop for more specific actions … … 439 441 440 442 441 domain. timestep = timestep443 domain.flux_timestep = timestep 442 444 #print domain.quantities['stage'].centroid_values 443 445 … … 468 470 from comp_flux_ext import compute_fluxes_ext 469 471 470 domain. timestep = compute_fluxes_ext(timestep,472 domain.flux_timestep = compute_fluxes_ext(timestep, 471 473 epsilon, 472 474 g, … … 501 503 from comp_flux_ext import compute_fluxes_ext_short 502 504 503 domain. timestep = compute_fluxes_ext_short(timestep,domain,stage,xmom,bed)505 domain.flux_timestep = compute_fluxes_ext_short(timestep,domain,stage,xmom,bed) 504 506 505 507 … … 526 528 max_speed_array = domain.max_speed_array 527 529 528 from comp_flux_ext_wellbalanced import compute_fluxes_ext_wellbalanced 530 from comp_flux_ext_wellbalanced import compute_fluxes_ext_wellbalanced #from comp_flux_ext import compute_fluxes_ext 529 531 530 domain. timestep = compute_fluxes_ext_wellbalanced(timestep,532 domain.flux_timestep = compute_fluxes_ext_wellbalanced(timestep, 531 533 epsilon, 532 534 g, -
anuga_work/development/anuga_1d/test_shallow_water.py
r5738 r5741 5 5 6 6 7 from shallow_water_domain import *8 from shallow_water_domain import flux_function as domain_flux_function7 from shallow_water_domain_new import * 8 from shallow_water_domain_new import flux_function as domain_flux_function 9 9 10 10 from Numeric import allclose, array, ones, Float, maximum, zeros … … 41 41 #print domain.quantities['stage'].explicit_update 42 42 #print domain.quantities['xmomentum'].explicit_update 43 #print stage_ud43 print stage_ud 44 44 45 45 assert allclose( domain.quantities['stage'].explicit_update, stage_ud ) … … 133 133 134 134 domain.default_order = 1 135 domain.default_time_order = 1 135 domain.set_timestepping_method('euler') 136 136 137 yieldstep=1.0 137 138 finaltime=1.0 … … 167 168 168 169 domain.default_order = 2 169 domain. default_time_order = 1170 domain.set_timestepping_method('rk2') 170 171 yieldstep=1.0 171 172 finaltime=1.0 … … 191 192 192 193 domain.default_order = 2 193 domain.default_time_order = 2 194 domain.set_timestepping_method('rk3') 195 194 196 yieldstep=1.0 195 197 finaltime=1.0 -
anuga_work/development/demos/netherlands.py
r5153 r5741 27 27 N = 130 # size = 33800 28 28 N = 600 # Size = 720000 29 N = 10029 N = 50 30 30 31 31 points, elements, boundary = rectangular_cross(N, N) … … 34 34 domain.check_integrity() 35 35 36 import sys 37 base = os.path.basename(sys.argv[0]) 38 domain.simulation_name = 'netherlands' 36 39 domain.set_name(os.path.splitext(__file__)[0]) 37 domain.set_timestepping_method('rk 3')40 domain.set_timestepping_method('rk2') 38 41 domain.set_default_order(2) 39 42 domain.set_store_vertices_uniquely(True) # Store as internally represented … … 130 133 domain.set_boundary({'left': Bd, 'right': Br, 'bottom': Br, 'top': Br}) 131 134 135 #------------------------------------------------------------------------------- 136 # Copy scripts to time stamped output directory and capture screen 137 # output to file 138 #------------------------------------------------------------------------------- 139 time = strftime('%Y%m%d_%H%M%S',localtime()) 140 141 output_dir = 'dam_break_'+time 142 output_file = 'dam_break' 143 144 copy_code_files(output_dir,__file__) 145 #start_screen_catcher(output_dir+'_') 146 132 147 133 148 #------------------------------------------------------------------------------ … … 139 154 # Initialise real-time visualiser 140 155 141 pass 142 #vis = RealtimeVisualiser(domain) 143 #vis.render_quantity_height("elevation", dynamic=False) 144 #vis.render_quantity_height("stage", dynamic=True) 145 #vis.colour_height_quantity('stage', (0.0, 0.0, 0.8)) 146 #vis.start() 156 #pass 157 visualise = True 158 if visualise: 159 from anuga.visualiser import RealtimeVisualiser 160 vis = RealtimeVisualiser(domain) 161 vis.render_quantity_height("elevation", offset=0.01, dynamic=False) 162 vis.render_quantity_height("stage", dynamic=True) 163 vis.colour_height_quantity('stage', (0.2, 0.2, 0.8)) 164 vis.start() 165 import time 166 time.sleep(2.0) 167 168 147 169 148 170 … … 151 173 t0 = time.time() 152 174 153 for t in domain.evolve(yieldstep = 0.0 05, finaltime = None):175 for t in domain.evolve(yieldstep = 0.05, finaltime = 5.0): 154 176 print domain.timestepping_statistics() 155 print domain.quantities['stage'].get_values(location='centroids', 156 indices=[0]) 157 158 #vis.update() 159 #time.sleep(0.1) 160 #raw_input('pause>') 161 #V.update_quantity('stage') 162 #rpdb.set_active() 163 #integral_label.text='Integral=%10.5e'%domain.quantities['stage'].get_integral() 164 #vis.evolveFinished() 177 #print domain.quantities['stage'].get_values(location='centroids', 178 #indices=[0]) 179 if visualise: 180 vis.update() 181 182 183 184 if visualise: vis.evolveFinished() 165 185 166 186 print 'That took %.2f seconds' %(time.time()-t0) -
anuga_work/development/shallow_water_1d_old/quantity.py
r4959 r5741 56 56 #Intialise centroid values 57 57 self.interpolate() 58 59 60 from Numeric import zeros, Float 61 62 #Allocate space for boundary values 63 #L = len(domain.boundary) 64 self.boundary_values = zeros(2, Float) #assumes no parrellism 65 66 #Allocate space for updates of conserved quantities by 67 #flux calculations and forcing functions 68 69 N = domain.number_of_elements 70 self.explicit_update = zeros(N, Float ) 71 self.semi_implicit_update = zeros(N, Float ) 72 73 self.gradients = zeros(N, Float) 74 self.qmax = zeros(self.centroid_values.shape, Float) 75 self.qmin = zeros(self.centroid_values.shape, Float) 76 77 self.beta = domain.beta 58 78 59 79 #Methods for operator overloading … … 381 401 return integral 382 402 383 class Conserved_quantity(Quantity):384 """Class conserved quantity adds to Quantity:385 386 storage and method for updating, and387 methods for extrapolation from centropid to vertices inluding388 gradients and limiters389 """390 391 def __init__(self, domain, vertex_values=None):392 Quantity.__init__(self, domain, vertex_values)393 394 from Numeric import zeros, Float395 396 #Allocate space for boundary values397 #L = len(domain.boundary)398 self.boundary_values = zeros(2, Float) #assumes no parrellism399 400 #Allocate space for updates of conserved quantities by401 #flux calculations and forcing functions402 403 N = domain.number_of_elements404 self.explicit_update = zeros(N, Float )405 self.semi_implicit_update = zeros(N, Float )406 407 self.gradients = zeros(N, Float)408 self.qmax = zeros(self.centroid_values.shape, Float)409 self.qmin = zeros(self.centroid_values.shape, Float)410 411 self.beta = domain.beta412 403 413 404 def update(self, timestep): … … 863 854 else: 864 855 qv[k,i] = qc[k] 856 857 858 class Conserved_quantity(Quantity): 859 """Class conserved quantity adds to Quantity: 860 861 storage and method for updating, and 862 methods for extrapolation from centropid to vertices inluding 863 gradients and limiters 864 """ 865 866 def __init__(self, domain, vertex_values=None): 867 Quantity.__init__(self, domain, vertex_values) 868 869 print "Use Quantity instead of Conserved_quantity" 870 865 871 866 872
Note: See TracChangeset
for help on using the changeset viewer.