/[escript]/trunk/escript/test/python/test_pdetools.py
ViewVC logotype

Diff of /trunk/escript/test/python/test_pdetools.py

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

revision 2250 by gross, Mon Dec 15 05:09:02 2008 UTC revision 2251 by gross, Fri Feb 6 06:50:39 2009 UTC
# Line 862  class Test_pdetools_noLumping(unittest.T Line 862  class Test_pdetools_noLumping(unittest.T
862                 self.Sinv=array([[ 9313.705360982807179,-5755.536981691270739,  806.289245589733696],                 self.Sinv=array([[ 9313.705360982807179,-5755.536981691270739,  806.289245589733696],
863                                   [-5755.536981691271649, 4606.321002756208145,-1630.50619635660928 ],                                   [-5755.536981691271649, 4606.321002756208145,-1630.50619635660928 ],
864                                   [  806.289245589733468,-1630.506196356609053, 2145.65035816388945 ]])                                   [  806.289245589733468,-1630.506196356609053, 2145.65035816388945 ]])
865             def inner_pBv(self,p,Bv):             def inner_pBv(self,p,v):
866                return dot(p,Bv)                return dot(p,matrixmultiply(transpose(self.Bt),v))
867             def inner_p(self,p0,p1):             def inner_p(self,p0,p1):
868                return dot(p0,p1)                return dot(p0,p1)
869             def inner_v(self,v0,v1):             def norm_v(self,v):
870                return dot(v0,v1)                 return sqrt(dot(v,v))
871             def B(self,v):             def getV(self,p,v):
872                 return matrixmultiply(transpose(self.Bt),v)                 out=self.b-matrixmultiply(self.Bt,p)
873             def solve_A(self,u,p):                 return solve_linear_equations(self.A,out)+v*self.getSubProblemTolerance()
874                  out=self.b-matrixmultiply(self.A,u)-matrixmultiply(self.Bt,p)             def norm_Bv(self,v):
875                  # for i in xrange(size(self.b)): out[i]/=self.A[i,i]                 t=matrixmultiply(transpose(self.Bt),v)
876                  return solve_linear_equations(self.A,out)+u*self.getSubProblemTolerance()                 return sqrt(dot(t,t))
877             def solve_prec(self,p):             def solve_AinvBt(self,p):
878                  out=zeros((size(p),),Float64)                 out=matrixmultiply(self.Bt,p)
879                  for i in xrange(size(p)): out[i]=p[i]*self.Sinv[i,i]                 return solve_linear_equations(self.A,out)
880                  return out             def solve_precB(self,v):
881                   out=matrixmultiply(transpose(self.Bt),v)
882                   for i in xrange(size(out)): out[i]*=self.Sinv[i,i]
883                   return out
884    
                 
885        tol=1.e-8        tol=1.e-8
886        ll=LL()        ll=LL()
887        ll.initialize()        ll.initialize()
888        ll.setTolerance(tol)        ll.setTolerance(tol)
889        # ll.setSubToleranceReductionFactor(0.1)        # ll.setSubToleranceReductionFactor(0.1)
890        x,p=ll.solve(ll.x_ref*1.20,ll.p_ref*(-2),max_iter=20, verbose=False, show_details=False, useUzawa=True, iter_restart=20,max_correction_steps=3)        x,p=ll.solve(ll.x_ref*1.20,ll.p_ref*(-2),max_iter=20, verbose=False, show_details=False, usePCG=True, iter_restart=20,max_correction_steps=3)
891        self.failUnless(Lsup(x-ll.x_ref)<=Lsup(ll.x_ref)*tol*10.,"wrong x solution")        self.failUnless(Lsup(x-ll.x_ref)<=Lsup(ll.x_ref)*tol*10.,"wrong x solution")
892        self.failUnless(Lsup(p-ll.p_ref)<=Lsup(ll.p_ref)*tol*10.,"wrong p solution")        self.failUnless(Lsup(p-ll.p_ref)<=Lsup(ll.p_ref)*tol*10.,"wrong p solution")
893    
# Line 969  class Test_pdetools_noLumping(unittest.T Line 971  class Test_pdetools_noLumping(unittest.T
971                 self.Sinv=array([[ 9313.705360982807179,-5755.536981691270739,  806.289245589733696],                 self.Sinv=array([[ 9313.705360982807179,-5755.536981691270739,  806.289245589733696],
972                                   [-5755.536981691271649, 4606.321002756208145,-1630.50619635660928 ],                                   [-5755.536981691271649, 4606.321002756208145,-1630.50619635660928 ],
973                                   [  806.289245589733468,-1630.506196356609053, 2145.65035816388945 ]])                                   [  806.289245589733468,-1630.506196356609053, 2145.65035816388945 ]])
974             def inner_pBv(self,p,Bv):             def inner_pBv(self,p,v):
975                return dot(p,Bv)                return dot(p,matrixmultiply(transpose(self.Bt),v))
976             def inner_p(self,p0,p1):             def inner_p(self,p0,p1):
977                return dot(p0,p1)                return dot(p0,p1)
978             def inner_v(self,v0,v1):             def norm_v(self,v):
979                return dot(v0,v1)                 return sqrt(dot(v,v))
980             def B(self,v):             def getV(self,p,v):
981                 return matrixmultiply(transpose(self.Bt),v)                 out=self.b-matrixmultiply(self.Bt,p)
982             def solve_A(self,u,p):                 return solve_linear_equations(self.A,out)+v*self.getSubProblemTolerance()
983                  out=self.b-matrixmultiply(self.A,u)-matrixmultiply(self.Bt,p)             def norm_Bv(self,v):
984                  return solve_linear_equations(self.A,out)+u*self.getSubProblemTolerance()                 t=matrixmultiply(transpose(self.Bt),v)
985             def solve_prec(self,p):                 return sqrt(dot(t,t))
986                  out=zeros((size(p),),Float64)             def solve_AinvBt(self,p):
987                  for i in xrange(size(p)): out[i]=p[i]*self.Sinv[i,i]                 out=matrixmultiply(self.Bt,p)
988                  # out=matrixmultiply(self.Sinv,p)                 return solve_linear_equations(self.A,out)
989                  return out             def solve_precB(self,v):
990                   out=matrixmultiply(transpose(self.Bt),v)
991                   for i in xrange(size(out)): out[i]*=self.Sinv[i,i]
992                   return out
993                                
994        tol=1.e-8        tol=1.e-8
995        ll=LL()        ll=LL()
996        ll.initialize()        ll.initialize()
997        ll.setTolerance(tol)        ll.setTolerance(tol)
998        # ll.setSubToleranceReductionFactor(0.1)        # ll.setSubToleranceReductionFactor(0.1)
999        x,p=ll.solve(ll.x_ref*1.20,ll.p_ref*(-2),max_iter=20, verbose=False, show_details=False, useUzawa=False, iter_restart=20,max_correction_steps=3)        x,p=ll.solve(ll.x_ref*1.20,ll.p_ref*(-2),max_iter=20, verbose=False, show_details=False, usePCG=False, iter_restart=20,max_correction_steps=3)
1000        self.failUnless(Lsup(x-ll.x_ref)<=Lsup(ll.x_ref)*tol*10.,"wrong x solution")        self.failUnless(Lsup(x-ll.x_ref)<=Lsup(ll.x_ref)*tol*10.,"wrong x solution")
1001        self.failUnless(Lsup(p-ll.p_ref)<=Lsup(ll.p_ref)*tol*10.,"wrong p solution")        self.failUnless(Lsup(p-ll.p_ref)<=Lsup(ll.p_ref)*tol*10.,"wrong p solution")
1002    

Legend:
Removed from v.2250  
changed lines
  Added in v.2251

  ViewVC Help
Powered by ViewVC 1.1.26