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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6651 - (hide annotations)
Wed Feb 7 02:12:08 2018 UTC (2 years, 2 months ago) by jfenwick
File MIME type: text/x-python
File size: 3831 byte(s)
Make everyone sad by touching all the files

Copyright dates update

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