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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4938 - (show annotations)
Wed May 14 01:13:23 2014 UTC (5 years, 3 months ago) by jfenwick
File MIME type: text/x-python
File size: 3794 byte(s)
Modify unit tests to read their classes from
esys.escriptcore.utestselect

Change the line in that file to switch between unittest and unittest2


1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2014 by University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Open Software License version 3.0
9 # http://www.opensource.org/licenses/osl-3.0.php
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16
17 __copyright__="""Copyright (c) 2003-2014 by University of Queensland
18 http://www.uq.edu.au
19 Primary Business: Queensland, Australia"""
20 __license__="""Licensed under the Open Software License version 3.0
21 http://www.opensource.org/licenses/osl-3.0.php"""
22 __url__="https://launchpad.net/escript-finley"
23
24 import sys
25 import os
26 import esys.escriptcore.utestselect as unittest
27
28 from esys.escript import *
29 from esys.escript.linearPDEs import *
30 from esys import dudley
31
32 import numpy
33
34 Pi=numpy.pi
35 numElements=15
36 sml=0.1
37
38 #
39 # this test the assemblage of problems with periodic boundary conditions:
40 #
41
42 #
43 # test solution is u_ex=sin(2*Pi*n*x0)*...*sin(2*Pi*n*x_dim)
44 #
45 def TheTest(msh,constraints,reduce):
46 n=ContinuousFunction(msh)
47 x=n.getX()
48 # set a test problem:
49 u_ex=Scalar(1,what=n)
50 for i in range(msh.getDim()):
51 u_ex*=sin(2*Pi*x[i])
52 mypde=LinearPDE(msh)
53 mypde.setSymmetryOn()
54 mypde.setDebugOn()
55 mypde.setReducedOrderTo(reduce)
56 mypde.setValue(A=numpy.identity(msh.getDim()),D=sml,Y=(sml+4*Pi**2*msh.getDim())*u_ex,q=constraints,r=u_ex)
57 return Lsup(mypde.getSolution()-u_ex)/Lsup(u_ex)
58
59 max_error=0
60 max_text="none"
61 for onElements in [False,True]:
62 if onElements==True:
63 onElmtext=", with elements on faces"
64 else:
65 onElmtext=""
66 for order in [1,2]:
67 for reduce in [False,True]:
68 if reduce==True:
69 redtext=",reduced"
70 else:
71 redtext=""
72 for dim in [2,3]:
73 if dim==2:
74 for i0 in [True,True]:
75 for i1 in [True,True]:
76 msh=dudley.Rectangle(numElements,numElements,order,periodic0=i0,periodic1=i1,useElementsOnFace=onElements)
77 n=ContinuousFunction(msh)
78 x=n.getX()
79 c=Scalar(0,what=n)
80 if i0==False:
81 c+=whereZero(x[0])+whereZero(x[0]-1.)
82 if i1==False:
83 c+=whereZero(x[1])+whereZero(x[1]-1.)
84 error=TheTest(msh,c,reduce)
85 text="Rectangle order = %d%s%s, periodic0= %d, periodic1= %d: error= %f"%(order,redtext,onElmtext,i0,i1,error)
86 print("@@ ",text)
87 if error>max_error:
88 max_error=error
89 max_text=text
90 elif dim==3:
91 for i0 in [True,False]:
92 for i1 in [True,False]:
93 for i2 in [True,False]:
94 msh=dudley.Brick(numElements,numElements,numElements,order,periodic0=i0,periodic1=i1,periodic2=i2,useElementsOnFace=onElements)
95 n=ContinuousFunction(msh)
96 x=n.getX()
97 c=Scalar(0,what=n)
98 if i0==False:
99 c+=whereZero(x[0])+whereZero(x[0]-1.)
100 if i1==False:
101 c+=whereZero(x[1])+whereZero(x[1]-1.)
102 if i2==False:
103 c+=whereZero(x[2])+whereZero(x[2]-1.)
104 error=TheTest(msh,c,reduce)
105 text="Brick order = %d%s%s, periodic0= %d, periodic1= %d, periodic2= %d: error= %f"%(order,redtext,onElmtext,i0,i1,i2,error)
106 print("@@ ",text)
107 if error>max_error:
108 max_error=error
109 max_text=text
110
111 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