/[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 2718 by jfenwick, Fri Aug 21 06:30:25 2009 UTC revision 2719 by gross, Wed Oct 14 06:38:03 2009 UTC
# Line 965  class Test_pdetools_noLumping(unittest.T Line 965  class Test_pdetools_noLumping(unittest.T
965                                   [  806.289245589733468,-1630.506196356609053, 2145.65035816388945 ]])                                   [  806.289245589733468,-1630.506196356609053, 2145.65035816388945 ]])
966             def inner_pBv(self,p,Bv):             def inner_pBv(self,p,Bv):
967                return dot(p,Bv)                return dot(p,Bv)
968             def Bv(self,v):             def Bv(self,v, tol):
969                return dot(transpose(self.Bt),v)                return dot(transpose(self.Bt),v)
970             def inner_p(self,p0,p1):             def inner_p(self,p0,p1):
971                return dot(p0,p1)                return dot(p0,p1)
972             def norm_v(self,v):             def norm_v(self,v):
973                 return sqrt(dot(v,v))                 return sqrt(dot(v,v))
974             def getV(self,p,v):             def getDV(self,p,v, tol):
975                 out=self.b-dot(self.Bt,p)                 dv=solve_linear_equations(self.A, self.b-dot(self.Bt,p)-dot(self.A,v))
976                 return solve_linear_equations(self.A,out)+v*self.getSubProblemTolerance()                 return dv*(1+tol)
977             def norm_Bv(self,Bv):             def norm_Bv(self,Bv):
978                 return sqrt(dot(Bv,Bv))                 return sqrt(dot(Bv,Bv))
979             def solve_AinvBt(self,p):             def solve_AinvBt(self,p, tol):
980                 out=dot(self.Bt,p)                 out=solve_linear_equations(self.A, dot(self.Bt,p))
981                 return solve_linear_equations(self.A,out)                 return out*(1.+tol)
982             def solve_prec(self,Bv):             def solve_prec(self,Bv, tol):
983                 out=Bv*1.                 out=Bv*1.
984                 for i in xrange(size(out)): out[i]*=self.Sinv[i,i]                 for i in xrange(size(out)): out[i]*=self.Sinv[i,i]
985                 return out                 return out*(1-tol)
986    
987        tol=1.e-8        tol=1.e-8
988        ll=LL()        ll=LL()
989        ll.initialize()        ll.initialize()
990        ll.setTolerance(tol)        ll.setTolerance(tol)
991        # ll.setSubToleranceReductionFactor(0.1)        # ll.setSubToleranceReductionFactor(0.1)
992        x,p=ll.solve(ll.x_ref*1.20,ll.p_ref*(-2),max_iter=20, verbose=False, usePCG=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, usePCG=True, iter_restart=20,max_correction_steps=10)
993        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")
994        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")
995    
# Line 1075  class Test_pdetools_noLumping(unittest.T Line 1075  class Test_pdetools_noLumping(unittest.T
1075                                   [  806.289245589733468,-1630.506196356609053, 2145.65035816388945 ]])                                   [  806.289245589733468,-1630.506196356609053, 2145.65035816388945 ]])
1076             def inner_pBv(self,p,Bv):             def inner_pBv(self,p,Bv):
1077                return dot(p,Bv)                return dot(p,Bv)
1078             def Bv(self,v):             def Bv(self,v, tol):
1079                return dot(transpose(self.Bt),v)                return dot(transpose(self.Bt),v)
1080             def inner_p(self,p0,p1):             def inner_p(self,p0,p1):
1081                return dot(p0,p1)                return dot(p0,p1)
1082             def norm_v(self,v):             def norm_v(self,v):
1083                 return sqrt(dot(v,v))                 return sqrt(dot(v,v))
1084             def getV(self,p,v):             def getDV(self,p,v, tol):
1085                 out=self.b-dot(self.Bt,p)                 dv=solve_linear_equations(self.A, self.b-dot(self.Bt,p)-dot(self.A,v))
1086                 return solve_linear_equations(self.A,out)+v*self.getSubProblemTolerance()                 return dv*(1+tol)
1087             def norm_Bv(self,Bv):             def norm_Bv(self,Bv):
1088                 return sqrt(dot(Bv,Bv))                 return sqrt(dot(Bv,Bv))
1089             def solve_AinvBt(self,p):             def solve_AinvBt(self,p, tol):
1090                 out=dot(self.Bt,p)                 out=solve_linear_equations(self.A, dot(self.Bt,p))
1091                 return solve_linear_equations(self.A,out)                 return out*(1.+tol)
1092             def solve_prec(self,Bv):             def solve_prec(self,Bv, tol):
1093                 out=Bv*1.                 out=Bv*1.
1094                 for i in xrange(size(out)): out[i]*=self.Sinv[i,i]                 for i in xrange(size(out)): out[i]*=self.Sinv[i,i]
1095                 return out                 return out*(1-tol)
1096                  
1097        tol=1.e-8        tol=1.e-8
1098        ll=LL()        ll=LL()
1099        ll.initialize()        ll.initialize()
1100        ll.setTolerance(tol)        ll.setTolerance(tol)
1101        # ll.setSubToleranceReductionFactor(0.1)        # ll.setSubToleranceReductionFactor(0.1)
1102        x,p=ll.solve(ll.x_ref*1.20,ll.p_ref*(-2),max_iter=20, verbose=False, usePCG=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, usePCG=False, iter_restart=20,max_correction_steps=10)
1103        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")
1104        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")
1105    

Legend:
Removed from v.2718  
changed lines
  Added in v.2719

  ViewVC Help
Powered by ViewVC 1.1.26