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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 859 - (show annotations)
Tue Sep 26 02:19:18 2006 UTC (13 years, 9 months ago) by gross
File MIME type: text/x-python
File size: 2122 byte(s)
tests for order2 tetrahedron elements added

1 # $Id:$
2 """
3 frame to ran a single test out of the Test_util suite
4 """
5
6 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
7 http://www.access.edu.au
8 Primary Business: Queensland, Australia"""
9 __license__="""Licensed under the Open Software License version 3.0
10 http://www.opensource.org/licenses/osl-3.0.php"""
11 import unittest
12 from esys.escript import *
13 from esys.finley import ReadMesh
14 from esys.escript.pdetools import Projector
15 import numarray
16 FINLEY_TEST_MESH_PATH="data_meshes/"
17
18 class Test_util2(unittest.TestCase):
19 RES_TOL=1.e-8
20 def setUp(self):
21 self.order=1
22 self.domain = ReadMesh(FINLEY_TEST_MESH_PATH+"tet_3D_order2.fly")
23 # self.domain = ReadMesh("tet_3D_order2.fly")
24 def tearDown(self):
25 del self.order
26 del self.domain
27
28 def test_normal_FunctionOnBoundary(self):
29 """
30 test getNormal() on boundary
31
32 assumptions: FunctionOnBoundary(self.domain) exists
33 """
34 dim=self.domain.getDim()
35 f=FunctionOnBoundary(self.domain)
36 x=f.getX()
37 ref=Vector(0.,what=f)
38 if dim==3:
39 ref+=whereZero(x[0]-1.,tol=self.RES_TOL)*[1,0,0]
40 ref+=whereZero(x[0],tol=self.RES_TOL)*[-1,0,0]
41 ref+=whereZero(x[1]-1.,tol=self.RES_TOL)*[0,1,0]
42 ref+=whereZero(x[1],tol=self.RES_TOL)*[0,-1,0]
43 ref+=whereZero(x[2]-1.,tol=self.RES_TOL)*[0,0,1]
44 ref+=whereZero(x[2],tol=self.RES_TOL)*[0,0,-1]
45 else:
46 ref+=whereZero(x[0]-1.,tol=self.RES_TOL)*[1,0]
47 ref+=whereZero(x[0],tol=self.RES_TOL)*[-1,0]
48 ref+=whereZero(x[1]-1.,tol=self.RES_TOL)*[0,1]
49 ref+=whereZero(x[1],tol=self.RES_TOL)*[0,-1]
50
51 res=f.getNormal()
52 print length(ref-res)
53 self.failUnlessEqual(res.getShape(),(dim,),"wrong shape of result.")
54 self.failUnlessEqual(res.getFunctionSpace(),f,"wrong functionspace of result.")
55 self.failUnless(Lsup(ref-res)<=self.RES_TOL,"wrong result")
56
57 if __name__ == '__main__':
58 suite = unittest.TestSuite()
59 suite.addTest(unittest.makeSuite(Test_util2))
60 s=unittest.TextTestRunner(verbosity=2).run(suite)
61
62

  ViewVC Help
Powered by ViewVC 1.1.26