Changeset 6011
- Timestamp:
- Nov 27, 2008, 4:13:46 PM (16 years ago)
- Location:
- anuga_core/source
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py
r6009 r6011 123 123 # FIXME (Ole): I think this should be get_time(), see ticket:306 124 124 return self.f(self.domain.time) 125 126 127 class File_boundary_time(Boundary):128 """Boundary values obtained from file and interpolated.129 conserved quantities as a function of time.130 131 Assumes that file contains a time series.132 133 No spatial info assumed.134 """135 136 #FIXME: Is this still necessary137 138 def __init__(self, filename, domain):139 import time140 from Numeric import array141 from anuga.config import time_format142 from anuga.abstract_2d_finite_volumes.util import File_function143 144 Boundary.__init__(self)145 146 self.F = File_function(filename, domain)147 self.domain = domain148 149 #Test150 q = self.F(0)151 152 d = len(domain.conserved_quantities)153 msg = 'Values specified in file must be a list or an array of length %d' %d154 assert len(q) == d, msg155 156 157 def __repr__(self):158 return 'File boundary'159 160 def evaluate(self, vol_id=None, edge_id=None):161 """Return linearly interpolated values based on domain.time162 163 vol_id and edge_id are ignored164 """165 166 # FIXME (Ole): I think this should be get_time(), see ticket:306167 t = self.domain.time168 return self.F(t)169 170 125 171 126 … … 277 232 self.default_boundary_invoked = False # Flag 278 233 279 # Store pointer to domain 234 # Store pointer to domain and verbosity 280 235 self.domain = domain 281 282 236 self.verbose = verbose 283 237 284 # Test285 238 286 239 # Here we'll flag indices outside the mesh as a warning … … 385 338 msg += 'vol_id=%s, edge_id=%s' %(str(vol_id), str(edge_id)) 386 339 raise Exception, msg 387 # FIXME: What should the semantics be?388 #return self.F(t)389 390 391 392 393 394 395 396 397 #THIS FAR (10/8/4)398 class Connective_boundary(Boundary):399 """Connective boundary returns values for the400 conserved quantities from a volume as defined by a connection table401 mapping between tuples of (volume id, face id) for volumes that402 have their boundaries connected.403 404 FIXME: Perhaps include possibility of mapping between405 different domains as well406 407 FIXME: In case of shallow water we may want to have a408 special version that casts this in terms of height rather than stage409 """410 411 412 def __init__(self, table):413 from domain import Volume414 415 Boundary.__init__(self)416 417 self.connection_table = table418 self.Volume = Volume419 420 def __repr__(self):421 return 'Connective boundary'422 423 #FIXME: IF we ever need to get field_values from connected volume,424 #that method could be overridden here (using same idea as in425 #get_conserved_quantities426 #def get_field_values()427 428 def get_conserved_quantities(self, volume, face=0):429 430 id = volume.id431 if self.connection_table.has_key((id, face)):432 other_id, other_face = self.connection_table[(id, face)]433 434 other_volume = self.Volume.instances[other_id]435 cmd = 'q = other_volume.conserved_quantities_face%d' %face;436 exec(cmd)437 return q438 else:439 msg = 'Volume, face tuple ($d, %d) has not been mapped'\440 %(id, face)441 raise msg442 443 444 445 446 447 #FIXME: Add a boundary with a general function of x,y, and t448 449 #FIXME: Add periodic boundaries e.g.:450 # Attempt at periodic conditions from advection_spik. Remember this451 #452 #first = 2*(N-1)*N453 #for i in range(1,2*N+1,2):454 # k = first + i-1#455 #456 # print i,k457 #458 # domain[i].faces[2].neighbour = domain[k].faces[1]459 # domain[k].faces[1].neighbour = domain[i].faces[2]460 461 462 463 class General_boundary(Boundary):464 """General boundary which can compute conserved quantities based on465 their previous value, conserved quantities of its neighbour and model time.466 467 Must specify initial conserved quantities,468 neighbour,469 domain to get access to model time470 a function f(q_old, neighbours_q, t) which must return471 new conserved quantities q as a function time472 473 FIXME: COMPLETE UNTESTED - JUST AN IDEA474 """475 476 def __init__(self, neighbour=None, conserved_quantities=None, domain=None, f=None):477 Boundary.__init__(self, neighbour=neighbour, conserved_quantities=conserved_quantities)478 479 self.f = f480 self.domain = domain481 482 483 def get_conserved_quantities(self, volume=None, face=0):484 485 # FIXME (Ole): I think this should be get_time(), see ticket:306486 return self.f(self.conserved_quantities,487 neighbour.conserved_quantities,488 self.domain.time)489 490 491 492 -
anuga_core/source/anuga/abstract_2d_finite_volumes/util.py
r5936 r6011 368 368 else: 369 369 gauge_neighbour_id=None 370 370 371 if domain_starttime is not None: 371 372
Note: See TracChangeset
for help on using the changeset viewer.