# Diff of /trunk/dudley/test/python/PoissonSolverTest.py

revision 3773 by jfenwick, Mon Oct 11 01:48:14 2010 UTC revision 3774 by jfenwick, Wed Jan 18 06:29:34 2012 UTC
# Line 37  def getDomain(dim,ne,height): Line 37  def getDomain(dim,ne,height):
37       ne2=int(ne*height+0.5)       ne2=int(ne*height+0.5)
38       mydomain=dudley.Brick(n0=ne,n1=ne,n2=ne2,l2=height,order=2)       mydomain=dudley.Brick(n0=ne,n1=ne,n2=ne2,l2=height,order=2)
39       totne=ne2*ne*ne       totne=ne2*ne*ne
40      print "%d -dimensional domain generated."%dim      print("%d -dimensional domain generated."%dim)
41      print "height of the domain is ",height      print("height of the domain is ",height)
42      print "total number of elements is ",totne      print("total number of elements is ",totne)
43      return mydomain      return mydomain
44
45
46  def Solve1(mydomain,height):  def Solve1(mydomain,height):
47      print "Fully constraint solution"      print("Fully constraint solution")
48      l=[1.,1.,1.]      l=[1.,1.,1.]
49      l[mydomain.getDim()-1]=height      l[mydomain.getDim()-1]=height
50      cf=ContinuousFunction(mydomain)      cf=ContinuousFunction(mydomain)
# Line 73  def Solve1(mydomain,height): Line 73  def Solve1(mydomain,height):
73      mypde.setValue(f=f,q=msk)      mypde.setValue(f=f,q=msk)
74      u=mypde.getSolution()      u=mypde.getSolution()
75      error=Lsup(u-u_ex)/Lsup(u_ex)      error=Lsup(u-u_ex)/Lsup(u_ex)
76      print "error = ",error      print("error = ",error)
77      return error      return error
78
79  def Solve2(mydomain,height):  def Solve2(mydomain,height):
80      print "Partially constraint solution"      print("Partially constraint solution")
81      l=[1.,1.,1.]      l=[1.,1.,1.]
82      l[mydomain.getDim()-1]=height      l[mydomain.getDim()-1]=height
83      print l      print(l)
84      cf=ContinuousFunction(mydomain)      cf=ContinuousFunction(mydomain)
85      x=cf.getX()      x=cf.getX()
86      #construct exact solution:      #construct exact solution:
# Line 106  def Solve2(mydomain,height): Line 106  def Solve2(mydomain,height):
106      mypde.setValue(f=f,q=msk)      mypde.setValue(f=f,q=msk)
107      u=mypde.getSolution()      u=mypde.getSolution()
108      error=Lsup(u-u_ex)/Lsup(u_ex)      error=Lsup(u-u_ex)/Lsup(u_ex)
109      print "error = ",error      print("error = ",error)
110      return error      return error
111
112
# Line 116  def main() : Line 116  def main() :
116         for dim in [2,3]:         for dim in [2,3]:
117         # for dim in [2]:         # for dim in [2]:
118            for height in height_list:            for height in height_list:
119               print "***************************************************************"               print("***************************************************************")
120               mydomain= getDomain(dim,ne,height)               mydomain= getDomain(dim,ne,height)
121               print "---------------------------------------------------------------"               print("---------------------------------------------------------------")
122               error=max(error,Solve1(mydomain,height))               error=max(error,Solve1(mydomain,height))
123               print "---------------------------------------------------------------"               print("---------------------------------------------------------------")
124               error=max(error,Solve2(mydomain,height))               error=max(error,Solve2(mydomain,height))
125               print "***************************************************************"               print("***************************************************************")
126
127      print "***************************************************************"      print("***************************************************************")
128      print "maximum error: ",error      print("maximum error: ",error)
129      print "***************************************************************"      print("***************************************************************")
130
131
132

Legend:
 Removed from v.3773 changed lines Added in v.3774