Changeset 648
- Timestamp:
- Dec 1, 2004, 4:36:33 PM (20 years ago)
- Location:
- inundation/ga/storm_surge/pyvolution
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/domain.py
r590 r648 180 180 More entries may point to the same boundary object 181 181 182 Schematically the mapping is: 183 184 self.boundary_segments: k: (vol_id, edge_id) 182 Schematically the mapping is from two dictionaries to one list 183 where the index is used as pointer to the boundary_values arrays 184 within each quantity. 185 185 186 self.boundary: (vol_id, edge_id): tag 186 187 boundary_map (input): tag: boundary_object 187 188 ---------------------------------------------- 188 self.boundary_objects: k: boundary_object189 self.boundary_objects: ((vol_id, edge_id), boundary_object) 189 190 190 191 191 192 Pre-condition: 192 self.boundary and self.boundary_segments havebeen built.193 self.boundary has been built. 193 194 194 195 Post-condition: … … 199 200 However, if a tag is not used to the domain, no error is thrown. 200 201 FIXME: This would lead to implementation of a 201 default boundary condition 202 default boundary condition 203 204 Note: If a segment is listed in the boundary dictionary and if it is 205 not None, it *will* become a boundary - 206 even if there is a neighbouring triangle. 207 This would be the case for internal boundaries 208 209 Boundary objects that are None will be skipped. 210 211 FIXME: If set_boundary is called multiple times and if Boundary 212 object is changed into None, the neighbour structure will not be 213 restored!!! 214 215 202 216 """ 203 217 204 218 self.boundary_objects = [] 205 for k, (vol_id, edge_id) in enumerate(self.boundary_segments): 219 220 #FIXME: Try to remove the sorting and fix test_mesh.py 221 x = self.boundary.keys() 222 x.sort() 223 for k, (vol_id, edge_id) in enumerate(x): 206 224 tag = self.boundary[ (vol_id, edge_id) ] 207 225 208 226 if boundary_map.has_key(tag): 209 227 B = boundary_map[tag] 210 self.boundary_objects.append(B) 228 229 if B is not None: 230 self.boundary_objects.append( ((vol_id, edge_id), B) ) 231 self.neighbours[vol_id, edge_id] = -len(self.boundary_objects) 232 else: 233 pass 234 #FIXME: Check and perhaps fix neighbour structure 235 211 236 212 237 else: … … 379 404 380 405 #FIXME: Update only those that change (if that can be worked out) 381 for i, B in enumerate(self.boundary_objects): 382 vol_id, edge_id = self.boundary_segments[i] 406 for i, ((vol_id, edge_id), B) in enumerate(self.boundary_objects): 383 407 q = B.evaluate(vol_id, edge_id) 384 408 -
inundation/ga/storm_surge/pyvolution/mesh.py
r645 r648 131 131 132 132 #Update boundary indices 133 self.build_boundary_structure()133 #self.build_boundary_structure() 134 134 135 135 … … 313 313 """ 314 314 315 #FIXME: Maybe obsolete 316 315 317 if self.boundary is None: 316 318 msg = 'Boundary dictionary must be defined before ' … … 436 438 #Check that all boundaries have 437 439 # unique, consecutive, negative indices 438 L = len(self.boundary) 439 for i in range(L): 440 id, edge = self.boundary_segments[i] 441 assert self.neighbours[id, edge] == -i-1 440 441 #L = len(self.boundary) 442 #for i in range(L): 443 # id, edge = self.boundary_segments[i] 444 # assert self.neighbours[id, edge] == -i-1 442 445 443 446 … … 445 448 #FIXME: Look into this further. 446 449 #FIXME (Ole): In pyvolution mark 3 this is OK again 447 for id, edge in self.boundary: 448 assert self.neighbours[id,edge] < 0 450 #NOTE: No longer works because neighbour structure is modified by 451 # domain set_boundary. 452 #for id, edge in self.boundary: 453 # assert self.neighbours[id,edge] < 0 449 454 450 455 -
inundation/ga/storm_surge/pyvolution/test_advection.py
r195 r648 46 46 domain.check_integrity() 47 47 48 assert allclose(domain.neighbours, [[-1,-2,-3]]) 49 48 50 49 #Populate boundary array with dirichlet conditions. 50 domain.neighbours = array([[-1,-2,-3]]) 51 51 domain.quantities['level'].boundary_values[:] = 1.0 52 52 … … 100 100 domain.check_integrity() 101 101 102 assert allclose(domain.neighbours, [[-1,-2,-3]])103 102 104 103 #Populate boundary array with dirichlet conditions. 104 domain.neighbours = array([[-1,-2,-3]]) 105 105 domain.quantities['level'].boundary_values[0] = 1.0 106 106 … … 131 131 domain.check_integrity() 132 132 133 assert allclose(domain.neighbours, [[1,-1,-2], [0,-3,-4]])134 133 135 134 #Populate boundary array with dirichlet conditions. 136 135 domain.neighbours = array([[1,-1,-2], [0,-3,-4]]) 137 136 domain.set_quantity('level', [1.0, 0.0], 'centroids') 138 137 domain.distribute_to_vertices_and_edges() -
inundation/ga/storm_surge/pyvolution/test_domain.py
r546 r648 137 137 assert allclose(q, [-1.5, -1.5, 0.]) 138 138 139 140 def test_boundary_indices(self): 141 142 from config import default_boundary_tag 143 144 145 a = [0.0, 0.5] 146 b = [0.0, 0.0] 147 c = [0.5, 0.5] 148 149 points = [a, b, c] 150 vertices = [ [0,1,2] ] 151 domain = Domain(points, vertices) 152 153 domain.set_boundary( {default_boundary_tag: Dirichlet_boundary([5,2,1])} ) 154 155 156 domain.check_integrity() 157 158 assert allclose(domain.neighbours, [[-1,-2,-3]]) 159 139 160 140 161 … … 185 206 assert domain.quantities['level'].boundary_values[5] ==\ 186 207 domain.get_conserved_quantities(3, edge=2)[0] #Transmissive (-1.5) 208 209 #Check enumeration 210 for k, ((vol_id, edge_id), _) in enumerate(domain.boundary_objects): 211 assert domain.neighbours[vol_id, edge_id] == -k-1 212 187 213 188 214 -
inundation/ga/storm_surge/pyvolution/test_generic_boundary_conditions.py
r625 r648 91 91 domain.set_boundary( {default_boundary_tag: T} ) 92 92 93 assert len(domain.boundary) == len(domain.boundary_segments) 94 assert len(domain.boundary_objects) == len(domain.boundary_segments) 93 94 #FIXME: should not necessarily be true always. 95 #E.g. with None as a boundary object. 96 assert len(domain.boundary) == len(domain.boundary_objects) 95 97 96 98 q = T.evaluate(0, 2) #Vol=0, edge=2 -
inundation/ga/storm_surge/pyvolution/test_mesh.py
r601 r648 209 209 210 210 211 def test_boundary_indices(self):212 a = [0.0, 0.5]213 b = [0.0, 0.0]214 c = [0.5, 0.5]215 216 points = [a, b, c]217 vertices = [ [0,1,2] ]218 mesh = Mesh(points, vertices)219 mesh.check_integrity()220 221 assert allclose(mesh.neighbours, [[-1,-2,-3]])222 223 211 224 212 … … 490 478 491 479 #Check enumeration 492 for k, (vol_id, edge_id) in enumerate(mesh.boundary_segments):493 b = -k-1494 assert mesh.neighbours[vol_id, edge_id] == b480 #for k, (vol_id, edge_id) in enumerate(mesh.boundary_segments): 481 # b = -k-1 482 # assert mesh.neighbours[vol_id, edge_id] == b 495 483 496 484 … … 525 513 526 514 #Check enumeration 527 for k, (vol_id, edge_id) in enumerate(mesh.boundary_segments):528 b = -k-1529 assert mesh.neighbours[vol_id, edge_id] == b515 #for k, (vol_id, edge_id) in enumerate(mesh.boundary_segments): 516 # b = -k-1 517 # assert mesh.neighbours[vol_id, edge_id] == b 530 518 531 519 def test_boundary_inputs_using_all_defaults(self): … … 563 551 564 552 #Check enumeration 565 for k, (vol_id, edge_id) in enumerate(mesh.boundary_segments):566 b = -k-1567 assert mesh.neighbours[vol_id, edge_id] == b553 #for k, (vol_id, edge_id) in enumerate(mesh.boundary_segments): 554 # b = -k-1 555 # assert mesh.neighbours[vol_id, edge_id] == b 568 556 569 557 -
inundation/ga/storm_surge/pyvolution/test_shallow_water.py
r646 r648 297 297 T = Transmissive_boundary(domain) 298 298 R = Reflective_boundary(domain) 299 domain.set_boundary( {'First': D, 'Second': T, 'Third': R, 'Internal':None}) 300 299 domain.set_boundary( {'First': D, 'Second': T, 300 'Third': R, 'Internal': None}) 301 301 302 domain.update_boundary() 302 303 #Level 304 assert domain.quantities['level'].boundary_values[0] == 2.5 305 assert domain.quantities['level'].boundary_values[0] ==\ 306 domain.get_conserved_quantities(0, edge=0)[0] #Reflective (2.5) 307 assert domain.quantities['level'].boundary_values[1] == 5. #Dirichlet 308 assert domain.quantities['level'].boundary_values[2] ==\ 309 domain.get_conserved_quantities(2, edge=0)[0] #Transmissive (4.5) 310 assert domain.quantities['level'].boundary_values[3] ==\ 311 domain.get_conserved_quantities(2, edge=1)[0] #Transmissive (4.5) 312 assert domain.quantities['level'].boundary_values[4] ==\ 313 domain.get_conserved_quantities(3, edge=1)[0] #Transmissive (-1.5) 314 assert domain.quantities['level'].boundary_values[5] ==\ 315 domain.get_conserved_quantities(3, edge=2)[0] #Reflective (-1.5) 316 317 #Xmomentum 318 assert domain.quantities['xmomentum'].boundary_values[0] == 1.0 #Reflective 319 assert domain.quantities['xmomentum'].boundary_values[1] == 2. #Dirichlet 320 assert domain.quantities['xmomentum'].boundary_values[2] ==\ 321 domain.get_conserved_quantities(2, edge=0)[1] #Transmissive 322 assert domain.quantities['xmomentum'].boundary_values[3] ==\ 323 domain.get_conserved_quantities(2, edge=1)[1] #Transmissive 324 assert domain.quantities['xmomentum'].boundary_values[4] ==\ 325 domain.get_conserved_quantities(3, edge=1)[1] #Transmissive 326 assert domain.quantities['xmomentum'].boundary_values[5] == -4.0 #Reflective 327 328 #Ymomentum 329 assert domain.quantities['ymomentum'].boundary_values[0] == -10.0 #Reflective 330 assert domain.quantities['ymomentum'].boundary_values[1] == 1. #Dirichlet 331 assert domain.quantities['ymomentum'].boundary_values[2] == 30. #Transmissive 332 assert domain.quantities['ymomentum'].boundary_values[3] == 30. #Transmissive 333 assert domain.quantities['ymomentum'].boundary_values[4] == 40. #Transmissive 334 assert domain.quantities['ymomentum'].boundary_values[5] == 40. #Reflective 303 domain.check_integrity() 335 304 336 305
Note: See TracChangeset
for help on using the changeset viewer.