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

Diff of /branches/diaplayground/escriptcore/test/python/test_linearPDEs.py

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

revision 5135 by caltinay, Thu May 15 01:40:06 2014 UTC revision 5136 by caltinay, Tue Sep 9 07:13:55 2014 UTC
# Line 102  class Test_LameEquation(Test_linearPDEs) Line 102  class Test_LameEquation(Test_linearPDEs)
102          self.checkContactsNotEmpty(mypde)          self.checkContactsNotEmpty(mypde)
103                    
104          self.assertTrue(self.check(mypde.getCoefficient("A"),0),"A is not 0")          self.assertTrue(self.check(mypde.getCoefficient("A"),0),"A is not 0")
105          self.assertTrue(self.check(mypde.getCoefficient("r"),r_ref),"r is nor x")          self.assertTrue(self.check(mypde.getCoefficient("r"),r_ref),"r is not x")
106    
107    
108      def test_setCoefficient_F(self):      def test_setCoefficient_F(self):
# Line 392  class Test_LinearPDE_noLumping(Test_line Line 392  class Test_LinearPDE_noLumping(Test_line
392      def test_SolverOptions(self):      def test_SolverOptions(self):
393          sb=SolverBuddy()          sb=SolverBuddy()
394          so=SolverOptions          so=SolverOptions
395          self.assertTrue(sb.getSmoother() == 28, "initial Smoother is wrong.")          self.assertTrue(sb.getSmoother() == so.GAUSS_SEIDEL, "initial Smoother is wrong.")
396          self.assertRaises(ValueError,sb.setSmoother,-1)          self.assertRaises(ValueError,sb.setSmoother,-1)
397          sb.setSmoother(so.GAUSS_SEIDEL)          sb.setSmoother(so.GAUSS_SEIDEL)
398          self.assertTrue(sb.getSmoother() == 28, "Gauss-Seidel smoother is not set.")          self.assertTrue(sb.getSmoother() == so.GAUSS_SEIDEL, "Gauss-Seidel smoother is not set.")
399          sb.setSmoother(so.JACOBI)          sb.setSmoother(so.JACOBI)
400          self.assertTrue(sb.getSmoother() == 10, "Jacobi smoother is not set.")          self.assertTrue(sb.getSmoother() == so.JACOBI, "Jacobi smoother is not set.")
401    
402          self.assertTrue(sb.getLevelMax() == 100, "initial  LevelMax is wrong.")          self.assertTrue(sb.getLevelMax() == 100, "initial LevelMax is wrong.")
403          self.assertRaises(ValueError,sb.setLevelMax,-1)          self.assertRaises(ValueError,sb.setLevelMax,-1)
404          sb.setLevelMax(20)          sb.setLevelMax(20)
405          self.assertTrue(sb.getLevelMax() == 20, "LevelMax is wrong.")          self.assertTrue(sb.getLevelMax() == 20, "LevelMax is wrong.")
406    
407          self.assertTrue(sb.getCoarseningThreshold() == 0.25, "initial  CoarseningThreshold is wrong.")          self.assertTrue(sb.getCoarseningThreshold() == 0.25, "initial CoarseningThreshold is wrong.")
408          self.assertRaises(ValueError,sb.setCoarseningThreshold,-1)          self.assertRaises(ValueError,sb.setCoarseningThreshold,-1)
409          sb.setCoarseningThreshold(0.1)          sb.setCoarseningThreshold(0.1)
410          self.assertTrue(sb.getCoarseningThreshold() == 0.1, "CoarseningThreshold is wrong.")          self.assertTrue(sb.getCoarseningThreshold() == 0.1, "CoarseningThreshold is wrong.")
411                    
412          self.assertTrue(sb.getMinCoarseMatrixSize() == 500, "initial  Minimum Coarse Matrix Size is wrong.")          self.assertTrue(sb.getMinCoarseMatrixSize() == 500, "initial Minimum Coarse Matrix Size is wrong.")
413          self.assertRaises(ValueError,sb.setMinCoarseMatrixSize,-1)          self.assertRaises(ValueError,sb.setMinCoarseMatrixSize,-1)
414          sb.setMinCoarseMatrixSize(1000)          sb.setMinCoarseMatrixSize(1000)
415          self.assertTrue(sb.getMinCoarseMatrixSize() == 1000, "Minimum Coarse Matrix Size is wrong.")          self.assertTrue(sb.getMinCoarseMatrixSize() == 1000, "Minimum Coarse Matrix Size is wrong.")
416    
417          self.assertTrue(sb.getNumSweeps() == 1, "initial  Sweeps is wrong.")          self.assertTrue(sb.getNumSweeps() == 1, "initial number of sweeps is wrong.")
418          self.assertRaises(ValueError,sb.setNumSweeps,-1)          self.assertRaises(ValueError,sb.setNumSweeps,-1)
419          sb.setNumSweeps(3)          sb.setNumSweeps(3)
420          self.assertTrue(sb.getNumSweeps() == 3, "Sweeps is wrong.")          self.assertTrue(sb.getNumSweeps() == 3, "Sweeps is wrong.")
421    
422          self.assertTrue(sb.getNumPreSweeps() == 1, "initial  PreSweeps is wrong.")          self.assertTrue(sb.getNumPreSweeps() == 1, "initial PreSweeps is wrong.")
423          self.assertRaises(ValueError,sb.setNumPreSweeps,-1)          self.assertRaises(ValueError,sb.setNumPreSweeps,-1)
424          sb.setNumPreSweeps(4)          sb.setNumPreSweeps(4)
425          self.assertTrue(sb.getNumPreSweeps() == 4, "PreSweeps is wrong.")          self.assertTrue(sb.getNumPreSweeps() == 4, "PreSweeps is wrong.")
426    
427          self.assertTrue(sb.getNumPostSweeps() == 1, "initial  PostSweeps is wrong.")          self.assertTrue(sb.getNumPostSweeps() == 1, "initial PostSweeps is wrong.")
428          self.assertRaises(ValueError,sb.setNumPostSweeps,-1)          self.assertRaises(ValueError,sb.setNumPostSweeps,-1)
429          sb.setNumPostSweeps(5)          sb.setNumPostSweeps(5)
430          self.assertTrue(sb.getNumPostSweeps() == 5, "PostSweeps is wrong.")          self.assertTrue(sb.getNumPostSweeps() == 5, "PostSweeps is wrong.")
# Line 434  class Test_LinearPDE_noLumping(Test_line Line 434  class Test_LinearPDE_noLumping(Test_line
434          sb.setTolerance(0.2)          sb.setTolerance(0.2)
435          self.assertTrue(sb.getTolerance() == 0.2, "Tolerance is wrong.")          self.assertTrue(sb.getTolerance() == 0.2, "Tolerance is wrong.")
436    
437          self.assertTrue(sb.getAbsoluteTolerance() == 0., "initial  AbsoluteTolerance is wrong.")          self.assertTrue(sb.getAbsoluteTolerance() == 0., "initial AbsoluteTolerance is wrong.")
438          self.assertRaises(ValueError,sb.setAbsoluteTolerance,-1)          self.assertRaises(ValueError,sb.setAbsoluteTolerance,-1)
439          sb.setAbsoluteTolerance(0.3)          sb.setAbsoluteTolerance(0.3)
440          self.assertTrue(sb.getAbsoluteTolerance() == 0.3, "AbsoluteTolerance is wrong.")          self.assertTrue(sb.getAbsoluteTolerance() == 0.3, "AbsoluteTolerance is wrong.")
# Line 459  class Test_LinearPDE_noLumping(Test_line Line 459  class Test_LinearPDE_noLumping(Test_line
459          sb.setRelaxationFactor(0.1)          sb.setRelaxationFactor(0.1)
460          self.assertTrue(sb.getRelaxationFactor() == 0.1, "Relaxation is wrong.")          self.assertTrue(sb.getRelaxationFactor() == 0.1, "Relaxation is wrong.")
461    
   
462          self.assertTrue(sb.getIterMax() == 100000, "initial IterMax is wrong.")          self.assertTrue(sb.getIterMax() == 100000, "initial IterMax is wrong.")
463          self.assertRaises(ValueError,sb.setIterMax,0)          self.assertRaises(ValueError,sb.setIterMax,0)
464          sb.setIterMax(11)          sb.setIterMax(11)
# Line 522  class Test_LinearPDE_noLumping(Test_line Line 521  class Test_LinearPDE_noLumping(Test_line
521          sb.setAcceptanceConvergenceFailure(accept=False)          sb.setAcceptanceConvergenceFailure(accept=False)
522          self.assertTrue(not sb.acceptConvergenceFailure(), "acceptConvergenceFailure (4) flag is wrong.")            self.assertTrue(not sb.acceptConvergenceFailure(), "acceptConvergenceFailure (4) flag is wrong.")  
523                    
524          self.assertTrue(sb.getReordering() == 30, "initial Reordering is wrong.")          self.assertTrue(sb.getReordering() == so.DEFAULT_REORDERING, "initial Reordering is wrong.")
525          self.assertRaises(ValueError,sb.setReordering,-1)          self.assertRaises(ValueError,sb.setReordering,-1)
526          sb.setReordering(so.NO_REORDERING)          sb.setReordering(so.NO_REORDERING)
527          self.assertTrue(sb.getReordering() == 17, "NO_REORDERING is not set.")          self.assertTrue(sb.getReordering() == so.NO_REORDERING, "NO_REORDERING is not set.")
528          sb.setReordering(so.MINIMUM_FILL_IN)          sb.setReordering(so.MINIMUM_FILL_IN)
529          self.assertTrue(sb.getReordering() == 18, "MINIMUM_FILL_IN is not set.")          self.assertTrue(sb.getReordering() == so.MINIMUM_FILL_IN, "MINIMUM_FILL_IN is not set.")
530          sb.setReordering(so.NESTED_DISSECTION)          sb.setReordering(so.NESTED_DISSECTION)
531          self.assertTrue(sb.getReordering() == 19, "NESTED_DISSECTION is not set.")          self.assertTrue(sb.getReordering() == so.NESTED_DISSECTION, "NESTED_DISSECTION is not set.")
532          sb.setReordering(so.DEFAULT_REORDERING)          sb.setReordering(so.DEFAULT_REORDERING)
533          self.assertTrue(sb.getReordering() == 30, "DEFAULT_REORDERING is not set.")          self.assertTrue(sb.getReordering() == so.DEFAULT_REORDERING, "DEFAULT_REORDERING is not set.")
534                    
535          self.assertTrue(sb.getPackage() == 0, "initial solver package is wrong.")          self.assertTrue(sb.getPackage() == so.DEFAULT, "initial solver package is wrong.")
536          self.assertRaises(ValueError,sb.setPackage,-1)          self.assertRaises(ValueError,sb.setPackage,-1)
537          sb.setPackage(so.PASO)          sb.setPackage(so.PASO)
538          self.assertTrue(sb.getPackage() == 21, "PASO is not set.")          self.assertTrue(sb.getPackage() == so.PASO, "PASO is not set.")
539            sb.setPackage(so.CUSP)
540            self.assertTrue(sb.getPackage() == so.CUSP, "CUSP is not set.")
541          sb.setPackage(so.SUPER_LU)          sb.setPackage(so.SUPER_LU)
542          self.assertTrue(sb.getPackage() == 31, "SUPER_LU is not set.")          self.assertTrue(sb.getPackage() == so.SUPER_LU, "SUPER_LU is not set.")
543          sb.setPackage(so.PASTIX)          sb.setPackage(so.PASTIX)
544          self.assertTrue(sb.getPackage() == 32, "PASTIX is not set.")          self.assertTrue(sb.getPackage() == so.PASTIX, "PASTIX is not set.")
545          sb.setPackage(so.MKL)          sb.setPackage(so.MKL)
546          self.assertTrue(sb.getPackage() == 15, "MKL is not set.")          self.assertTrue(sb.getPackage() == so.MKL, "MKL is not set.")
547          sb.setPackage(so.UMFPACK)          sb.setPackage(so.UMFPACK)
548          self.assertTrue(sb.getPackage() == 16, "UMFPACK is not set.")          self.assertTrue(sb.getPackage() == so.UMFPACK, "UMFPACK is not set.")
549          sb.setPackage(so.TRILINOS)          sb.setPackage(so.TRILINOS)
550          self.assertTrue(sb.getPackage() == 24, "TRILINOS is not set.")          self.assertTrue(sb.getPackage() == so.TRILINOS, "TRILINOS is not set.")
551    
552          self.assertTrue(sb.getSolverMethod() == 0, "initial SolverMethod is wrong.")          self.assertTrue(sb.getSolverMethod() == so.DEFAULT, "initial SolverMethod is wrong.")
553          self.assertRaises(ValueError,sb.setSolverMethod,-1)          self.assertRaises(ValueError,sb.setSolverMethod,-1)
554          sb.setSolverMethod(so.DIRECT)          sb.setSolverMethod(so.DIRECT)
555          self.assertTrue(sb.getSolverMethod() == 1, "DIRECT is not set.")          self.assertTrue(sb.getSolverMethod() == so.DIRECT, "DIRECT is not set.")
556          sb.setSolverMethod(so.CHOLEVSKY)          sb.setSolverMethod(so.CHOLEVSKY)
557          self.assertTrue(sb.getSolverMethod() == 2, "CHOLEVSKY is not set.")          self.assertTrue(sb.getSolverMethod() == so.CHOLEVSKY, "CHOLEVSKY is not set.")
558          sb.setSolverMethod(so.PCG)          sb.setSolverMethod(so.PCG)
559          self.assertTrue(sb.getSolverMethod() == 3, "PCG is not set.")          self.assertTrue(sb.getSolverMethod() == so.PCG, "PCG is not set.")
560          sb.setSolverMethod(so.CR)          sb.setSolverMethod(so.CR)
561          self.assertTrue(sb.getSolverMethod() == 4, "CR is not set.")          self.assertTrue(sb.getSolverMethod() == so.CR, "CR is not set.")
562          sb.setSolverMethod(so.CGS)          sb.setSolverMethod(so.CGS)
563          self.assertTrue(sb.getSolverMethod() == 5, "CGS is not set.")          self.assertTrue(sb.getSolverMethod() == so.CGS, "CGS is not set.")
564          sb.setSolverMethod(so.BICGSTAB)          sb.setSolverMethod(so.BICGSTAB)
565          self.assertTrue(sb.getSolverMethod() == 6, "BICGSTAB is not set.")          self.assertTrue(sb.getSolverMethod() == so.BICGSTAB, "BICGSTAB is not set.")
566          sb.setSolverMethod(so.GMRES)          sb.setSolverMethod(so.GMRES)
567          self.assertTrue(sb.getSolverMethod() == 11, "GMRES is not set.")          self.assertTrue(sb.getSolverMethod() == so.GMRES, "GMRES is not set.")
568          sb.setSolverMethod(so.PRES20)          sb.setSolverMethod(so.PRES20)
569          self.assertTrue(sb.getSolverMethod() == 12, "PRES20 is not set.")          self.assertTrue(sb.getSolverMethod() == so.PRES20, "PRES20 is not set.")
570          sb.setSolverMethod(so.LUMPING)          sb.setSolverMethod(so.LUMPING)
571          self.assertTrue(sb.getSolverMethod() == 13, "LUMPING is not set.")          self.assertTrue(sb.getSolverMethod() == so.LUMPING, "LUMPING is not set.")
572          sb.setSolverMethod(so.ITERATIVE)          sb.setSolverMethod(so.ITERATIVE)
573          self.assertTrue(sb.getSolverMethod() == 20, "ITERATIVE is not set.")          self.assertTrue(sb.getSolverMethod() == so.ITERATIVE, "ITERATIVE is not set.")
574            sb.setSolverMethod(so.LSQR)
575            self.assertTrue(sb.getSolverMethod() == so.LSQR, "LSQR is not set.")
576          sb.setSolverMethod(so.NONLINEAR_GMRES)          sb.setSolverMethod(so.NONLINEAR_GMRES)
577          self.assertTrue(sb.getSolverMethod() == 25, "NONLINEAR_GMRES is not set.")          self.assertTrue(sb.getSolverMethod() == so.NONLINEAR_GMRES, "NONLINEAR_GMRES is not set.")
578          sb.setSolverMethod(so.TFQMR)          sb.setSolverMethod(so.TFQMR)
579          self.assertTrue(sb.getSolverMethod() == 26, "TFQMR is not set.")          self.assertTrue(sb.getSolverMethod() == so.TFQMR, "TFQMR is not set.")
580          sb.setSolverMethod(so.MINRES)          sb.setSolverMethod(so.MINRES)
581          self.assertTrue(sb.getSolverMethod() == 27, "MINRES is not set.")          self.assertTrue(sb.getSolverMethod() == so.MINRES, "MINRES is not set.")
582          sb.setSolverMethod(so.DEFAULT)          sb.setSolverMethod(so.DEFAULT)
583          self.assertTrue(sb.getSolverMethod() == 0, "DEFAULT is not set.")          self.assertTrue(sb.getSolverMethod() == so.DEFAULT, "DEFAULT is not set.")
584    
585          self.assertTrue(sb.getPreconditioner() == 10, "initial Preconditioner is wrong.")          self.assertTrue(sb.getPreconditioner() == so.JACOBI, "initial Preconditioner is wrong.")
586          self.assertRaises(ValueError,sb.setPreconditioner,-1)          self.assertRaises(ValueError,sb.setPreconditioner,-1)
587          sb.setPreconditioner(so.ILU0)          sb.setPreconditioner(so.ILU0)
588          self.assertTrue(sb.getPreconditioner() == 8, "ILU0 is not set.")          self.assertTrue(sb.getPreconditioner() == so.ILU0, "ILU0 is not set.")
589          sb.setPreconditioner(so.ILUT)          sb.setPreconditioner(so.ILUT)
590          self.assertTrue(sb.getPreconditioner() == 9, "ILUT is not set.")          self.assertTrue(sb.getPreconditioner() == so.ILUT, "ILUT is not set.")
591          sb.setPreconditioner(so.JACOBI)          sb.setPreconditioner(so.JACOBI)
592          self.assertTrue(sb.getPreconditioner() == 10, "JACOBI is not set.")          self.assertTrue(sb.getPreconditioner() == so.JACOBI, "JACOBI is not set.")
593          if getEscriptParamInt('DISABLE_AMG', 0):          if getEscriptParamInt('DISABLE_AMG', 0):
594              print("AMG test disabled on MPI build")              print("AMG test disabled on MPI build")
595          else:          else:
596              sb.setPreconditioner(so.AMG)              sb.setPreconditioner(so.AMG)
597              self.assertTrue(sb.getPreconditioner() == 22, "AMG is not set.")              self.assertTrue(sb.getPreconditioner() == so.AMG, "AMG is not set.")
598          sb.setPreconditioner(so.REC_ILU)          sb.setPreconditioner(so.REC_ILU)
599          self.assertTrue(sb.getPreconditioner() == 23, "REC_ILU is not set.")          self.assertTrue(sb.getPreconditioner() == so.REC_ILU, "REC_ILU is not set.")
600          sb.setPreconditioner(so.GAUSS_SEIDEL)          sb.setPreconditioner(so.GAUSS_SEIDEL)
601          self.assertTrue(sb.getPreconditioner() == 28, "GAUSS_SEIDEL is not set.")          self.assertTrue(sb.getPreconditioner() == so.GAUSS_SEIDEL, "GAUSS_SEIDEL is not set.")
602          sb.setPreconditioner(so.RILU)          sb.setPreconditioner(so.RILU)
603          self.assertTrue(sb.getPreconditioner() == 29, "RILU is not set.")          self.assertTrue(sb.getPreconditioner() == so.RILU, "RILU is not set.")
604          sb.setPreconditioner(so.AMLI)          sb.setPreconditioner(so.AMLI)
605          self.assertTrue(sb.getPreconditioner() == 38, "AMLI is not set.")          self.assertTrue(sb.getPreconditioner() == so.AMLI, "AMLI is not set.")
606          sb.setPreconditioner(so.NO_PRECONDITIONER)          sb.setPreconditioner(so.NO_PRECONDITIONER)
607          self.assertTrue(sb.getPreconditioner() == 36, "NO_PRECONDITIONER is not set.")                  self.assertTrue(sb.getPreconditioner() == so.NO_PRECONDITIONER, "NO_PRECONDITIONER is not set.")        
608    
609          self.assertTrue(sb.getCoarsening() == 0, "initial Coarseningr is wrong.")          self.assertTrue(sb.getCoarsening() == so.DEFAULT, "initial Coarsening is wrong.")
610          self.assertRaises(ValueError,sb.setCoarsening,-1)          self.assertRaises(ValueError,sb.setCoarsening,-1)
611          sb.setCoarsening(so.YAIR_SHAPIRA_COARSENING)          sb.setCoarsening(so.YAIR_SHAPIRA_COARSENING)
612          self.assertTrue(sb.getCoarsening() == 33, "YAIR_SHAPIRA_COARSENING is not set.")          self.assertTrue(sb.getCoarsening() == so.YAIR_SHAPIRA_COARSENING, "YAIR_SHAPIRA_COARSENING is not set.")
613          sb.setCoarsening(so.RUGE_STUEBEN_COARSENING)          sb.setCoarsening(so.RUGE_STUEBEN_COARSENING)
614          self.assertTrue(sb.getCoarsening() == 34, "RUGE_STUEBEN_COARSENING is not set.")          self.assertTrue(sb.getCoarsening() == so.RUGE_STUEBEN_COARSENING, "RUGE_STUEBEN_COARSENING is not set.")
615          sb.setCoarsening(so.AGGREGATION_COARSENING)          sb.setCoarsening(so.AGGREGATION_COARSENING)
616          self.assertTrue(sb.getCoarsening() == 35, "AGREGATION_COARSENING is not set.")          self.assertTrue(sb.getCoarsening() == so.AGGREGATION_COARSENING, "AGREGATION_COARSENING is not set.")
617          sb.setCoarsening(so.STANDARD_COARSENING)          sb.setCoarsening(so.STANDARD_COARSENING)
618          self.assertTrue(sb.getCoarsening() == 39, "STANDARD_COARSENING is not set.")          self.assertTrue(sb.getCoarsening() == so.STANDARD_COARSENING, "STANDARD_COARSENING is not set.")
619          sb.setCoarsening(so.DEFAULT)          sb.setCoarsening(so.DEFAULT)
620          self.assertTrue(sb.getCoarsening() == 0, "DEFAULT is not set.")          self.assertTrue(sb.getCoarsening() == so.DEFAULT, "DEFAULT is not set.")
621    
622          self.assertTrue(sb.getDiagnostics("num_iter") == 0, "initial num_iter is wrong.")          self.assertTrue(sb.getDiagnostics("num_iter") == 0, "initial num_iter is wrong.")
623          self.assertTrue(sb.getDiagnostics("num_inner_iter") == 0, "initial num_inner_iter is wrong.")          self.assertTrue(sb.getDiagnostics("num_inner_iter") == 0, "initial num_inner_iter is wrong.")

Legend:
Removed from v.5135  
changed lines
  Added in v.5136

  ViewVC Help
Powered by ViewVC 1.1.26