/[escript]/trunk/finley/py_src/finleybench.py
ViewVC logotype

Diff of /trunk/finley/py_src/finleybench.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 381 by gross, Mon Dec 19 03:15:44 2005 UTC revision 383 by gross, Mon Dec 19 06:10:45 2005 UTC
# Line 31  __url__="http://www.iservo.edu.au/esys/e Line 31  __url__="http://www.iservo.edu.au/esys/e
31  __version__="$Revision:$"  __version__="$Revision:$"
32  __date__="$Date:$"  __date__="$Date:$"
33    
34    from esys.escript import Lsup,whereZero,kronecker
35  from esys.escript.benchmark import BenchmarkProblem, Options, BenchmarkFilter  from esys.escript.benchmark import BenchmarkProblem, Options, BenchmarkFilter
 from esys.escript import Lsup  
36  import esys.finley  import esys.finley
37    from esys.escript.linearPDEs import LinearPDE
38  import os  import os
39    
40  class FinleyFilter(BenchmarkFilter):  class FinleyFilter(BenchmarkFilter):
# Line 77  class FinleyFilter(BenchmarkFilter): Line 78  class FinleyFilter(BenchmarkFilter):
78         for a in self.__args:         for a in self.__args:
79           out.append(result[a])           out.append(result[a])
80         return out         return out
81          
82    class FinleyOptions(Options):
83       """
84       finley solver options to be handed over to paso
85    
86       """
87       def __init__(self,solver_method=None,
88                         preconditioner=None,
89                         package=None,
90                         tolerance=None,
91                         verbose=False):
92           self.strmap={
93                          LinearPDE.DIRECT : "DIRECT",
94                          LinearPDE.PCG:  "PCG",
95                          LinearPDE.CR:  "CR",
96                          LinearPDE.CGS: "CGS",
97                          LinearPDE.BICGSTAB: "BICGSTAB",
98                          LinearPDE.SSOR: "SSOR",
99                          LinearPDE.ILU0: "ILU0",
100                          LinearPDE.ILUT: "ILUT",
101                          LinearPDE.JACOBI: "JACOBI",
102                          LinearPDE.GMRES:  "GMRES",
103                          LinearPDE.PRES20:  "PRES20",
104                          LinearPDE.LUMPING:  "LUMPIMG",
105                          LinearPDE.NO_REORDERING:  "NO_REORDERING",
106                          LinearPDE.MINIMUM_FILL_IN:  "MINIMUM_FILL_IN",
107                          LinearPDE.NESTED_DISSECTION: "NESTED_DISSECTION",
108                          LinearPDE.SCSL:  "SCSL",
109                          LinearPDE.MKL:  "MKL",
110                          LinearPDE.UMFPACK: "UMFPACK",
111                          LinearPDE.PASO:  "PASO"
112                      }
113           name=""
114           if solver_method==None:
115                 solver_method==LinearPDE.PRES20
116           else:
117                 name+=self.strmap[solver_method]
118           if preconditioner==None:
119                 preconditioner==LinearPDE.JACOBI
120           else:
121                 if not name=="": name+="+"
122                 name+=self.strmap[preconditioner]
123           if package==None:
124                 package==LinearPDE.PASO
125           else:
126                 if not name=="": name+=" with "
127                 name+=self.strmap[package]
128           if tolerance==None:
129                 tolerance=1.e-8
130           else:
131                 if not name=="": name+=", "
132                 name+="tol = %s"%tolerance
133           self.solver_method=solver_method
134           self.preconditioner=preconditioner
135           self.tolerance=tolerance
136           self.package=package
137           self.verbose=verbose
138           super(FinleyOptions,self).__init__(name=name)
139    
140    
141    
142  class FinleyProblem(BenchmarkProblem):  class FinleyProblem(BenchmarkProblem):
# Line 96  class FinleyProblem(BenchmarkProblem): Line 155  class FinleyProblem(BenchmarkProblem):
155         """         """
156         domain=self.getDomain()         domain=self.getDomain()
157         pde,u=self.getTestProblem(domain)         pde,u=self.getTestProblem(domain)
158         pde.setTolerance(options.getTolerance())         pde.setTolerance(options.tolerance)
159         pde.setSolverMethod(options.getSolverMethod())         pde.setSolverMethod(options.solver_method,options.preconditioner)
160         pde.setSolverPackage(options.getSolverPackage())         pde.setSolverPackage(options.package)
161         a=os.times()[4]         a=os.times()[4]
162         u_h=pde.getSolution(options.getPasoOptions())         uh=pde.getSolution(verbose=options.verbose)
163         a=os.times()[4]-a         a=os.times()[4]-a
164         if u==None:         if u==None:
165            return {FinleyFilter.TIME : a ,FinleyFilter.TIME : None }            return {FinleyFilter.TIME : a , FinleyFilter.ERROR : None }
166         else:         else:
167            error=Lsup(u-uh)/Lsup(u)            error=Lsup(u-uh)/Lsup(u)
168            return {FinleyFilter.TIME : a ,FinleyFilter.TIME : error }            return {FinleyFilter.TIME : a , FinleyFilter.ERROR : error }
169    
170     def getTestProblem(self,domain):     def getTestProblem(self,domain):
171         """         """
# Line 157  class RegularFinleyProblem(FinleyProblem Line 216  class RegularFinleyProblem(FinleyProblem
216         @return: a domain         @return: a domain
217         @rtype: L{escript.Domain}         @rtype: L{escript.Domain}
218         """         """
219         if dim==2:         if self.__dim==2:
220            domain=esys.finley.Rectangle(n0=self.__n,n1=self.__n,order=order)            domain=esys.finley.Rectangle(n0=self.__n,n1=self.__n,order=self.__order)
221         else:         else:
222            domain=esys.finley.Brick(n0=self.__n,n1=self.__n,n2=self.__n,order=order)            domain=esys.finley.Brick(n0=self.__n,n1=self.__n,n2=self.__n,order=self.__order)
223         return domain         return domain
224    
225  class LaplaceProblem(RegularFinleyProblem):  class LaplaceProblem(RegularFinleyProblem):
# Line 182  class LaplaceProblem(RegularFinleyProble Line 241  class LaplaceProblem(RegularFinleyProble
241           for i in range(1,domain.getDim()):           for i in range(1,domain.getDim()):
242              msk+=whereZero(x[i])+whereZero(x[i]-1.)              msk+=whereZero(x[i])+whereZero(x[i]-1.)
243              u*=(x[i]-i)              u*=(x[i]-i)
244           pde=LinearPDE(mydomain)           pde=LinearPDE(domain)
245           pde.setSymmetryOn()           pde.setSymmetryOn()
246           pde.setValue(A=kronnecker,q=msk,r=u)           pde.setValue(A=kronecker(domain),q=msk,r=u)
247           return pde,u           return pde,u
248    
249  class Laplace2DOrder1_30k(LaplaceProblem):  class Laplace2DOrder1_30k(LaplaceProblem):

Legend:
Removed from v.381  
changed lines
  Added in v.383

  ViewVC Help
Powered by ViewVC 1.1.26