/[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 149 - (show annotations)
Thu Sep 1 03:31:39 2005 UTC (14 years, 7 months ago) by jgs
Original Path: trunk/esys2/finley/test/python/RecTest.py
File MIME type: text/x-python
File size: 2962 byte(s)
Merge of development branch dev-02 back to main trunk on 2005-09-01

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