Ignore:
Timestamp:
Mar 4, 2009, 2:09:28 PM (15 years ago)
Author:
jgriffin
Message:

updated Time_boundary to allow for default boundary condition beyond length of time series

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py

    r6174 r6448  
    8888    # FIXME (Ole): We should rename f to function to be consistent with
    8989    # Transmissive_Momentum_Set_Stage_Boundary (cf posting by rrraman)
    90     def __init__(self, domain = None, f = None):
     90    def __init__(self, domain = None, f = None, default_boundary = None):
    9191        Boundary.__init__(self)
    9292
     
    122122    def evaluate(self, vol_id=None, edge_id=None):
    123123        # FIXME (Ole): I think this should be get_time(), see ticket:306
    124         return self.f(self.domain.time)
     124        try:
     125            res = self.f(self.domain.time)
     126        except Modeltime_too_early, e:
     127            raise Modeltime_too_early, e
     128        except Modeltime_too_late, e:
     129            if self.default_boundary is None:
     130                raise Exception, e # Reraise exception
     131            else:
     132                # Pass control to default boundary
     133                res = self.default_boundary.evaluate(vol_id, edge_id)
     134               
     135                # Ensure that result cannot be manipulated
     136                # This is a real danger in case the
     137                # default_boundary is a Dirichlet type
     138                # for instance.
     139                res = res.copy()
     140               
     141                if self.default_boundary_invoked is False:
     142                    # Issue warning the first time
     143                    msg = '%s' %str(e)
     144                    msg += 'Instead I will use the default boundary: %s\n'\
     145                        %str(self.default_boundary)
     146                    msg += 'Note: Further warnings will be supressed'
     147                    warn(msg)
     148               
     149                    # FIXME (Ole): Replace this crude flag with
     150                    # Python's ability to print warnings only once.
     151                    # See http://docs.python.org/lib/warning-filter.html
     152                    self.default_boundary_invoked = True
     153
     154        return res
    125155
    126156
Note: See TracChangeset for help on using the changeset viewer.