Changeset 8455
- Timestamp:
- Jul 5, 2012, 5:17:34 PM (13 years ago)
- Location:
- trunk/anuga_core/source
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/__init__.py
r8447 r8455 150 150 151 151 152 152 indent = ' ' 153 153 154 154 #----------------------------- -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py
r8420 r8455 113 113 114 114 self.number_of_boundaries = self.mesh.number_of_boundaries 115 self.boundary_length = self.mesh.boundary_length 116 self.tag_boundary_cells = self.mesh.tag_boundary_cells 115 117 #self.number_of_full_nodes = self.mesh.number_of_full_nodes 116 118 #self.number_of_full_triangles = self.mesh.number_of_full_triangles … … 1316 1318 self._order_ = self.default_order 1317 1319 1318 assert finaltime > self.get_starttime(), 'finaltime is less than starttime!'1320 assert finaltime >= self.get_starttime(), 'finaltime is less than starttime!' 1319 1321 1320 1322 if finaltime is not None and duration is not None: … … 1691 1693 return q_evol 1692 1694 1693 def update_boundary (self):1695 def update_boundary_old(self): 1694 1696 """Go through list of boundary objects and update boundary values 1695 1697 for all conserved quantities on boundary. … … 1728 1730 Q = self.quantities[name] 1729 1731 Q.boundary_values[i] = q_evol[j] 1732 1733 1734 def update_boundary_old_2(self): 1735 """Go through list of boundary objects and update boundary values 1736 for all conserved quantities on boundary. 1737 It is assumed that the ordering of conserved quantities is 1738 consistent between the domain and the boundary object, i.e. 1739 the jth element of vector q must correspond to the jth conserved 1740 quantity in domain. 1741 """ 1742 1743 1744 for i in range(self.boundary_length): 1745 vol_id = self.boundary_cells[i] 1746 edge_id = self.boundary_edges[i] 1747 blah, B = self.boundary_objects[i] 1748 1749 if B is None: 1750 log.critical('WARNING: Ignored boundary segment (None)') 1751 else: 1752 q_bdry = B.evaluate(vol_id, edge_id) 1753 1754 if len(q_bdry) == len(self.evolved_quantities): 1755 # conserved and evolved quantities are the same 1756 q_evol = q_bdry 1757 elif len(q_bdry) == len(self.conserved_quantities): 1758 # boundary just returns conserved quantities 1759 # Need to calculate all the evolved quantities 1760 # Use default conversion 1761 1762 q_evol = self.get_evolved_quantities(vol_id, edge = edge_id) 1763 1764 q_evol = self.conserved_values_to_evolved_values \ 1765 (q_bdry, q_evol) 1766 else: 1767 msg = 'Boundary must return array of either conserved' 1768 msg += ' or evolved quantities' 1769 raise Exception(msg) 1770 1771 for j, name in enumerate(self.evolved_quantities): 1772 Q = self.quantities[name] 1773 Q.boundary_values[i] = q_evol[j] 1774 1775 1776 1777 # for i, ((vol_id, edge_id), B) in enumerate(self.boundary_objects): 1778 # if B is None: 1779 # log.critical('WARNING: Ignored boundary segment (None)') 1780 # else: 1781 # q_bdry = B.evaluate(vol_id, edge_id) 1782 # 1783 # if len(q_bdry) == len(self.evolved_quantities): 1784 # # conserved and evolved quantities are the same 1785 # q_evol = q_bdry 1786 # elif len(q_bdry) == len(self.conserved_quantities): 1787 # # boundary just returns conserved quantities 1788 # # Need to calculate all the evolved quantities 1789 # # Use default conversion 1790 # 1791 # q_evol = self.get_evolved_quantities(vol_id, edge = edge_id) 1792 # 1793 # q_evol = self.conserved_values_to_evolved_values \ 1794 # (q_bdry, q_evol) 1795 # else: 1796 # msg = 'Boundary must return array of either conserved' 1797 # msg += ' or evolved quantities' 1798 # raise Exception(msg) 1799 # 1800 # for j, name in enumerate(self.evolved_quantities): 1801 # Q = self.quantities[name] 1802 # Q.boundary_values[i] = q_evol[j] 1803 1804 1805 def update_boundary(self): 1806 """Go through list of boundary objects and update boundary values 1807 for all conserved quantities on boundary. 1808 It is assumed that the ordering of conserved quantities is 1809 consistent between the domain and the boundary object, i.e. 1810 the jth element of vector q must correspond to the jth conserved 1811 quantity in domain. 1812 """ 1813 1814 1815 for tag in self.tag_boundary_cells: 1816 1817 #print tag 1818 1819 B = self.boundary_map[tag] 1820 1821 #if B is None: 1822 # log.critical('WARNING: Ignored boundary segment (None)') 1823 1824 for i in self.tag_boundary_cells[tag]: 1825 vol_id = self.boundary_cells[i] 1826 edge_id = self.boundary_edges[i] 1827 1828 if B is None: 1829 pass 1830 else: 1831 q_bdry = B.evaluate(vol_id, edge_id) 1832 1833 if len(q_bdry) == len(self.evolved_quantities): 1834 # conserved and evolved quantities are the same 1835 q_evol = q_bdry 1836 elif len(q_bdry) == len(self.conserved_quantities): 1837 # boundary just returns conserved quantities 1838 # Need to calculate all the evolved quantities 1839 # Use default conversion 1840 1841 q_evol = self.get_evolved_quantities(vol_id, edge = edge_id) 1842 1843 q_evol = self.conserved_values_to_evolved_values \ 1844 (q_bdry, q_evol) 1845 else: 1846 msg = 'Boundary must return array of either conserved' 1847 msg += ' or evolved quantities' 1848 raise Exception(msg) 1849 1850 for j, name in enumerate(self.evolved_quantities): 1851 Q = self.quantities[name] 1852 Q.boundary_values[i] = q_evol[j] 1853 1730 1854 1731 1855 def compute_fluxes(self): -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py
r8280 r8455 191 191 #Update boundary indices FIXME: OBSOLETE 192 192 #self.build_boundary_structure() 193 194 193 195 194 196 #FIXME check integrity? … … 376 378 377 379 self.boundary = boundary 380 self.boundary_length = len(self.boundary) 378 381 379 382 … … 402 405 return self.tagged_elements 403 406 404 def build_boundary_structure(self):405 """Traverse boundary and406 enumerate neighbour indices from -1 and407 counting down.408 409 Precondition:410 self.boundary is defined.411 Post condition:412 neighbour array has unique negative indices for boundary413 boundary_segments array imposes an ordering on segments414 (not otherwise available from the dictionary)415 416 Note: If a segment is listed in the boundary dictionary417 it *will* become a boundary - even if there is a neighbouring triangle.418 This would be the case for internal boundaries419 """420 421 #FIXME: Now Obsolete - maybe use some comments from here in422 #domain.set_boundary423 424 if self.boundary is None:425 msg = 'Boundary dictionary must be defined before '426 msg += 'building boundary structure'427 raise Exception(msg)428 429 430 self.boundary_segments = self.boundary.keys()431 self.boundary_segments.sort()432 433 index = -1434 for id, edge in self.boundary_segments:435 436 #FIXME: One would detect internal boundaries as follows437 #if self.neighbours[id, edge] > -1:438 # log.critical('Internal boundary')439 440 self.neighbours[id, edge] = index441 442 self.boundary_enumeration[id,edge] = index443 444 index -= 1445 407 # def build_boundary_structure(self): 408 # """Traverse boundary and 409 # enumerate neighbour indices from -1 and 410 # counting down. 411 # 412 # Precondition: 413 # self.boundary is defined. 414 # Post condition: 415 # neighbour array has unique negative indices for boundary 416 # boundary_segments array imposes an ordering on segments 417 # (not otherwise available from the dictionary) 418 # 419 # Note: If a segment is listed in the boundary dictionary 420 # it *will* become a boundary - even if there is a neighbouring triangle. 421 # This would be the case for internal boundaries 422 # """ 423 # 424 # #FIXME: Now Obsolete - maybe use some comments from here in 425 # #domain.set_boundary 426 # 427 # if self.boundary is None: 428 # msg = 'Boundary dictionary must be defined before ' 429 # msg += 'building boundary structure' 430 # raise Exception(msg) 431 # 432 # 433 # self.boundary_segments = self.boundary.keys() 434 # self.boundary_segments.sort() 435 # 436 # index = -1 437 # for id, edge in self.boundary_segments: 438 # 439 # #FIXME: One would detect internal boundaries as follows 440 # #if self.neighbours[id, edge] > -1: 441 # # log.critical('Internal boundary') 442 # 443 # self.neighbours[id, edge] = index 444 # 445 # self.boundary_enumeration[id,edge] = index 446 # 447 # index -= 1 448 # 446 449 447 450 … … 467 470 self.boundary_enumeration = {} 468 471 472 473 469 474 X = self.boundary.keys() 470 475 X.sort() 471 476 477 #print 'X', X 472 478 index = -1 473 479 for id, edge in X: … … 484 490 485 491 for id, edge in X: 486 487 492 j = self.boundary_enumeration[id,edge] 488 493 self.boundary_cells[j] = id 489 494 self.boundary_edges[j] = edge 490 495 496 # For each tag create list of boundary edges 497 self.tag_boundary_cells = {} 498 499 tags = self.get_boundary_tags() 500 501 #print tags 502 503 for tag in tags: 504 self.tag_boundary_cells[tag] = [] 505 506 507 for j in range(self.boundary_length): 508 id = self.boundary_cells[j] 509 edge = self.boundary_edges[j] 510 tag = self.boundary[id, edge] 511 #print tag, id, edge 512 self.tag_boundary_cells[tag].append(j) 513 514 515 #print self.tag_boundary_cells 491 516 492 517 def get_boundary_tags(self): -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
r8164 r8455 72 72 73 73 # Allocate space for boundary values 74 self.boundary_length = L = len(domain.boundary) 74 #self.boundary_length = domain.boundary_length 75 self.boundary_length = L = self.domain.boundary_length 75 76 self.boundary_values = num.zeros(L, num.float) 76 77 -
trunk/anuga_core/source/anuga/file/test_sww.py
r8405 r8455 41 41 yiel=0.01 42 42 points, vertices, boundary = rectangular(10,10) 43 44 #print "=============== boundary rect =======================" 45 #print boundary 43 46 44 47 #Create shallow water domain … … 76 79 pass 77 80 81 #print boundary 78 82 79 83 … … 81 85 domain2 = load_sww_as_domain(filename, None, fail_if_NaN=False, 82 86 verbose=self.verbose) 87 88 # Unfortunately we loss the boundaries top, bottom, left and right, 89 # they are now all lumped into "exterior" 90 91 #print "=============== boundary domain2 =======================" 92 #print domain2.boundary 93 94 95 #print domain2.get_boundary_tags() 96 83 97 #points, vertices, boundary = rectangular(15,15) 84 98 #domain2.boundary = boundary … … 110 124 domain.set_quantity('friction', 0.1) 111 125 domain.store = False 112 domain.set_boundary({' left': Bd, 'right': Bd, 'top': Bd, 'bottom': Bd})126 domain.set_boundary({'exterior': Bd, 'left' : Bd, 'right': Bd, 'top': Bd, 'bottom': Bd}) 113 127 114 128 … … 131 145 #print 'domain2.boundary' 132 146 #print domain2.boundary 133 domain2.set_boundary({' left': Bd,'right': Bd, 'top': Bd, 'bottom': Bd})147 domain2.set_boundary({'exterior': Bd, 'left' : Bd, 'right': Bd, 'top': Bd, 'bottom': Bd}) 134 148 #domain2.set_boundary({'exterior': Bd}) 135 149 -
trunk/anuga_core/source/anuga/operators/run_set_stage.py
r8454 r8455 60 60 from anuga.operators.set_value_operators import Circular_set_stage_operator 61 61 62 cop1 = Circular_set_stage_operator(domain, stage=h0+20.0, center=(0.0, 0.0), radius=100.0 ) 63 cop2 = Circular_set_stage_operator(domain, stage=h0+20.0, center=(2000.0, 1000.0), radius=100.0 ) 62 import math 63 64 stage1 = lambda t: h0 + 20.0 * math.sin(t/3.0) 65 cop1 = Circular_set_stage_operator(domain, stage=stage1, center=(0.0, 0.0), radius=100.0 ) 66 67 stage2 = lambda t: h0 + 30.0 * math.sin(t/6.0) 68 cop2 = Circular_set_stage_operator(domain, stage=stage2, center=(2000.0, 1000.0), radius=100.0 ) 64 69 65 70 #print cop1.statistics() -
trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r8418 r8455 304 304 self.store = flag 305 305 306 def get_store(self): 307 """Get whether data saved to sww file. 308 """ 309 310 return self.store 311 306 312 307 313 def set_sloped_mannings_function(self, flag=True): … … 342 348 """Get method for computing fluxes. 343 349 344 Currently 345 original 346 wb_1 350 See set_compute_fluxes_method for possible choices. 347 351 """ 348 352 … … 1010 1014 1011 1015 1016 1012 1017 def evolve(self, 1013 1018 yieldstep=None, -
trunk/anuga_core/source/anuga/shallow_water/shallow_water_ext.c
r8400 r8455 451 451 452 452 /*Compute fluxes between volumes for the shallow water wave equation 453 cast in terms of the 'stage', w = h+z using 454 the 'central scheme' as described in 455 456 Kurganov, Noelle, Petrova. 'Semidiscrete Central-Upwind Schemes For 457 Hyperbolic Conservation Laws and Hamilton-Jacobi Equations'. 458 Siam J. Sci. Comput. Vol. 23, No. 3, pp. 707-740. 459 460 The implemented formula is given in equation (3.15) on page 714 453 * cast in terms of the 'stage', w = h+z using 454 * the 'central scheme' as described in 455 * 456 * Kurganov, Noelle, Petrova. 'Semidiscrete Central-Upwind Schemes For 457 * Hyperbolic Conservation Laws and Hamilton-Jacobi Equations'. 458 * Siam J. Sci. Comput. Vol. 23, No. 3, pp. 707-740. 459 * 460 * The implemented formula is given in equation (3.15) on page 714. 461 * 462 * The pressure term is calculated using simpson's rule so that it 463 * will well balance with the standard ghz_x gravity term 461 464 */ 462 465 … … 464 467 int i; 465 468 //double hl, hr; 466 double uh_left, vh_left, u_left ;467 double uh_right, vh_right, u_right ;469 double uh_left, vh_left, u_left, v_left; 470 double uh_right, vh_right, u_right, v_right; 468 471 double s_min, s_max, soundspeed_left, soundspeed_right; 469 472 double denom, inverse_denominator; … … 531 534 // Momentum in y-direction 532 535 vh_left = q_left_rotated[2]; 536 v_left = _compute_speed(&vh_left, &h_left, 537 epsilon, h0, limiting_threshold); 538 533 539 vh_right = q_right_rotated[2]; 540 v_right = _compute_speed(&vh_right, &h_right, 541 epsilon, h0, limiting_threshold); 534 542 535 543 // Limit y-momentum if necessary … … 615 623 edgeflux[i] *= inverse_denominator; 616 624 } 625 /* 626 if (edgeflux[0] > 0.0) { 627 edgeflux[2] = edgeflux[0]*v_left; 628 } else { 629 edgeflux[2] = edgeflux[0]*v_right; 630 } 631 */ 617 632 618 633 // Maximal wavespeed -
trunk/anuga_core/source/anuga_parallel/parallel_api.py
r8282 r8455 62 62 domain_name = domain.get_name() 63 63 domain_dir = domain.get_datadir() 64 domain_store = domain.get_store() 64 65 georef = domain.geo_reference 65 66 number_of_global_triangles = domain.number_of_triangles … … 69 70 70 71 for p in range(1, numprocs): 71 send((domain_name, domain_dir, georef, \72 send((domain_name, domain_dir, domain_store, georef, \ 72 73 number_of_global_triangles, number_of_global_nodes), p) 73 74 else: 74 75 if verbose: print 'P%d: Receiving domain attributes' %(myid) 75 76 76 domain_name, domain_dir, georef, \77 domain_name, domain_dir, domain_store, georef, \ 77 78 number_of_global_triangles, number_of_global_nodes = receive(0) 78 79 … … 177 178 #------------------------------------------------------------------------ 178 179 domain.set_name(domain_name) 179 domain.set_datadir(domain_dir) 180 domain.set_datadir(domain_dir) 181 domain.set_store(domain_store) 180 182 domain.geo_reference = georef 181 183 -
trunk/anuga_core/source/anuga_parallel/parallel_generic_communications.py
r8209 r8455 33 33 """ 34 34 35 pypar.barrier() 35 36 36 37 37 import time -
trunk/anuga_core/source/anuga_parallel/parallel_shallow_water.py
r8301 r8455 18 18 19 19 import numpy as num 20 from os.path import join 20 21 21 22 … … 131 132 def sww_merge(self, verbose=False, delete_old=False): 132 133 133 if self.processor == 0 and self.numproc > 1 :134 if self.processor == 0 and self.numproc > 1 and self.store : 134 135 import anuga.utilities.sww_merge as merge 136 137 global_name = join(self.get_datadir(),self.get_global_name()) 135 138 136 merge.sww_merge_parallel( self.get_global_name(),self.numproc,verbose,delete_old)139 merge.sww_merge_parallel(global_name,self.numproc,verbose,delete_old) 137 140 138 141 -
trunk/anuga_core/source/anuga_parallel/run_parallel_sw_merimbula.py
r8447 r8455 85 85 domain = create_domain_from_file(mesh_filename) 86 86 domain.set_quantity('stage', Set_Stage(x0, x1, 2.0)) 87 domain.set_datadir('Data') 88 domain.set_name('merimbula_new') 89 domain.set_store(False) 87 90 #domain.set_quantity('elevation', Set_Elevation(500.0)) 88 91 … … 106 109 #-------------------------------------------------------------------------- 107 110 111 108 112 #domain.smooth = False 109 113 domain.set_default_order(2) … … 111 115 #domain.set_CFL(0.7) 112 116 #domain.set_beta(1.5) 113 domain.set_name('merimbula') 117 114 118 115 119 #for p in range(numprocs): … … 144 148 t0 = time.time() 145 149 146 for t in domain.evolve(yieldstep = yield step, finaltime = finaltime):150 for t in domain.evolve(yieldstep = yieldtime, finaltime = finaltime): 147 151 if myid == 0: 148 152 domain.write_time()
Note: See TracChangeset
for help on using the changeset viewer.