# Diff of /trunk-mpi-branch/finley/test/python/testframe.py

revision 1276 by ksteube, Tue Feb 13 22:56:57 2007 UTC revision 1277 by gross, Mon Aug 27 04:15:51 2007 UTC
# Line 18  FINLEY_TEST_MESH_PATH="data_meshes/" Line 18  FINLEY_TEST_MESH_PATH="data_meshes/"
18
19  NE=6 # number of element in each spatial direction (must be even)  NE=6 # number of element in each spatial direction (must be even)
20
21  class Test_AssemblePDEwithFinley_3Do2_Contact_withElementsOnFace(unittest.TestCase):  class Test_X(unittest.TestCase):
22     RES_TOL=1.e-7     RES_TOL=1.e-7
23     ABS_TOL=1.e-8     ABS_TOL=1.e-8
24     def setUp(self):     def setUp(self):
25         d1 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=2,useElementsOnFace=True)          self.order=1
26         x1 = ContinuousFunction(d1).getX()          d1 = Rectangle(n0=NE/2+1,n1=NE,l0=0.5,order=1)
27         ContinuousFunction(d1).setTags(1,Scalar(1,ContinuousFunction(d1)))          d2 = Rectangle(n0=NE/2,n1=NE,l0=0.5,order=1)
28         d2 = Brick(n0=int(NE/2),n1=NE,n2=NE,l0=0.5,order=2,useElementsOnFace=True)          d2.setX(d2.getX()+[0.5,0.])
29         ContinuousFunction(d2).setTags(2,Scalar(1,ContinuousFunction(d2)))          self.domain = JoinFaces([d1,d2],optimize=False)
d2.setX(d2.getX()+[0.5,0.,0.])
self.domain = JoinFaces([d1,d2])
self.domain.write("m.fly")
def test_assemblage_3D_solO2_coeffOFull_NEqu1_B_Const_typeContact_comp0(self):
x=self.domain.getX()
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
B_test=Data(0.,(3,),Function(self.domain))
B_test[0]=1
Y_test=(-3)-7*x[2]+9*x[1]+8*x[0]
x_boundary=FunctionOnBoundary(self.domain).getX()
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.])
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)
n_contact=FunctionOnContactZero(self.domain).getNormal()
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)
pde=LinearPDE(self.domain)
pde.setValue(B=B_test, Y=Y_test, y=y_test, y_contact=y_contact_test)
r=pde.getResidual(u)
rhs=pde.getRightHandSide()
self.failUnless(Lsup(rhs)>0,"right hand side is zero")
self.failUnless(Lsup(r)<=self.RES_TOL*Lsup(rhs),"residual is too big")
30     def tearDown(self):     def tearDown(self):
31            del self.order
32          del self.domain          del self.domain
33       def test_integrate_onFunctionOnBoundary_fromData_ReducedContinuousFunction_rank0(self):
34          """
35          tests integral of rank 0 Data on the FunctionOnBoundary
36
37          assumptions: ReducedContinuousFunction(self.domain) exists
38                       self.domain supports integral on FunctionOnBoundary
39          """
40          o=1
41          dim=self.domain.getDim()
42          w_ref=FunctionOnBoundary(self.domain)
43          w=ReducedContinuousFunction(self.domain)
44          x=w.getX()
45          arg=Data(0,(),w)
46          if dim==2:
47            arg=(-0.0177156089276)*x[0]+(-1.07750293477)*x[1]
48            ref=(0.674554765151)*(1+2.*(dim-1.)/(o+1.))+(-1.76977330884)*dim
49          else:
50            arg=(0.304688056778)*x[0]+(0.548485298428)*x[1]+(0.672370309114)*x[2]
51            ref=(0.0121419382123)*(1+2.*(dim-1.)/(o+1.))+(1.51340172611)*dim
52          res=integrate(arg,where=w_ref)
53          self.failUnless(isinstance(res,float),"wrong type of result.")
54          self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
55
56
57
58
59  if __name__ == '__main__':  if __name__ == '__main__':
60     suite = unittest.TestSuite()     suite = unittest.TestSuite()
62     s=unittest.TextTestRunner(verbosity=2).run(suite)     s=unittest.TextTestRunner(verbosity=2).run(suite)
63
64

Legend:
 Removed from v.1276 changed lines Added in v.1277