# Contents of /trunk/finley/test/python/RecTest.py

Revision 102 - (show annotations)
Wed Dec 15 07:08:39 2004 UTC (15 years, 3 months ago) by jgs
Original Path: trunk/esys2/finley/test/python/RecTest.py
File MIME type: text/x-python
File size: 3398 byte(s)
*** empty log message ***

 1 # \$Id\$ 2 import sys 3 import os 4 import unittest 5 6 esys_root=os.getenv('ESYS_ROOT') 7 sys.path.append(esys_root+'/finley/lib') 8 sys.path.append(esys_root+'/escript/lib') 9 sys.path.append(esys_root+'/escript/py_src') 10 11 from escript import * 12 from util import * 13 from linearPDEs import * 14 15 import finley 16 import numarray 17 18 # 19 # this test the assemblage of problems with periodic boundary conditions: 20 # 21 numElements=15 22 sml=0.1 23 # 24 # test solution is u_ex=sin(2*Pi*n*x0)*...*sin(2*Pi*n*x_dim) 25 # 26 def TheTest(msh,constraints,reduce): 27 n=ContinuousFunction(msh) 28 x=n.getX() 29 # set a test problem: 30 u_ex=Scalar(1,what=n) 31 for i in range(msh.getDim()): 32 u_ex*=sin(2*Pi*x[i]) 33 mypde=LinearPDE(A=numarray.identity(msh.getDim()),D=sml,Y=(sml+4*Pi**2*msh.getDim())*u_ex,q=constraints,r=u_ex) 34 mypde.setSymmetryOn() 35 mypde.setDebugOn() 36 mypde.setReducedOrderTo(reduce) 37 return Lsup(mypde.getSolution()-u_ex)/Lsup(u_ex) 38 39 max_error=0 40 max_text="none" 41 for onElements in [False,True]: 42 if onElements==True: 43 onElmtext=", with elements on faces" 44 else: 45 onElmtext="" 46 for order in [1,2]: 47 for reduce in [False,True]: 48 if reduce==True: 49 redtext=",reduced" 50 else: 51 redtext="" 52 for dim in [2,3]: 53 if dim==2: 54 # for i0 in [True,False]: 55 # for i1 in [True,False]: 56 for i0 in [True,True]: 57 for i1 in [True,True]: 58 msh=finley.Rectangle(numElements,numElements,order,periodic0=i0,periodic1=i1,useElementsOnFace=onElements) 59 n=ContinuousFunction(msh) 60 x=n.getX() 61 c=Scalar(0,what=n) 62 if i0==False: 63 c+=x[0].whereZero()+(x[0]-1.).whereZero() 64 if i1==False: 65 c+=x[1].whereZero()+(x[1]-1.).whereZero() 66 error=TheTest(msh,c,reduce) 67 text="Rectangle order = %d%s%s, periodic0= %d, periodic1= %d: error= %f"%(order,redtext,onElmtext,i0,i1,error) 68 print "@@ ",text 69 if error>max_error: 70 max_error=error 71 max_text=text 72 elif dim==3: 73 for i0 in [True,False]: 74 for i1 in [True,False]: 75 for i2 in [True,False]: 76 msh=finley.Brick(numElements,numElements,numElements,order,periodic0=i0,periodic1=i1,periodic2=i2,useElementsOnFace=onElements) 77 n=ContinuousFunction(msh) 78 x=n.getX() 79 c=Scalar(0,what=n) 80 if i0==False: 81 c+=x[0].whereZero()+(x[0]-1.).whereZero() 82 if i1==False: 83 c+=x[1].whereZero()+(x[1]-1.).whereZero() 84 if i2==False: 85 c+=x[2].whereZero()+(x[2]-1.).whereZero() 86 error=TheTest(msh,c,reduce) 87 text="Brick order = %d%s%s, periodic0= %d, periodic1= %d, periodic2= %d: error= %f"%(order,redtext,onElmtext,i0,i1,i2,error) 88 print "@@ ",text 89 if error>max_error: 90 max_error=error 91 max_text=text 92 93 print "@@@@ maximum error for :",max_text

## Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision