/[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 3259 by jfenwick, Mon Oct 11 01:48:14 2010 UTC revision 3551 by jfenwick, Fri Aug 19 03:53:41 2011 UTC
# Line 55  class Test_Generators(unittest.TestCase) Line 55  class Test_Generators(unittest.TestCase)
55  #         dom.write(os.path.join(DUDLEY_TEST_MESH_PATH,reference))  #         dom.write(os.path.join(DUDLEY_TEST_MESH_PATH,reference))
56        dom_string=open(dom_file).read().splitlines()        dom_string=open(dom_file).read().splitlines()
57        ref_string=open(os.path.join(DUDLEY_TEST_MESH_PATH,reference)).read().splitlines()        ref_string=open(os.path.join(DUDLEY_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.assertEqual(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()
61       if os.name == "nt":       if os.name == "nt":
62             line=line.replace("e+00","e+0").replace("e-00","e-0")             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))           self.assertEqual(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 180  class Test_GMSHReader(unittest.TestCase) Line 180  class Test_GMSHReader(unittest.TestCase)
180     def compare(self, test_file, reference_file):     def compare(self, test_file, reference_file):
181        dom_string=open(test_file).read().splitlines()        dom_string=open(test_file).read().splitlines()
182        ref_string=open(reference_file).read().splitlines()        ref_string=open(reference_file).read().splitlines()
183        self.failUnlessEqual(len(dom_string),len(ref_string),"number of lines in mesh files does not match reference")        self.assertEqual(len(dom_string),len(ref_string),"number of lines in mesh files does not match reference")
184        for l in range(1,len(ref_string)):        for l in range(1,len(ref_string)):
185       line=dom_string[l].strip()       line=dom_string[l].strip()
186       if os.name == "nt":       if os.name == "nt":
187             line=line.replace("e+00","e+0").replace("e-00","e-0")             line=line.replace("e+00","e+0").replace("e-00","e-0")
188           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.assertEqual(line,ref_string[l].strip(),"line %d (%s) in mesh files does not match reference (%s)"%(l,ref_string[l].strip(),line))
189    
190     def test_Tri3(self):     def test_Tri3(self):
191           file="tri3_gmsh.msh"           file="tri3_gmsh.msh"
# Line 244  class Test_Reader(unittest.TestCase): Line 244  class Test_Reader(unittest.TestCase):
244         dom.write(test)         dom.write(test)
245         dom2 = ReadMesh(test,3,optimize=False)         dom2 = ReadMesh(test,3,optimize=False)
246         t=getTagNames(dom)         t=getTagNames(dom)
247         self.failUnless(len(t)==6)         self.assertTrue(len(t)==6)
248         self.failUnless("A" in t)         self.assertTrue("A" in t)
249         self.failUnless("B" in t)         self.assertTrue("B" in t)
250         self.failUnless(dom2.getTag("A") == 1)         self.assertTrue(dom2.getTag("A") == 1)
251         self.failUnless(dom2.getTag("B") == 2)         self.assertTrue(dom2.getTag("B") == 2)
252         self.failUnless(dom2.isValidTagName("A"))         self.assertTrue(dom2.isValidTagName("A"))
253         self.failUnless(dom2.isValidTagName("B"))         self.assertTrue(dom2.isValidTagName("B"))
254    
255  class Test_Integration(unittest.TestCase):  class Test_Integration(unittest.TestCase):
256     TOL=EPSILON*500.     TOL=EPSILON*500.
# Line 262  class Test_Integration(unittest.TestCase Line 262  class Test_Integration(unittest.TestCase
262               res=integrate(x[0]**i*x[1]**j)               res=integrate(x[0]**i*x[1]**j)
263               ref=1./((i+1)*(j+1))               ref=1./((i+1)*(j+1))
264               error=abs(res-ref)/abs(ref)               error=abs(res-ref)/abs(ref)
265               self.failUnless(error<=self.TOL,"integration for order (%s,%s) failed. True value = %s, calculated = %s"%(i,j,ref,res))               self.assertTrue(error<=self.TOL,"integration for order (%s,%s) failed. True value = %s, calculated = %s"%(i,j,ref,res))
266    
267               res=integrate(x_bound[0]**i*x_bound[1]**j)               res=integrate(x_bound[0]**i*x_bound[1]**j)
268               ref=0               ref=0
# Line 275  class Test_Integration(unittest.TestCase Line 275  class Test_Integration(unittest.TestCase
275               else:               else:
276                  ref += 1./(i+1)                  ref += 1./(i+1)
277               error=abs(res-ref)/abs(ref)               error=abs(res-ref)/abs(ref)
278               self.failUnless(error<=self.TOL,"surface integration for order (%s,%s) failed. True value = %s, calculated = %s"%(i,j,ref,res))               self.assertTrue(error<=self.TOL,"surface integration for order (%s,%s) failed. True value = %s, calculated = %s"%(i,j,ref,res))
279                            
280     def __test_2DT(self,dom,order,raise_tol=1.):     def __test_2DT(self,dom,order,raise_tol=1.):
281         x=Function(dom).getX()         x=Function(dom).getX()
# Line 287  class Test_Integration(unittest.TestCase Line 287  class Test_Integration(unittest.TestCase
287               ref=1./((i+1)*(j+1))               ref=1./((i+1)*(j+1))
288               error=abs(res-ref)/abs(ref)               error=abs(res-ref)/abs(ref)
289               # print order,error               # print order,error
290               self.failUnless(error<=self.TOL*raise_tol,"integration for order (%s,%s) failed. True value = %s, calculated = %s"%(i,j,ref,res))               self.assertTrue(error<=self.TOL*raise_tol,"integration for order (%s,%s) failed. True value = %s, calculated = %s"%(i,j,ref,res))
291    
292               res=integrate(x_bound[0]**i*x_bound[1]**j)               res=integrate(x_bound[0]**i*x_bound[1]**j)
293               ref=0               ref=0
# Line 300  class Test_Integration(unittest.TestCase Line 300  class Test_Integration(unittest.TestCase
300               else:               else:
301                  ref += 1./(i+1)                  ref += 1./(i+1)
302               error=abs(res-ref)/abs(ref)               error=abs(res-ref)/abs(ref)
303               self.failUnless(error<=self.TOL*raise_tol,"surface integration for order (%s,%s) failed. True value = %s, calculated = %s"%(i,j,ref,res))               self.assertTrue(error<=self.TOL*raise_tol,"surface integration for order (%s,%s) failed. True value = %s, calculated = %s"%(i,j,ref,res))
304    
305    
306     def __test_3DQ(self,dom,order):     def __test_3DQ(self,dom,order):
# Line 312  class Test_Integration(unittest.TestCase Line 312  class Test_Integration(unittest.TestCase
312               res=integrate(x[0]**i*x[1]**j*x[2]**k)               res=integrate(x[0]**i*x[1]**j*x[2]**k)
313               ref=1./((i+1)*(j+1)*(k+1))               ref=1./((i+1)*(j+1)*(k+1))
314               error=abs(res-ref)/abs(ref)               error=abs(res-ref)/abs(ref)
315               self.failUnless(error<=self.TOL,"integration for order (%s,%s,%s) failed. True value = %s, calculated = %s (error=%e)"%(i,j,k,ref,res, error))               self.assertTrue(error<=self.TOL,"integration for order (%s,%s,%s) failed. True value = %s, calculated = %s (error=%e)"%(i,j,k,ref,res, error))
316    
317               res=integrate(x_bound[0]**i*x_bound[1]**j*x_bound[2]**k)               res=integrate(x_bound[0]**i*x_bound[1]**j*x_bound[2]**k)
318               ref=0               ref=0
# Line 329  class Test_Integration(unittest.TestCase Line 329  class Test_Integration(unittest.TestCase
329               else:               else:
330                  ref += 1./((i+1)*(j+1))                  ref += 1./((i+1)*(j+1))
331               error=abs(res-ref)/abs(ref)               error=abs(res-ref)/abs(ref)
332               self.failUnless(error<=self.TOL,"surface integration for order (%s,%s,%s) failed. True value = %s, calculated = %s (error=%e)"%(i,j,k,ref,res, error))               self.assertTrue(error<=self.TOL,"surface integration for order (%s,%s,%s) failed. True value = %s, calculated = %s (error=%e)"%(i,j,k,ref,res, error))
333    
334     def __test_3DT(self,dom,order,raise_tol=1.):     def __test_3DT(self,dom,order,raise_tol=1.):
335         x=Function(dom).getX()         x=Function(dom).getX()
# Line 341  class Test_Integration(unittest.TestCase Line 341  class Test_Integration(unittest.TestCase
341                  res=integrate(x[0]**i*x[1]**j*x[2]**k)                  res=integrate(x[0]**i*x[1]**j*x[2]**k)
342                  ref=1./((i+1)*(j+1)*(k+1))                  ref=1./((i+1)*(j+1)*(k+1))
343                  error=abs(res-ref)/abs(ref)                  error=abs(res-ref)/abs(ref)
344                  self.failUnless(error<=self.TOL*raise_tol,"integration for order (%s,%s,%s) failed. True value = %s, calculated = %s (error=%e)"%(i,j,k,ref,res,error))                  self.assertTrue(error<=self.TOL*raise_tol,"integration for order (%s,%s,%s) failed. True value = %s, calculated = %s (error=%e)"%(i,j,k,ref,res,error))
345    
346                  res=integrate(x_bound[0]**i*x_bound[1]**j*x_bound[2]**k)                  res=integrate(x_bound[0]**i*x_bound[1]**j*x_bound[2]**k)
347                  ref=0                  ref=0
# Line 358  class Test_Integration(unittest.TestCase Line 358  class Test_Integration(unittest.TestCase
358                  else:                  else:
359                     ref += 1./((i+1)*(j+1))                     ref += 1./((i+1)*(j+1))
360                  error=abs(res-ref)/abs(ref)                  error=abs(res-ref)/abs(ref)
361                  self.failUnless(error<=self.TOL*raise_tol,"surface integration for order (%s,%s,%s) failed. True value = %s, calculated = %s (error=%e)"%(i,j,k,ref,res,error))                  self.assertTrue(error<=self.TOL*raise_tol,"surface integration for order (%s,%s,%s) failed. True value = %s, calculated = %s (error=%e)"%(i,j,k,ref,res,error))
362    
363     #===================================================================================================     #===================================================================================================
364     def test_hex2D_order1_integorder1(self):     def test_hex2D_order1_integorder1(self):

Legend:
Removed from v.3259  
changed lines
  Added in v.3551

  ViewVC Help
Powered by ViewVC 1.1.26