/[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 876 by gross, Tue Sep 26 02:19:18 2006 UTC revision 877 by gross, Wed Oct 25 03:06:58 2006 UTC
# Line 10  __license__="""Licensed under the Open S Line 10  __license__="""Licensed under the Open S
10               http://www.opensource.org/licenses/osl-3.0.php"""               http://www.opensource.org/licenses/osl-3.0.php"""
11  import unittest  import unittest
12  from esys.escript import *  from esys.escript import *
13  from esys.finley import ReadMesh  from esys.escript.linearPDEs import LinearPDE
14  from esys.escript.pdetools import Projector  from esys.finley import Rectangle, JoinFaces
15  import numarray  import numarray
16  FINLEY_TEST_MESH_PATH="data_meshes/"  FINLEY_TEST_MESH_PATH="data_meshes/"
17    
18    NE=6 # number of element in each spatial direction (must be even)
19  class Test_util2(unittest.TestCase):  class Test_util2(unittest.TestCase):
20     RES_TOL=1.e-8    RES_TOL=1.e-7
21     def setUp(self):    ABS_TOL=1.e-8
22          self.order=1    def setUp(self):
23          self.domain = ReadMesh(FINLEY_TEST_MESH_PATH+"tet_3D_order2.fly")         d1 = Rectangle(n0=int(NE/2),n1=NE,l0=0.5,order=1)
24          # self.domain = ReadMesh("tet_3D_order2.fly")         x1 = ContinuousFunction(d1).getX()
25     def tearDown(self):         ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1)))
26          del self.order         d2 = Rectangle(n0=int(NE/2),n1=NE,l0=0.5,order=1)
27           ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2)))
28           d2.setX(d2.getX()+[0.5,0.])
29           self.domain = JoinFaces([d1,d2])
30      def tearDown(self):
31          del self.domain          del self.domain
32    
33     def test_normal_FunctionOnBoundary(self):    #==================================================
34       """    def test_assemblage_2D_solO1_coeffOFull_NEqu1_d_contact_Const_typeContact(self):
35       test getNormal() on boundary      x=self.domain.getX()
36        jump=Data(0.,(),ContinuousFunction(self.domain))
37       assumptions: FunctionOnBoundary(self.domain) exists      jump.setTaggedValue(2,1.)
38       """      u=((-6)+x[1]-6*x[0])*jump
39       dim=self.domain.getDim()      d_contact_test=Data(4,(),FunctionOnContactZero(self.domain))
40       f=FunctionOnBoundary(self.domain)      y_contact_test=(-24)+4*x[1]-24*x[0]
41       x=f.getX()      pde=LinearPDE(self.domain)
42       ref=Vector(0.,what=f)      pde.setValue(d_contact=d_contact_test, y_contact=y_contact_test)
43       if dim==3:      r=pde.getResidual(u)
44           ref+=whereZero(x[0]-1.,tol=self.RES_TOL)*[1,0,0]      rhs=pde.getRightHandSide()
45           ref+=whereZero(x[0],tol=self.RES_TOL)*[-1,0,0]      self.failUnless(Lsup(rhs)>0,"right hand side is zero")
46           ref+=whereZero(x[1]-1.,tol=self.RES_TOL)*[0,1,0]      self.failUnless(Lsup(r)<=self.RES_TOL*Lsup(rhs),"residual is too big")
          ref+=whereZero(x[1],tol=self.RES_TOL)*[0,-1,0]  
          ref+=whereZero(x[2]-1.,tol=self.RES_TOL)*[0,0,1]  
          ref+=whereZero(x[2],tol=self.RES_TOL)*[0,0,-1]  
      else:  
          ref+=whereZero(x[0]-1.,tol=self.RES_TOL)*[1,0]  
          ref+=whereZero(x[0],tol=self.RES_TOL)*[-1,0]  
          ref+=whereZero(x[1]-1.,tol=self.RES_TOL)*[0,1]  
          ref+=whereZero(x[1],tol=self.RES_TOL)*[0,-1]  
   
      res=f.getNormal()  
      print length(ref-res)  
      self.failUnlessEqual(res.getShape(),(dim,),"wrong shape of result.")  
      self.failUnlessEqual(res.getFunctionSpace(),f,"wrong functionspace of result.")  
      self.failUnless(Lsup(ref-res)<=self.RES_TOL,"wrong result")  
47    
48  if __name__ == '__main__':  if __name__ == '__main__':
49     suite = unittest.TestSuite()     suite = unittest.TestSuite()

Legend:
Removed from v.876  
changed lines
  Added in v.877

  ViewVC Help
Powered by ViewVC 1.1.26