Esempio n. 1
0
 def test_get_boundary_segments(self):
     """
     Test 
     """
     #
     # Define Mesh
     # 
     mesh = QuadMesh(resolution=(2,2))
     mesh.record('mesh_1')
     mesh.cells.get_child(2).mark('1')
     mesh.cells.refine(refinement_flag='1') 
     
     #
     # 
     # 
     for segment in mesh.get_boundary_segments(subforest_flag=None):
         for he in segment:
             pass
Esempio n. 2
0
 def test_mark_region(self):
     """
     This is a method in Mesh2D, but 
     """
     #
     # Define Mesh
     # 
     mesh = QuadMesh(resolution=(2,2))
     mesh.cells.get_child(2).mark('1')
     mesh.cells.refine(refinement_flag='1')
     
     #
     # Mark left boundary vertices 
     #  
     f_left = lambda x,dummy: np.abs(x)<1e-9
     mesh.mark_region('left', f_left, on_boundary=True)
     
     #
     # Check that left boundary vertices are the only  
     # 
     count = 0
     for segment in mesh.get_boundary_segments():
         for he in segment:
             # Half-edge should not be marked 
             self.assertFalse(he.is_marked('left'))
             
             # Cell should not be marked
             self.assertFalse(he.cell().is_marked('left'))
             
             for v in he.get_vertices():
                 if f_left(*v.coordinates()):
                     #
                     # Left boundary vertices should be marked
                     # 
                     self.assertTrue(v.is_marked('left'))
                     count += 1
                 else:
                     #
                     # No other boundary vertices should be marked
                     # 
                     self.assertFalse(v.is_marked('left'))
     self.assertEqual(count, 8)