/[escript]/trunk/finley/test/python/SimpleSolve.py
ViewVC logotype

Diff of /trunk/finley/test/python/SimpleSolve.py

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

revision 96 by jgs, Tue Oct 26 06:53:54 2004 UTC revision 97 by jgs, Tue Dec 14 05:39:33 2004 UTC
# Line 4  import sys Line 4  import sys
4  import os  import os
5  import unittest  import unittest
6    
7  esys_root=os.getenv('ESYS_ROOT')  from esys.escript import *
8  sys.path.append(esys_root+'/finley/lib')  from esys.linearPDEs import *
9  sys.path.append(esys_root+'/escript/lib')  from esys import finley
 sys.path.append(esys_root+'/escript/py_src')  
   
 from escript import *  
 from util import *  
 from linearPDE import *  
 import finley  
10    
11  print "\nSimpleSolve.py"  print "\nSimpleSolve.py"
12  print "--------------"  print "--------------"
13    
 my_options = {  
           "verbose" : True,  
           "reordering" : NO_REORDERING,  
           "tolerance" : 1.E-8,  
           "final_residual" : 0.,  
           "iterative_method" : PCG,  
           "preconditioner" : JACOBI,  
           "iter_max" :  5000,  
           "iter" : 0,  
           "drop_tolerance" : 1.10,  
           "drop_storage" : 2.  
 }  
   
14  alpha=0.01  alpha=0.01
15    
 print "\nOptions: ", my_options  
   
16  # generate mesh  # generate mesh
17    
18  print "\nGenerate mesh: finley.Rectangle(9,12,1)=>"  # print "\nGenerate mesh: finley.Rectangle(9,12,1)=>"
19  mydomain=finley.Rectangle(9,12,1)  # mydomain=finley.Rectangle(1,1)
20    
21  print "\nGenerate mesh: finley.Rectangle(4,4,1)=>"  # print "\nGenerate mesh: finley.Rectangle(4,4,1)=>"
22  mydomain=finley.Rectangle(4,4,1)  # mydomain=finley.Rectangle(4,4,1)
23    
24  print "\nGenerate mesh: finley.Rectangle(151,151,1)=>"  print "\nGenerate mesh: finley.Rectangle(151,151,1)=>"
25  mydomain=finley.Rectangle(151,151,1)  mydomain=finley.Rectangle(151,151,1)
# Line 68  x=e.getX() Line 47  x=e.getX()
47  print "norm_u_ex=u_ex.Lsup():"  print "norm_u_ex=u_ex.Lsup():"
48  norm_u_ex=u_ex.Lsup()  norm_u_ex=u_ex.Lsup()
49    
50  print "mypde=linearPDE( A=[[1.,0.7],[0.7,1.]], D=alpha, Y=alpha, domain=mydomain)"  print "mypde=LinearPDE( A=[[1.,0.8],[0.4,1.]], D=alpha, Y=alpha, domain=mydomain)"
51  mypde=linearPDE(A=[[1.,0.7],[0.7,1.]],D=alpha,Y=alpha,domain=mydomain)  mypde=LinearPDE(A=[[1.,0.8],[0.4,1.]],D=alpha,Y=alpha,domain=mydomain)
52  #mypde=linearPDE(A=[[1.,0.],[0.,1.]],D=alpha,Y=alpha,domain=mydomain)  mypde.setDebugOn()
53    #mypde=LinearPDE(A=[[1.,0.],[0.,1.]],D=alpha,Y=alpha,domain=mydomain)
54    mypde.getOperator().saveMM("t.msh")
55    
56  # generate a test solution 1  # generate a test solution 1
57    
58  print "\nGenerate a test solution (1)"  print "\nGenerate a test solution (1)"
59  print "----------------------------"  print "----------------------------"
60    
61  print "\nDirect Solver (1)=>"  print "\nIterative Solver (1)=>"
62    
63  u_d=mypde.getSolution(iterative=False,**my_options)  u_i=mypde.getSolution()
64    
65  print "\nIterative Solver (1)=>"  print "\nDirect Solver (1)=>"
66    
67    mypde.setSolverMethod(DIRECT)
68    u_d=mypde.getSolution()
69    
 u_i=mypde.getSolution(iterative=True,**my_options)  
70    
71  print "\n***************************************************************"  print "\n***************************************************************"
72  error=u_ex-u_d  error=u_ex-u_d
# Line 103  x=n.getX() Line 86  x=n.getX()
86  print "msk=x[0].whereZero()+(x[0]-1.).whereZero()"  print "msk=x[0].whereZero()+(x[0]-1.).whereZero()"
87  msk=x[0].whereZero()+(x[0]-1.).whereZero()  msk=x[0].whereZero()+(x[0]-1.).whereZero()
88    
89  print "mypde=linearPDE(A=[[1.,0.],[0.,1.]],q=msk,r=u_ex)"  print "mypde=LinearPDE(A=[[1.,0.],[0.,1.]],q=msk,r=u_ex)"
90  mypde=linearPDE(A=[[1.,0.],[0.,1.]],q=msk,r=u_ex)  mypde=LinearPDE(A=[[1.,0.],[0.,1.]],q=msk,r=u_ex)
91    mypde.setDebugOn()
92    
93  # generate a test solution 2  # generate a test solution 2
94    
# Line 113  print "----------------------------" Line 97  print "----------------------------"
97    
98  print "\nDirect Solver (2)=>"  print "\nDirect Solver (2)=>"
99    
100  u_d=mypde.getSolution(iterative=False,**my_options)  # mypde.setSymmetryOn() : is not woking yet!
101    mypde.setSolverMethod(DIRECT)
102    u_d=mypde.getSolution()
103    
104  print "\nIterative Solver (2)=>"  print "\nIterative Solver (2)=>"
105    
106  u_i=mypde.getSolution(iterative=True,**my_options)  #mypde.setSymmetryOn()
107    mypde.setSolverMethod(DEFAULT_METHOD)
108    u_i=mypde.getSolution()
109    
110  print "\n******************************************************************"  print "\n******************************************************************"
111  error=u_ex-u_d  error=u_ex-u_d

Legend:
Removed from v.96  
changed lines
  Added in v.97

  ViewVC Help
Powered by ViewVC 1.1.26