Changeset 4666 for anuga_core/source/anuga/utilities
- Timestamp:
- Aug 8, 2007, 2:29:01 PM (18 years ago)
- Location:
- anuga_core/source/anuga/utilities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/utilities/quad.py
r4655 r4666 27 27 """ 28 28 29 def __init__(self, southern, northern, western, eastern, 29 def __init__(self, southern, northern, western, eastern, mesh, 30 30 name = 'cell', 31 31 max_points_per_cell = 4): … … 39 39 self.western = round(western,5) 40 40 self.eastern = round(eastern,5) 41 self.mesh = mesh 41 42 42 43 # The points in this cell … … 63 64 cn = self.northern 64 65 cw = self.western 65 ce = self.eastern 66 ce = self.eastern 67 mesh = self.mesh 66 68 67 69 # create 4 child cells 68 self.AddChild(Cell((cn+cs)/2,cn,cw,(cw+ce)/2, self.name+'_nw'))69 self.AddChild(Cell((cn+cs)/2,cn,(cw+ce)/2,ce, self.name+'_ne'))70 self.AddChild(Cell(cs,(cn+cs)/2,(cw+ce)/2,ce, self.name+'_se'))71 self.AddChild(Cell(cs,(cn+cs)/2,cw,(cw+ce)/2, self.name+'_sw'))70 self.AddChild(Cell((cn+cs)/2,cn,cw,(cw+ce)/2,mesh,self.name+'_nw')) 71 self.AddChild(Cell((cn+cs)/2,cn,(cw+ce)/2,ce,mesh,self.name+'_ne')) 72 self.AddChild(Cell(cs,(cn+cs)/2,(cw+ce)/2,ce,mesh,self.name+'_se')) 73 self.AddChild(Cell(cs,(cn+cs)/2,cw,(cw+ce)/2,mesh,self.name+'_sw')) 72 74 73 75 … … 140 142 if len(args) == 2: 141 143 point_id = int(args[1]) 142 x, y = self. __class__.mesh.get_nodes()[point_id]144 x, y = self.mesh.get_nodes()[point_id] 143 145 144 146 #print point_id, x, y … … 181 183 self.store(point) 182 184 else: 183 x = self. __class__.mesh.coordinates[point][0]184 y = self. __class__.mesh.coordinates[point][1]185 x = self.mesh.coordinates[point][0] 186 y = self.mesh.coordinates[point][1] 185 187 print "(" + str(x) + "," + str(y) + ")" 186 188 raise 'point not in region: %s' %str(point) … … 223 225 # print "verts", verts 224 226 for vert in verts: 225 triangle_list = self. __class__.mesh.get_triangles_and_vertices_per_node(vert)227 triangle_list = self.mesh.get_triangles_and_vertices_per_node(vert) 226 228 for k, _ in triangle_list: 227 229 if not triangles.has_key(k): 228 230 # print 'k',k 229 tri = self. __class__.mesh.get_vertex_coordinates(k)230 n0 = self. __class__.mesh.get_normal(k, 0)231 n1 = self. __class__.mesh.get_normal(k, 1)232 n2 = self. __class__.mesh.get_normal(k, 2)231 tri = self.mesh.get_vertex_coordinates(k) 232 n0 = self.mesh.get_normal(k, 0) 233 n1 = self.mesh.get_normal(k, 1) 234 n2 = self.mesh.get_normal(k, 2) 233 235 triangles[k]=(tri, (n0, n1, n2)) 234 236 self.triangles = triangles.items() … … 418 420 419 421 420 #Class initialisation method 421 def initialise(cls, mesh): 422 cls.mesh = mesh 423 424 initialise = classmethod(initialise) 422 #Class initialisation method 423 # this is bad. It adds a huge memory structure to the class. 424 # When the instance is deleted the mesh hangs round (leaks). 425 #def initialise(cls, mesh): 426 # cls.mesh = mesh 427 428 #initialise = classmethod(initialise) 425 429 426 430 def build_quadtree(mesh, max_points_per_cell = 4): 427 431 """Build quad tree for mesh. 428 432 429 All vertices in mesh are stored in quadtree and a reference to the root is returned. 433 All vertices in mesh are stored in quadtree and a reference 434 to the root is returned. 430 435 """ 431 436 432 437 from Numeric import minimum, maximum 433 438 434 #Initialise435 Cell.initialise(mesh)436 439 437 440 #Make root cell … … 445 448 446 449 447 #Ensure boundary points are fully contained in region 448 #It is a property of the cell structure that points on xmax or ymax of any given cell 449 #belong to the neighbouring cell. 450 #Hence, the root cell needs to be expanded slightly 450 # Ensure boundary points are fully contained in region 451 # It is a property of the cell structure that 452 # points on xmax or ymax of any given cell 453 # belong to the neighbouring cell. 454 # Hence, the root cell needs to be expanded slightly 451 455 ymax += (ymax-ymin)/10 452 456 xmax += (xmax-xmin)/10 … … 462 466 463 467 #FIXME: Use mesh.filename if it exists 464 root = Cell(ymin, ymax, xmin, xmax, 468 root = Cell(ymin, ymax, xmin, xmax,mesh, 465 469 #name = .... 466 470 max_points_per_cell = max_points_per_cell) -
anuga_core/source/anuga/utilities/test_quad.py
r4655 r4666 12 12 13 13 def setUp(self): 14 self.cell = Cell(100, 140, 0, 40, 'cell')15 14 16 15 a = [3, 107] … … 30 29 mesh = Mesh(points, vertices) 31 30 self.mesh = mesh 32 Cell.initialise(mesh)31 self.cell = Cell(100, 140, 0, 40, mesh, 'cell') 33 32 34 33 def tearDown(self):
Note: See TracChangeset
for help on using the changeset viewer.