/[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 2319 by gross, Thu Mar 19 03:19:41 2009 UTC revision 2548 by jfenwick, Mon Jul 20 06:20:06 2009 UTC
# Line 1  Line 1 
1    
2  ########################################################  ########################################################
3  #  #
4  # Copyright (c) 2003-2008 by University of Queensland  # Copyright (c) 2003-2009 by University of Queensland
5  # Earth Systems Science Computational Center (ESSCC)  # Earth Systems Science Computational Center (ESSCC)
6  # http://www.uq.edu.au/esscc  # http://www.uq.edu.au/esscc
7  #  #
# Line 17  http://www.uq.edu.au/esscc Line 17  http://www.uq.edu.au/esscc
17  Primary Business: Queensland, Australia"""  Primary Business: Queensland, Australia"""
18  __license__="""Licensed under the Open Software License version 3.0  __license__="""Licensed under the Open Software License version 3.0
19  http://www.opensource.org/licenses/osl-3.0.php"""  http://www.opensource.org/licenses/osl-3.0.php"""
20  __url__="http://www.uq.edu.au/esscc/escript-finley"  __url__="https://launchpad.net/escript-finley"
21    
22  """  """
23  checks the mesh generators against the reference meshes in test_meshes and test the finley integration schemes.  checks the mesh generators against the reference meshes in test_meshes and test the finley integration schemes.
# Line 39  try: Line 39  try:
39  except KeyError:  except KeyError:
40       FINLEY_WORKDIR='.'       FINLEY_WORKDIR='.'
41    
42  FINLEY_TEST_MESH_PATH=FINLEY_TEST_DATA+"/data_meshes/"  FINLEY_TEST_MESH_PATH=os.path.join(FINLEY_TEST_DATA,"data_meshes")
43  #if os.name == "nt":  #if os.name == "nt":
44  #   FINLEY_TEST_MESH_PATH = FINLEY_TEST_MESH_PATH+"win32/"  #   FINLEY_TEST_MESH_PATH = os.path.join(FINLEY_TEST_MESH_PATH,"win32")
45  FINLEY_WORKDIR_PATH=FINLEY_WORKDIR+"/"  FINLEY_WORKDIR_PATH=FINLEY_WORKDIR
46    
47  TEST_FILE_EXT=".test"  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):
51        dom_file=FINLEY_WORKDIR_PATH+TEST_FILE_EXT        dom_file=os.path.join(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(os.path.join(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(os.path.join(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)):
60       line=dom_string[l].strip()       line=dom_string[l].strip()
# Line 180  class Test_GMSHReader(unittest.TestCase) Line 180  class Test_GMSHReader(unittest.TestCase)
180     def test_Tri3(self):     def test_Tri3(self):
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 = os.path.join(FINLEY_WORKDIR,"tri3_test.fly")
184           dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,2,optimize=False)           dom = ReadGmsh(os.path.join(FINLEY_TEST_MESH_PATH,file),2,optimize=False)
185           dom.write(test)           dom.write(test)
186           self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)           self.compare(test, os.path.join(FINLEY_TEST_MESH_PATH,ref))
187    
188     def test_Tri6(self):     def test_Tri6(self):
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 = os.path.join(FINLEY_WORKDIR,"tri8_test.fly")
192           dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,2,optimize=False)           dom = ReadGmsh(os.path.join(FINLEY_TEST_MESH_PATH,file),2,optimize=False)
193           dom.write(test)           dom.write(test)
194           self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)           self.compare(test, os.path.join(FINLEY_TEST_MESH_PATH,ref))
195    
196     def test_Tet4(self):     def test_Tet4(self):
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 = os.path.join(FINLEY_WORKDIR,"tet4_test.fly")
200           dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,3,optimize=False)           dom = ReadGmsh(os.path.join(FINLEY_TEST_MESH_PATH,file),3,optimize=False)
201           dom.write(test)           dom.write(test)
202           self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)           self.compare(test, os.path.join(FINLEY_TEST_MESH_PATH,ref))
203    
204     def test_Tet10(self):     def test_Tet10(self):
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 = os.path.join(FINLEY_WORKDIR,"tet10_test.fly")
208           dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,3,optimize=False)           dom = ReadGmsh(os.path.join(FINLEY_TEST_MESH_PATH,file),3,optimize=False)
209           dom.write(test)           dom.write(test)
210           self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)           self.compare(test, os.path.join(FINLEY_TEST_MESH_PATH,ref))
211    
212  class Test_Reader(unittest.TestCase):  class Test_Reader(unittest.TestCase):
213     def test_ReadWriteTagNames(self):     def test_ReadWriteTagNames(self):
214         file="hex_2D_order2.msh"         file="hex_2D_order2.msh"
215         test = FINLEY_WORKDIR+os.sep+"test.fly"         test = os.path.join(FINLEY_WORKDIR,"test.fly")
216         dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+file,3,optimize=False)         dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,file),3,optimize=False)
217         insertTagNames(dom,A=1,B=2)         insertTagNames(dom,A=1,B=2)
218         dom.write(test)         dom.write(test)
219         dom2 = ReadMesh(test,3,optimize=False)         dom2 = ReadMesh(test,3,optimize=False)
# Line 376  class Test_Integration(unittest.TestCase Line 376  class Test_Integration(unittest.TestCase
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):
379        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tri3.fly",optimize=False,integrationOrder=1)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tri3.fly"),optimize=False,integrationOrder=1)
380        self.__test_2DT(my_dom,1)        self.__test_2DT(my_dom,1)
381     def test_Tet2D_order2(self):     def test_Tet2D_order2(self):
382        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tri3.fly",optimize=False,integrationOrder=2)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tri3.fly"),optimize=False,integrationOrder=2)
383        self.__test_2DT(my_dom,2)        self.__test_2DT(my_dom,2)
384     def test_Tet2D_order3(self):     def test_Tet2D_order3(self):
385        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tri3.fly",optimize=False,integrationOrder=3)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tri3.fly"),optimize=False,integrationOrder=3)
386        self.__test_2DT(my_dom,3)        self.__test_2DT(my_dom,3)
387     def test_Tet2D_order4(self):     def test_Tet2D_order4(self):
388        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tri3.fly",optimize=False,integrationOrder=4)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tri3.fly"),optimize=False,integrationOrder=4)
389        self.__test_2DT(my_dom,4)        self.__test_2DT(my_dom,4)
390     def test_Tet2D_order5(self):     def test_Tet2D_order5(self):
391        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tri3.fly",optimize=False,integrationOrder=5)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tri3.fly"),optimize=False,integrationOrder=5)
392        self.__test_2DT(my_dom,5)        self.__test_2DT(my_dom,5)
393     def test_Tet2D_order6(self):     def test_Tet2D_order6(self):
394        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tri3.fly",optimize=False,integrationOrder=6)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tri3.fly"),optimize=False,integrationOrder=6)
395        self.__test_2DT(my_dom,6)        self.__test_2DT(my_dom,6)
396     def test_Tet2D_order7(self):     def test_Tet2D_order7(self):
397        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tri3.fly",optimize=False,integrationOrder=7)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tri3.fly"),optimize=False,integrationOrder=7)
398        self.__test_2DT(my_dom,7)        self.__test_2DT(my_dom,7)
399     def test_Tet2D_order8(self):     def test_Tet2D_order8(self):
400        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tri3.fly",optimize=False,integrationOrder=8)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tri3.fly"),optimize=False,integrationOrder=8)
401        self.__test_2DT(my_dom,8,1./sqrt(EPSILON))        self.__test_2DT(my_dom,8,1./sqrt(EPSILON))
402     def test_Tet2D_order9(self):     def test_Tet2D_order9(self):
403        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tri3.fly",optimize=False,integrationOrder=9)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tri3.fly"),optimize=False,integrationOrder=9)
404        self.__test_2DT(my_dom,9,1./sqrt(EPSILON))        self.__test_2DT(my_dom,9,1./sqrt(EPSILON))
405     def test_Tet2D_order10(self):     def test_Tet2D_order10(self):
406        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tri3.fly",optimize=False,integrationOrder=10)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tri3.fly"),optimize=False,integrationOrder=10)
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):
# Line 448  class Test_Integration(unittest.TestCase Line 448  class Test_Integration(unittest.TestCase
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):
451        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tet4.fly",optimize=False,integrationOrder=1)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tet4.fly"),optimize=False,integrationOrder=1)
452        self.__test_3DT(my_dom,1)        self.__test_3DT(my_dom,1)
453     def test_Tet3D_order2(self):     def test_Tet3D_order2(self):
454        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tet4.fly",optimize=False,integrationOrder=2)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tet4.fly"),optimize=False,integrationOrder=2)
455        self.__test_3DT(my_dom,2)        self.__test_3DT(my_dom,2)
456     def test_Tet3D_order3(self):     def test_Tet3D_order3(self):
457        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tet4.fly",optimize=False,integrationOrder=3)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tet4.fly"),optimize=False,integrationOrder=3)
458        self.__test_3DT(my_dom,3)        self.__test_3DT(my_dom,3)
459     def test_Tet3D_order4(self):     def test_Tet3D_order4(self):
460        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tet4.fly",optimize=False,integrationOrder=4)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tet4.fly"),optimize=False,integrationOrder=4)
461        self.__test_3DT(my_dom,4)        self.__test_3DT(my_dom,4)
462     def test_Tet3D_order5(self):     def test_Tet3D_order5(self):
463        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tet4.fly",optimize=False,integrationOrder=5)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tet4.fly"),optimize=False,integrationOrder=5)
464        self.__test_3DT(my_dom,5)        self.__test_3DT(my_dom,5)
465     def test_Tet3D_order6(self):     def test_Tet3D_order6(self):
466        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tet4.fly",optimize=False,integrationOrder=6)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tet4.fly"),optimize=False,integrationOrder=6)
467        self.__test_3DT(my_dom,6,1./sqrt(EPSILON))        self.__test_3DT(my_dom,6,1./sqrt(EPSILON))
468     def test_Tet3D_order7(self):     def test_Tet3D_order7(self):
469        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tet4.fly",optimize=False,integrationOrder=7)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tet4.fly"),optimize=False,integrationOrder=7)
470        self.__test_3DT(my_dom,7,1./sqrt(EPSILON))        self.__test_3DT(my_dom,7,1./sqrt(EPSILON))
471     def test_Tet3D_order8(self):     def test_Tet3D_order8(self):
472        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tet4.fly",optimize=False,integrationOrder=8)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tet4.fly"),optimize=False,integrationOrder=8)
473        self.__test_3DT(my_dom,8,1./sqrt(EPSILON))        self.__test_3DT(my_dom,8,1./sqrt(EPSILON))
474     def test_Tet3D_order9(self):     def test_Tet3D_order9(self):
475        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tet4.fly",optimize=False,integrationOrder=9)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tet4.fly"),optimize=False,integrationOrder=9)
476        self.__test_3DT(my_dom,9,1./sqrt(EPSILON))        self.__test_3DT(my_dom,9,1./sqrt(EPSILON))
477     def test_Tet3D_order10(self):     def test_Tet3D_order10(self):
478        my_dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+"tet4.fly",optimize=False,integrationOrder=10)        my_dom = ReadMesh(os.path.join(FINLEY_TEST_MESH_PATH,"tet4.fly"),optimize=False,integrationOrder=10)
479        self.__test_3DT(my_dom,10)        self.__test_3DT(my_dom,10)
480    
481  if __name__ == '__main__':  if __name__ == '__main__':

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

  ViewVC Help
Powered by ViewVC 1.1.26