/[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 888 - (show annotations)
Tue Nov 7 08:31:26 2006 UTC (13 years, 3 months ago) by gross
File MIME type: text/x-python
File size: 2865 byte(s)
Problem in Mesh_findMatchingFaces.c fixed:
default tolerance in python interface was set too tight.



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.escript.linearPDEs import LinearPDE
14 from esys.finley import Rectangle, JoinFaces, Brick
15
16 import numarray
17 FINLEY_TEST_MESH_PATH="data_meshes/"
18
19 NE=6 # number of element in each spatial direction (must be even)
20
21 class Test_AssemblePDEwithFinley_3Do2_Contact_withElementsOnFace(unittest.TestCase):
22 RES_TOL=1.e-7
23 ABS_TOL=1.e-8
24 def setUp(self):
25 d1 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=2,useElementsOnFace=True)
26 x1 = ContinuousFunction(d1).getX()
27 ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1)))
28 d2 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=2,useElementsOnFace=True)
29 ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2)))
30 d2.setX(d2.getX()+[0.5,0.,0.])
31 self.domain = JoinFaces([d1,d2])
32 self.domain.write("m.fly")
33 def test_assemblage_3D_solO2_coeffOFull_NEqu1_B_Const_typeContact_comp0(self):
34 x=self.domain.getX()
35 u=(-4)+3*x[2]+6*x[2]**2-2*x[1]-5*x[1]*x[2]-8*x[1]**2+3*x[0]+7*x[0]*x[2]-9*x[0]*x[1]-4*x[0]**2
36 B_test=Data(0.,(3,),Function(self.domain))
37 B_test[0]=1
38 Y_test=(-3)-7*x[2]+9*x[1]+8*x[0]
39 x_boundary=FunctionOnBoundary(self.domain).getX()
40 n=whereZero(x_boundary[0] ,self.ABS_TOL)*numarray.array([-1., 0., 0.])+whereZero(x_boundary[0]-1.,self.ABS_TOL)*numarray.array([ 1., 0., 0.])+whereZero(x_boundary[1] ,self.ABS_TOL)*numarray.array([ 0.,-1., 0.])+whereZero(x_boundary[1]-1.,self.ABS_TOL)*numarray.array([ 0., 1., 0.])+whereZero(x_boundary[2] ,self.ABS_TOL)*numarray.array([ 0., 0.,-1.])+whereZero(x_boundary[2]-1.,self.ABS_TOL)*numarray.array([ 0., 0., 1.])
41 y_test=n[0]*((-4)+3*x[2]+6*x[2]**2-2*x[1]-5*x[1]*x[2]-8*x[1]**2+3*x[0]+7*x[0]*x[2]-9*x[0]*x[1]-4*x[0]**2)
42 n_contact=FunctionOnContactZero(self.domain).getNormal()
43 y_contact_test=n_contact[0]*(4-3*x[2]-6*x[2]**2+2*x[1]+5*x[1]*x[2]+8*x[1]**2-3*x[0]-7*x[0]*x[2]+9*x[0]*x[1]+4*x[0]**2)
44 pde=LinearPDE(self.domain)
45 pde.setValue(B=B_test, Y=Y_test, y=y_test, y_contact=y_contact_test)
46 r=pde.getResidual(u)
47 rhs=pde.getRightHandSide()
48 self.failUnless(Lsup(rhs)>0,"right hand side is zero")
49 self.failUnless(Lsup(r)<=self.RES_TOL*Lsup(rhs),"residual is too big")
50 def tearDown(self):
51 del self.domain
52
53 if __name__ == '__main__':
54 suite = unittest.TestSuite()
55 suite.addTest(unittest.makeSuite(Test_AssemblePDEwithFinley_3Do2_Contact_withElementsOnFace))
56 s=unittest.TextTestRunner(verbosity=2).run(suite)
57
58

  ViewVC Help
Powered by ViewVC 1.1.26