/[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 857 - (show annotations)
Tue Sep 26 01:00:45 2006 UTC (13 years, 10 months ago) by gross
File MIME type: text/x-python
File size: 2068 byte(s)
tests for order1 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_order1.fly")
23 def tearDown(self):
24 del self.order
25 del self.domain
26
27 def test_normal_FunctionOnBoundary(self):
28 """
29 test getNormal() on boundary
30
31 assumptions: FunctionOnBoundary(self.domain) exists
32 """
33 dim=self.domain.getDim()
34 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__':
57 suite = unittest.TestSuite()
58 suite.addTest(unittest.makeSuite(Test_util2))
59 s=unittest.TextTestRunner(verbosity=2).run(suite)
60
61

  ViewVC Help
Powered by ViewVC 1.1.26