2
########################################################
4
# Copyright (c) 2003-2010 by University of Queensland
5
# Earth Systems Science Computational Center (ESSCC)
6
# http://www.uq.edu.au/esscc
8
# Primary Business: Queensland, Australia
9
# Licensed under the Open Software License version 3.0
10
# http://www.opensource.org/licenses/osl-3.0.php
12
########################################################
14
__copyright__="""Copyright (c) 2003-2010 by University of Queensland
15
Earth Systems Science Computational Center (ESSCC)
16
http://www.uq.edu.au/esscc
17
Primary Business: Queensland, Australia"""
18
__license__="""Licensed under the Open Software License version 3.0
19
http://www.opensource.org/licenses/osl-3.0.php"""
20
__url__="https://launchpad.net/escript-finley"
22
from esys.escript import *
23
from esys.escript.linearPDEs import Poisson
24
from esys import dudley
26
ne_list=[10,15,22,33,50,75]
27
height_list=[0.25,0.5,1.]
30
def getDomain(dim,ne,height):
33
ne1=int(ne*height+0.5)
34
mydomain=dudley.Rectangle(n0=ne,n1=ne1,l1=height,order=1)
37
ne2=int(ne*height+0.5)
38
mydomain=dudley.Brick(n0=ne,n1=ne,n2=ne2,l2=height,order=2)
40
print "%d -dimensional domain generated."%dim
41
print "height of the domain is ",height
42
print "total number of elements is ",totne
46
def Solve1(mydomain,height):
47
print "Fully constraint solution"
49
l[mydomain.getDim()-1]=height
50
cf=ContinuousFunction(mydomain)
52
#construct exact solution:
54
for i in range(mydomain.getDim()):
55
u_ex*=x[i]*(x[i]-l[i])
58
for i in range(mydomain.getDim()):
59
msk+=whereZero(x[i])+whereZero(x[i]-l[i])
60
#construct right hand side
62
for i in range(mydomain.getDim()):
64
for j in range(mydomain.getDim()):
71
mypde=Poisson(mydomain)
72
mypde.setTolerance(1.e-10)
73
mypde.setValue(f=f,q=msk)
75
error=Lsup(u-u_ex)/Lsup(u_ex)
76
print "error = ",error
79
def Solve2(mydomain,height):
80
print "Partially constraint solution"
82
l[mydomain.getDim()-1]=height
84
cf=ContinuousFunction(mydomain)
86
#construct exact solution:
88
for i in range(mydomain.getDim()):
89
u_ex*=x[i]*(2*l[i]-x[i])
92
for i in range(mydomain.getDim()):
94
#construct right hand side
96
for i in range(mydomain.getDim()):
98
for j in range(mydomain.getDim()):
102
f_p*=x[j]*(2*l[j]-x[j])
104
mypde=Poisson(mydomain)
105
mypde.setTolerance(1.e-10)
106
mypde.setValue(f=f,q=msk)
107
u=mypde.getSolution()
108
error=Lsup(u-u_ex)/Lsup(u_ex)
109
print "error = ",error
118
for height in height_list:
119
print "***************************************************************"
120
mydomain= getDomain(dim,ne,height)
121
print "---------------------------------------------------------------"
122
error=max(error,Solve1(mydomain,height))
123
print "---------------------------------------------------------------"
124
error=max(error,Solve2(mydomain,height))
125
print "***************************************************************"
127
print "***************************************************************"
128
print "maximum error: ",error
129
print "***************************************************************"
133
import profile as Pr, pstats as Ps
136
if __name__ == "__main__":
139
Pr.run('main()','eos_stats')
140
stats = Ps.Stats('eos_stats')
142
stats.sort_stats('time')