/[escript]/trunk/finley/test/python/RecTest.py
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 82 - (show annotations)
Tue Oct 26 06:53:54 2004 UTC (15 years, 5 months ago) by jgs
Original Path: trunk/esys2/finley/test/python/RecTest.py
File MIME type: text/x-python
File size: 3242 byte(s)
Initial revision

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26