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

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

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

revision 856 by gross, Fri Sep 22 09:30:06 2006 UTC revision 857 by gross, Tue Sep 26 01:00:45 2006 UTC
# Line 16  import numarray Line 16  import numarray
16  FINLEY_TEST_MESH_PATH="data_meshes/"  FINLEY_TEST_MESH_PATH="data_meshes/"
17    
18  class Test_util2(unittest.TestCase):  class Test_util2(unittest.TestCase):
19     RES_TOL=1.e-2     RES_TOL=1.e-8
   
20     def setUp(self):     def setUp(self):
21          self.order=1          self.order=1
22          self.domain = ReadMesh(FINLEY_TEST_MESH_PATH+"tet_2D_order2.fly")          self.domain = ReadMesh(FINLEY_TEST_MESH_PATH+"tet_3D_order1.fly")
23     def tearDown(self):     def tearDown(self):
24          del self.order          del self.order
25          del self.domain          del self.domain
26     def testProjector_rank0_fast(self):  
27        x=ContinuousFunction(self.domain).getX()     def test_normal_FunctionOnBoundary(self):
28        h=Lsup(self.domain.getSize())       """
29        p=Projector(self.domain,reduce=False,fast=True)       test getNormal() on boundary
30        td_ref=x[0]  
31        td=p(td_ref.interpolate(Function(self.domain)))       assumptions: FunctionOnBoundary(self.domain) exists
32        print td       """
33        print td_ref-td       dim=self.domain.getDim()
34        self.failUnless(Lsup(td-td_ref)<Lsup(td_ref)*h,"value wrong")       f=FunctionOnBoundary(self.domain)
35         x=f.getX()
36         ref=Vector(0.,what=f)
37         if dim==3:
38             ref+=whereZero(x[0]-1.,tol=self.RES_TOL)*[1,0,0]
39             ref+=whereZero(x[0],tol=self.RES_TOL)*[-1,0,0]
40             ref+=whereZero(x[1]-1.,tol=self.RES_TOL)*[0,1,0]
41             ref+=whereZero(x[1],tol=self.RES_TOL)*[0,-1,0]
42             ref+=whereZero(x[2]-1.,tol=self.RES_TOL)*[0,0,1]
43             ref+=whereZero(x[2],tol=self.RES_TOL)*[0,0,-1]
44         else:
45             ref+=whereZero(x[0]-1.,tol=self.RES_TOL)*[1,0]
46             ref+=whereZero(x[0],tol=self.RES_TOL)*[-1,0]
47             ref+=whereZero(x[1]-1.,tol=self.RES_TOL)*[0,1]
48             ref+=whereZero(x[1],tol=self.RES_TOL)*[0,-1]
49    
50         res=f.getNormal()
51         print length(ref-res)
52         self.failUnlessEqual(res.getShape(),(dim,),"wrong shape of result.")
53         self.failUnlessEqual(res.getFunctionSpace(),f,"wrong functionspace of result.")
54         self.failUnless(Lsup(ref-res)<=self.RES_TOL,"wrong result")
55    
56  if __name__ == '__main__':  if __name__ == '__main__':
57     suite = unittest.TestSuite()     suite = unittest.TestSuite()

Legend:
Removed from v.856  
changed lines
  Added in v.857

  ViewVC Help
Powered by ViewVC 1.1.26