/[escript]/trunk/finley/test/python/run_generators.py
ViewVC logotype

Diff of /trunk/finley/test/python/run_generators.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2318 by ksteube, Thu Oct 2 06:51:48 2008 UTC revision 2319 by gross, Thu Mar 19 03:19:41 2009 UTC
# Line 48  TEST_FILE_EXT=".test" Line 48  TEST_FILE_EXT=".test"
48  class Test_Generators(unittest.TestCase):  class Test_Generators(unittest.TestCase):
49    
50     def checker(self,dom,reference):     def checker(self,dom,reference):
       if getMPISizeWorld() > 1: return  
51        dom_file=FINLEY_WORKDIR_PATH+TEST_FILE_EXT        dom_file=FINLEY_WORKDIR_PATH+TEST_FILE_EXT
52        dom.write(dom_file)        dom.write(dom_file)
53  # Uncomment this section to dump the files for regression testing  # Uncomment this section to dump the files for regression testing
54  #      if True:  #      if True:
55  #         dom.write(FINLEY_TEST_MESH_PATH+reference)  #         dom.write(FINLEY_TEST_MESH_PATH+reference)
56        dom_string=open(dom_file).read().splitlines()        dom_string=open(dom_file).read().splitlines()
57        ref_string=open(FINLEY_TEST_MESH_PATH+reference).read().splitlines()        ref_string=open(FINLEY_TEST_MESH_PATH+reference).read().splitlines()
58        self.failUnlessEqual(len(dom_string),len(ref_string),"number of lines in mesh files does not match reference")        self.failUnlessEqual(len(dom_string),len(ref_string),"number of lines in mesh files does not match reference")
59        for l in range(1,len(ref_string)):        for l in range(1,len(ref_string)):
# Line 104  class Test_Generators(unittest.TestCase) Line 103  class Test_Generators(unittest.TestCase)
103        self.checker(my_dom,file)        self.checker(my_dom,file)
104    
105     def test_hex_contact_2D_order1(self):     def test_hex_contact_2D_order1(self):
       if getMPISizeWorld() != 1: return  
106        file="hex_contact_2D_order1.msh"        file="hex_contact_2D_order1.msh"
107        ms1=Rectangle(1,1,1,l1=0.5,useElementsOnFace=False)        ms1=Rectangle(1,1,1,l1=0.5,useElementsOnFace=False)
108        ms2=Rectangle(1,1,1,l1=0.5,useElementsOnFace=False)        ms2=Rectangle(1,1,1,l1=0.5,useElementsOnFace=False)
# Line 113  class Test_Generators(unittest.TestCase) Line 111  class Test_Generators(unittest.TestCase)
111        self.checker(my_dom,file)        self.checker(my_dom,file)
112    
113     def test_hex_contact_2D_order1_onFace(self):     def test_hex_contact_2D_order1_onFace(self):
       if getMPISizeWorld() != 1: return  
114        file="hex_contact_2D_order1_onFace.msh"        file="hex_contact_2D_order1_onFace.msh"
115        ms1=Rectangle(1,1,1,l1=0.5,useElementsOnFace=True)        ms1=Rectangle(1,1,1,l1=0.5,useElementsOnFace=True)
116        ms2=Rectangle(1,1,1,l1=0.5,useElementsOnFace=True)        ms2=Rectangle(1,1,1,l1=0.5,useElementsOnFace=True)
# Line 122  class Test_Generators(unittest.TestCase) Line 119  class Test_Generators(unittest.TestCase)
119        self.checker(my_dom,file)        self.checker(my_dom,file)
120    
121     def test_hex_contact_2D_order2(self):     def test_hex_contact_2D_order2(self):
       if getMPISizeWorld() != 1: return  
122        file="hex_contact_2D_order2.msh"        file="hex_contact_2D_order2.msh"
123        ms1=Rectangle(1,1,2,l1=0.5,useElementsOnFace=False)        ms1=Rectangle(1,1,2,l1=0.5,useElementsOnFace=False)
124        ms2=Rectangle(1,1,2,l1=0.5,useElementsOnFace=False)        ms2=Rectangle(1,1,2,l1=0.5,useElementsOnFace=False)
# Line 131  class Test_Generators(unittest.TestCase) Line 127  class Test_Generators(unittest.TestCase)
127        self.checker(my_dom,file)        self.checker(my_dom,file)
128    
129     def test_hex_contact_2D_order2_onFace(self):     def test_hex_contact_2D_order2_onFace(self):
       if getMPISizeWorld() != 1: return  
130        file="hex_contact_2D_order2_onFace.msh"        file="hex_contact_2D_order2_onFace.msh"
131        ms1=Rectangle(1,1,2,l1=0.5,useElementsOnFace=True)        ms1=Rectangle(1,1,2,l1=0.5,useElementsOnFace=True)
132        ms2=Rectangle(1,1,2,l1=0.5,useElementsOnFace=True)        ms2=Rectangle(1,1,2,l1=0.5,useElementsOnFace=True)
# Line 140  class Test_Generators(unittest.TestCase) Line 135  class Test_Generators(unittest.TestCase)
135        self.checker(my_dom,file)        self.checker(my_dom,file)
136    
137     def test_hex_contact_3D_order1(self):     def test_hex_contact_3D_order1(self):
       if getMPISizeWorld() != 1: return  
138        file="hex_contact_3D_order1.msh"        file="hex_contact_3D_order1.msh"
139        ms1=Brick(1,1,1,1,l2=0.5,useElementsOnFace=False)        ms1=Brick(1,1,1,1,l2=0.5,useElementsOnFace=False)
140        ms2=Brick(1,1,1,1,l2=0.5,useElementsOnFace=False)        ms2=Brick(1,1,1,1,l2=0.5,useElementsOnFace=False)
# Line 149  class Test_Generators(unittest.TestCase) Line 143  class Test_Generators(unittest.TestCase)
143        self.checker(my_dom,file)        self.checker(my_dom,file)
144    
145     def test_hex_contact_3D_order1_onFace(self):     def test_hex_contact_3D_order1_onFace(self):
       if getMPISizeWorld() != 1: return  
146        file="hex_contact_3D_order1_onFace.msh"        file="hex_contact_3D_order1_onFace.msh"
147        ms1=Brick(1,1,1,1,l2=0.5,useElementsOnFace=True)        ms1=Brick(1,1,1,1,l2=0.5,useElementsOnFace=True)
148        ms2=Brick(1,1,1,1,l2=0.5,useElementsOnFace=True)        ms2=Brick(1,1,1,1,l2=0.5,useElementsOnFace=True)
# Line 158  class Test_Generators(unittest.TestCase) Line 151  class Test_Generators(unittest.TestCase)
151        self.checker(my_dom,file)        self.checker(my_dom,file)
152    
153     def test_hex_contact_3D_order2(self):     def test_hex_contact_3D_order2(self):
       if getMPISizeWorld() != 1: return  
154        file="hex_contact_3D_order2.msh"        file="hex_contact_3D_order2.msh"
155        ms1=Brick(1,1,1,2,l2=0.5,useElementsOnFace=False)        ms1=Brick(1,1,1,2,l2=0.5,useElementsOnFace=False)
156        ms2=Brick(1,1,1,2,l2=0.5,useElementsOnFace=False)        ms2=Brick(1,1,1,2,l2=0.5,useElementsOnFace=False)
# Line 167  class Test_Generators(unittest.TestCase) Line 159  class Test_Generators(unittest.TestCase)
159        self.checker(my_dom,file)        self.checker(my_dom,file)
160    
161     def test_hex_contact_3D_order2_onFace(self):     def test_hex_contact_3D_order2_onFace(self):
       if getMPISizeWorld() != 1: return  
162        file="hex_contact_3D_order2_onFace.msh"        file="hex_contact_3D_order2_onFace.msh"
163        ms1=Brick(1,1,1,2,l2=0.5,useElementsOnFace=True)        ms1=Brick(1,1,1,2,l2=0.5,useElementsOnFace=True)
164        ms2=Brick(1,1,1,2,l2=0.5,useElementsOnFace=True)        ms2=Brick(1,1,1,2,l2=0.5,useElementsOnFace=True)
# Line 187  class Test_GMSHReader(unittest.TestCase) Line 178  class Test_GMSHReader(unittest.TestCase)
178           self.failUnlessEqual(line,ref_string[l].strip(),"line %d (%s) in mesh files does not match reference (%s)"%(l,ref_string[l].strip(),line))           self.failUnlessEqual(line,ref_string[l].strip(),"line %d (%s) in mesh files does not match reference (%s)"%(l,ref_string[l].strip(),line))
179    
180     def test_Tri3(self):     def test_Tri3(self):
        # ReadGmsh is not MPI parallel  
        if getMPISizeWorld() == 1:  
181           file="tri3_gmsh.msh"           file="tri3_gmsh.msh"
182           ref ="tri3.fly"           ref ="tri3.fly"
183           test = FINLEY_WORKDIR+os.sep+"tri3_test.fly"           test = FINLEY_WORKDIR+os.sep+"tri3_test.fly"
# Line 197  class Test_GMSHReader(unittest.TestCase) Line 186  class Test_GMSHReader(unittest.TestCase)
186           self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)           self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)
187    
188     def test_Tri6(self):     def test_Tri6(self):
        # ReadGmsh is not MPI parallel  
        if getMPISizeWorld() == 1:  
189           file="tri6_gmsh.msh"           file="tri6_gmsh.msh"
190           ref="tri6.fly"           ref="tri6.fly"
191           test = FINLEY_WORKDIR+os.sep+"tri8_test.fly"           test = FINLEY_WORKDIR+os.sep+"tri8_test.fly"
# Line 207  class Test_GMSHReader(unittest.TestCase) Line 194  class Test_GMSHReader(unittest.TestCase)
194           self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)           self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)
195    
196     def test_Tet4(self):     def test_Tet4(self):
        # ReadGmsh is not MPI parallel  
        if getMPISizeWorld() == 1:  
197           file="tet4_gmsh.msh"           file="tet4_gmsh.msh"
198           ref="tet4.fly"           ref="tet4.fly"
199           test = FINLEY_WORKDIR+os.sep+"tet4_test.fly"           test = FINLEY_WORKDIR+os.sep+"tet4_test.fly"
# Line 217  class Test_GMSHReader(unittest.TestCase) Line 202  class Test_GMSHReader(unittest.TestCase)
202           self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)           self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)
203    
204     def test_Tet10(self):     def test_Tet10(self):
        # ReadGmsh is not MPI parallel  
        if getMPISizeWorld() == 1:  
205           file="tet10_gmsh.msh"           file="tet10_gmsh.msh"
206           ref="tet10.fly"           ref="tet10.fly"
207           test = FINLEY_WORKDIR+os.sep+"tet10_test.fly"           test = FINLEY_WORKDIR+os.sep+"tet10_test.fly"
# Line 228  class Test_GMSHReader(unittest.TestCase) Line 211  class Test_GMSHReader(unittest.TestCase)
211    
212  class Test_Reader(unittest.TestCase):  class Test_Reader(unittest.TestCase):
213     def test_ReadWriteTagNames(self):     def test_ReadWriteTagNames(self):
        if getMPISizeWorld() != 1: return  
214         file="hex_2D_order2.msh"         file="hex_2D_order2.msh"
215         test = FINLEY_WORKDIR+os.sep+"test.fly"         test = FINLEY_WORKDIR+os.sep+"test.fly"
216         dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+file,3,optimize=False)         dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+file,3,optimize=False)
# Line 353  class Test_Integration(unittest.TestCase Line 335  class Test_Integration(unittest.TestCase
335                  self.failUnless(error<=self.TOL*raise_tol,"surface integration for order (%s,%s,%s) failed. True value = %s, calculated = %s"%(i,j,k,ref,res))                  self.failUnless(error<=self.TOL*raise_tol,"surface integration for order (%s,%s,%s) failed. True value = %s, calculated = %s"%(i,j,k,ref,res))
336    
337     def test_hex2D_order1(self):     def test_hex2D_order1(self):
338        my_dom=Rectangle(1,1,integrationOrder=1)        NE=getMPIRankWorld()
339          my_dom=Rectangle(NE,NE,integrationOrder=1)
340        self.__test_2DQ(my_dom,1)        self.__test_2DQ(my_dom,1)
341     def test_hex2D_order2(self):     def test_hex2D_order2(self):
342        my_dom=Rectangle(1,1,integrationOrder=2)        NE=getMPIRankWorld()
343          my_dom=Rectangle(NE,NE,integrationOrder=2)
344        self.__test_2DQ(my_dom,2)        self.__test_2DQ(my_dom,2)
345     def test_hex2D_order3(self):     def test_hex2D_order3(self):
346        my_dom=Rectangle(1,1,integrationOrder=3)        NE=getMPIRankWorld()
347          my_dom=Rectangle(NE,NE,integrationOrder=3)
348        self.__test_2DQ(my_dom,3)        self.__test_2DQ(my_dom,3)
349     def test_hex2D_order4(self):     def test_hex2D_order4(self):
350        my_dom=Rectangle(1,1,integrationOrder=4)        NE=getMPIRankWorld()
351          my_dom=Rectangle(NE,NE,integrationOrder=4)
352        self.__test_2DQ(my_dom,4)        self.__test_2DQ(my_dom,4)
353     def test_hex2D_order5(self):     def test_hex2D_order5(self):
354        my_dom=Rectangle(1,1,integrationOrder=5)        NE=getMPIRankWorld()
355          my_dom=Rectangle(NE,NE,integrationOrder=5)
356        self.__test_2DQ(my_dom,5)        self.__test_2DQ(my_dom,5)
357     def test_hex2D_order6(self):     def test_hex2D_order6(self):
358        my_dom=Rectangle(1,1,integrationOrder=6)        NE=getMPIRankWorld()
359          my_dom=Rectangle(NE,NE,integrationOrder=6)
360        self.__test_2DQ(my_dom,6)        self.__test_2DQ(my_dom,6)
361     def test_hex2D_order7(self):     def test_hex2D_order7(self):
362        my_dom=Rectangle(1,1,integrationOrder=7)        NE=getMPIRankWorld()
363          my_dom=Rectangle(NE,NE,integrationOrder=7)
364        self.__test_2DQ(my_dom,7)        self.__test_2DQ(my_dom,7)
365     def test_hex2D_order8(self):     def test_hex2D_order8(self):
366        my_dom=Rectangle(1,1,integrationOrder=8)        NE=getMPIRankWorld()
367          my_dom=Rectangle(NE,NE,integrationOrder=8)
368        self.__test_2DQ(my_dom,8)        self.__test_2DQ(my_dom,8)
369     def test_hex2D_order9(self):     def test_hex2D_order9(self):
370        my_dom=Rectangle(1,1,integrationOrder=9)        NE=getMPIRankWorld()
371          my_dom=Rectangle(NE,NE,integrationOrder=9)
372        self.__test_2DQ(my_dom,9)        self.__test_2DQ(my_dom,9)
373     def test_hex2D_order10(self):     def test_hex2D_order10(self):
374        my_dom=Rectangle(1,1,integrationOrder=10)        NE=getMPIRankWorld()
375          my_dom=Rectangle(NE,NE,integrationOrder=10)
376        self.__test_2DQ(my_dom,10)        self.__test_2DQ(my_dom,10)
377    
378     def test_Tet2D_order1(self):     def test_Tet2D_order1(self):
# Line 415  class Test_Integration(unittest.TestCase Line 407  class Test_Integration(unittest.TestCase
407        self.__test_2DT(my_dom,10)        self.__test_2DT(my_dom,10)
408    
409     def test_hex3D_order1(self):     def test_hex3D_order1(self):
410        my_dom=Brick(1,1,1,integrationOrder=1)        NE=getMPIRankWorld()
411          my_dom=Brick(NE,NE,NE,integrationOrder=1)
412        self.__test_3DQ(my_dom,1)        self.__test_3DQ(my_dom,1)
413     def test_hex3D_order2(self):     def test_hex3D_order2(self):
414        my_dom=Brick(1,1,1,integrationOrder=2)        NE=getMPIRankWorld()
415          my_dom=Brick(NE,NE,NE,integrationOrder=2)
416        self.__test_3DQ(my_dom,2)        self.__test_3DQ(my_dom,2)
417     def test_hex3D_order3(self):     def test_hex3D_order3(self):
418        my_dom=Brick(1,1,1,integrationOrder=3)        NE=getMPIRankWorld()
419          my_dom=Brick(NE,NE,NE,integrationOrder=3)
420        self.__test_3DQ(my_dom,3)        self.__test_3DQ(my_dom,3)
421     def test_hex3D_order4(self):     def test_hex3D_order4(self):
422        my_dom=Brick(1,1,1,integrationOrder=4)        NE=getMPIRankWorld()
423          my_dom=Brick(NE,NE,NE,integrationOrder=4)
424        self.__test_3DQ(my_dom,4)        self.__test_3DQ(my_dom,4)
425     def test_hex3D_order5(self):     def test_hex3D_order5(self):
426        my_dom=Brick(1,1,1,integrationOrder=5)        NE=getMPIRankWorld()
427          my_dom=Brick(NE,NE,NE,integrationOrder=5)
428        self.__test_3DQ(my_dom,5)        self.__test_3DQ(my_dom,5)
429     def test_hex3D_order6(self):     def test_hex3D_order6(self):
430        my_dom=Brick(1,1,1,integrationOrder=6)        NE=getMPIRankWorld()
431          my_dom=Brick(NE,NE,NE,integrationOrder=6)
432        self.__test_3DQ(my_dom,6)        self.__test_3DQ(my_dom,6)
433     def test_hex3D_order7(self):     def test_hex3D_order7(self):
434        my_dom=Brick(1,1,1,integrationOrder=7)        NE=getMPIRankWorld()
435          my_dom=Brick(NE,NE,NE,integrationOrder=7)
436        self.__test_3DQ(my_dom,7)        self.__test_3DQ(my_dom,7)
437     def test_hex3D_order8(self):     def test_hex3D_order8(self):
438        my_dom=Brick(1,1,1,integrationOrder=8)        NE=getMPIRankWorld()
439          my_dom=Brick(NE,NE,NE,integrationOrder=8)
440        self.__test_3DQ(my_dom,8)        self.__test_3DQ(my_dom,8)
441     def test_hex3D_order9(self):     def test_hex3D_order9(self):
442        my_dom=Brick(1,1,1,integrationOrder=9)        NE=getMPIRankWorld()
443          my_dom=Brick(NE,NE,NE,integrationOrder=9)
444        self.__test_3DQ(my_dom,9)        self.__test_3DQ(my_dom,9)
445     def test_hex3D_order10(self):     def test_hex3D_order10(self):
446        my_dom=Brick(1,1,1,integrationOrder=10)        NE=getMPIRankWorld()
447          my_dom=Brick(NE,NE,NE,integrationOrder=10)
448        self.__test_3DQ(my_dom,10)        self.__test_3DQ(my_dom,10)
449    
450     def test_Tet3D_order1(self):     def test_Tet3D_order1(self):
# Line 478  class Test_Integration(unittest.TestCase Line 480  class Test_Integration(unittest.TestCase
480    
481  if __name__ == '__main__':  if __name__ == '__main__':
482     suite = unittest.TestSuite()     suite = unittest.TestSuite()
483     suite.addTest(unittest.makeSuite(Test_Generators))  
484     suite.addTest(unittest.makeSuite(Test_GMSHReader))     if getMPISizeWorld() == 1:
485     suite.addTest(unittest.makeSuite(Test_Reader))          suite.addTest(unittest.makeSuite(Test_Generators))
486       else:
487            print "Test_Generators is dropped as number of processors >1"
488    
489       if getMPISizeWorld() == 1:
490            suite.addTest(unittest.makeSuite(Test_GMSHReader))
491       else:
492            print "Test_GMSHReader is dropped as number of processors >1"
493    
494       if getMPISizeWorld() == 1:
495            suite.addTest(unittest.makeSuite(Test_Reader))
496       else:
497            print "Test_Reader is dropped as number of processors >1"
498    
499     suite.addTest(unittest.makeSuite(Test_Integration))     suite.addTest(unittest.makeSuite(Test_Integration))
500     s=unittest.TextTestRunner(verbosity=2).run(suite)     s=unittest.TextTestRunner(verbosity=2).run(suite)
501     if not s.wasSuccessful(): sys.exit(1)     if not s.wasSuccessful(): sys.exit(1)
   

Legend:
Removed from v.2318  
changed lines
  Added in v.2319

  ViewVC Help
Powered by ViewVC 1.1.26