/[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 389 by gross, Tue Dec 20 03:17:28 2005 UTC
# Line 14  Line 14 
14  some benchmarks for tetsing the finley solver. The idea is to develop a set of standart benchmarks  some benchmarks for tetsing the finley solver. The idea is to develop a set of standart benchmarks
15    
16    * Laplace2Dorder1_?k    * Laplace2Dorder1_?k
17      * Laplace2Dorder2_?k
18      * Laplace3Dorder1_?k
19    * Laplace3Dorder2_?k    * Laplace3Dorder2_?k
20    
21  where ? is approximatively the number of unknowns in 1000.  where ? is approximatively the number of unknowns in 1000.
# Line 31  __url__="http://www.iservo.edu.au/esys/e Line 33  __url__="http://www.iservo.edu.au/esys/e
33  __version__="$Revision:$"  __version__="$Revision:$"
34  __date__="$Date:$"  __date__="$Date:$"
35    
36    from esys.escript import Lsup,whereZero,kronecker
37  from esys.escript.benchmark import BenchmarkProblem, Options, BenchmarkFilter  from esys.escript.benchmark import BenchmarkProblem, Options, BenchmarkFilter
 from esys.escript import Lsup  
38  import esys.finley  import esys.finley
39    from esys.escript.linearPDEs import LinearPDE
40  import os  import os
41    
42  class FinleyFilter(BenchmarkFilter):  class FinleyFilter(BenchmarkFilter):
# Line 77  class FinleyFilter(BenchmarkFilter): Line 80  class FinleyFilter(BenchmarkFilter):
80         for a in self.__args:         for a in self.__args:
81           out.append(result[a])           out.append(result[a])
82         return out         return out
83          
84    class FinleyOptions(Options):
85       """
86       finley solver options to be handed over to paso
87    
88       """
89       def __init__(self,solver_method=None,
90                         preconditioner=None,
91                         package=None,
92                         tolerance=None,
93                         verbose=False):
94           self.strmap={
95                          LinearPDE.DIRECT : "DIRECT",
96                          LinearPDE.PCG:  "PCG",
97                          LinearPDE.CR:  "CR",
98                          LinearPDE.CGS: "CGS",
99                          LinearPDE.BICGSTAB: "BICGSTAB",
100                          LinearPDE.SSOR: "SSOR",
101                          LinearPDE.ILU0: "ILU0",
102                          LinearPDE.ILUT: "ILUT",
103                          LinearPDE.JACOBI: "JACOBI",
104                          LinearPDE.GMRES:  "GMRES",
105                          LinearPDE.PRES20:  "PRES20",
106                          LinearPDE.LUMPING:  "LUMPIMG",
107                          LinearPDE.NO_REORDERING:  "NO_REORDERING",
108                          LinearPDE.MINIMUM_FILL_IN:  "MINIMUM_FILL_IN",
109                          LinearPDE.NESTED_DISSECTION: "NESTED_DISSECTION",
110                          LinearPDE.SCSL:  "SCSL",
111                          LinearPDE.MKL:  "MKL",
112                          LinearPDE.UMFPACK: "UMFPACK",
113                          LinearPDE.PASO:  "PASO"
114                      }
115           name=""
116           if solver_method==None:
117                 solver_method==LinearPDE.PRES20
118           else:
119                 name+=self.strmap[solver_method]
120           if preconditioner==None:
121                 preconditioner==LinearPDE.JACOBI
122           else:
123                 if not name=="": name+="+"
124                 name+=self.strmap[preconditioner]
125           if package==None:
126                 package==LinearPDE.PASO
127           else:
128                 if not name=="": name+=" with "
129                 name+=self.strmap[package]
130           if tolerance==None:
131                 tolerance=1.e-8
132           else:
133                 if not name=="": name+=", "
134                 name+="tol = %s"%tolerance
135           self.solver_method=solver_method
136           self.preconditioner=preconditioner
137           self.tolerance=tolerance
138           self.package=package
139           self.verbose=verbose
140           super(FinleyOptions,self).__init__(name=name)
141    
142    
143    
144  class FinleyProblem(BenchmarkProblem):  class FinleyProblem(BenchmarkProblem):
# Line 96  class FinleyProblem(BenchmarkProblem): Line 157  class FinleyProblem(BenchmarkProblem):
157         """         """
158         domain=self.getDomain()         domain=self.getDomain()
159         pde,u=self.getTestProblem(domain)         pde,u=self.getTestProblem(domain)
160         pde.setTolerance(options.getTolerance())         pde.setTolerance(options.tolerance)
161         pde.setSolverMethod(options.getSolverMethod())         pde.setSolverMethod(options.solver_method,options.preconditioner)
162         pde.setSolverPackage(options.getSolverPackage())         pde.setSolverPackage(options.package)
163         a=os.times()[4]         a=os.times()[4]
164         u_h=pde.getSolution(options.getPasoOptions())         uh=pde.getSolution(verbose=options.verbose)
165         a=os.times()[4]-a         a=os.times()[4]-a
166         if u==None:         if u==None:
167            return {FinleyFilter.TIME : a ,FinleyFilter.TIME : None }            return {FinleyFilter.TIME : a , FinleyFilter.ERROR : None }
168         else:         else:
169            error=Lsup(u-uh)/Lsup(u)            error=Lsup(u-uh)/Lsup(u)
170            return {FinleyFilter.TIME : a ,FinleyFilter.TIME : error }            return {FinleyFilter.TIME : a , FinleyFilter.ERROR : error }
171    
172     def getTestProblem(self,domain):     def getTestProblem(self,domain):
173         """         """
# Line 157  class RegularFinleyProblem(FinleyProblem Line 218  class RegularFinleyProblem(FinleyProblem
218         @return: a domain         @return: a domain
219         @rtype: L{escript.Domain}         @rtype: L{escript.Domain}
220         """         """
221         if dim==2:         if self.__dim==2:
222            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)
223         else:         else:
224            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)
225         return domain         return domain
226    
227  class LaplaceProblem(RegularFinleyProblem):  class LaplaceProblem(RegularFinleyProblem):
# Line 182  class LaplaceProblem(RegularFinleyProble Line 243  class LaplaceProblem(RegularFinleyProble
243           for i in range(1,domain.getDim()):           for i in range(1,domain.getDim()):
244              msk+=whereZero(x[i])+whereZero(x[i]-1.)              msk+=whereZero(x[i])+whereZero(x[i]-1.)
245              u*=(x[i]-i)              u*=(x[i]-i)
246           pde=LinearPDE(mydomain)           pde=LinearPDE(domain)
247           pde.setSymmetryOn()           pde.setSymmetryOn()
248           pde.setValue(A=kronnecker,q=msk,r=u)           pde.setValue(A=kronecker(domain),q=msk,r=u)
249           return pde,u           return pde,u
250    
251  class Laplace2DOrder1_30k(LaplaceProblem):  class Laplace2DOrder1_30k(LaplaceProblem):
252      def __init__(self):     def __init__(self):
253           super(Laplace2DOrder1_30k,self).__init__(n=176,order=1,dim=2)        super(Laplace2DOrder1_30k,self).__init__(n=172,order=1,dim=2)
 class Laplace2DOrder2_30k(LaplaceProblem):  
     def __init__(self):  
          super(Laplace2DOrder2_30k,self).__init__(n=88,order=2,dim=2)  
254  class Laplace2DOrder1_60k(LaplaceProblem):  class Laplace2DOrder1_60k(LaplaceProblem):
255      def __init__(self):     def __init__(self):
256           super(Laplace2DOrder1_60k,self).__init__(n=248,order=1,dim=2)        super(Laplace2DOrder1_60k,self).__init__(n=244,order=1,dim=2)
 class Laplace2DOrder2_60k(LaplaceProblem):  
     def __init__(self):  
          super(Laplace2DOrder2_60k,self).__init__(n=124,order=2,dim=2)  
257  class Laplace2DOrder1_120k(LaplaceProblem):  class Laplace2DOrder1_120k(LaplaceProblem):
258      def __init__(self):     def __init__(self):
259           super(Laplace2DOrder1_120k,self).__init__(n=349,order=1,dim=2)        super(Laplace2DOrder1_120k,self).__init__(n=345,order=1,dim=2)
 class Laplace2DOrder2_120k(LaplaceProblem):  
     def __init__(self):  
          super(Laplace2DOrder2_120k,self).__init__(n=175,order=2,dim=2)  
260  class Laplace2DOrder1_240k(LaplaceProblem):  class Laplace2DOrder1_240k(LaplaceProblem):
261      def __init__(self):     def __init__(self):
262           super(Laplace2DOrder1_240k,self).__init__(n=492,order=1,dim=2)        super(Laplace2DOrder1_240k,self).__init__(n=489,order=1,dim=2)
 class Laplace2DOrder2_240k(LaplaceProblem):  
     def __init__(self):  
          super(Laplace2DOrder2_240k,self).__init__(n=246,order=2,dim=2)  
263  class Laplace2DOrder1_480k(LaplaceProblem):  class Laplace2DOrder1_480k(LaplaceProblem):
264      def __init__(self):     def __init__(self):
265           super(Laplace2DOrder1_480k,self).__init__(n=694,order=1,dim=2)        super(Laplace2DOrder1_480k,self).__init__(n=692,order=1,dim=2)
 class Laplace2DOrder2_480k(LaplaceProblem):  
     def __init__(self):  
          super(Laplace2DOrder2_480k,self).__init__(n=347,order=2,dim=2)  
266  class Laplace2DOrder1_960k(LaplaceProblem):  class Laplace2DOrder1_960k(LaplaceProblem):
267      def __init__(self):     def __init__(self):
268           super(Laplace2DOrder1_960k,self).__init__(n=978,order=1,dim=2)        super(Laplace2DOrder1_960k,self).__init__(n=979,order=1,dim=2)
269    class Laplace2DOrder1_1920k(LaplaceProblem):
270       def __init__(self):
271          super(Laplace2DOrder1_1920k,self).__init__(n=1385,order=1,dim=2)
272    class Laplace2DOrder1_3840k(LaplaceProblem):
273       def __init__(self):
274          super(Laplace2DOrder1_3840k,self).__init__(n=1959,order=1,dim=2)
275    class Laplace2DOrder1_7680k(LaplaceProblem):
276       def __init__(self):
277          super(Laplace2DOrder1_7680k,self).__init__(n=2770,order=1,dim=2)
278    class Laplace2DOrder1_15360k(LaplaceProblem):
279       def __init__(self):
280          super(Laplace2DOrder1_15360k,self).__init__(n=3918,order=1,dim=2)
281    class Laplace2DOrder2_30k(LaplaceProblem):
282       def __init__(self):
283          super(Laplace2DOrder2_30k,self).__init__(n=86,order=2,dim=2)
284    class Laplace2DOrder2_60k(LaplaceProblem):
285       def __init__(self):
286          super(Laplace2DOrder2_60k,self).__init__(n=122,order=2,dim=2)
287    class Laplace2DOrder2_120k(LaplaceProblem):
288       def __init__(self):
289          super(Laplace2DOrder2_120k,self).__init__(n=173,order=2,dim=2)
290    class Laplace2DOrder2_240k(LaplaceProblem):
291       def __init__(self):
292          super(Laplace2DOrder2_240k,self).__init__(n=244,order=2,dim=2)
293    class Laplace2DOrder2_480k(LaplaceProblem):
294       def __init__(self):
295          super(Laplace2DOrder2_480k,self).__init__(n=346,order=2,dim=2)
296  class Laplace2DOrder2_960k(LaplaceProblem):  class Laplace2DOrder2_960k(LaplaceProblem):
297      def __init__(self):     def __init__(self):
298           super(Laplace2DOrder2_960k,self).__init__(n=489,order=2,dim=2)        super(Laplace2DOrder2_960k,self).__init__(n=489,order=2,dim=2)
299    class Laplace2DOrder2_1920k(LaplaceProblem):
300       def __init__(self):
301          super(Laplace2DOrder2_1920k,self).__init__(n=692,order=2,dim=2)
302    class Laplace2DOrder2_3840k(LaplaceProblem):
303       def __init__(self):
304          super(Laplace2DOrder2_3840k,self).__init__(n=979,order=2,dim=2)
305    class Laplace2DOrder2_7680k(LaplaceProblem):
306       def __init__(self):
307          super(Laplace2DOrder2_7680k,self).__init__(n=1385,order=2,dim=2)
308    class Laplace2DOrder2_15360k(LaplaceProblem):
309       def __init__(self):
310          super(Laplace2DOrder2_15360k,self).__init__(n=1959,order=2,dim=2)
311    class Laplace3DOrder1_30k(LaplaceProblem):
312       def __init__(self):
313          super(Laplace3DOrder1_30k,self).__init__(n=30,order=1,dim=3)
314    class Laplace3DOrder1_60k(LaplaceProblem):
315       def __init__(self):
316          super(Laplace3DOrder1_60k,self).__init__(n=38,order=1,dim=3)
317    class Laplace3DOrder1_120k(LaplaceProblem):
318       def __init__(self):
319          super(Laplace3DOrder1_120k,self).__init__(n=48,order=1,dim=3)
320    class Laplace3DOrder1_240k(LaplaceProblem):
321       def __init__(self):
322          super(Laplace3DOrder1_240k,self).__init__(n=61,order=1,dim=3)
323    class Laplace3DOrder1_480k(LaplaceProblem):
324       def __init__(self):
325          super(Laplace3DOrder1_480k,self).__init__(n=77,order=1,dim=3)
326    class Laplace3DOrder1_960k(LaplaceProblem):
327       def __init__(self):
328          super(Laplace3DOrder1_960k,self).__init__(n=98,order=1,dim=3)
329    class Laplace3DOrder1_1920k(LaplaceProblem):
330       def __init__(self):
331          super(Laplace3DOrder1_1920k,self).__init__(n=123,order=1,dim=3)
332    class Laplace3DOrder1_3840k(LaplaceProblem):
333       def __init__(self):
334          super(Laplace3DOrder1_3840k,self).__init__(n=156,order=1,dim=3)
335    class Laplace3DOrder1_7680k(LaplaceProblem):
336       def __init__(self):
337          super(Laplace3DOrder1_7680k,self).__init__(n=196,order=1,dim=3)
338    class Laplace3DOrder1_15360k(LaplaceProblem):
339       def __init__(self):
340          super(Laplace3DOrder1_15360k,self).__init__(n=248,order=1,dim=3)
341    class Laplace3DOrder2_30k(LaplaceProblem):
342       def __init__(self):
343          super(Laplace3DOrder2_30k,self).__init__(n=15,order=2,dim=3)
344    class Laplace3DOrder2_60k(LaplaceProblem):
345       def __init__(self):
346          super(Laplace3DOrder2_60k,self).__init__(n=19,order=2,dim=3)
347    class Laplace3DOrder2_120k(LaplaceProblem):
348       def __init__(self):
349          super(Laplace3DOrder2_120k,self).__init__(n=24,order=2,dim=3)
350    class Laplace3DOrder2_240k(LaplaceProblem):
351       def __init__(self):
352          super(Laplace3DOrder2_240k,self).__init__(n=31,order=2,dim=3)
353    class Laplace3DOrder2_480k(LaplaceProblem):
354       def __init__(self):
355          super(Laplace3DOrder2_480k,self).__init__(n=39,order=2,dim=3)
356    class Laplace3DOrder2_960k(LaplaceProblem):
357       def __init__(self):
358          super(Laplace3DOrder2_960k,self).__init__(n=49,order=2,dim=3)
359    class Laplace3DOrder2_1920k(LaplaceProblem):
360       def __init__(self):
361          super(Laplace3DOrder2_1920k,self).__init__(n=62,order=2,dim=3)
362    class Laplace3DOrder2_3840k(LaplaceProblem):
363       def __init__(self):
364          super(Laplace3DOrder2_3840k,self).__init__(n=78,order=2,dim=3)
365    class Laplace3DOrder2_7680k(LaplaceProblem):
366       def __init__(self):
367          super(Laplace3DOrder2_7680k,self).__init__(n=98,order=2,dim=3)
368    class Laplace3DOrder2_15360k(LaplaceProblem):
369       def __init__(self):
370          super(Laplace3DOrder2_15360k,self).__init__(n=124,order=2,dim=3)
371    
372    if __name__=="__main__":
373       test=""
374       n0=30000
375       for d in [2,3]:
376         for o in [1,2]:
377            for i in range(10):
378                 dofs=n0*2**i
379                 n=int((float(dofs)**(1./float(d))-1)/o+0.5)
380                 name="Laplace%sDOrder%s_%sk"%(d,o,dofs/1000)
381                 print "class %s(LaplaceProblem):"%name
382                 print "   def __init__(self):"
383                 print "      super(%s,self).__init__(n=%s,order=%s,dim=%s)"%(name,n,o,d)
384                 test+="addProblem(%s())\n"%name
385       print test
386    

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

  ViewVC Help
Powered by ViewVC 1.1.26