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

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

## Properties

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