Ignore:
Timestamp:
Nov 11, 2010, 11:55:52 AM (14 years ago)
Author:
habili
Message:

Fixed bug where starttime and duration in the evolve function did not produce correct results. Starttime is now set in the constructor of Domain and is 0 by default. time is is to starttime. Also a bug was fixed where duration did not correctly calculate the finaltime. Associated unit tests have also been fixed to reflect the change.

Location:
trunk/anuga_core/source/anuga/shallow_water
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r8047 r8068  
    106106                 full_send_dict=None,
    107107                 ghost_recv_dict=None,
     108                 starttime=0,
    108109                 processor=0,
    109110                 numproc=1,
     
    140141            other_quantities = ['elevation', 'friction']
    141142       
     143       
    142144        Generic_Domain.__init__(self,
    143145                            coordinates,
     
    155157                            full_send_dict,
    156158                            ghost_recv_dict,
     159                            starttime,
    157160                            processor,
    158161                            numproc,
     
    563566        self.distribute_to_vertices_and_edges()
    564567
    565         if self.store is True and self.time == 0.0:
     568        if self.store is True and self.get_time() == self.get_starttime():
    566569            self.initialise_storage()
    567570
  • trunk/anuga_core/source/anuga/shallow_water/test_data_manager.py

    r7872 r8068  
    783783       
    784784        temp_time=num.zeros(int(finaltime/yieldstep)+1,num.float)
     785       
     786        domain_time.set_starttime(domain_fbound.get_starttime())
     787       
    785788        for i, t in enumerate(domain_time.evolve(yieldstep=yieldstep,
    786789                                                   finaltime=finaltime,
     
    831834if __name__ == "__main__":
    832835    #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')
    834837   
    835838   
  • trunk/anuga_core/source/anuga/shallow_water/test_forcing.py

    r7844 r8068  
    591591        domain.forcing_terms.append(R)
    592592
    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)
    598595
    599596        domain.compute_forcing_terms()
     
    602599                            (3*domain.get_time() + 7)/1000)
    603600        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)
    609602
    610603        assert num.allclose(domain.quantities['stage'].explicit_update[0], 0)
     
    657650        domain.forcing_terms.append(R)
    658651
    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)
    664654
    665655        domain.compute_forcing_terms()
     
    668658                            (3*domain.get_time() + 7)/1000)
    669659        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)
    675661
    676662        assert num.allclose(domain.quantities['stage'].explicit_update[0], 0)
  • trunk/anuga_core/source/anuga/shallow_water/test_forcing_terms.py

    r7814 r8068  
    887887        domain.forcing_terms.append(R)
    888888
    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)
    894891
    895892        domain.compute_forcing_terms()
     
    898895                            (3*domain.get_time() + 7)/1000)
    899896        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)
    905898
    906899        assert num.allclose(domain.quantities['stage'].explicit_update[0], 0)
     
    953946        domain.forcing_terms.append(R)
    954947
    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)
    960950
    961951        domain.compute_forcing_terms()
     
    964954                            (3*domain.get_time() + 7)/1000)
    965955        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
    971958
    972959        assert num.allclose(domain.quantities['stage'].explicit_update[0], 0)
  • trunk/anuga_core/source/anuga/shallow_water/test_system.py

    r7778 r8068  
    8383        """
    8484     
    85         boundary_starttime = 500
     85        boundary_starttime = 0
    8686        boundary_filename = self.create_sww_boundary(boundary_starttime)
    8787        filename = tempfile.mktemp(".sww")
     
    131131        """
    132132       
    133         boundary_starttime = 500
     133        boundary_starttime = 0
    134134        boundary_filename = self.create_sww_boundary(boundary_starttime)
    135135        #print "boundary_filename",boundary_filename
     
    147147        domain.set_name(senario_name)                 
    148148        domain.set_datadir(dir)
    149         new_starttime = 510.
     149        new_starttime = 0.
    150150        domain.set_starttime(new_starttime)
    151151
     
    178178        msg += "Not logic. "
    179179        msg += "It's testing that starttime is working"
    180         assert num.allclose(stage[2,0], 11.9867153168),msg
     180        assert num.allclose(stage[2,0], 4.7981238),msg
    181181       
    182182       
Note: See TracChangeset for help on using the changeset viewer.