- Timestamp:
- May 15, 2009, 2:33:56 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r6928 r7043 121 121 from warnings import warn 122 122 123 123 import math 124 124 125 125 # … … 1401 1401 1402 1402 1403 1403 1404 1405 class Inflow_boundary(Boundary): 1406 """Apply given flow in m^3/s to boundary segment. 1407 Depth and momentum is derived using Manning's formula. 1408 1409 Underlying domain must be specified when boundary is instantiated 1410 """ 1411 1412 # FIXME (Ole): This is work in progress and definitely not finished. 1413 # The associated test has been disabled 1414 1415 def __init__(self, domain=None, rate=0.0): 1416 Boundary.__init__(self) 1417 1418 if domain is None: 1419 msg = 'Domain must be specified for ' 1420 msg += 'Inflow boundary' 1421 raise Exception, msg 1422 1423 self.domain = domain 1424 1425 # FIXME(Ole): Allow rate to be time dependent as well 1426 self.rate = rate 1427 self.tag = None # Placeholder for tag associated with this object. 1428 1429 def __repr__(self): 1430 return 'Inflow_boundary(%s)' %self.domain 1431 1432 def evaluate(self, vol_id, edge_id): 1433 """Apply inflow rate at each edge of this boundary 1434 """ 1435 1436 # First find all segments having the same tag is vol_id, edge_id 1437 # This will be done the first time evaluate is called. 1438 if self.tag is None: 1439 boundary = self.domain.boundary 1440 self.tag = boundary[(vol_id, edge_id)] 1441 1442 # Find total length of boundary with this tag 1443 length = 0.0 1444 for v_id, e_id in boundary: 1445 if self.tag == boundary[(v_id, e_id)]: 1446 length += self.domain.mesh.get_edgelength(v_id, e_id) 1447 1448 self.length = length 1449 self.average_momentum = self.rate/length 1450 1451 1452 # Average momentum has now been established across this boundary 1453 # Compute momentum in the inward normal direction 1454 1455 inward_normal = -self.domain.mesh.get_normal(vol_id, edge_id) 1456 xmomentum, ymomentum = self.average_momentum * inward_normal 1457 1458 # Compute depth based on Manning's formula v = 1/n h^{2/3} sqrt(S) 1459 # Where v is velocity, n is manning's coefficient, h is depth and S is the slope into the domain. 1460 # Let mu be the momentum (vh), then this equation becomes: mu = 1/n h^{5/3} sqrt(S) 1461 # from which we can isolate depth to get 1462 # h = (mu n/sqrt(S) )^{3/5} 1463 1464 slope = 0 # get gradient for this triangle dot normal 1465 1466 # get manning coef from this triangle 1467 friction = self.domain.get_quantity('friction').get_values(location='edges', 1468 indices=[vol_id])[0] 1469 mannings_n = friction[edge_id] 1470 1471 if slope > epsilon and mannings_n > epsilon: 1472 depth = pow(self.average_momentum * mannings_n/math.sqrt(slope), 3.0/5) 1473 else: 1474 depth = 1.0 1475 1476 # Elevation on this edge 1477 1478 z = self.domain.get_quantity('elevation').get_values(location='edges', 1479 indices=[vol_id])[0] 1480 elevation = z[edge_id] 1481 1482 # Assign conserved quantities and return 1483 q = num.array([elevation + depth, xmomentum, ymomentum], num.Float) 1484 return q 1485 1486 1487 1488 1489 1404 1490 1405 1491 class Field_boundary(Boundary):
Note: See TracChangeset
for help on using the changeset viewer.