Ignore:
Timestamp:
Jan 5, 2007, 5:51:51 PM (18 years ago)
Author:
duncan
Message:

changing the mesh generator and triangle interface to work with Numeric arrys, as input

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/pmesh/test_mesh.py

    r3541 r4139  
    10681068                        ,
    10691069                        'exported Ascii xya file is wrong')
    1070            
     1070     
     1071    def test_lone_vert_in_mesh_gen_c_layer(self):
     1072        # currently just a copy of the above test
     1073        a = Vertex (0,0)
     1074        b = Vertex (0,3)
     1075        c = Vertex (3,3)
     1076        d = Vertex (1,2)
     1077        e = Vertex (3,1)
     1078        #f = Vertex (3,1)
     1079     
     1080        s1 = Segment(a,b, tag = 50)
     1081        s2 = Segment(b,c, tag = 40)
     1082        s3 = Segment(c,a, tag = 30)
     1083     
     1084        r1 = Region(2, 1,tag = 1.3)
     1085        h1 = Hole(1,4)
     1086        # Warning mesh can't produce this type of data structure its self
     1087        m = Mesh(userVertices=[a,b,c,d,e],
     1088                 userSegments=[s1,s2,s3],
     1089                 regions=[r1],
     1090                 holes = [h1])
     1091       
     1092        fileName = tempfile.mktemp(".xya")
     1093        #fileName = 't.xya'
     1094        #os.remove(fileName)
     1095        m.exportPointsFile(fileName)
     1096        file = open(fileName)
     1097        lFile = file.read().split('\n')
     1098        file.close()
     1099
     1100        os.remove(fileName)
     1101        self.failUnless(lFile[0] == "" and
     1102                        lFile[1] == "0,0" and
     1103                        lFile[2] == "0,3" and
     1104                        lFile[3] == "3,3"
     1105                        ,
     1106                        'exported Ascii xya file is wrong')
     1107        self.failUnless(lFile[4] == "1,2" and
     1108                        lFile[5] == "3,1"
     1109                        ,
     1110                        'exported Ascii xya file is wrong')
     1111       
     1112        # vertex e is outside of the outline, so
     1113        # it is a loner and it is removed.
     1114        m.generateMesh("Q", maxArea = 2.1)
     1115        fileName = tempfile.mktemp(".xya")
     1116        #fileName = 't.xya'
     1117        #m.export_mesh_file('m.tsh')
     1118        m.exportPointsFile(fileName)
     1119        file = open(fileName)
     1120        lFile = file.read().split('\n')
     1121        file.close()
     1122        os.remove(fileName)
     1123       
     1124        self.failUnless(lFile[0] == "" and
     1125                        lFile[1] == "0.0,0.0" and
     1126                        lFile[2] == "0.0,3.0" and
     1127                        lFile[3] == "3.0,3.0" and
     1128                        lFile[4] == "1.0,2.0"
     1129                        ,
     1130                        'exported Ascii xya file is wrong')
     1131       
    10711132    def test_exportPointsFilefile2(self):
    10721133        m = Mesh()
     
    22762337if __name__ == "__main__":
    22772338    suite = unittest.makeSuite(meshTestCase,'test')
    2278     #suite = unittest.makeSuite(meshTestCase,'test_add_points_and_segments')
     2339    #suite = unittest.makeSuite(meshTestCase,'test_exportASCIIsegmentoutlinefile')
     2340    #suite = unittest.makeSuite(meshTestCase,'test_e')
    22792341    runner = unittest.TextTestRunner() #verbosity=2)
    22802342    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.