Changeset 8010
- Timestamp:
- Sep 9, 2010, 10:15:21 PM (14 years ago)
- Location:
- trunk/anuga_core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/documentation/user_manual/demos/buildings.py
r8006 r8010 30 30 # Create the "world" as a long, skinny channel 31 31 boundary_poly = poly_from_box(0, length, 0, width) 32 boundary_tags = {'left': [0], 'bottom': [1], 'right': [2], 'top': [3]} 32 33 33 34 # Place 3 buildings downstream … … 36 37 poly_from_box(35, 40, 3.5, 8.5)] # downstream box 37 38 38 building_tags = [ { 'upstream' : [ 0,1,2,3]},39 { 'middle' : None},40 { 'downstream' : [0,1 ,2,3]} ]39 building_tags = [ { 'upstream' : [1]}, # Set segment[0], default others 40 None, # Use default interior tag 41 { 'downstream' : [0,1]} ] # set segments[0,1],default others 41 42 42 #building_tags = None43 43 44 44 # create a domain mesh, with 3 building holes in it 45 45 domain = anuga.create_domain_from_regions(boundary_poly, 46 boundary_tags={'left': [0], 47 'bottom': [1], 48 'right': [2], 49 'top': [3]}, 46 boundary_tags=boundary_tags, 50 47 maximum_triangle_area = resolution, 51 48 mesh_filename = 'building.msh', … … 76 73 Bo = anuga.Dirichlet_boundary([-5, 0, 0]) # Outflow 77 74 75 print domain.get_boundary_tags() 76 78 77 domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br, 79 'middle': Br , # this is the internal middle building boundary80 'downstream' : Br ,# downstream building81 'upstream' : Br# upstream building boundary78 'interior': Br ,# default interior boundary tag 79 'downstream': Br ,# downstream building 80 'upstream' : Br # upstream building boundary 82 81 }) 83 82 … … 88 87 for t in domain.evolve(yieldstep=0.2, finaltime=15.0): 89 88 print domain.timestepping_statistics() 89 90 90 91 91 # now turn off the tap … … 94 94 for t in domain.evolve(yieldstep=0.1, finaltime=30.0): 95 95 print domain.timestepping_statistics() 96 -
trunk/anuga_core/source/anuga/pmesh/mesh.py
r7873 r8010 737 737 segments.append( [lo, hi] ) 738 738 region_dict['segments'] = segments 739 region_dict['segment_tags'] = self._tag_dict2list(segment_tags, N) 739 region_dict['segment_tags'] = self._tag_dict2list(segment_tags, N, 740 hole=hole) 740 741 741 742 … … 757 758 return inner 758 759 759 def _tag_dict2list(self, tags, number_of_segs ):760 def _tag_dict2list(self, tags, number_of_segs, hole=False): 760 761 """ 761 762 Convert a tag dictionary from this sort of format; … … 771 772 # Due to this default this method is too connected to 772 773 # _add_area_from_polygon 773 segment_tags = ['']*number_of_segs 774 775 if hole: 776 default_tag ='interior' 777 else: 778 default_tag ='' 779 segment_tags = [default_tag]*number_of_segs 774 780 if tags is not None: 775 781 for key in tags: -
trunk/anuga_core/source/anuga/pmesh/mesh_interface.py
r8006 r8010 318 318 tags = hole_tags[n] 319 319 except: 320 tags = None320 tags = {} 321 321 m.add_hole_from_polygon(polygon, 322 322 segment_tags=tags, -
trunk/anuga_core/source/anuga/pmesh/test_mesh.py
r7873 r8010 1757 1757 self.failUnless(segs[2].tag=='bom', 1758 1758 'FAILED!') 1759 self.failUnless(segs[3].tag==' ',1759 self.failUnless(segs[3].tag=='interior', 1760 1760 'FAILED!') 1761 1761 verts = m.getUserVertices() … … 1775 1775 self.failUnless(point_x == new_point_x, ' failed') 1776 1776 self.failUnless(point_y == new_point_y, ' failed') 1777 1778 1779 1780 1781 def test_add_hole_from_polygon_none_tag(self): 1782 x=-500 1783 y=-1000 1784 m=Mesh(geo_reference=Geo_reference(56,x,y)) 1785 1786 # These are the absolute values 1787 polygon_absolute = [[0,0],[1,0],[1,1],[0,1]] 1788 1789 x_p = -10 1790 y_p = -40 1791 geo_ref_poly = Geo_reference(56, x_p, y_p) 1792 polygon = geo_ref_poly.change_points_geo_ref(polygon_absolute) 1793 1794 poly_point = m.add_hole_from_polygon(polygon, 1795 None, 1796 geo_reference=geo_ref_poly) 1797 # poly_point values are relative to the mesh geo-ref 1798 # make them absolute 1799 #print "poly_point.x+x",poly_point.x+x 1800 #print "poly_point.y+y",poly_point.y+y 1801 #print "polygon_absolute", polygon_absolute 1802 self.failUnless(is_inside_polygon([poly_point.x+x,poly_point.y+y], 1803 polygon_absolute, closed = False), 1804 'FAILED!') 1805 1806 self.failUnless(len(m.holes)==1, 1807 'FAILED!') 1808 segs = m.getUserSegments() 1809 self.failUnless(len(segs)==4, 1810 'FAILED!') 1811 self.failUnless(len(m.userVertices)==4, 1812 'FAILED!') 1813 1814 self.failUnless(segs[0].tag=='interior', 1815 'FAILED!') 1816 self.failUnless(segs[1].tag=='interior', 1817 'FAILED!') 1818 1819 self.failUnless(segs[2].tag=='interior', 1820 'FAILED!') 1821 self.failUnless(segs[3].tag=='interior', 1822 'FAILED!') 1823 verts = m.getUserVertices() 1824 #print "User verts",verts 1825 #print 'polygon',polygon 1826 #vert values are relative 1827 for point,new_point in map(None,polygon,verts): 1828 point_x = point[0] + geo_ref_poly.get_xllcorner() 1829 new_point_x = new_point.x + m.geo_reference.get_xllcorner() 1830 point_y = point[1] + geo_ref_poly.get_yllcorner() 1831 #print "new_point.y",new_point.y 1832 #print "m.geo_ref.get_yllcorner()",m.geo_reference.get_yllcorner() 1833 new_point_y = new_point.y + m.geo_reference.get_yllcorner() 1834 #print "point_y",point_y 1835 #print "new_point_y",new_point_y 1836 1837 self.failUnless(point_x == new_point_x, ' failed') 1838 self.failUnless(point_y == new_point_y, ' failed') 1777 1839 1778 1840 def test_add_circle(self):
Note: See TracChangeset
for help on using the changeset viewer.