Changeset 5657 for anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py
- Timestamp:
- Aug 14, 2008, 10:26:06 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py
r5373 r5657 2 2 """ 3 3 4 from warnings import warn 5 4 6 from anuga.utilities.numerical_tools import NAN 7 from anuga.fit_interpolate.interpolate import Modeltime_too_late 8 from anuga.fit_interpolate.interpolate import Modeltime_too_early 5 9 6 10 … … 183 187 Note that the resulting solution history is not exactly the same as if 184 188 the models were coupled as there is no feedback into the source model. 189 190 Optional keyword argument default_boundary must be either None or 191 an instance of class descending from class Boundary. 192 This will be used in case model time exceeds that available in the 193 underlying data. 185 194 186 195 """ … … 189 198 # rather than File_boundary 190 199 191 def __init__(self, filename, domain, time_thinning=1, 192 use_cache=False, verbose=False, boundary_polygon=None): 200 def __init__(self, filename, domain, 201 time_thinning=1, 202 boundary_polygon=None, 203 default_boundary=None, 204 use_cache=False, 205 verbose=False): 206 193 207 import time 194 208 from Numeric import array, zeros, Float … … 251 265 verbose=verbose, 252 266 boundary_polygon=boundary_polygon) 253 267 268 # Check and store default_boundary 269 msg = 'Keyword argument default_boundary must be either None ' 270 msg += 'or a boundary object.\n I got %s' %(str(default_boundary)) 271 assert default_boundary is None or isinstance(default_boundary, Boundary), msg 272 self.default_boundary = default_boundary 273 self.default_boundary_invoked = False # Flag 274 275 # Store pointer to domain 254 276 self.domain = domain 277 278 self.verbose = verbose 255 279 256 280 # Test … … 293 317 294 318 t = self.domain.time 319 295 320 if vol_id is not None and edge_id is not None: 296 321 i = self.boundary_indices[ vol_id, edge_id ] 297 res = self.F(t, point_id = i) 322 323 324 #res = self.F(t, point_id = i) 325 try: 326 res = self.F(t, point_id = i) 327 except (Modeltime_too_late, Modeltime_too_early), e: 328 if self.default_boundary is None: 329 raise Exception, e # Reraise exception 330 else: 331 if self.default_boundary_invoked is False: 332 # Issue warning the first time 333 msg = '%s' %str(e) 334 msg += 'Instead I will using the default boundary: %s\n'\ 335 %str(self.default_boundary) 336 msg += 'Note: Further warnings will be supressed' 337 warn(msg) 338 339 # FIXME (Ole): Replace this crude flag with 340 # Python's ability to print warnings only once. 341 # See http://docs.python.org/lib/warning-filter.html 342 self.default_boundary_invoked = True 343 344 # Pass control to default boundary 345 res = self.default_boundary.evaluate(vol_id, edge_id) 346 347 298 348 if res == NAN: 299 349 x,y=self.midpoint_coordinates[i,:]
Note: See TracChangeset
for help on using the changeset viewer.