Changeset 8069
- Timestamp:
- Nov 11, 2010, 4:47:02 PM (14 years ago)
- Location:
- branches/anuga_1_2_0/anuga_core/source/anuga
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/anuga_1_2_0/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py
r7810 r8069 62 62 full_send_dict=None, 63 63 ghost_recv_dict=None, 64 starttime=0.0, 64 65 processor=0, 65 66 numproc=1, … … 253 254 self.finaltime = None 254 255 self.recorded_min_timestep = self.recorded_max_timestep = 0.0 255 self.starttime = 0# Physical starttime if any256 # (0 is 1 Jan 1970 00:00:00)256 self.starttime = starttime # Physical starttime if any 257 self.time = self.starttime 257 258 self.timestep = 0.0 258 259 self.flux_timestep = 0.0 … … 496 497 """Get the absolute model time (seconds).""" 497 498 498 return self.time + self.starttime 499 return self.time 500 501 ## 502 # @brief Get current timestep. 503 # @return The curent timestep (seconds). 504 def get_timestep(self): 505 """et current timestep (seconds).""" 506 507 return self.timestep 499 508 500 509 ## … … 1213 1222 # Observe time interval restriction if any 1214 1223 if self.monitor_time_interval is not None and\ 1215 (self. time< self.monitor_time_interval[0] or\1216 self. time> self.monitor_time_interval[1]):1224 (self.get_time() < self.monitor_time_interval[0] or\ 1225 self.get_time() > self.monitor_time_interval[1]): 1217 1226 return 1218 1227 … … 1237 1246 maxloc = Q.get_maximum_location() 1238 1247 info_block['max_location'] = maxloc 1239 info_block['max_time'] = self. time1248 info_block['max_time'] = self.get_time() 1240 1249 1241 1250 # Update minimum … … 1246 1255 minloc = Q.get_minimum_location() 1247 1256 info_block['min_location'] = minloc 1248 info_block['min_time'] = self. time1257 info_block['min_time'] = self.get_time() 1249 1258 1250 1259 ## … … 1364 1373 def set_starttime(self, time): 1365 1374 self.starttime = float(time) 1375 self.set_time(self.starttime) 1376 1366 1377 1367 1378 ################################################################################ … … 1415 1426 % self.get_boundary_tags()) 1416 1427 assert hasattr(self, 'boundary_objects'), msg 1417 1428 1429 if self.get_time() != self.get_starttime(): 1430 self.set_time(self.get_starttime()) 1431 1418 1432 if yieldstep is None: 1419 1433 yieldstep = self.evolve_max_timestep … … 1423 1437 self._order_ = self.default_order 1424 1438 1439 assert finaltime > self.get_starttime(), 'finaltime is less than starttime!' 1440 1425 1441 if finaltime is not None and duration is not None: 1426 1442 msg = 'Only one of finaltime and duration may be specified' … … 1433 1449 1434 1450 N = len(self) # Number of triangles 1435 self.yieldtime = self. time+ yieldstep # set next yield time1451 self.yieldtime = self.get_time() + yieldstep # set next yield time 1436 1452 1437 1453 # Initialise interval of timestep sizes (for reporting only) … … 1458 1474 1459 1475 if skip_initial_step is False: 1460 yield(self. time) # Yield initial values1476 yield(self.get_time()) # Yield initial values 1461 1477 1462 1478 while True: 1463 # Evolve One Step, using appropriate timestepping method 1479 1480 initial_time = self.get_time() 1481 1464 1482 if self.get_timestepping_method() == 'euler': 1465 self.evolve_one_euler_step(yieldstep, finaltime)1483 self.evolve_one_euler_step(yieldstep, self.finaltime) 1466 1484 1467 1485 elif self.get_timestepping_method() == 'rk2': 1468 self.evolve_one_rk2_step(yieldstep, finaltime)1486 self.evolve_one_rk2_step(yieldstep, self.finaltime) 1469 1487 1470 1488 elif self.get_timestepping_method() == 'rk3': 1471 self.evolve_one_rk3_step(yieldstep, finaltime)1489 self.evolve_one_rk3_step(yieldstep, self.finaltime) 1472 1490 1473 1491 # Update extrema if necessary (for reporting) … … 1479 1497 1480 1498 # Yield results 1481 if finaltime is not None and self.time >= finaltime-epsilon: 1482 if self.time > finaltime: 1499 if self.finaltime is not None and self.get_time() >= self.finaltime-epsilon: 1500 1501 if self.get_time() > self.finaltime: 1483 1502 # FIXME (Ole, 30 April 2006): Do we need this check? 1484 1503 # Probably not (Ole, 18 September 2008). 1485 1504 # Now changed to Exception. 1486 msg = ('WARNING (domain.py): time overshot finaltime. ' 1487 'Contact Ole.Nielsen@ga.gov.au') 1505 msg = ('WARNING (domain.py): time overshot finaltime. ') 1488 1506 raise Exception, msg 1489 1507 1490 # Yield final time and stop1491 self. time = finaltime1492 yield(self. time)1508 # Log and then Yield final time and stop 1509 self.set_time(self.finaltime) 1510 yield(self.get_time()) 1493 1511 break 1494 1512 1495 1513 # if we are at the next yield point 1496 if self. time>= self.yieldtime:1514 if self.get_time() >= self.yieldtime: 1497 1515 # Yield (intermediate) time and allow inspection of domain 1498 1516 if self.checkpoint is True: … … 1500 1518 self.delete_old_checkpoints() 1501 1519 1502 # Pass control on to outer loop for more specific actions1503 yield(self. time)1520 # Log and then Pass control on to outer loop for more specific actions 1521 yield(self.get_time()) 1504 1522 1505 1523 # Reinitialise … … 1578 1596 1579 1597 # Update time 1580 self. time += self.timestep1598 self.set_time(self.get_time() + self.timestep) 1581 1599 1582 1600 # Update vertex and edge values … … 1632 1650 self.backup_conserved_quantities() 1633 1651 1634 initial_time = self. time1652 initial_time = self.get_time() 1635 1653 1636 1654 ###### … … 1654 1672 1655 1673 # Update time 1656 self. time += self.timestep1674 self.set_time(self.time + self.timestep) 1657 1675 1658 1676 # Update vertex and edge values … … 1690 1708 1691 1709 # Set substep time 1692 self. time = initial_time + self.timestep*0.51710 self.set_time(initial_time + self.timestep*0.5) 1693 1711 1694 1712 # Update vertex and edge values … … 1723 1741 1724 1742 # Set new time 1725 self. time = initial_time + self.timestep1743 self.set_time(initial_time + self.timestep) 1726 1744 1727 1745 # Update vertex and edge values … … 1875 1893 1876 1894 # Ensure that final time is not exceeded 1877 if finaltime is not None and self. time+ timestep > finaltime :1878 timestep = finaltime -self.time1895 if finaltime is not None and self.get_time() + timestep > finaltime : 1896 timestep = finaltime - self.get_time() 1879 1897 1880 1898 # Ensure that model time is aligned with yieldsteps 1881 if self. time+ timestep > self.yieldtime:1882 timestep = self.yieldtime - self. time1899 if self.get_time() + timestep > self.yieldtime: 1900 timestep = self.yieldtime - self.get_time() 1883 1901 1884 1902 self.timestep = timestep … … 2009 2027 for i in range(self.number_of_full_triangles): 2010 2028 if self.max_speed[i] > bins[-1]: 2011 msg = 'Time=%f: Ignoring isolated high ' % self. time2029 msg = 'Time=%f: Ignoring isolated high ' % self.get_time() 2012 2030 msg += 'speed triangle ' 2013 2031 msg += '#%d of %d with max speed=%f' \ -
branches/anuga_1_2_0/anuga_core/source/anuga/abstract_2d_finite_volumes/test_gauge.py
r7778 r8069 84 84 os.remove(self.sww.filename) 85 85 86 def _create_sww(self ):86 def _create_sww(self,stage=10.0, timestep=2.0): 87 87 self.sww = SWW_file(self.domain) 88 88 self.sww.store_connectivity() 89 89 self.sww.store_timestep() 90 self.domain.set_quantity('stage', 10.0) # This is automatically limited90 self.domain.set_quantity('stage', stage) # This is automatically limited 91 91 # so it will not be less than the elevation 92 self.domain. time = 2.92 self.domain.set_time(self.domain.get_time()-self.domain.starttime+timestep) 93 93 self.sww.store_timestep() 94 94 … … 245 245 246 246 domain = self.domain 247 domain.set_starttime(5) 248 self._create_sww() 247 domain.set_starttime(1) 248 249 self._create_sww(timestep=2) 249 250 250 251 # test the function … … 258 259 point2, 0.5, 2.0, 9.0\n") 259 260 file_id.close() 260 261 261 262 sww2csv_gauges(self.sww.filename, 262 263 points_file, … … 265 266 266 267 # point1_answers_array = [[0.0,1.0,-5.0,3.0,4.0], [2.0,10.0,-5.0,3.0,4.0]] 267 point1_answers_array = [[ 5.0,5.0/3600.,1.0,6.0,-5.0,3.0,4.0], [7.0,7.0/3600.,10.0,15.0,-5.0,3.0,4.0]]268 point1_answers_array = [[2.0,2.0/3600.,1.0,6.0,-5.0,3.0,4.0], [3.0,3.0/3600.,10.0,15.0,-5.0,3.0,4.0]] 268 269 point1_filename = 'gauge_point1.csv' 269 270 point1_handle = file(point1_filename) … … 279 280 assert num.allclose(line[i], point1_answers_array[i]) 280 281 281 point2_answers_array = [[ 5.0,5.0/3600.,1.0,1.5,-0.5,3.0,4.0], [7.0,7.0/3600.,10.0,10.5,-0.5,3.0,4.0]]282 point2_answers_array = [[2.0,2.0/3600.,1.0,1.5,-0.5,3.0,4.0], [3.0,3.0/3600.,10.0,10.5,-0.5,3.0,4.0]] 282 283 point2_filename = 'gauge_point2.csv' 283 284 point2_handle = file(point2_filename) -
branches/anuga_1_2_0/anuga_core/source/anuga/file/sww.py
r7862 r8069 941 941 942 942 try: 943 domain = Domain(coordinates, volumes, boundary )943 domain = Domain(coordinates, volumes, boundary, starttime=(float(starttime) + float(t))) 944 944 except AssertionError, e: 945 945 fid.close() -
branches/anuga_1_2_0/anuga_core/source/anuga/file/test_read_sww.py
r7762 r8069 151 151 new_domain.set_quantity(qname, q) 152 152 153 154 new_domain.set_starttime(sww_file.get_time())155 153 #------------------------------------------------------------------ 156 154 # Setup boundary conditions -
branches/anuga_1_2_0/anuga_core/source/anuga/file/test_sww.py
r7872 r8069 103 103 #Now evolve them both, just to be sure 104 104 ######################################x 105 domain.time = 0. 105 106 106 from time import sleep 107 107 … … 116 116 pass 117 117 118 final = final - (domain2.starttime-domain.starttime)119 118 #BUT since domain1 gets time hacked back to 0: 120 final = final + (domain2.starttime-domain.starttime) 119 120 final = final + (domain2.get_starttime() - domain.get_starttime()) 121 121 122 122 domain2.smooth = False -
branches/anuga_1_2_0/anuga_core/source/anuga/file_conversion/sww2dem.py
r7841 r8069 78 78 'elevation'. Quantity is not a list of quantities. 79 79 80 if timestep (an index) is given, output quantity at that timestep81 82 if reduction is given and its an index, output quantity at that timestep. If reduction is given83 and is a built in function, use that to reduce quantity over all timesteps.80 If reduction is given and it's an index, sww2dem will output the quantity at that time-step. 81 If reduction is given and it's a built in function (eg max, min, mean), then that 82 function is used to reduce the quantity over all time-steps. If reduction is not given, 83 reduction is set to "max" by default. 84 84 85 85 datum -
branches/anuga_1_2_0/anuga_core/source/anuga/file_conversion/test_urs2sts.py
r7866 r8069 1411 1411 1412 1412 domain_drchlt = Domain(meshname) 1413 domain_drchlt.set_starttime(2.0) 1413 1414 domain_drchlt.set_quantity('stage', tide) 1414 1415 Br = Reflective_boundary(domain_drchlt) … … 1554 1555 1555 1556 domain_drchlt = Domain(meshname) 1557 domain_drchlt.set_starttime(2.0) 1556 1558 domain_drchlt.set_quantity('stage', tide) 1557 1559 Br = Reflective_boundary(domain_drchlt) … … 1919 1921 1920 1922 domain_drchlt = Domain(meshname) 1923 domain_drchlt.set_starttime(2.0) 1921 1924 domain_drchlt.set_quantity('stage', tide) 1922 1925 Br = Reflective_boundary(domain_drchlt) -
branches/anuga_1_2_0/anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r7870 r8069 106 106 full_send_dict=None, 107 107 ghost_recv_dict=None, 108 starttime=0, 108 109 processor=0, 109 110 numproc=1, … … 155 156 full_send_dict, 156 157 ghost_recv_dict, 158 starttime, 157 159 processor, 158 160 numproc, … … 561 563 self.distribute_to_vertices_and_edges() 562 564 563 if self.store is True and self. time == 0.0:565 if self.store is True and self.get_time() == self.get_starttime(): 564 566 self.initialise_storage() 565 567 -
branches/anuga_1_2_0/anuga_core/source/anuga/shallow_water/test_data_manager.py
r7872 r8069 783 783 784 784 temp_time=num.zeros(int(finaltime/yieldstep)+1,num.float) 785 786 domain_time.set_starttime(domain_fbound.get_starttime()) 787 785 788 for i, t in enumerate(domain_time.evolve(yieldstep=yieldstep, 786 789 finaltime=finaltime, … … 831 834 if __name__ == "__main__": 832 835 #suite = unittest.makeSuite(Test_Data_Manager, 'test_sww2domain2') 833 suite = unittest.makeSuite(Test_Data_Manager, 'test _sww')836 suite = unittest.makeSuite(Test_Data_Manager, 'test') 834 837 835 838 -
branches/anuga_1_2_0/anuga_core/source/anuga/shallow_water/test_forcing.py
r7844 r8069 591 591 domain.forcing_terms.append(R) 592 592 593 # This will test that time used in the forcing function takes 594 # startime into account. 595 domain.starttime = 5.0 596 597 domain.time = 7. 593 # This will test that time is set to starttime in set_starttime 594 domain.set_starttime(5.0) 598 595 599 596 domain.compute_forcing_terms() … … 602 599 (3*domain.get_time() + 7)/1000) 603 600 assert num.allclose(domain.quantities['stage'].explicit_update[1], 604 (3*(domain.time + domain.starttime) + 7)/1000) 605 606 # Using internal time her should fail 607 assert not num.allclose(domain.quantities['stage'].explicit_update[1], 608 (3*domain.time + 7)/1000) 601 (3*domain.get_starttime() + 7)/1000) 609 602 610 603 assert num.allclose(domain.quantities['stage'].explicit_update[0], 0) … … 657 650 domain.forcing_terms.append(R) 658 651 659 # This will test that time used in the forcing function takes 660 # startime into account. 661 domain.starttime = 5.0 662 663 domain.time = 7. 652 # This will test that time is set to starttime in set_starttime 653 domain.set_starttime(5.0) 664 654 665 655 domain.compute_forcing_terms() … … 668 658 (3*domain.get_time() + 7)/1000) 669 659 assert num.allclose(domain.quantities['stage'].explicit_update[1], 670 (3*(domain.time + domain.starttime) + 7)/1000) 671 672 # Using internal time her should fail 673 assert not num.allclose(domain.quantities['stage'].explicit_update[1], 674 (3*domain.time + 7)/1000) 660 (3*domain.get_starttime() + 7)/1000) 675 661 676 662 assert num.allclose(domain.quantities['stage'].explicit_update[0], 0) -
branches/anuga_1_2_0/anuga_core/source/anuga/shallow_water/test_forcing_terms.py
r7814 r8069 887 887 domain.forcing_terms.append(R) 888 888 889 # This will test that time used in the forcing function takes 890 # startime into account. 891 domain.starttime = 5.0 892 893 domain.time = 7. 889 # This will test that time is set to starttime in set_starttime 890 domain.set_starttime(5.0) 894 891 895 892 domain.compute_forcing_terms() … … 898 895 (3*domain.get_time() + 7)/1000) 899 896 assert num.allclose(domain.quantities['stage'].explicit_update[1], 900 (3*(domain.time + domain.starttime) + 7)/1000) 901 902 # Using internal time her should fail 903 assert not num.allclose(domain.quantities['stage'].explicit_update[1], 904 (3*domain.time + 7)/1000) 897 (3*domain.get_starttime() + 7)/1000) 905 898 906 899 assert num.allclose(domain.quantities['stage'].explicit_update[0], 0) … … 953 946 domain.forcing_terms.append(R) 954 947 955 # This will test that time used in the forcing function takes 956 # startime into account. 957 domain.starttime = 5.0 958 959 domain.time = 7. 948 # This will test that time is set to starttime in set_starttime 949 domain.set_starttime(5.0) 960 950 961 951 domain.compute_forcing_terms() … … 964 954 (3*domain.get_time() + 7)/1000) 965 955 assert num.allclose(domain.quantities['stage'].explicit_update[1], 966 (3*(domain.time + domain.starttime) + 7)/1000) 967 968 # Using internal time her should fail 969 assert not num.allclose(domain.quantities['stage'].explicit_update[1], 970 (3*domain.time + 7)/1000) 956 (3*domain.get_starttime() + 7)/1000) 971 957 972 958 assert num.allclose(domain.quantities['stage'].explicit_update[0], 0) -
branches/anuga_1_2_0/anuga_core/source/anuga/shallow_water/test_system.py
r7778 r8069 83 83 """ 84 84 85 boundary_starttime = 50085 boundary_starttime = 0 86 86 boundary_filename = self.create_sww_boundary(boundary_starttime) 87 87 filename = tempfile.mktemp(".sww") … … 131 131 """ 132 132 133 boundary_starttime = 500133 boundary_starttime = 0 134 134 boundary_filename = self.create_sww_boundary(boundary_starttime) 135 135 #print "boundary_filename",boundary_filename … … 147 147 domain.set_name(senario_name) 148 148 domain.set_datadir(dir) 149 new_starttime = 510.149 new_starttime = 0. 150 150 domain.set_starttime(new_starttime) 151 151 … … 178 178 msg += "Not logic. " 179 179 msg += "It's testing that starttime is working" 180 assert num.allclose(stage[2,0], 11.9867153168),msg180 assert num.allclose(stage[2,0], 4.7981238),msg 181 181 182 182
Note: See TracChangeset
for help on using the changeset viewer.