Exemplo n.º 1
0
 for i in range(1,n+1):
   U[:,i], info = spla.cg(M,dt*ft[i-1]*F+(M-dt*(A+M))*U[:,i-1])
   if info:
     print "i =", i, "info =", info
 print "time of cg:  ", time()-t
 if not np.isfinite(U[:,-1]).all():
   print "error of cg:  inf"
 else:
   error2 = lofu-np.dot(U[:,-1],F)
   if error2<0.0:
     print "error of cg:  nan ( error^2 =", error2, ")"
   else:
     print "error of cg: ", np.sqrt(error2)
 
 t = time()
 diagM = FEM.massLumping(coord,trian)
 M = sp.spdiags(diagM, 0, coord.shape[0], coord.shape[0], format="csr")
 V = np.zeros((coord.shape[0],n+1))
 for i in range(1,n+1):
   V[:,i] = (dt*ft[i-1]*F+(M-dt*(A+M))*V[:,i-1])/diagM
 print "time of mass lumping:  ", time()-t
 if not np.isfinite(V[:,-1]).all():
   print "error of mass lumping:  inf"
 else:
   error2 = lofu-np.dot(V[:,-1],F)
   if error2<0.0:
     print "error of mass lumping:  nan ( error^2 =", error2, ")"
   else:
     print "error of mass lumping: ", np.sqrt(error2)
 
 #FEM.plot(coord,trian,U[:,-1]-uASL)