/[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 1830 by ksteube, Thu Oct 2 06:51:48 2008 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
7  #  #
8  #           Copyright 2003-2007 by ACceSS MNRF  # Primary Business: Queensland, Australia
9  #       Copyright 2007 by University of Queensland  # Licensed under the Open Software License version 3.0
10  #  # http://www.opensource.org/licenses/osl-3.0.php
11  #                http://esscc.uq.edu.au  #
12  #        Primary Business: Queensland, Australia  ########################################################
13  #  Licensed under the Open Software License version 3.0  
14  #     http://www.opensource.org/licenses/osl-3.0.php  __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__="http://www.uq.edu.au/esscc/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"
48  class Test_Generators(unittest.TestCase):  class Test_Generators(unittest.TestCase):
49    
50     def checker(self,dom,reference):     def checker(self,dom,reference):
51          if getMPISizeWorld() > 1: return
52        dom_file=FINLEY_WORKDIR_PATH+TEST_FILE_EXT        dom_file=FINLEY_WORKDIR_PATH+TEST_FILE_EXT
53        dom.write(dom_file)        dom.write(dom_file)
54  # Uncomment this section to dump the files for regression testing  # Uncomment this section to dump the files for regression testing
# Line 58  class Test_Generators(unittest.TestCase) Line 58  class Test_Generators(unittest.TestCase)
58        ref_string=open(FINLEY_TEST_MESH_PATH+reference).read().splitlines()        ref_string=open(FINLEY_TEST_MESH_PATH+reference).read().splitlines()
59        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")
60        for l in range(1,len(ref_string)):        for l in range(1,len(ref_string)):
61           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()
62         if os.name == "nt":
63               line=line.replace("e+00","e+0").replace("e-00","e-0")
64             self.failUnlessEqual(line,ref_string[l].strip(),"line %d (%s) in mesh files does not match reference (%s)"%(l,ref_string[l].strip(),line))
65    
66     def test_hex_2D_order1(self):     def test_hex_2D_order1(self):
67        file="hex_2D_order1.msh"        file="hex_2D_order1.msh"
# Line 101  class Test_Generators(unittest.TestCase) Line 104  class Test_Generators(unittest.TestCase)
104        self.checker(my_dom,file)        self.checker(my_dom,file)
105    
106     def test_hex_contact_2D_order1(self):     def test_hex_contact_2D_order1(self):
107          if getMPISizeWorld() != 1: return
108        file="hex_contact_2D_order1.msh"        file="hex_contact_2D_order1.msh"
109        ms1=Rectangle(1,1,1,l1=0.5,useElementsOnFace=False)        ms1=Rectangle(1,1,1,l1=0.5,useElementsOnFace=False)
110        ms2=Rectangle(1,1,1,l1=0.5,useElementsOnFace=False)        ms2=Rectangle(1,1,1,l1=0.5,useElementsOnFace=False)
# Line 109  class Test_Generators(unittest.TestCase) Line 113  class Test_Generators(unittest.TestCase)
113        self.checker(my_dom,file)        self.checker(my_dom,file)
114    
115     def test_hex_contact_2D_order1_onFace(self):     def test_hex_contact_2D_order1_onFace(self):
116          if getMPISizeWorld() != 1: return
117        file="hex_contact_2D_order1_onFace.msh"        file="hex_contact_2D_order1_onFace.msh"
118        ms1=Rectangle(1,1,1,l1=0.5,useElementsOnFace=True)        ms1=Rectangle(1,1,1,l1=0.5,useElementsOnFace=True)
119        ms2=Rectangle(1,1,1,l1=0.5,useElementsOnFace=True)        ms2=Rectangle(1,1,1,l1=0.5,useElementsOnFace=True)
# Line 117  class Test_Generators(unittest.TestCase) Line 122  class Test_Generators(unittest.TestCase)
122        self.checker(my_dom,file)        self.checker(my_dom,file)
123    
124     def test_hex_contact_2D_order2(self):     def test_hex_contact_2D_order2(self):
125          if getMPISizeWorld() != 1: return
126        file="hex_contact_2D_order2.msh"        file="hex_contact_2D_order2.msh"
127        ms1=Rectangle(1,1,2,l1=0.5,useElementsOnFace=False)        ms1=Rectangle(1,1,2,l1=0.5,useElementsOnFace=False)
128        ms2=Rectangle(1,1,2,l1=0.5,useElementsOnFace=False)        ms2=Rectangle(1,1,2,l1=0.5,useElementsOnFace=False)
# Line 125  class Test_Generators(unittest.TestCase) Line 131  class Test_Generators(unittest.TestCase)
131        self.checker(my_dom,file)        self.checker(my_dom,file)
132    
133     def test_hex_contact_2D_order2_onFace(self):     def test_hex_contact_2D_order2_onFace(self):
134          if getMPISizeWorld() != 1: return
135        file="hex_contact_2D_order2_onFace.msh"        file="hex_contact_2D_order2_onFace.msh"
136        ms1=Rectangle(1,1,2,l1=0.5,useElementsOnFace=True)        ms1=Rectangle(1,1,2,l1=0.5,useElementsOnFace=True)
137        ms2=Rectangle(1,1,2,l1=0.5,useElementsOnFace=True)        ms2=Rectangle(1,1,2,l1=0.5,useElementsOnFace=True)
# Line 133  class Test_Generators(unittest.TestCase) Line 140  class Test_Generators(unittest.TestCase)
140        self.checker(my_dom,file)        self.checker(my_dom,file)
141    
142     def test_hex_contact_3D_order1(self):     def test_hex_contact_3D_order1(self):
143          if getMPISizeWorld() != 1: return
144        file="hex_contact_3D_order1.msh"        file="hex_contact_3D_order1.msh"
145        ms1=Brick(1,1,1,1,l2=0.5,useElementsOnFace=False)        ms1=Brick(1,1,1,1,l2=0.5,useElementsOnFace=False)
146        ms2=Brick(1,1,1,1,l2=0.5,useElementsOnFace=False)        ms2=Brick(1,1,1,1,l2=0.5,useElementsOnFace=False)
# Line 141  class Test_Generators(unittest.TestCase) Line 149  class Test_Generators(unittest.TestCase)
149        self.checker(my_dom,file)        self.checker(my_dom,file)
150    
151     def test_hex_contact_3D_order1_onFace(self):     def test_hex_contact_3D_order1_onFace(self):
152          if getMPISizeWorld() != 1: return
153        file="hex_contact_3D_order1_onFace.msh"        file="hex_contact_3D_order1_onFace.msh"
154        ms1=Brick(1,1,1,1,l2=0.5,useElementsOnFace=True)        ms1=Brick(1,1,1,1,l2=0.5,useElementsOnFace=True)
155        ms2=Brick(1,1,1,1,l2=0.5,useElementsOnFace=True)        ms2=Brick(1,1,1,1,l2=0.5,useElementsOnFace=True)
# Line 149  class Test_Generators(unittest.TestCase) Line 158  class Test_Generators(unittest.TestCase)
158        self.checker(my_dom,file)        self.checker(my_dom,file)
159    
160     def test_hex_contact_3D_order2(self):     def test_hex_contact_3D_order2(self):
161          if getMPISizeWorld() != 1: return
162        file="hex_contact_3D_order2.msh"        file="hex_contact_3D_order2.msh"
163        ms1=Brick(1,1,1,2,l2=0.5,useElementsOnFace=False)        ms1=Brick(1,1,1,2,l2=0.5,useElementsOnFace=False)
164        ms2=Brick(1,1,1,2,l2=0.5,useElementsOnFace=False)        ms2=Brick(1,1,1,2,l2=0.5,useElementsOnFace=False)
# Line 157  class Test_Generators(unittest.TestCase) Line 167  class Test_Generators(unittest.TestCase)
167        self.checker(my_dom,file)        self.checker(my_dom,file)
168    
169     def test_hex_contact_3D_order2_onFace(self):     def test_hex_contact_3D_order2_onFace(self):
170          if getMPISizeWorld() != 1: return
171        file="hex_contact_3D_order2_onFace.msh"        file="hex_contact_3D_order2_onFace.msh"
172        ms1=Brick(1,1,1,2,l2=0.5,useElementsOnFace=True)        ms1=Brick(1,1,1,2,l2=0.5,useElementsOnFace=True)
173        ms2=Brick(1,1,1,2,l2=0.5,useElementsOnFace=True)        ms2=Brick(1,1,1,2,l2=0.5,useElementsOnFace=True)
# Line 170  class Test_GMSHReader(unittest.TestCase) Line 181  class Test_GMSHReader(unittest.TestCase)
181        ref_string=open(reference_file).read().splitlines()        ref_string=open(reference_file).read().splitlines()
182        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")
183        for l in range(1,len(ref_string)):        for l in range(1,len(ref_string)):
184           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()
185         if os.name == "nt":
186               line=line.replace("e+00","e+0").replace("e-00","e-0")
187             self.failUnlessEqual(line,ref_string[l].strip(),"line %d (%s) in mesh files does not match reference (%s)"%(l,ref_string[l].strip(),line))
188    
189     def test_Tri3(self):     def test_Tri3(self):
190         file="tri3_gmsh.msh"         # ReadGmsh is not MPI parallel
191         ref ="tri3.fly"         if getMPISizeWorld() == 1:
192         test = FINLEY_WORKDIR+os.sep+"tri3_test.fly"           file="tri3_gmsh.msh"
193         dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,2,optimize=False)           ref ="tri3.fly"
194         dom.write(test)           test = FINLEY_WORKDIR+os.sep+"tri3_test.fly"
195         self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)           dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,2,optimize=False)
196             dom.write(test)
197             self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)
198    
199     def test_Tri6(self):     def test_Tri6(self):
200         file="tri6_gmsh.msh"         # ReadGmsh is not MPI parallel
201         ref="tri6.fly"         if getMPISizeWorld() == 1:
202         test = FINLEY_WORKDIR+os.sep+"tri8_test.fly"           file="tri6_gmsh.msh"
203         dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,2,optimize=False)           ref="tri6.fly"
204         dom.write(test)           test = FINLEY_WORKDIR+os.sep+"tri8_test.fly"
205         self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)           dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,2,optimize=False)
206             dom.write(test)
207             self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)
208    
209     def test_Tet4(self):     def test_Tet4(self):
210         file="tet4_gmsh.msh"         # ReadGmsh is not MPI parallel
211         ref="tet4.fly"         if getMPISizeWorld() == 1:
212         test = FINLEY_WORKDIR+os.sep+"tet4_test.fly"           file="tet4_gmsh.msh"
213         dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,3,optimize=False)           ref="tet4.fly"
214         dom.write(test)           test = FINLEY_WORKDIR+os.sep+"tet4_test.fly"
215         self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)           dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,3,optimize=False)
216             dom.write(test)
217             self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)
218    
219     def test_Tet10(self):     def test_Tet10(self):
220         file="tet10_gmsh.msh"         # ReadGmsh is not MPI parallel
221         ref="tet10.fly"         if getMPISizeWorld() == 1:
222         test = FINLEY_WORKDIR+os.sep+"tet10_test.fly"           file="tet10_gmsh.msh"
223         dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,3,optimize=False)           ref="tet10.fly"
224         dom.write(test)           test = FINLEY_WORKDIR+os.sep+"tet10_test.fly"
225         self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)           dom = ReadGmsh(FINLEY_TEST_MESH_PATH+os.sep+file,3,optimize=False)
226             dom.write(test)
227             self.compare(test, FINLEY_TEST_MESH_PATH+os.sep+ref)
228    
229  class Test_Reader(unittest.TestCase):  class Test_Reader(unittest.TestCase):
230     def test_ReadWriteTagNames(self):     def test_ReadWriteTagNames(self):
231           if getMPISizeWorld() != 1: return
232         file="hex_2D_order2.msh"         file="hex_2D_order2.msh"
233         test = FINLEY_WORKDIR+os.sep+"test.fly"         test = FINLEY_WORKDIR+os.sep+"test.fly"
234         dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+file,3,optimize=False)         dom = ReadMesh(FINLEY_TEST_MESH_PATH+os.sep+file,3,optimize=False)

Legend:
Removed from v.1388  
changed lines
  Added in v.1830

  ViewVC Help
Powered by ViewVC 1.1.26