Changeset 1826
- Timestamp:
- Sep 13, 2005, 11:49:38 AM (19 years ago)
- Location:
- inundation/pyvolution
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/domain.py
r1825 r1826 322 322 323 323 def write_time(self): 324 print self.timestepping_statistics() 325 326 #Old version 327 #if self.min_timestep == self.max_timestep: 328 # print 'Time = %.4f, delta t = %.8f, steps=%d (%d)'\ 329 # %(self.time, self.min_timestep, self.number_of_steps, 330 # self.number_of_first_order_steps) 331 #elif self.min_timestep > self.max_timestep: 332 # print 'Time = %.4f, steps=%d (%d)'\ 333 # %(self.time, self.number_of_steps, 334 # self.number_of_first_order_steps) 335 #else: 336 # print 'Time = %.4f, delta t in [%.8f, %.8f], steps=%d (%d)'\ 337 # %(self.time, self.min_timestep, 338 # self.max_timestep, self.number_of_steps, 339 # self.number_of_first_order_steps) 340 341 def timestepping_statistics(self): 342 """Return string with time stepping statistics for printing or logging 343 """ 344 345 msg = '' 324 346 if self.min_timestep == self.max_timestep: 325 print 'Time = %.4f, delta t = %.8f, steps=%d (%d)'\326 %(self.time, self.min_timestep, self.number_of_steps,327 self.number_of_first_order_steps)347 msg += 'Time = %.4f, delta t = %.8f, steps=%d (%d)\n'\ 348 %(self.time, self.min_timestep, self.number_of_steps, 349 self.number_of_first_order_steps) 328 350 elif self.min_timestep > self.max_timestep: 329 print 'Time = %.4f, steps=%d (%d)'\330 %(self.time, self.number_of_steps,331 self.number_of_first_order_steps)351 msg += 'Time = %.4f, steps=%d (%d)\n'\ 352 %(self.time, self.number_of_steps, 353 self.number_of_first_order_steps) 332 354 else: 333 print 'Time = %.4f, delta t in [%.8f, %.8f], steps=%d (%d)'\ 334 %(self.time, self.min_timestep, 335 self.max_timestep, self.number_of_steps, 336 self.number_of_first_order_steps) 337 338 def boundary_stats(self, quantities = None, tags = None): 355 msg += 'Time = %.4f, delta t in [%.8f, %.8f], steps=%d (%d)\n'\ 356 %(self.time, self.min_timestep, 357 self.max_timestep, self.number_of_steps, 358 self.number_of_first_order_steps) 359 360 return msg 361 362 363 def write_boundary(self): 364 print self.boundary_statistics() 365 366 def boundary_statistics(self, quantities = None, tags = None): 339 367 """Output statistics about boundary forcing at each timestep 340 368 … … 351 379 If tags are specified only report on those, otherwise take all tags. 352 380 353 #FIXME: Should return text string354 381 """ 355 382 356 383 #Input checks 357 import types 384 import types, string 358 385 359 386 if quantities is None: … … 376 403 assert type(tags) == types.ListType, msg 377 404 378 379 #Output stats 380 381 print 'Boundary values at time %.4f:' %self.time 382 405 #Determine width of longest quantity name (for cosmetic purposes) 406 maxwidth = 0 407 for name in quantities: 408 w = len(name) 409 if w > maxwidth: 410 maxwidth = w 411 412 #Output stats 413 msg = 'Boundary values at time %.4f:\n' %self.time 383 414 for tag in tags: 384 print ' Tag: %s' %tag385 415 msg += ' %s:\n' %tag 416 386 417 for name in quantities: 387 418 q = self.quantities[name] 388 419 389 420 #Find range of boundary values for tag and q 390 421 maxval = minval = None 391 for i, ((vol_id, edge_id), B) in enumerate(self.boundary_objects): 422 for i, ((vol_id, edge_id), B) in\ 423 enumerate(self.boundary_objects): 392 424 if self.boundary[(vol_id, edge_id)] == tag: 393 425 v = q.boundary_values[i] 394 426 if minval is None or v < minval: minval = v 395 427 if maxval is None or v > maxval: maxval = v 396 428 397 429 if minval is None or maxval is None: 398 print 'Sorry no information about tag %s and quantity %s' %(tag, name) 430 msg += ' Sorry no information available about' +\ 431 ' tag %s and quantity %s\n' %(tag, name) 399 432 else: 400 print ' %s\t in [%12.8f, %12.8f]'\ 401 %(name, minval, maxval) 402 403 404 405 406 #for name in quantities: 407 # q = self.quantities[name] 408 # 409 # if tag is None: 410 # #Take entire boundary 411 # print ' Quantity %s: min = %12.8f, max = %12.8f'\ 412 # %(name, min(q.boundary_values), max(q.boundary_values)) 413 # else: 414 # #Take only boundary associated with tag 415 # maxval = minval = None 416 # for i, ((vol_id, edge_id), B) in enumerate(self.boundary_objects): 417 # if self.boundary[(vol_id, edge_id)] == tag: 418 # v = q.boundary_values[i] 419 # if minval is None or v < minval: minval = v 420 # if maxval is None or v > maxval: maxval = v 421 # 422 # if minval is None or maxval is None: 423 # print 'Sorry no information about tag %s' %tag 424 # else: 425 # print ' Quantity %s, tag %s: min = %12.8f, max = %12.8f'\ 426 # %(name, tag, minval, maxval) 427 428 429 430 431 432 433 434 435 436 433 msg += ' %s in [%12.8f, %12.8f]\n'\ 434 %(string.ljust(name, maxwidth), minval, maxval) 435 436 437 return msg 438 439 437 440 def get_name(self): 438 441 return self.filename -
inundation/pyvolution/netherlands.py
r1751 r1826 169 169 for t in domain.evolve(yieldstep = 0.02, finaltime = 15.0): 170 170 domain.write_time() 171 domain.write_boundary() 172 171 173 print domain.quantities['stage'].get_values(location='centroids', 172 174 indices=[0])
Note: See TracChangeset
for help on using the changeset viewer.