/[escript]/trunk/dudley/test/python/fixme_run_generators.py
ViewVC logotype

Diff of /trunk/dudley/test/python/fixme_run_generators.py

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

revision 1388 by trankine, Fri Jan 11 07:45:58 2008 UTC revision 2344 by jfenwick, Mon Mar 30 02:13:58 2009 UTC
# Line 1  Line 1 
1    
2    ########################################################
3  #  #
4  # $Id$  # Copyright (c) 2003-2008 by University of Queensland
5  #  # Earth Systems Science Computational Center (ESSCC)
6  #######################################################  # http://www.uq.edu.au/esscc
 #  
 #           Copyright 2003-2007 by ACceSS MNRF  
 #       Copyright 2007 by University of Queensland  
 #  
 #                http://esscc.uq.edu.au  
 #        Primary Business: Queensland, Australia  
 #  Licensed under the Open Software License version 3.0  
 #     http://www.opensource.org/licenses/osl-3.0.php  
7  #  #
8  #######################################################  # Primary Business: Queensland, Australia
9    # Licensed under the Open Software License version 3.0
10    # http://www.opensource.org/licenses/osl-3.0.php
11  #  #
12    ########################################################
13    
14    __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15    Earth Systems Science Computational Center (ESSCC)
16    http://www.uq.edu.au/esscc
17    Primary Business: Queensland, Australia"""
18    __license__="""Licensed under the Open Software License version 3.0
19    http://www.opensource.org/licenses/osl-3.0.php"""
20    __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.
24  """  """
25    
 __copyright__="""  Copyright (c) 2006 by ACcESS MNRF  
                     http://www.access.edu.au  
                 Primary Business: Queensland, Australia"""  
 __license__="""Licensed under the Open Software License version 3.0  
              http://www.opensource.org/licenses/osl-3.0.php"""  
   
26  import sys  import sys
27  import os  import os
28  import unittest  import unittest
# Line 41  except KeyError: Line 40  except KeyError:
40       FINLEY_WORKDIR='.'       FINLEY_WORKDIR='.'
41    
42  FINLEY_TEST_MESH_PATH=FINLEY_TEST_DATA+"/data_meshes/"  FINLEY_TEST_MESH_PATH=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 = 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"
# Line 54  class Test_Generators(unittest.TestCase) Line 53  class Test_Generators(unittest.TestCase)
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)):
60           self.failUnlessEqual(dom_string[l].strip(),ref_string[l].strip(),"line %d (%s) in mesh files does not match reference (%s)"%(l,ref_string[l].strip(),dom_string[l].strip()))       line=dom_string[l].strip()
61         if os.name == "nt":
62               line=line.replace("e+00","e+0").replace("e-00","e-0")
63             self.failUnlessEqual(line,ref_string[l].strip(),"line %d (%s) in mesh files does not match reference (%s)"%(l,ref_string[l].strip(),line))
64    
65     def test_hex_2D_order1(self):     def test_hex_2D_order1(self):
66        file="hex_2D_order1.msh"        file="hex_2D_order1.msh"
# Line 170  class Test_GMSHReader(unittest.TestCase) Line 172  class Test_GMSHReader(unittest.TestCase)
172        ref_string=open(reference_file).read().splitlines()        ref_string=open(reference_file).read().splitlines()
173        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")
174        for l in range(1,len(ref_string)):        for l in range(1,len(ref_string)):
175           self.failUnlessEqual(dom_string[l].strip(),ref_string[l].strip(),"line %d (%s) in mesh files does not match reference (%s)"%(l,ref_string[l].strip(),dom_string[l].strip()))       line=dom_string[l].strip()
176         if os.name == "nt":
177               line=line.replace("e+00","e+0").replace("e-00","e-0")
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))
179    
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 = FINLEY_WORKDIR+os.sep+"tri3_test.fly"
184         dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,2,optimize=False)           dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+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, FINLEY_TEST_MESH_PATH+os.sep+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 = FINLEY_WORKDIR+os.sep+"tri8_test.fly"
192         dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,2,optimize=False)           dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+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, FINLEY_TEST_MESH_PATH+os.sep+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 = FINLEY_WORKDIR+os.sep+"tet4_test.fly"
200         dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,3,optimize=False)           dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+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, FINLEY_TEST_MESH_PATH+os.sep+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 = FINLEY_WORKDIR+os.sep+"tet10_test.fly"
208         dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,3,optimize=False)           dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+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, FINLEY_TEST_MESH_PATH+os.sep+ref)
211    
212  class Test_Reader(unittest.TestCase):  class Test_Reader(unittest.TestCase):
213     def test_ReadWriteTagNames(self):     def test_ReadWriteTagNames(self):
# Line 330  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 392  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 455  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.1388  
changed lines
  Added in v.2344

  ViewVC Help
Powered by ViewVC 1.1.26