# Diff of /trunk/finley/test/python/testframe.py

revision 1374 by ksteube, Mon Sep 24 06:18:44 2007 UTC revision 1375 by gross, Wed Jan 9 00:15:05 2008 UTC
# Line 31  from esys.finley import Rectangle, JoinF Line 31  from esys.finley import Rectangle, JoinF
31  import numarray  import numarray
32  FINLEY_TEST_MESH_PATH="data_meshes/"  FINLEY_TEST_MESH_PATH="data_meshes/"
33
34  NE=6 # number of element in each spatial direction (must be even)  NE=1 # number of element in each spatial direction (must be even)
35
36  class Test_X(unittest.TestCase):  class Test_X(unittest.TestCase):
37     RES_TOL=1.e-7     RES_TOL=1.e-7
38     ABS_TOL=1.e-8     ABS_TOL=1.e-8
39       DEBUG=True
40     def setUp(self):     def setUp(self):
41          self.order=1          self.domain = Rectangle(n0=NE,n1=NE,l0=0.5,order=1)
d1 = Rectangle(n0=NE/2+1,n1=NE,l0=0.5,order=1)
d2 = Rectangle(n0=NE/2,n1=NE,l0=0.5,order=1)
d2.setX(d2.getX()+[0.5,0.])
self.domain = JoinFaces([d1,d2],optimize=False)
def tearDown(self):
del self.order
del self.domain
def test_integrate_onFunctionOnBoundary_fromData_ReducedContinuousFunction_rank0(self):
"""
tests integral of rank 0 Data on the FunctionOnBoundary

assumptions: ReducedContinuousFunction(self.domain) exists
self.domain supports integral on FunctionOnBoundary
"""
o=1
dim=self.domain.getDim()
w_ref=FunctionOnBoundary(self.domain)
w=ReducedContinuousFunction(self.domain)
x=w.getX()
arg=Data(0,(),w)
if dim==2:
arg=(-0.0177156089276)*x[0]+(-1.07750293477)*x[1]
ref=(0.674554765151)*(1+2.*(dim-1.)/(o+1.))+(-1.76977330884)*dim
else:
arg=(0.304688056778)*x[0]+(0.548485298428)*x[1]+(0.672370309114)*x[2]
ref=(0.0121419382123)*(1+2.*(dim-1.)/(o+1.))+(1.51340172611)*dim
res=integrate(arg,where=w_ref)
self.failUnless(isinstance(res,float),"wrong type of result.")
self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")

42
43       def test_setCoefficient_y_reduced_Scalar_using_y(self):
44            d=self.domain.getDim()
45            mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG)
46            mypde.setValue(y=Scalar(1.,ReducedFunctionOnBoundary(self.domain)))
47            coeff=mypde.getCoefficientOfGeneralPDE("y_reduced")
48            self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1))
49
50  if __name__ == '__main__':  if __name__ == '__main__':
51     suite = unittest.TestSuite()     suite = unittest.TestSuite()

Legend:
 Removed from v.1374 changed lines Added in v.1375