/[escript]/trunk/escriptcore/test/python/test_linearPDEs.py
ViewVC logotype

Diff of /trunk/escriptcore/test/python/test_linearPDEs.py

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

revision 4820 by sshaw, Thu Mar 20 23:53:44 2014 UTC revision 4821 by sshaw, Tue Apr 1 04:58:33 2014 UTC
# Line 31  __author__="Lutz Gross, l.gross@uq.edu.a Line 31  __author__="Lutz Gross, l.gross@uq.edu.a
31    
32  from esys.escript.util import Lsup,kronecker,interpolate,whereZero, outer, swap_axes  from esys.escript.util import Lsup,kronecker,interpolate,whereZero, outer, swap_axes
33  from esys.escript import Function,FunctionOnBoundary,FunctionOnContactZero,Solution,ReducedSolution,Vector,ContinuousFunction,Scalar, ReducedFunction,ReducedFunctionOnBoundary,ReducedFunctionOnContactZero,Data, Tensor4, Tensor, getEscriptParamInt, canInterpolate  from esys.escript import Function,FunctionOnBoundary,FunctionOnContactZero,Solution,ReducedSolution,Vector,ContinuousFunction,Scalar, ReducedFunction,ReducedFunctionOnBoundary,ReducedFunctionOnContactZero,Data, Tensor4, Tensor, getEscriptParamInt, canInterpolate
34  from esys.escript.linearPDEs import LinearPDE,IllegalCoefficientValue,Poisson, IllegalCoefficientFunctionSpace, TransportPDE, IllegalCoefficient, Helmholtz, LameEquation, SolverOptions  from esys.escript.linearPDEs import SolverBuddy, LinearPDE,IllegalCoefficientValue,Poisson, IllegalCoefficientFunctionSpace, TransportPDE, IllegalCoefficient, Helmholtz, LameEquation, SolverOptions
35  import numpy  import numpy
36  import unittest  import unittest
37    
# Line 390  class Test_LinearPDE_noLumping(Test_line Line 390  class Test_LinearPDE_noLumping(Test_line
390      N=4      N=4
391    
392      def test_SolverOptions(self):      def test_SolverOptions(self):
393          so=SolverOptions()          sb=SolverBuddy()
394            so=SolverOptions
395            self.assertTrue(sb.getSmoother() == 28, "initial Smoother is wrong.")
396            self.assertRaises(ValueError,sb.setSmoother,-1)
397            sb.setSmoother(so.GAUSS_SEIDEL)
398            self.assertTrue(sb.getSmoother() == 28, "Gauss-Seidel smoother is not set.")
399            sb.setSmoother(so.JACOBI)
400            self.assertTrue(sb.getSmoother() == 10, "Jacobi smoother is not set.")
401    
402            self.assertTrue(sb.getLevelMax() == 100, "initial  LevelMax is wrong.")
403            self.assertRaises(ValueError,sb.setLevelMax,-1)
404            sb.setLevelMax(20)
405            self.assertTrue(sb.getLevelMax() == 20, "LevelMax is wrong.")
406    
407            self.assertTrue(sb.getCoarseningThreshold() == 0.25, "initial  CoarseningThreshold is wrong.")
408            self.assertRaises(ValueError,sb.setCoarseningThreshold,-1)
409            sb.setCoarseningThreshold(0.1)
410            self.assertTrue(sb.getCoarseningThreshold() == 0.1, "CoarseningThreshold is wrong.")
411                    
412          self.assertTrue(so.getSmoother() == 28, "initial Smoother is wrong.")          self.assertTrue(sb.getMinCoarseMatrixSize() == 500, "initial  Minimum Coarse Matrix Size is wrong.")
413          self.assertRaises(ValueError,so.setSmoother,-1)          self.assertRaises(ValueError,sb.setMinCoarseMatrixSize,-1)
414          so.setSmoother(so.GAUSS_SEIDEL)          sb.setMinCoarseMatrixSize(1000)
415          self.assertTrue(so.getSmoother() == 28, "Gauss-Seidel smoother is not set.")          self.assertTrue(sb.getMinCoarseMatrixSize() == 1000, "Minimum Coarse Matrix Size is wrong.")
416          so.setSmoother(so.JACOBI)  
417          self.assertTrue(so.getSmoother() == 10, "Jacobi smoother is not set.")          self.assertTrue(sb.getNumSweeps() == 1, "initial  Sweeps is wrong.")
418            self.assertRaises(ValueError,sb.setNumSweeps,-1)
419          self.assertTrue(so.getLevelMax() == 100, "initial  LevelMax is wrong.")          sb.setNumSweeps(3)
420          self.assertRaises(ValueError,so.setLevelMax,-1)          self.assertTrue(sb.getNumSweeps() == 3, "Sweeps is wrong.")
421          so.setLevelMax(20)  
422          self.assertTrue(so.getLevelMax() == 20, "LevelMax is wrong.")          self.assertTrue(sb.getNumPreSweeps() == 1, "initial  PreSweeps is wrong.")
423            self.assertRaises(ValueError,sb.setNumPreSweeps,-1)
424          self.assertTrue(so.getCoarseningThreshold() == 0.25, "initial  CoarseningThreshold is wrong.")          sb.setNumPreSweeps(4)
425          self.assertRaises(ValueError,so.setCoarseningThreshold,-1)          self.assertTrue(sb.getNumPreSweeps() == 4, "PreSweeps is wrong.")
426          so.setCoarseningThreshold(0.1)  
427          self.assertTrue(so.getCoarseningThreshold() == 0.1, "CoarseningThreshold is wrong.")          self.assertTrue(sb.getNumPostSweeps() == 1, "initial  PostSweeps is wrong.")
428            self.assertRaises(ValueError,sb.setNumPostSweeps,-1)
429            sb.setNumPostSweeps(5)
430            self.assertTrue(sb.getNumPostSweeps() == 5, "PostSweeps is wrong.")
431    
432            self.assertTrue(sb.getTolerance() == 1.e-8, "initial Tolerance is wrong.")
433            self.assertRaises(ValueError,sb.setTolerance,-1)
434            sb.setTolerance(0.2)
435            self.assertTrue(sb.getTolerance() == 0.2, "Tolerance is wrong.")
436    
437            self.assertTrue(sb.getAbsoluteTolerance() == 0., "initial  AbsoluteTolerance is wrong.")
438            self.assertRaises(ValueError,sb.setAbsoluteTolerance,-1)
439            sb.setAbsoluteTolerance(0.3)
440            self.assertTrue(sb.getAbsoluteTolerance() == 0.3, "AbsoluteTolerance is wrong.")
441    
442            self.assertTrue(sb.getInnerTolerance() == 0.9, "initial InnerTolerance is wrong.")
443            self.assertRaises(ValueError,sb.setInnerTolerance,-1)
444            sb.setInnerTolerance(0.4)
445            self.assertTrue(sb.getInnerTolerance() == 0.4, "InnerTolerance is wrong.")
446    
447            self.assertTrue(sb.getDropTolerance() == 0.01, "initial DropTolerance is wrong.")
448            self.assertRaises(ValueError,sb.setDropTolerance,-1)
449            sb.setDropTolerance(0.5)
450            self.assertTrue(sb.getDropTolerance() == 0.5, "DropDropTolerance is wrong.")
451    
452            self.assertTrue(sb.getDropStorage() == 2., "initial DropStorage is wrong.")
453            self.assertRaises(ValueError,sb.setDropStorage,-1)
454            sb.setDropStorage(10)
455            self.assertTrue(sb.getDropStorage() == 10, "DropStorage is wrong.")
456                    
457          self.assertTrue(so.getMinCoarseMatrixSize() == 500, "initial  Minimum Coarse Matrix Size is wrong.")          self.assertTrue(sb.getRelaxationFactor() == 0.3, "initial RelaxationFactor is wrong.")
458          self.assertRaises(ValueError,so.setMinCoarseMatrixSize,-1)          self.assertRaises(ValueError,sb.setRelaxationFactor,-1)
459          so.setMinCoarseMatrixSize(1000)          sb.setRelaxationFactor(0.1)
460          self.assertTrue(so.getMinCoarseMatrixSize() == 1000, "Minimum Coarse Matrix Size is wrong.")          self.assertTrue(sb.getRelaxationFactor() == 0.1, "Relaxation is wrong.")
461    
462          self.assertTrue(so.getNumSweeps() == 1, "initial  Sweeps is wrong.")  
463          self.assertRaises(ValueError,so.setNumSweeps,-1)          self.assertTrue(sb.getIterMax() == 100000, "initial IterMax is wrong.")
464          so.setNumSweeps(3)          self.assertRaises(ValueError,sb.setIterMax,0)
465          self.assertTrue(so.getNumSweeps() == 3, "Sweeps is wrong.")          sb.setIterMax(11)
466            self.assertTrue(sb.getIterMax() == 11, "IterMax is wrong.")
467          self.assertTrue(so.getNumPreSweeps() == 1, "initial  PreSweeps is wrong.")  
468          self.assertRaises(ValueError,so.setNumPreSweeps,-1)          self.assertTrue(sb.getInnerIterMax() == 10, "initial InnerIterMax is wrong.")
469          so.setNumPreSweeps(4)          self.assertRaises(ValueError,sb.setInnerIterMax,0)
470          self.assertTrue(so.getNumPreSweeps() == 4, "PreSweeps is wrong.")          sb.setInnerIterMax(12)
471            self.assertTrue(sb.getInnerIterMax() == 12, "InnerIterMax is wrong.")
472          self.assertTrue(so.getNumPostSweeps() == 1, "initial  PostSweeps is wrong.")  
473          self.assertRaises(ValueError,so.setNumPostSweeps,-1)          self.assertTrue(sb.getTruncation() == 20, "initial Truncation is wrong.")
474          so.setNumPostSweeps(5)          self.assertRaises(ValueError,sb.setTruncation,0)
475          self.assertTrue(so.getNumPostSweeps() == 5, "PostSweeps is wrong.")          sb.setTruncation(13)
476            self.assertTrue(sb.getTruncation() == 13, "Truncation is wrong.")
477          self.assertTrue(so.getTolerance() == 1.e-8, "initial Tolerance is wrong.")  
478          self.assertRaises(ValueError,so.setTolerance,-1)          self.assertTrue(sb.getRestart() == 0, "initial Truncation is wrong.")
479          so.setTolerance(0.2)          self.assertRaises(ValueError,sb.setTruncation,0)
480          self.assertTrue(so.getTolerance() == 0.2, "Tolerance is wrong.")          sb.setRestart(14)
481            self.assertTrue(sb.getRestart() == 14, "Truncation is wrong.")
482          self.assertTrue(so.getAbsoluteTolerance() == 0., "initial  AbsoluteTolerance is wrong.")          sb.setRestart(0)
483          self.assertRaises(ValueError,so.setAbsoluteTolerance,-1)          self.assertTrue(sb.getRestart() == 0, "Truncation is wrong.")
         so.setAbsoluteTolerance(0.3)  
         self.assertTrue(so.getAbsoluteTolerance() == 0.3, "AbsoluteTolerance is wrong.")  
   
         self.assertTrue(so.getInnerTolerance() == 0.9, "initial InnerTolerance is wrong.")  
         self.assertRaises(ValueError,so.setInnerTolerance,-1)  
         so.setInnerTolerance(0.4)  
         self.assertTrue(so.getInnerTolerance() == 0.4, "InnerTolerance is wrong.")  
   
         self.assertTrue(so.getDropTolerance() == 0.01, "initial DropTolerance is wrong.")  
         self.assertRaises(ValueError,so.setDropTolerance,-1)  
         so.setDropTolerance(0.5)  
         self.assertTrue(so.getDropTolerance() == 0.5, "DropDropTolerance is wrong.")  
   
         self.assertTrue(so.getDropStorage() == 2., "initial DropStorage is wrong.")  
         self.assertRaises(ValueError,so.setDropStorage,-1)  
         so.setDropStorage(10)  
         self.assertTrue(so.getDropStorage() == 10, "DropStorage is wrong.")  
484                    
485          self.assertTrue(so.getRelaxationFactor() == 0.3, "initial RelaxationFactor is wrong.")          self.assertTrue(not sb.isVerbose(), "initial verbosity flag is wrong.")
486          self.assertRaises(ValueError,so.setRelaxationFactor,-1)          sb.setVerbosityOn()
487          so.setRelaxationFactor(0.1)          self.assertTrue(sb.isVerbose(), "verbosity (1) flag is wrong.")
488          self.assertTrue(so.getRelaxationFactor() == 0.1, "Relaxation is wrong.")          sb.setVerbosityOff()
489            self.assertTrue(not sb.isVerbose(), "verbosity (2) flag is wrong.")
490            sb.setVerbosity(True)
491          self.assertTrue(so.getIterMax() == 100000, "initial IterMax is wrong.")          self.assertTrue(sb.isVerbose(), "verbosity (3) flag is wrong.")
492          self.assertRaises(ValueError,so.setIterMax,0)          sb.setVerbosity(False)
493          so.setIterMax(11)          self.assertTrue(not sb.isVerbose(), "verbosity (4) flag is wrong.")
494          self.assertTrue(so.getIterMax() == 11, "IterMax is wrong.")  
495            self.assertTrue(not sb.isSymmetric(), "initial symmetry flag is wrong.")
496          self.assertTrue(so.getInnerIterMax() == 10, "initial InnerIterMax is wrong.")          sb.setSymmetryOn()
497          self.assertRaises(ValueError,so.setInnerIterMax,0)          self.assertTrue(sb.isSymmetric(), "symmetry (1) flag is wrong.")
498          so.setInnerIterMax(12)          sb.setSymmetryOff()
499          self.assertTrue(so.getInnerIterMax() == 12, "InnerIterMax is wrong.")          self.assertTrue(not sb.isSymmetric(), "symmetry (2) flag is wrong.")
500            sb.setSymmetry(True)
501          self.assertTrue(so.getTruncation() == 20, "initial Truncation is wrong.")          self.assertTrue(sb.isSymmetric(), "symmetry (3) flag is wrong.")
502          self.assertRaises(ValueError,so.setTruncation,0)          sb.setSymmetry(False)
503          so.setTruncation(13)          self.assertTrue(not sb.isSymmetric(), "symmetry (4) flag is wrong.")
504          self.assertTrue(so.getTruncation() == 13, "Truncation is wrong.")  
505            self.assertTrue(sb.adaptInnerTolerance(), "initial InnerToleranceAdaption flag is wrong.")
506          self.assertTrue(so.getRestart() == None, "initial Truncation is wrong.")          sb.setInnerToleranceAdaptionOn()
507          self.assertRaises(ValueError,so.setTruncation,0)          self.assertTrue(sb.adaptInnerTolerance(), "InnerToleranceAdaption (1) flag is wrong.")
508          so.setRestart(14)          sb.setInnerToleranceAdaptionOff()
509          self.assertTrue(so.getRestart() == 14, "Truncation is wrong.")          self.assertTrue(not sb.adaptInnerTolerance(), "InnerToleranceAdaption (2) flag is wrong.")
510          so.setRestart(None)          sb.setInnerToleranceAdaption(adapt=True)
511          self.assertTrue(so.getRestart() == None, "Truncation is wrong.")          self.assertTrue(sb.adaptInnerTolerance(), "InnerToleranceAdaption (3) flag is wrong.")
512                    sb.setInnerToleranceAdaption(adapt=False)
513          self.assertTrue(not so.isVerbose(), "initial verbosity flag is wrong.")          self.assertTrue(not sb.adaptInnerTolerance(), "InnerToleranceAdaption (4) flag is wrong.")
         so.setVerbosityOn()  
         self.assertTrue(so.isVerbose(), "verbosity (1) flag is wrong.")  
         so.setVerbosityOff()  
         self.assertTrue(not so.isVerbose(), "verbosity (2) flag is wrong.")  
         so.setVerbosity(verbose=True)  
         self.assertTrue(so.isVerbose(), "verbosity (3) flag is wrong.")  
         so.setVerbosity(verbose=False)  
         self.assertTrue(not so.isVerbose(), "verbosity (4) flag is wrong.")  
   
         self.assertTrue(not so.isSymmetric(), "initial symmetry flag is wrong.")  
         so.setSymmetryOn()  
         self.assertTrue(so.isSymmetric(), "symmetry (1) flag is wrong.")  
         so.setSymmetryOff()  
         self.assertTrue(not so.isSymmetric(), "symmetry (2) flag is wrong.")  
         so.setSymmetry(flag=True)  
         self.assertTrue(so.isSymmetric(), "symmetry (3) flag is wrong.")  
         so.setSymmetry(flag=False)  
         self.assertTrue(not so.isSymmetric(), "symmetry (4) flag is wrong.")  
   
         self.assertTrue(so.adaptInnerTolerance(), "initial InnerToleranceAdaption flag is wrong.")  
         so.setInnerToleranceAdaptionOn()  
         self.assertTrue(so.adaptInnerTolerance(), "InnerToleranceAdaption (1) flag is wrong.")  
         so.setInnerToleranceAdaptionOff()  
         self.assertTrue(not so.adaptInnerTolerance(), "InnerToleranceAdaption (2) flag is wrong.")  
         so.setInnerToleranceAdaption(adapt=True)  
         self.assertTrue(so.adaptInnerTolerance(), "InnerToleranceAdaption (3) flag is wrong.")  
         so.setInnerToleranceAdaption(adapt=False)  
         self.assertTrue(not so.adaptInnerTolerance(), "InnerToleranceAdaption (4) flag is wrong.")  
514            
515          self.assertTrue(not so.acceptConvergenceFailure(), "initial acceptConvergenceFailure flag is wrong.")          self.assertTrue(not sb.acceptConvergenceFailure(), "initial acceptConvergenceFailure flag is wrong.")
516          so.setAcceptanceConvergenceFailureOn()          sb.setAcceptanceConvergenceFailureOn()
517          self.assertTrue(so.acceptConvergenceFailure(), "acceptConvergenceFailure (1) flag is wrong.")          self.assertTrue(sb.acceptConvergenceFailure(), "acceptConvergenceFailure (1) flag is wrong.")
518          so.setAcceptanceConvergenceFailureOff()          sb.setAcceptanceConvergenceFailureOff()
519          self.assertTrue(not so.acceptConvergenceFailure(), "acceptConvergenceFailure (2) flag is wrong.")          self.assertTrue(not sb.acceptConvergenceFailure(), "acceptConvergenceFailure (2) flag is wrong.")
520          so.setAcceptanceConvergenceFailure(accept=True)          sb.setAcceptanceConvergenceFailure(accept=True)
521          self.assertTrue(so.acceptConvergenceFailure(), "acceptConvergenceFailure (3) flag is wrong.")          self.assertTrue(sb.acceptConvergenceFailure(), "acceptConvergenceFailure (3) flag is wrong.")
522          so.setAcceptanceConvergenceFailure(accept=False)          sb.setAcceptanceConvergenceFailure(accept=False)
523          self.assertTrue(not so.acceptConvergenceFailure(), "acceptConvergenceFailure (4) flag is wrong.")            self.assertTrue(not sb.acceptConvergenceFailure(), "acceptConvergenceFailure (4) flag is wrong.")  
524                    
525          self.assertTrue(so.getReordering() == 30, "initial Reordering is wrong.")          self.assertTrue(sb.getReordering() == 30, "initial Reordering is wrong.")
526          self.assertRaises(ValueError,so.setReordering,-1)          self.assertRaises(ValueError,sb.setReordering,-1)
527          so.setReordering(so.NO_REORDERING)          sb.setReordering(so.NO_REORDERING)
528          self.assertTrue(so.getReordering() == 17, "NO_REORDERING is not set.")          self.assertTrue(sb.getReordering() == 17, "NO_REORDERING is not set.")
529          so.setReordering(so.MINIMUM_FILL_IN)          sb.setReordering(so.MINIMUM_FILL_IN)
530          self.assertTrue(so.getReordering() == 18, "MINIMUM_FILL_IN is not set.")          self.assertTrue(sb.getReordering() == 18, "MINIMUM_FILL_IN is not set.")
531          so.setReordering(so.NESTED_DISSECTION)          sb.setReordering(so.NESTED_DISSECTION)
532          self.assertTrue(so.getReordering() == 19, "NESTED_DISSECTION is not set.")          self.assertTrue(sb.getReordering() == 19, "NESTED_DISSECTION is not set.")
533          so.setReordering(so.DEFAULT_REORDERING)          sb.setReordering(so.DEFAULT_REORDERING)
534          self.assertTrue(so.getReordering() == 30, "DEFAULT_REORDERING is not set.")          self.assertTrue(sb.getReordering() == 30, "DEFAULT_REORDERING is not set.")
535                    
536          self.assertTrue(so.getPackage() == 0, "initial solver package is wrong.")          self.assertTrue(sb.getPackage() == 0, "initial solver package is wrong.")
537          self.assertRaises(ValueError,so.setPackage,-1)          self.assertRaises(ValueError,sb.setPackage,-1)
538          so.setPackage(so.PASO)          sb.setPackage(so.PASO)
539          self.assertTrue(so.getPackage() == 21, "PASO is not set.")          self.assertTrue(sb.getPackage() == 21, "PASO is not set.")
540          so.setPackage(so.SUPER_LU)          sb.setPackage(so.SUPER_LU)
541          self.assertTrue(so.getPackage() == 31, "SUPER_LU is not set.")          self.assertTrue(sb.getPackage() == 31, "SUPER_LU is not set.")
542          so.setPackage(so.PASTIX)          sb.setPackage(so.PASTIX)
543          self.assertTrue(so.getPackage() == 32, "PASTIX is not set.")          self.assertTrue(sb.getPackage() == 32, "PASTIX is not set.")
544          so.setPackage(so.MKL)          sb.setPackage(so.MKL)
545          self.assertTrue(so.getPackage() == 15, "MKL is not set.")          self.assertTrue(sb.getPackage() == 15, "MKL is not set.")
546          so.setPackage(so.UMFPACK)          sb.setPackage(so.UMFPACK)
547          self.assertTrue(so.getPackage() == 16, "UMFPACK is not set.")          self.assertTrue(sb.getPackage() == 16, "UMFPACK is not set.")
548          so.setPackage(so.TRILINOS)          sb.setPackage(so.TRILINOS)
549          self.assertTrue(so.getPackage() == 24, "TRILINOS is not set.")          self.assertTrue(sb.getPackage() == 24, "TRILINOS is not set.")
550    
551          self.assertTrue(so.getSolverMethod() == 0, "initial SolverMethod is wrong.")          self.assertTrue(sb.getSolverMethod() == 0, "initial SolverMethod is wrong.")
552          self.assertRaises(ValueError,so.setSolverMethod,-1)          self.assertRaises(ValueError,sb.setSolverMethod,-1)
553          so.setSolverMethod(so.DIRECT)          sb.setSolverMethod(so.DIRECT)
554          self.assertTrue(so.getSolverMethod() == 1, "DIRECT is not set.")          self.assertTrue(sb.getSolverMethod() == 1, "DIRECT is not set.")
555          so.setSolverMethod(so.CHOLEVSKY)          sb.setSolverMethod(so.CHOLEVSKY)
556          self.assertTrue(so.getSolverMethod() == 2, "CHOLEVSKY is not set.")          self.assertTrue(sb.getSolverMethod() == 2, "CHOLEVSKY is not set.")
557          so.setSolverMethod(so.PCG)          sb.setSolverMethod(so.PCG)
558          self.assertTrue(so.getSolverMethod() == 3, "PCG is not set.")          self.assertTrue(sb.getSolverMethod() == 3, "PCG is not set.")
559          so.setSolverMethod(so.CR)          sb.setSolverMethod(so.CR)
560          self.assertTrue(so.getSolverMethod() == 4, "CR is not set.")          self.assertTrue(sb.getSolverMethod() == 4, "CR is not set.")
561          so.setSolverMethod(so.CGS)          sb.setSolverMethod(so.CGS)
562          self.assertTrue(so.getSolverMethod() == 5, "CGS is not set.")          self.assertTrue(sb.getSolverMethod() == 5, "CGS is not set.")
563          so.setSolverMethod(so.BICGSTAB)          sb.setSolverMethod(so.BICGSTAB)
564          self.assertTrue(so.getSolverMethod() == 6, "BICGSTAB is not set.")          self.assertTrue(sb.getSolverMethod() == 6, "BICGSTAB is not set.")
565          so.setSolverMethod(so.GMRES)          sb.setSolverMethod(so.GMRES)
566          self.assertTrue(so.getSolverMethod() == 11, "GMRES is not set.")          self.assertTrue(sb.getSolverMethod() == 11, "GMRES is not set.")
567          so.setSolverMethod(so.PRES20)          sb.setSolverMethod(so.PRES20)
568          self.assertTrue(so.getSolverMethod() == 12, "PRES20 is not set.")          self.assertTrue(sb.getSolverMethod() == 12, "PRES20 is not set.")
569          so.setSolverMethod(so.LUMPING)          sb.setSolverMethod(so.LUMPING)
570          self.assertTrue(so.getSolverMethod() == 13, "LUMPING is not set.")          self.assertTrue(sb.getSolverMethod() == 13, "LUMPING is not set.")
571          so.setSolverMethod(so.ITERATIVE)          sb.setSolverMethod(so.ITERATIVE)
572          self.assertTrue(so.getSolverMethod() == 20, "ITERATIVE is not set.")          self.assertTrue(sb.getSolverMethod() == 20, "ITERATIVE is not set.")
573          so.setSolverMethod(so.NONLINEAR_GMRES)          sb.setSolverMethod(so.NONLINEAR_GMRES)
574          self.assertTrue(so.getSolverMethod() == 25, "NONLINEAR_GMRES is not set.")          self.assertTrue(sb.getSolverMethod() == 25, "NONLINEAR_GMRES is not set.")
575          so.setSolverMethod(so.TFQMR)          sb.setSolverMethod(so.TFQMR)
576          self.assertTrue(so.getSolverMethod() == 26, "TFQMR is not set.")          self.assertTrue(sb.getSolverMethod() == 26, "TFQMR is not set.")
577          so.setSolverMethod(so.MINRES)          sb.setSolverMethod(so.MINRES)
578          self.assertTrue(so.getSolverMethod() == 27, "MINRES is not set.")          self.assertTrue(sb.getSolverMethod() == 27, "MINRES is not set.")
579          so.setSolverMethod(so.DEFAULT)          sb.setSolverMethod(so.DEFAULT)
580          self.assertTrue(so.getSolverMethod() == 0, "DEFAULT is not set.")          self.assertTrue(sb.getSolverMethod() == 0, "DEFAULT is not set.")
581    
582          self.assertTrue(so.getPreconditioner() == 10, "initial Preconditioner is wrong.")          self.assertTrue(sb.getPreconditioner() == 10, "initial Preconditioner is wrong.")
583          self.assertRaises(ValueError,so.setPreconditioner,-1)          self.assertRaises(ValueError,sb.setPreconditioner,-1)
584          so.setPreconditioner(so.ILU0)          sb.setPreconditioner(so.ILU0)
585          self.assertTrue(so.getPreconditioner() == 8, "ILU0 is not set.")          self.assertTrue(sb.getPreconditioner() == 8, "ILU0 is not set.")
586          so.setPreconditioner(so.ILUT)          sb.setPreconditioner(so.ILUT)
587          self.assertTrue(so.getPreconditioner() == 9, "ILUT is not set.")          self.assertTrue(sb.getPreconditioner() == 9, "ILUT is not set.")
588          so.setPreconditioner(so.JACOBI)          sb.setPreconditioner(so.JACOBI)
589          self.assertTrue(so.getPreconditioner() == 10, "JACOBI is not set.")          self.assertTrue(sb.getPreconditioner() == 10, "JACOBI is not set.")
590          if getEscriptParamInt('DISABLE_AMG', 0):          if getEscriptParamInt('DISABLE_AMG', 0):
591              print("AMG test disabled on MPI build")              print("AMG test disabled on MPI build")
592          else:          else:
593              so.setPreconditioner(so.AMG)              sb.setPreconditioner(so.AMG)
594              self.assertTrue(so.getPreconditioner() == 22, "AMG is not set.")              self.assertTrue(sb.getPreconditioner() == 22, "AMG is not set.")
595          so.setPreconditioner(so.REC_ILU)          sb.setPreconditioner(so.REC_ILU)
596          self.assertTrue(so.getPreconditioner() == 23, "REC_ILU is not set.")          self.assertTrue(sb.getPreconditioner() == 23, "REC_ILU is not set.")
597          so.setPreconditioner(so.GAUSS_SEIDEL)          sb.setPreconditioner(so.GAUSS_SEIDEL)
598          self.assertTrue(so.getPreconditioner() == 28, "GAUSS_SEIDEL is not set.")          self.assertTrue(sb.getPreconditioner() == 28, "GAUSS_SEIDEL is not set.")
599          so.setPreconditioner(so.RILU)          sb.setPreconditioner(so.RILU)
600          self.assertTrue(so.getPreconditioner() == 29, "RILU is not set.")          self.assertTrue(sb.getPreconditioner() == 29, "RILU is not set.")
601          so.setPreconditioner(so.AMLI)          sb.setPreconditioner(so.AMLI)
602          self.assertTrue(so.getPreconditioner() == 38, "AMLI is not set.")          self.assertTrue(sb.getPreconditioner() == 38, "AMLI is not set.")
603          so.setPreconditioner(so.NO_PRECONDITIONER)          sb.setPreconditioner(so.NO_PRECONDITIONER)
604          self.assertTrue(so.getPreconditioner() == 36, "NO_PRECONDITIONER is not set.")                  self.assertTrue(sb.getPreconditioner() == 36, "NO_PRECONDITIONER is not set.")        
605    
606          self.assertTrue(so.getCoarsening() == 0, "initial Coarseningr is wrong.")          self.assertTrue(sb.getCoarsening() == 0, "initial Coarseningr is wrong.")
607          self.assertRaises(ValueError,so.setCoarsening,-1)          self.assertRaises(ValueError,sb.setCoarsening,-1)
608          so.setCoarsening(so.YAIR_SHAPIRA_COARSENING)          sb.setCoarsening(so.YAIR_SHAPIRA_COARSENING)
609          self.assertTrue(so.getCoarsening() == 33, "YAIR_SHAPIRA_COARSENING is not set.")          self.assertTrue(sb.getCoarsening() == 33, "YAIR_SHAPIRA_COARSENING is not set.")
610          so.setCoarsening(so.RUGE_STUEBEN_COARSENING)          sb.setCoarsening(so.RUGE_STUEBEN_COARSENING)
611          self.assertTrue(so.getCoarsening() == 34, "RUGE_STUEBEN_COARSENING is not set.")          self.assertTrue(sb.getCoarsening() == 34, "RUGE_STUEBEN_COARSENING is not set.")
612          so.setCoarsening(so.AGGREGATION_COARSENING)          sb.setCoarsening(so.AGGREGATION_COARSENING)
613          self.assertTrue(so.getCoarsening() == 35, "AGREGATION_COARSENING is not set.")          self.assertTrue(sb.getCoarsening() == 35, "AGREGATION_COARSENING is not set.")
614          so.setCoarsening(so.STANDARD_COARSENING)          sb.setCoarsening(so.STANDARD_COARSENING)
615          self.assertTrue(so.getCoarsening() == 39, "STANDARD_COARSENING is not set.")          self.assertTrue(sb.getCoarsening() == 39, "STANDARD_COARSENING is not set.")
616          so.setCoarsening(so.DEFAULT)          sb.setCoarsening(so.DEFAULT)
617          self.assertTrue(so.getCoarsening() == 0, "DEFAULT is not set.")          self.assertTrue(sb.getCoarsening() == 0, "DEFAULT is not set.")
618    
619          self.assertTrue(so.getDiagnostics("num_iter") == None, "initial num_iter is wrong.")          self.assertTrue(sb.getDiagnostics("num_iter") == 0, "initial num_iter is wrong.")
620          self.assertTrue(so.getDiagnostics("num_inner_iter") == None, "initial num_inner_iter is wrong.")          self.assertTrue(sb.getDiagnostics("num_inner_iter") == 0, "initial num_inner_iter is wrong.")
621          self.assertTrue(so.getDiagnostics("time") == None, "initial time is wrong.")          self.assertTrue(sb.getDiagnostics("time") == 0, "initial time is wrong.")
622          self.assertTrue(so.getDiagnostics("set_up_time") == None, "initial set_up_time is wrong.")          self.assertTrue(sb.getDiagnostics("set_up_time") == 0, "initial set_up_time is wrong.")
623          self.assertTrue(so.getDiagnostics("residual_norm") == None, "initial residual_norm is wrong.")          self.assertTrue(sb.getDiagnostics("residual_norm") == 0, "initial residual_norm is wrong.")
624          self.assertTrue(so.getDiagnostics("converged") == None, "initial converged is wrong.")          self.assertTrue(sb.getDiagnostics("converged") == 0, "initial converged is wrong.")
625          self.assertTrue(so.hasConverged() == None, "initial convergence flag is wrong.")          self.assertTrue(sb.hasConverged() == 0, "initial convergence flag is wrong.")
626          self.assertTrue(so.getDiagnostics("cum_num_inner_iter") == 0, "initial cum_num_inner_iter is wrong.")          self.assertTrue(sb.getDiagnostics("cum_num_inner_iter") == 0, "initial cum_num_inner_iter is wrong.")
627          self.assertTrue(so.getDiagnostics("cum_num_iter") == 0, "initial cum_num_iter is wrong.")          self.assertTrue(sb.getDiagnostics("cum_num_iter") == 0, "initial cum_num_iter is wrong.")
628          self.assertTrue(so.getDiagnostics("cum_time") ==0, "initial cum_time is wrong.")          self.assertTrue(sb.getDiagnostics("cum_time") ==0, "initial cum_time is wrong.")
629          self.assertTrue(so.getDiagnostics("cum_set_up_time") == 0, "initial cum_set_up_time is wrong.")          self.assertTrue(sb.getDiagnostics("cum_set_up_time") == 0, "initial cum_set_up_time is wrong.")
630    
631          so._updateDiagnostics("num_iter",1)          sb._updateDiagnostics("num_iter",1)
632          so._updateDiagnostics("num_inner_iter",2)          sb._updateDiagnostics("num_inner_iter",2)
633          so._updateDiagnostics("time",3)          sb._updateDiagnostics("time",3)
634          so._updateDiagnostics("set_up_time",4)          sb._updateDiagnostics("set_up_time",4)
635          so._updateDiagnostics("residual_norm",5)          sb._updateDiagnostics("residual_norm",5)
636          so._updateDiagnostics("converged",True)          sb._updateDiagnostics("converged",True)
637    
638          self.assertTrue(so.getDiagnostics("num_iter") == 1, "num_iter is wrong.")          self.assertTrue(sb.getDiagnostics("num_iter") == 1, "num_iter is wrong.")
639          self.assertTrue(so.getDiagnostics("num_inner_iter") == 2, "num_inner_iter is wrong.")          self.assertTrue(sb.getDiagnostics("num_inner_iter") == 2, "num_inner_iter is wrong.")
640          self.assertTrue(so.getDiagnostics("time") == 3, "time is wrong.")          self.assertTrue(sb.getDiagnostics("time") == 3, "time is wrong.")
641          self.assertTrue(so.getDiagnostics("set_up_time") == 4, "set_up_time is wrong.")          self.assertTrue(sb.getDiagnostics("set_up_time") == 4, "set_up_time is wrong.")
642          self.assertTrue(so.getDiagnostics("residual_norm") == 5, "residual_norm is wrong.")          self.assertTrue(sb.getDiagnostics("residual_norm") == 5, "residual_norm is wrong.")
643          self.assertTrue(so.getDiagnostics("converged"), "converged is wrong.")          self.assertTrue(sb.getDiagnostics("converged"), "converged is wrong.")
644          self.assertTrue(so.hasConverged(), "convergence flag is wrong.")          self.assertTrue(sb.hasConverged(), "convergence flag is wrong.")
645          self.assertTrue(so.getDiagnostics("cum_num_inner_iter") == 2, "cum_num_inner_iter is wrong.")          self.assertTrue(sb.getDiagnostics("cum_num_inner_iter") == 2, "cum_num_inner_iter is wrong.")
646          self.assertTrue(so.getDiagnostics("cum_num_iter") == 1, "cum_num_iter is wrong.")          self.assertTrue(sb.getDiagnostics("cum_num_iter") == 1, "cum_num_iter is wrong.")
647          self.assertTrue(so.getDiagnostics("cum_time") ==3, "cum_time is wrong.")          self.assertTrue(sb.getDiagnostics("cum_time") ==3, "cum_time is wrong.")
648          self.assertTrue(so.getDiagnostics("cum_set_up_time") == 4, "cum_set_up_time is wrong.")            self.assertTrue(sb.getDiagnostics("cum_set_up_time") == 4, "cum_set_up_time is wrong.")  
649                    
650          so.resetDiagnostics()          sb.resetDiagnostics()
651          self.assertTrue(so.getDiagnostics("num_iter") == None, "initial num_iter is wrong.")          self.assertTrue(sb.getDiagnostics("num_iter") == 0, "initial num_iter is wrong.")
652          self.assertTrue(so.getDiagnostics("num_inner_iter") == None, "initial num_inner_iter is wrong.")          self.assertTrue(sb.getDiagnostics("num_inner_iter") == 0, "initial num_inner_iter is wrong.")
653          self.assertTrue(so.getDiagnostics("time") == None, "initial time is wrong.")          self.assertTrue(sb.getDiagnostics("time") == 0, "initial time is wrong.")
654          self.assertTrue(so.getDiagnostics("set_up_time") == None, "initial set_up_time is wrong.")          self.assertTrue(sb.getDiagnostics("set_up_time") == 0, "initial set_up_time is wrong.")
655          self.assertTrue(so.getDiagnostics("residual_norm") == None, "initial residual_norm is wrong.")          self.assertTrue(sb.getDiagnostics("residual_norm") == 0, "initial residual_norm is wrong.")
656          self.assertTrue(so.getDiagnostics("converged") == None, "initial converged is wrong.")          self.assertTrue(sb.getDiagnostics("converged") == 0, "initial converged is wrong.")
657          self.assertTrue(so.hasConverged() == None, "initial convergence flag is wrong")                self.assertTrue(sb.hasConverged() == 0, "initial convergence flag is wrong")      
658          self.assertTrue(so.getDiagnostics("cum_num_inner_iter") == 2, "cum_num_inner_iter is wrong.")          self.assertTrue(sb.getDiagnostics("cum_num_inner_iter") == 2, "cum_num_inner_iter is wrong.")
659          self.assertTrue(so.getDiagnostics("cum_num_iter") == 1, "cum_num_iter is wrong.")          self.assertTrue(sb.getDiagnostics("cum_num_iter") == 1, "cum_num_iter is wrong.")
660          self.assertTrue(so.getDiagnostics("cum_time") ==3, "cum_time is wrong.")          self.assertTrue(sb.getDiagnostics("cum_time") == 3, "cum_time is wrong.")
661          self.assertTrue(so.getDiagnostics("cum_set_up_time") == 4, "cum_set_up_time is wrong.")          self.assertTrue(sb.getDiagnostics("cum_set_up_time") == 4, "cum_set_up_time is wrong.")
662    
663          so._updateDiagnostics("num_iter",10)          sb._updateDiagnostics("num_iter",10)
664          so._updateDiagnostics("num_inner_iter",20)          sb._updateDiagnostics("num_inner_iter",20)
665          so._updateDiagnostics("time",30)          sb._updateDiagnostics("time",30)
666          so._updateDiagnostics("set_up_time",40)          sb._updateDiagnostics("set_up_time",40)
667          so._updateDiagnostics("residual_norm",50)          sb._updateDiagnostics("residual_norm",50)
668          so._updateDiagnostics("converged",False)          sb._updateDiagnostics("converged",False)
669    
670          self.assertTrue(so.getDiagnostics("num_iter") == 10, "num_iter is wrong.")          self.assertTrue(sb.getDiagnostics("num_iter") == 10, "num_iter is wrong.")
671          self.assertTrue(so.getDiagnostics("num_inner_iter") == 20, "num_inner_iter is wrong.")          self.assertTrue(sb.getDiagnostics("num_inner_iter") == 20, "num_inner_iter is wrong.")
672          self.assertTrue(so.getDiagnostics("time") == 30, "time is wrong.")          self.assertTrue(sb.getDiagnostics("time") == 30, "time is wrong.")
673          self.assertTrue(so.getDiagnostics("set_up_time") == 40, "set_up_time is wrong.")          self.assertTrue(sb.getDiagnostics("set_up_time") == 40, "set_up_time is wrong.")
674          self.assertTrue(so.getDiagnostics("residual_norm") == 50, "residual_norm is wrong.")          self.assertTrue(sb.getDiagnostics("residual_norm") == 50, "residual_norm is wrong.")
675          self.assertTrue(not so.getDiagnostics("converged"), "converged is wrong.")          self.assertTrue(not sb.getDiagnostics("converged"), "converged is wrong.")
676          self.assertTrue(not so.hasConverged(), "convergence flag is wrong.")          self.assertTrue(not sb.hasConverged(), "convergence flag is wrong.")
677          self.assertTrue(so.getDiagnostics("cum_num_inner_iter") == 22, "cum_num_inner_iter is wrong.")          self.assertTrue(sb.getDiagnostics("cum_num_inner_iter") == 22, "cum_num_inner_iter is wrong.")
678          self.assertTrue(so.getDiagnostics("cum_num_iter") == 11, "cum_num_iter is wrong.")          self.assertTrue(sb.getDiagnostics("cum_num_iter") == 11, "cum_num_iter is wrong.")
679          self.assertTrue(so.getDiagnostics("cum_time") ==33, "cum_time is wrong.")          self.assertTrue(sb.getDiagnostics("cum_time") ==33, "cum_time is wrong.")
680          self.assertTrue(so.getDiagnostics("cum_set_up_time") == 44, "cum_set_up_time is wrong.")            self.assertTrue(sb.getDiagnostics("cum_set_up_time") == 44, "cum_set_up_time is wrong.")  
681    
682          so.resetDiagnostics(all=True)          sb.resetDiagnostics(all=True)
683          self.assertTrue(so.getDiagnostics("num_iter") == None, "initial num_iter is wrong.")          self.assertTrue(sb.getDiagnostics("num_iter") == 0, "initial num_iter is wrong.")
684          self.assertTrue(so.getDiagnostics("num_inner_iter") == None, "initial num_inner_iter is wrong.")          self.assertTrue(sb.getDiagnostics("num_inner_iter") == 0, "initial num_inner_iter is wrong.")
685          self.assertTrue(so.getDiagnostics("time") == None, "initial time is wrong.")          self.assertTrue(sb.getDiagnostics("time") == 0, "initial time is wrong.")
686          self.assertTrue(so.getDiagnostics("set_up_time") == None, "initial set_up_time is wrong.")          self.assertTrue(sb.getDiagnostics("set_up_time") == 0, "initial set_up_time is wrong.")
687          self.assertTrue(so.getDiagnostics("residual_norm") == None, "initial residual_norm is wrong.")          self.assertTrue(sb.getDiagnostics("residual_norm") == 0, "initial residual_norm is wrong.")
688          self.assertTrue(so.getDiagnostics("converged") == None, "initial converged is wrong.")          self.assertTrue(sb.getDiagnostics("converged") == 0, "initial converged is wrong.")
689          self.assertTrue(so.hasConverged() == None, "initial convergence flag is wrong.")          self.assertTrue(sb.hasConverged() == 0, "initial convergence flag is wrong.")
690          self.assertTrue(so.getDiagnostics("cum_num_inner_iter") == 0, "initial cum_num_inner_iter is wrong.")          self.assertTrue(sb.getDiagnostics("cum_num_inner_iter") == 0, "initial cum_num_inner_iter is wrong.")
691          self.assertTrue(so.getDiagnostics("cum_num_iter") == 0, "initial cum_num_iter is wrong.")          self.assertTrue(sb.getDiagnostics("cum_num_iter") == 0, "initial cum_num_iter is wrong.")
692          self.assertTrue(so.getDiagnostics("cum_time") ==0, "initial cum_time is wrong.")          self.assertTrue(sb.getDiagnostics("cum_time") ==0, "initial cum_time is wrong.")
693          self.assertTrue(so.getDiagnostics("cum_set_up_time") == 0, "initial cum_set_up_time is wrong.")          self.assertTrue(sb.getDiagnostics("cum_set_up_time") == 0, "initial cum_set_up_time is wrong.")
694                    
695      def test_setCoefficient_WithIllegalFunctionSpace(self):      def test_setCoefficient_WithIllegalFunctionSpace(self):
696          mypde=LinearPDE(self.domain,debug=self.DEBUG)          mypde=LinearPDE(self.domain,debug=self.DEBUG)

Legend:
Removed from v.4820  
changed lines
  Added in v.4821

  ViewVC Help
Powered by ViewVC 1.1.26