Ignore:
Timestamp:
Mar 17, 2009, 4:02:54 PM (15 years ago)
Author:
rwilson
Message:

Revert back to 6481, prior to auto-merge of trunk and numpy branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/numpy/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py

    r6517 r6533  
    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,
    91                  f=None,
    92                  default_boundary=None,
    93                  verbose=False):
     90    def __init__(self, domain = None, f = None):
    9491        Boundary.__init__(self)
    95         self.default_boundary = default_boundary
    96         self.default_boundary_invoked = False    # Flag
    97         self.domain = domain
    98         self.verbose = verbose
    9992
    10093        try:
     
    129122    def evaluate(self, vol_id=None, edge_id=None):
    130123        # FIXME (Ole): I think this should be get_time(), see ticket:306
    131         try:
    132             res = self.f(self.domain.time)
    133         except Modeltime_too_early, e:
    134             raise Modeltime_too_early, e
    135         except Modeltime_too_late, e:
    136             if self.default_boundary is None:
    137                 raise Exception, e # Reraise exception
    138             else:
    139                 # Pass control to default boundary
    140                 res = self.default_boundary.evaluate(vol_id, edge_id)
    141                
    142                 # Ensure that result cannot be manipulated
    143                 # This is a real danger in case the
    144                 # default_boundary is a Dirichlet type
    145                 # for instance.
    146                 res = res.copy()
    147                
    148                 if self.default_boundary_invoked is False:
    149                     if self.verbose:               
    150                         # Issue warning the first time
    151                         msg = '%s' %str(e)
    152                         msg += 'Instead I will use the default boundary: %s\n'\
    153                             %str(self.default_boundary)
    154                         msg += 'Note: Further warnings will be supressed'
    155                         print msg
    156                
    157                     # FIXME (Ole): Replace this crude flag with
    158                     # Python's ability to print warnings only once.
    159                     # See http://docs.python.org/lib/warning-filter.html
    160                     self.default_boundary_invoked = True
    161 
    162         return res
     124        return self.f(self.domain.time)
    163125
    164126
     
    337299                    if self.default_boundary_invoked is False:
    338300                        # Issue warning the first time
    339                         if self.verbose:
    340                             msg = '%s' %str(e)
    341                             msg += 'Instead I will use the default boundary: %s\n'\
    342                                 %str(self.default_boundary)
    343                             msg += 'Note: Further warnings will be supressed'
    344                             print msg
     301                        msg = '%s' %str(e)
     302                        msg += 'Instead I will use the default boundary: %s\n'\
     303                            %str(self.default_boundary)
     304                        msg += 'Note: Further warnings will be supressed'
     305                        warn(msg)
    345306                   
    346307                        # FIXME (Ole): Replace this crude flag with
Note: See TracChangeset for help on using the changeset viewer.