Changeset 8068
- Timestamp:
- Nov 11, 2010, 11:55:52 AM (14 years ago)
- Location:
- trunk/anuga_core/source/anuga
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py
r8065 r8068 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 254 255 # Model time 255 self.time = 0.0256 256 self.finaltime = None 257 257 self.recorded_min_timestep = self.recorded_max_timestep = 0.0 258 self.starttime = 0# Physical starttime if any259 # (0 is 1 Jan 1970 00:00:00)258 self.starttime = starttime # Physical starttime if any 259 self.time = self.starttime 260 260 self.timestep = 0.0 261 261 self.flux_timestep = 0.0 … … 499 499 """Get the absolute model time (seconds).""" 500 500 501 return self.time + self.starttime 502 501 return self.time 503 502 504 503 ## … … 1016 1015 1017 1016 model_time = self.get_time() 1017 1018 1018 if self.recorded_min_timestep == self.recorded_max_timestep: 1019 1019 msg += 'Time = %.4f, delta t = %.8f, steps=%d' \ … … 1225 1225 # Observe time interval restriction if any 1226 1226 if self.monitor_time_interval is not None and\ 1227 (self. time< self.monitor_time_interval[0] or\1228 self. time> self.monitor_time_interval[1]):1227 (self.get_time() < self.monitor_time_interval[0] or\ 1228 self.get_time() > self.monitor_time_interval[1]): 1229 1229 return 1230 1230 … … 1249 1249 maxloc = Q.get_maximum_location() 1250 1250 info_block['max_location'] = maxloc 1251 info_block['max_time'] = self. time1251 info_block['max_time'] = self.get_time() 1252 1252 1253 1253 # Update minimum … … 1258 1258 minloc = Q.get_minimum_location() 1259 1259 info_block['min_location'] = minloc 1260 info_block['min_time'] = self. time1260 info_block['min_time'] = self.get_time() 1261 1261 1262 1262 ## … … 1376 1376 def set_starttime(self, time): 1377 1377 self.starttime = float(time) 1378 self.set_time(self.starttime) 1379 1378 1380 1379 1381 ################################################################################ … … 1427 1429 % self.get_boundary_tags()) 1428 1430 assert hasattr(self, 'boundary_objects'), msg 1429 1431 1432 if self.get_time() != self.get_starttime(): 1433 self.set_time(self.get_starttime()) 1434 1430 1435 if yieldstep is None: 1431 1436 yieldstep = self.evolve_max_timestep … … 1435 1440 self._order_ = self.default_order 1436 1441 1442 assert finaltime > self.get_starttime(), 'finaltime is less than starttime!' 1443 1437 1444 if finaltime is not None and duration is not None: 1438 1445 msg = 'Only one of finaltime and duration may be specified' … … 1445 1452 1446 1453 N = len(self) # Number of triangles 1447 self.yieldtime = self. time+ yieldstep # set next yield time1454 self.yieldtime = self.get_time() + yieldstep # set next yield time 1448 1455 1449 1456 # Initialise interval of timestep sizes (for reporting only) … … 1467 1474 self.update_extrema() 1468 1475 1469 1470 1471 1476 # Or maybe restore from latest checkpoint 1472 1477 if self.checkpoint is True: … … 1474 1479 1475 1480 if skip_initial_step is False: 1476 yield(self. time) # Yield initial values1481 yield(self.get_time()) # Yield initial values 1477 1482 1478 1483 while True: 1479 1484 1480 initial_time = self. time1485 initial_time = self.get_time() 1481 1486 1482 1487 #========================================== … … 1484 1489 #========================================== 1485 1490 if self.get_timestepping_method() == 'euler': 1486 self.evolve_one_euler_step(yieldstep, finaltime)1491 self.evolve_one_euler_step(yieldstep, self.finaltime) 1487 1492 1488 1493 elif self.get_timestepping_method() == 'rk2': 1489 self.evolve_one_rk2_step(yieldstep, finaltime)1494 self.evolve_one_rk2_step(yieldstep, self.finaltime) 1490 1495 1491 1496 elif self.get_timestepping_method() == 'rk3': 1492 self.evolve_one_rk3_step(yieldstep, finaltime)1497 self.evolve_one_rk3_step(yieldstep, self.finaltime) 1493 1498 1494 1499 #========================================== … … 1503 1508 1504 1509 # Update time 1505 self. time = initial_time + self.timestep1510 self.set_time(initial_time + self.timestep) 1506 1511 1507 1512 # Update vertex and edge values … … 1519 1524 1520 1525 # Yield results 1521 if finaltime is not None and self.time >= finaltime-epsilon: 1522 if self.time > finaltime: 1526 if self.finaltime is not None and self.get_time() >= self.finaltime-epsilon: 1527 1528 if self.get_time() > self.finaltime: 1523 1529 # FIXME (Ole, 30 April 2006): Do we need this check? 1524 1530 # Probably not (Ole, 18 September 2008). 1525 1531 # Now changed to Exception. 1526 msg = ('WARNING (domain.py): time overshot finaltime. ' 1527 'Contact Ole.Nielsen@ga.gov.au') 1532 msg = ('WARNING (domain.py): time overshot finaltime. ') 1528 1533 raise Exception, msg 1529 1534 1530 1535 # Log and then Yield final time and stop 1531 self. time = finaltime1536 self.set_time(self.finaltime) 1532 1537 self.log_operator_timestepping_statistics() 1533 yield(self. time)1538 yield(self.get_time()) 1534 1539 break 1535 1540 1536 1541 # if we are at the next yield point 1537 if self. time>= self.yieldtime:1542 if self.get_time() >= self.yieldtime: 1538 1543 # Yield (intermediate) time and allow inspection of domain 1539 1544 if self.checkpoint is True: … … 1543 1548 # Log and then Pass control on to outer loop for more specific actions 1544 1549 self.log_operator_timestepping_statistics() 1545 yield(self. time)1550 yield(self.get_time()) 1546 1551 1547 1552 # Reinitialise … … 1614 1619 1615 1620 # Update time 1616 self. time += self.timestep1621 self.set_time(self.get_time() + self.timestep) 1617 1622 1618 1623 # Update vertex and edge values … … 1663 1668 self.backup_conserved_quantities() 1664 1669 1665 initial_time = self. time1670 initial_time = self.get_time() 1666 1671 1667 1672 ###### … … 1685 1690 1686 1691 # Update time 1687 self. time += self.timestep1692 self.set_time(self.time + self.timestep) 1688 1693 1689 1694 # Update vertex and edge values … … 1721 1726 1722 1727 # Set substep time 1723 self. time = initial_time + self.timestep*0.51728 self.set_time(initial_time + self.timestep*0.5) 1724 1729 1725 1730 # Update vertex and edge values … … 1754 1759 1755 1760 # Set new time 1756 self. time = initial_time + self.timestep1761 self.set_time(initial_time + self.timestep) 1757 1762 1758 1763 … … 1941 1946 1942 1947 # Ensure that final time is not exceeded 1943 if finaltime is not None and self. time+ timestep > finaltime :1944 timestep = finaltime -self.time1948 if finaltime is not None and self.get_time() + timestep > finaltime : 1949 timestep = finaltime - self.get_time() 1945 1950 1946 1951 # Ensure that model time is aligned with yieldsteps 1947 if self. time+ timestep > self.yieldtime:1948 timestep = self.yieldtime - self. time1952 if self.get_time() + timestep > self.yieldtime: 1953 timestep = self.yieldtime - self.get_time() 1949 1954 1950 1955 self.timestep = timestep … … 2075 2080 for i in range(self.number_of_full_triangles): 2076 2081 if self.max_speed[i] > bins[-1]: 2077 msg = 'Time=%f: Ignoring isolated high ' % self. time2082 msg = 'Time=%f: Ignoring isolated high ' % self.get_time() 2078 2083 msg += 'speed triangle ' 2079 2084 msg += '#%d of %d with max speed=%f' \ -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_gauge.py
r8063 r8068 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) -
trunk/anuga_core/source/anuga/file/sww.py
r7862 r8068 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() … … 952 952 953 953 domain.geo_reference = geo_reference 954 955 domain.starttime = float(starttime) + float(t)956 domain.time = 0.0957 954 958 955 for quantity in other_quantities: -
trunk/anuga_core/source/anuga/file/test_read_sww.py
r7762 r8068 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 -
trunk/anuga_core/source/anuga/file/test_sww.py
r7872 r8068 103 103 #Now evolve them both, just to be sure 104 104 ######################################x 105 domain.time = 0.106 105 from time import sleep 107 106 … … 116 115 pass 117 116 118 final = final - (domain2.starttime-domain.starttime)119 117 #BUT since domain1 gets time hacked back to 0: 120 final = final + (domain2.starttime-domain.starttime) 118 119 final = final + (domain2.get_starttime() - domain.get_starttime()) 121 120 122 121 domain2.smooth = False -
trunk/anuga_core/source/anuga/file_conversion/test_urs2sts.py
r7866 r8068 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) -
trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r8047 r8068 106 106 full_send_dict=None, 107 107 ghost_recv_dict=None, 108 starttime=0, 108 109 processor=0, 109 110 numproc=1, … … 140 141 other_quantities = ['elevation', 'friction'] 141 142 143 142 144 Generic_Domain.__init__(self, 143 145 coordinates, … … 155 157 full_send_dict, 156 158 ghost_recv_dict, 159 starttime, 157 160 processor, 158 161 numproc, … … 563 566 self.distribute_to_vertices_and_edges() 564 567 565 if self.store is True and self. time == 0.0:568 if self.store is True and self.get_time() == self.get_starttime(): 566 569 self.initialise_storage() 567 570 -
trunk/anuga_core/source/anuga/shallow_water/test_data_manager.py
r7872 r8068 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 -
trunk/anuga_core/source/anuga/shallow_water/test_forcing.py
r7844 r8068 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) -
trunk/anuga_core/source/anuga/shallow_water/test_forcing_terms.py
r7814 r8068 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) 957 971 958 972 959 assert num.allclose(domain.quantities['stage'].explicit_update[0], 0) -
trunk/anuga_core/source/anuga/shallow_water/test_system.py
r7778 r8068 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.