# Diff of /trunk/finley/test/python/SolveTest.py

trunk/esys2/finley/test/python/SolveTest.py revision 117 by jgs, Fri Apr 1 05:48:57 2005 UTC trunk/finley/test/python/SolveTest.py revision 617 by elspeth, Wed Mar 22 02:58:17 2006 UTC
# Line 14  Line 14
14
15  """  """
16
18                        http://www.access.edu.au
22  from esys.escript import *  from esys.escript import *
23  from esys.linearPDEs import *  from esys.escript.linearPDEs import *
24  import esys.finley as pdelib  import esys.finley as pdelib
25  from time import time  from time import time
26
# Line 62  def solveVector(numDim, totalNumElem, le Line 67  def solveVector(numDim, totalNumElem, le
67      # Set Boundary Mask / pdelib Template "q" Parameter Vector      # Set Boundary Mask / pdelib Template "q" Parameter Vector
68      bndryMask = Vector(value = 0, what = contfunc)      bndryMask = Vector(value = 0, what = contfunc)
69      for i in range(meshDim):      for i in range(meshDim):
70          bndryMask += (x[i].whereZero() + (x[i]-recDim[i]).whereZero()) \          bndryMask += (whereZero(x[i]) + whereZero(x[i]-recDim[i])) \
71                  * ones((numDim,))                  * ones((numDim,))
72
73      # Set True Solution / pdelib Template "r" Parameter Vector      # Set True Solution / pdelib Template "r" Parameter Vector
# Line 82  def solveVector(numDim, totalNumElem, le Line 87  def solveVector(numDim, totalNumElem, le
87      mypde=LinearPDE(mesh)      mypde=LinearPDE(mesh)
88      mypde.setValue(A = A, Y = - 2 * alpha * (meshDim - 1)*ones(meshDim), q = bndryMask, r = u)      mypde.setValue(A = A, Y = - 2 * alpha * (meshDim - 1)*ones(meshDim), q = bndryMask, r = u)
89      mypde.setSolverMethod(solver_method_id)      mypde.setSolverMethod(solver_method_id)
90        # mypde.getOperator().saveMM("g.mm")
91
92      # Solve for Approximate Solution      # Solve for Approximate Solution
93      tm=time()      tm=time()
94      u_approx = mypde.getSolution(preconditioner=prec_id,iter_max=10000)      u_approx = mypde.getSolution(verbose=True,preconditioner=prec_id,iter_max=10000)
95      tm=time()-tm      tm=time()-tm
96
97      # Report Results      # Report Results
# Line 131  def solveScalar(numDim, totalNumElem, le Line 137  def solveScalar(numDim, totalNumElem, le
137      # Set Boundary Mask / pdelib Template "q" Parameter Vector      # Set Boundary Mask / pdelib Template "q" Parameter Vector
138      bndryMask = Scalar(value = 0, what = contfunc)      bndryMask = Scalar(value = 0, what = contfunc)
139      for i in range(meshDim):      for i in range(meshDim):
140          bndryMask += (x[i].whereZero() + (x[i]-recDim[i]).whereZero()) * 1.0          bndryMask += (whereZero(x[i]) + whereZero(x[i]-recDim[i])) * 1.0
141
142      # Set True Solution / pdelib Template "r" Parameter Vector      # Set True Solution / pdelib Template "r" Parameter Vector
143      u = Scalar(value = 0, what = contfunc)      u = Scalar(value = 0, what = contfunc)
# Line 145  def solveScalar(numDim, totalNumElem, le Line 151  def solveScalar(numDim, totalNumElem, le
151
152      # Solve for Approximate Solution      # Solve for Approximate Solution
153      tm=time()      tm=time()
154      u_approx = mypde.getSolution(preconditioner=prec_id,iter_max=10000)      u_approx = mypde.getSolution(verbose=True,preconditioner=prec_id,iter_max=10000)
155      tm=time()-tm      tm=time()-tm
156
157      # Report Results      # Report Results
# Line 160  def solveScalar(numDim, totalNumElem, le Line 166  def solveScalar(numDim, totalNumElem, le
166  print "Test is started:"  print "Test is started:"
167  print "----------------"  print "----------------"
168  error=0.  error=0.
169  for numDim in [2,3]:  for numDim in [2, 3]:
170       # for totalNumElem in [51200]:
171     for totalNumElem in [100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400,204800]:     for totalNumElem in [100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400,204800]:
172        for problem in [solveScalar,solveVector]:        for problem in [solveScalar,solveVector]:
173           if totalNumElem*2**numDim*numDim< 200000: error=max([problem(numDim, totalNumElem, len_x0, alpha,"DIRECT",""),error])        #for problem in [solveVector]:
174           for solver_method in [ "PCG" ]:           error=max([problem(numDim, totalNumElem, len_x0, alpha,"PCG",""),error])
175              for prec in [ "JACOBI", "ILU0" ]:           error=max([problem(numDim, totalNumElem, len_x0, alpha,"DIRECT",""),error])
176                 error=max([problem(numDim, totalNumElem, len_x0, alpha, solver_method,prec),error])           #if totalNumElem*2**numDim*numDim< 200000: error=max([problem(numDim, totalNumElem, len_x0, alpha,"DIRECT",""),error])
177             # for solver_method in [ "PCG" ]:
178             #    for prec in [ "JACOBI", "ILU0" ]:
179             #       error=max([problem(numDim, totalNumElem, len_x0, alpha, solver_method,prec),error])
180  print "----------------"  print "----------------"
181  print "maximum error over all tests is ",error  print "maximum error over all tests is ",error
182  print "----------------"  print "----------------"

Legend:
 Removed from v.117 changed lines Added in v.617