Changeset 8064


Ignore:
Timestamp:
Nov 3, 2010, 1:58:23 PM (14 years ago)
Author:
habili
Message:

fixed bug relating finaltime and duration - they weren't being set and used correctly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py

    r8023 r8064  
    499499        """Get the absolute model time (seconds)."""
    500500
    501         return self.time + self.starttime
    502 
     501        return self.time
    503502
    504503    ##
     
    10161015
    10171016        model_time = self.get_time()
     1017 
    10181018        if self.recorded_min_timestep == self.recorded_max_timestep:
    10191019            msg += 'Time = %.4f, delta t = %.8f, steps=%d' \
     
    12251225        # Observe time interval restriction if any
    12261226        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]):
    12291229            return
    12301230
     
    12491249                maxloc = Q.get_maximum_location()
    12501250                info_block['max_location'] = maxloc
    1251                 info_block['max_time'] = self.time
     1251                info_block['max_time'] = self.get_time()
    12521252
    12531253            # Update minimum
     
    12581258                minloc = Q.get_minimum_location()
    12591259                info_block['min_location'] = minloc
    1260                 info_block['min_time'] = self.time
     1260                info_block['min_time'] = self.get_time()
    12611261
    12621262    ##
     
    14281428        assert hasattr(self, 'boundary_objects'), msg
    14291429
     1430        self.set_time(self.get_starttime())
     1431
    14301432        if yieldstep is None:
    14311433            yieldstep = self.evolve_max_timestep
     
    14451447
    14461448        N = len(self)                             # Number of triangles
    1447         self.yieldtime = self.time + yieldstep    # set next yield time
     1449        self.yieldtime = self.get_time() + yieldstep    # set next yield time
    14481450
    14491451        # Initialise interval of timestep sizes (for reporting only)
     
    14671469        self.update_extrema()
    14681470
    1469 
    1470 
    14711471        # Or maybe restore from latest checkpoint
    14721472        if self.checkpoint is True:
     
    14741474
    14751475        if skip_initial_step is False:
    1476             yield(self.time)      # Yield initial values
     1476            yield(self.get_time())      # Yield initial values
    14771477
    14781478        while True:
    14791479
    1480             initial_time = self.time
     1480            initial_time = self.get_time()
    14811481
    14821482            #==========================================
     
    14841484            #==========================================
    14851485            if self.get_timestepping_method() == 'euler':
    1486                 self.evolve_one_euler_step(yieldstep, finaltime)
     1486                self.evolve_one_euler_step(yieldstep, self.finaltime)
    14871487
    14881488            elif self.get_timestepping_method() == 'rk2':
    1489                 self.evolve_one_rk2_step(yieldstep, finaltime)
     1489                self.evolve_one_rk2_step(yieldstep, self.finaltime)
    14901490
    14911491            elif self.get_timestepping_method() == 'rk3':
    1492                 self.evolve_one_rk3_step(yieldstep, finaltime)
     1492                self.evolve_one_rk3_step(yieldstep, self.finaltime)
    14931493
    14941494            #==========================================
     
    15031503
    15041504            # Update time
    1505             self.time = initial_time + self.timestep
     1505            self.set_time(initial_time + self.timestep)
    15061506
    15071507            # Update vertex and edge values
     
    15191519
    15201520            # Yield results
    1521             if finaltime is not None and self.time >= finaltime-epsilon:
    1522                 if self.time > finaltime:
     1521            if self.finaltime is not None and self.get_time() >= self.finaltime-epsilon:
     1522               
     1523                if self.get_time() > self.finaltime:
    15231524                    # FIXME (Ole, 30 April 2006): Do we need this check?
    15241525                    # Probably not (Ole, 18 September 2008).
    15251526                    # Now changed to Exception.
    1526                     msg = ('WARNING (domain.py): time overshot finaltime. '
    1527                            'Contact Ole.Nielsen@ga.gov.au')
     1527                    msg = ('WARNING (domain.py): time overshot finaltime. ')
    15281528                    raise Exception, msg
    15291529
    15301530                # Log and then Yield final time and stop
    1531                 self.time = finaltime
     1531                self.set_time(self.finaltime)
    15321532                self.log_operator_timestepping_statistics()
    1533                 yield(self.time)
     1533                yield(self.get_time())
    15341534                break
    15351535
    15361536            # if we are at the next yield point
    1537             if self.time >= self.yieldtime:
     1537            if self.get_time() >= self.yieldtime:
    15381538                # Yield (intermediate) time and allow inspection of domain
    15391539                if self.checkpoint is True:
     
    15431543                # Log and then Pass control on to outer loop for more specific actions
    15441544                self.log_operator_timestepping_statistics()
    1545                 yield(self.time)
     1545                yield(self.get_time())
    15461546
    15471547                # Reinitialise
     
    16141614
    16151615        # Update time
    1616         self.time += self.timestep
     1616        self.set_time(self.get_time() + self.timestep)
    16171617
    16181618        # Update vertex and edge values
     
    16631663        self.backup_conserved_quantities()
    16641664
    1665         initial_time = self.time
     1665        initial_time = self.get_time()
    16661666
    16671667        ######
     
    16851685
    16861686        # Update time
    1687         self.time += self.timestep
     1687        self.set_time(self.time + self.timestep)
    16881688
    16891689        # Update vertex and edge values
     
    17211721
    17221722        # Set substep time
    1723         self.time = initial_time + self.timestep*0.5
     1723        self.set_time(initial_time + self.timestep*0.5)
    17241724
    17251725        # Update vertex and edge values
     
    17541754
    17551755        # Set new time
    1756         self.time = initial_time + self.timestep
     1756        self.set_time(initial_time + self.timestep)
    17571757
    17581758
     
    19411941
    19421942        # Ensure that final time is not exceeded
    1943         if finaltime is not None and self.time + timestep > finaltime :
    1944             timestep = finaltime-self.time
     1943        if finaltime is not None and self.get_time() + timestep > finaltime :
     1944            timestep = finaltime - self.get_time()
    19451945
    19461946        # Ensure that model time is aligned with yieldsteps
    1947         if self.time + timestep > self.yieldtime:
    1948             timestep = self.yieldtime - self.time
     1947        if self.get_time() + timestep > self.yieldtime:
     1948            timestep = self.yieldtime - self.get_time()
    19491949
    19501950        self.timestep = timestep
     
    20752075            for i in range(self.number_of_full_triangles):
    20762076                if self.max_speed[i] > bins[-1]:
    2077                     msg = 'Time=%f: Ignoring isolated high ' % self.time
     2077                    msg = 'Time=%f: Ignoring isolated high ' % self.get_time()
    20782078                    msg += 'speed triangle '
    20792079                    msg += '#%d of %d with max speed=%f' \
Note: See TracChangeset for help on using the changeset viewer.