Changeset 5847
- Timestamp:
- Oct 18, 2008, 9:13:18 PM (16 years ago)
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/domain.py
r5729 r5847 199 199 self.CFL = CFL 200 200 self.set_timestepping_method(timestepping_method) 201 201 self.set_beta(beta_w) 202 202 self.boundary_map = None # Will be populated by set_boundary 203 203 … … 297 297 298 298 return self.time + self.starttime 299 300 def set_beta(self,beta): 301 """Set default beta for limiting 302 """ 303 304 self.beta = beta 305 for name in self.quantities: 306 #print 'setting beta for quantity ',name 307 Q = self.quantities[name] 308 Q.set_beta(beta) 309 310 def get_beta(self): 311 """Get default beta for limiting 312 """ 313 314 return self.beta 299 315 300 316 def set_default_order(self, n): … … 1206 1222 self.update_ghosts() 1207 1223 1224 1225 # Update time 1226 self.time += self.timestep 1227 1208 1228 # Update vertex and edge values 1209 1229 self.distribute_to_vertices_and_edges() … … 1212 1232 self.update_boundary() 1213 1233 1214 # Update time1215 self.time += self.timestep1216 1234 1217 1235 … … 1243 1261 self.update_ghosts() 1244 1262 1263 # Update time 1264 self.time += self.timestep 1265 1245 1266 # Update vertex and edge values 1246 1267 self.distribute_to_vertices_and_edges() … … 1248 1269 # Update boundary values 1249 1270 self.update_boundary() 1250 1251 # Update time1252 self.time += self.timestep1253 1271 1254 1272 #------------------------------------ … … 1309 1327 self.update_ghosts() 1310 1328 1329 # Update time 1330 self.time += self.timestep 1331 1311 1332 # Update vertex and edge values 1312 1333 self.distribute_to_vertices_and_edges() … … 1315 1336 self.update_boundary() 1316 1337 1317 # Update time1318 self.time += self.timestep1319 1338 1320 1339 #------------------------------------ … … 1339 1358 self.update_ghosts() 1340 1359 1360 1361 # Set substep time 1362 self.time = initial_time + self.timestep*0.5 1363 1341 1364 # Update vertex and edge values 1342 1365 self.distribute_to_vertices_and_edges() … … 1345 1368 self.update_boundary() 1346 1369 1347 # Set substep time1348 self.time = initial_time + self.timestep*0.51349 1370 1350 1371 #------------------------------------ … … 1369 1390 self.update_ghosts() 1370 1391 1392 # Set new time 1393 self.time = initial_time + self.timestep 1394 1371 1395 # Update vertex and edge values 1372 1396 self.distribute_to_vertices_and_edges() … … 1375 1399 self.update_boundary() 1376 1400 1377 # Set new time 1378 self.time = initial_time + self.timestep 1379 1380 1401 1381 1402 def evolve_to_end(self, finaltime = 1.0): 1382 """Iterate evolve all the way to the end 1383 """ 1403 """Iterate evolve all the way to the end """ 1384 1404 1385 1405 for _ in self.evolve(yieldstep=None, finaltime=finaltime): -
anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
r5776 r5847 82 82 self.centroid_backup_values = zeros(N, Float) 83 83 84 self. beta = 1.084 self.set_beta(1.0) 85 85 86 86 … … 223 223 # """ 224 224 # pass 225 225 226 def set_beta(self,beta): 227 """Set default beta value for limiting 228 """ 229 230 if beta < 0.0: 231 print 'WARNING: setting beta < 0.0' 232 if beta > 2.0: 233 print 'WARNING: setting beta > 2.0' 234 235 self.beta = beta 236 237 def get_beta(self): 238 """Get default beta value for limiting 239 """ 240 241 return self.beta 226 242 227 243 def interpolate(self): -
anuga_core/source/anuga/advection/advection.py
r5242 r5847 73 73 74 74 #Only first is implemented for advection 75 self.default_order = self.order = 1 76 75 self.set_default_order(1) 76 self.set_beta(1.0) 77 77 78 self.smooth = True 78 79 … … 82 83 msg = 'Conserved quantity must be "stage"' 83 84 assert self.conserved_quantities[0] == 'stage', msg 85 86 87 def distribute_to_vertices_and_edges(self): 88 """Extrapolate conserved quantities from centroid to 89 vertices and edge-midpoints for each volume 90 91 Default implementation is straight first order, 92 i.e. constant values throughout each element and 93 no reference to non-conserved quantities. 94 """ 95 96 for name in self.conserved_quantities: 97 Q = self.quantities[name] 98 if self._order_ == 1: 99 Q.extrapolate_first_order() 100 elif self._order_ == 2: 101 Q.extrapolate_second_order_and_limit_by_edge() 102 #Q.limit() 103 else: 104 raise 'Unknown order' 105 #Q.interpolate_from_vertices_to_edges() 106 107 84 108 85 109 … … 161 185 162 186 163 def evolve(self,164 yieldstep = None,165 finaltime = None,166 duration = None,167 skip_initial_step = False):168 169 """Specialisation of basic evolve method from parent class170 """171 172 #Call basic machinery from parent class173 for t in Generic_domain.evolve(self,174 yieldstep=yieldstep,175 finaltime=finaltime,176 duration=duration,177 skip_initial_step=skip_initial_step):178 179 #Pass control on to outer loop for more specific actions180 yield(t)187 ## def evolve(self, 188 ## yieldstep = None, 189 ## finaltime = None, 190 ## duration = None, 191 ## skip_initial_step = False): 192 193 ## """Specialisation of basic evolve method from parent class 194 ## """ 195 196 ## #Call basic machinery from parent class 197 ## for t in Generic_domain.evolve(self, 198 ## yieldstep=yieldstep, 199 ## finaltime=finaltime, 200 ## duration=duration, 201 ## skip_initial_step=skip_initial_step): 202 203 ## #Pass control on to outer loop for more specific actions 204 ## yield(t) 181 205 182 206 -
anuga_core/source/anuga/shallow_water/shallow_water_ext.c
r5618 r5847 1877 1877 radii = get_consecutive_array(domain, "radii"); 1878 1878 areas = get_consecutive_array(domain, "areas"); 1879 tri_full_flag = get_consecutive_array(domain, " normals");1879 tri_full_flag = get_consecutive_array(domain, "tri_full_flag"); 1880 1880 already_computed_flux = get_consecutive_array(domain, "already_computed_flux"); 1881 1881 max_speed_array = get_consecutive_array(domain, "max_speed"); -
anuga_core/source/anuga/shallow_water/test_system.py
r4712 r5847 150 150 for t in domain.evolve(yieldstep = 5, finaltime = 9.0): 151 151 pass 152 # printdomain.write_time()152 #domain.write_time() 153 153 #print "domain.time", domain.time 154 154 … … 157 157 times = fid.variables['time'][:] 158 158 stage = fid.variables['stage'][:] 159 #print stage 159 160 #print "times", times 160 161 #print "fid.starttime", fid.starttime -
anuga_core/source/anuga_parallel/parallel_api.py
r3928 r5847 43 43 # FIXME: Dummy assignment (until boundaries are refactored to 44 44 # be independent of domains until they are applied) 45 bdmap = {} 46 for tag in domain.get_boundary_tags(): 47 bdmap[tag] = None 48 49 50 domain.set_boundary(bdmap) 45 if myid == 0: 46 bdmap = {} 47 for tag in domain.get_boundary_tags(): 48 bdmap[tag] = None 49 50 51 domain.set_boundary(bdmap) 51 52 52 53 -
anuga_core/source/anuga_parallel/test_parallel_sw_runup.py
r5822 r5847 32 32 33 33 #-------------------------------------------------------------------------- 34 # Setup computational domain 34 # Setup computational domain on processor 0 35 35 #-------------------------------------------------------------------------- 36 points, vertices, boundary = rectangular_cross(10, 10) # Basic mesh 36 if myid == 0 : 37 points, vertices, boundary = rectangular_cross(10, 10) # Basic mesh 37 38 38 #if myid == 0: 39 # print 'points', points 40 # print 'vertices', vertices 39 #print 'points', points 40 #print 'vertices', vertices 41 41 42 domain = Domain(points, vertices, boundary) # Create domain 42 domain = Domain(points, vertices, boundary) # Create domain 43 else: 44 domain = None 43 45 44 46 #-------------------------------------------------------------------------- … … 49 51 return -x/2 # linear bed slope 50 52 51 domain.set_quantity('elevation', topography) # Use function for elevation 52 domain.set_quantity('friction', 0.0) # Constant friction 53 domain.set_quantity('stage', expression='elevation') # Dry initial stage 53 54 if myid == 0: 55 domain.set_quantity('elevation', topography) # Use function for elevation 56 domain.set_quantity('friction', 0.0) # Constant friction 57 domain.set_quantity('stage', expression='elevation') # Dry initial stage 54 58 55 59 … … 129 133 stage = domain.get_quantity('stage') 130 134 w = stage.get_values(interpolation_points=interpolation_points) 135 136 print 'P%d:w(%f) = '%(myid,domain.get_time()),w 131 137 132 138 for i, _ in enumerate(interpolation_points): 133 139 gauge_values[i].append(w[i]) 134 140 135 if myid == 0:136 for i, (x,y) in enumerate(interpolation_points):141 ## if myid == 0: 142 ## for i, (x,y) in enumerate(interpolation_points): 137 143 138 try:139 from pylab import *140 except:141 pass142 else:143 ion()144 hold(False)145 plot(time, gauge_values[i], 'r.-')146 #time, predicted_gauge_values[i], 'k-')144 ## try: 145 ## from pylab import * 146 ## except: 147 ## pass 148 ## else: 149 ## ion() 150 ## hold(False) 151 ## plot(time, gauge_values[i], 'r.-') 152 ## #time, predicted_gauge_values[i], 'k-') 147 153 148 title('Gauge %d (%f,%f)' %(i,x,y))149 xlabel('time(s)')150 ylabel('stage (m)')151 #legend(('Observed', 'Modelled'), shadow=True, loc='upper left')152 #savefig('Gauge_%d.png' %i, dpi = 300)154 ## title('Gauge %d (%f,%f)' %(i,x,y)) 155 ## xlabel('time(s)') 156 ## ylabel('stage (m)') 157 ## #legend(('Observed', 'Modelled'), shadow=True, loc='upper left') 158 ## #savefig('Gauge_%d.png' %i, dpi = 300) 153 159 154 raw_input('Next')160 ## raw_input('Next') 155 161 156 162 -
anuga_core/source/obsolete_code/netherlands-chris.py
r3565 r5847 97 97 N = 60 98 98 99 N = 4 99 N = 40 100 100 #N = 140 101 101 #N = 15 … … 165 165 domain.set_quantity('stage', Constant_height(Z, 0.)) 166 166 167 168 visualize = True 169 if visualize: 170 from anuga.visualiser import RealtimeVisualiser 171 vis = RealtimeVisualiser(domain) 172 vis.render_quantity_height("elevation", zScale=100, offset = 5.0, dynamic=False) 173 vis.render_quantity_height("stage", zScale =100, dynamic=True, opacity = 0.3) 174 vis.colour_height_quantity('stage', (lambda q:q['stage'], -0.5, 0.5)) 175 vis.start() 176 177 time.sleep(2.0) 178 179 180 167 181 #Evolve 168 182 import time … … 172 186 domain.write_time() 173 187 174 188 if visualize: vis.update() 189 190 if visualize: vis.evolveFinished() 175 191 176 192 -
anuga_core/source/pypar-numeric/mandelbrot_example/compile.py
r5779 r5847 149 149 if os.name == 'posix' and os.uname()[4] == 'x86_64': 150 150 #Extra flags for 64 bit architectures 151 #s += ' -fPIC -m64' #gcc152 s += ' -fPIC -tp amd64' #pgcc151 s += ' -fPIC -m64' #gcc 152 #s += ' -fPIC -tp amd64' #pgcc 153 153 154 154 -
anuga_core/source/pypar-numeric/mandelbrot_example/mandel_sequential.py
r5779 r5847 12 12 # User definable parameters 13 13 kmax = 2**15 # Maximal number of iterations (=number of colors) 14 M = N = 700 # width = height = N (200, 400, 600, 700 are good)14 M = N = 200 # width = height = N (200, 400, 600, 700 are good) 15 15 16 16 # Region in complex plane -
anuga_core/source/pypar-numeric/mandelbrot_example/mandelplot.py
r5779 r5847 18 18 """ 19 19 20 from Tkinter import Frame, Canvas, TOP, NW, PhotoImage 20 #from Tkinter import Frame, Canvas, TOP, NW, PhotoImage 21 from pylab import imshow, show 21 22 from Numeric import transpose, Float 22 from Image import new # PIL23 #from Image import new # PIL 23 24 import time 24 25 … … 27 28 # User definable parameters 28 29 29 imtype = 'ppm' # Image format (e.g 'ppm', 'bmp', 'tiff')30 filename ='mandel' # Base filename30 #imtype = 'ppm' # Image format (e.g 'ppm', 'bmp', 'tiff') 31 #filename ='mandel' # Base filename 31 32 32 33 exponent = 0.998 # Exponent for morphing colors, good with kmax = 2**15 … … 47 48 A = transpose(A).astype(Float) 48 49 49 im = new("RGB", A.shape)50 #im = new("RGB", A.shape) 50 51 51 52 … … 78 79 79 80 # Save image to file 80 im.putdata(L) 81 im.save(filename + '.' + imtype, imtype) 81 imshow(A) 82 show() 83 84 #im.save(filename + '.' + imtype, imtype) 82 85 print 'Computed plot in %.2f seconds: ' %(time.time()-t0) 83 86 … … 88 91 # sys.exit() 89 92 90 import os91 os.system('xv %s' %(filename + '.' + imtype))93 #import os 94 #os.system('xv %s' %(filename + '.' + imtype)) 92 95 93 96 -
anuga_validation/okushiri_2005/run_okushiri_parallel.py
r4299 r5847 39 39 #------------------------- 40 40 # Create Domain from mesh 41 # on processor 0 41 42 #------------------------- 42 domain = Domain(project.mesh_filename, use_cache=use_cache, verbose=True) 43 print domain.statistics() 43 if myid == 0 : 44 domain = Domain(project.mesh_filename, use_cache=use_cache, verbose=True) 45 print domain.statistics() 44 46 45 46 #------------------------- 47 # Initial Conditions 48 #------------------------- 49 domain.set_quantity('friction', 0.0) 50 domain.set_quantity('stage', 0.0) 51 domain.set_quantity('elevation', 52 filename=project.bathymetry_filename, 53 alpha=0.02, 54 verbose=True, 55 use_cache=use_cache) 56 47 #------------------------- 48 # Initial Conditions 49 # At present need to do the 50 # fitting of the bathymetry 51 # on a global domain, ie before 52 # distributing the domain 53 #------------------------- 54 domain.set_quantity('friction', 0.0) 55 domain.set_quantity('stage', 0.0) 56 domain.set_quantity('elevation', 57 filename=project.bathymetry_filename, 58 alpha=0.02, 59 verbose=True, 60 use_cache=use_cache) 61 else: 62 domain = None 57 63 58 64 #------------------------- … … 86 92 domain.set_boundary({'wave': Bts, 'wall': Br}) 87 93 94 # Select triangle containing ch5 for diagnostic output 95 # around known gauge 96 # This should get triangle id 32833 with centroid (4.5244, 1.1972) on one processor 97 try: 98 triangle_id = domain.get_triangle_containing_point([4.521, 1.196]) 99 except: 100 triangle_id = None 101 88 102 89 103 #------------------------- … … 94 108 95 109 for t in domain.evolve(yieldstep = 0.05, finaltime = 22.5): 96 domain.write_time() 110 if myid == 0 : 111 domain.write_time() 112 113 if triangle_id is not None : 114 print domain.timestepping_statistics(track_speeds=False, 115 triangle_id=triangle_id) 97 116 98 117 print 'That took %.2f seconds' %(time.time()-t0) -
anuga_validation/performance_tests/run_profile.py
r5320 r5847 57 57 s = 'for t in domain.evolve(yieldstep = 0.02, finaltime = 0.2): domain.write_time()' 58 58 59 #for t in domain.evolve(yieldstep = 0.02, finaltime = 0.2): domain.write_time() 60 59 61 60 62 import profile, pstats
Note: See TracChangeset
for help on using the changeset viewer.