/[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 99 by jgs, Tue Dec 14 05:39:33 2004 UTC revision 100 by jgs, Wed Dec 15 03:48:48 2004 UTC
# Line 4  import sys Line 4  import sys
4  import os  import os
5  import unittest  import unittest
6    
7  from esys.escript import *  esys_root=os.getenv('ESYS_ROOT')
8  from esys.linearPDEs import *  sys.path.append(esys_root+'/finley/lib')
9  from esys import finley  sys.path.append(esys_root+'/escript/lib')
10    sys.path.append(esys_root+'/escript/py_src')
11    
12    from escript import *
13    from util import *
14    from linearPDE import *
15    import finley
16    
17  print "\nSimpleSolve.py"  print "\nSimpleSolve.py"
18  print "--------------"  print "--------------"
19    
20    my_options = {
21              "verbose" : True,
22              "reordering" : NO_REORDERING,
23              "tolerance" : 1.E-8,
24              "final_residual" : 0.,
25              "iterative_method" : PCG,
26              "preconditioner" : JACOBI,
27              "iter_max" :  5000,
28              "iter" : 0,
29              "drop_tolerance" : 1.10,
30              "drop_storage" : 2.
31    }
32    
33  alpha=0.01  alpha=0.01
34    
35    print "\nOptions: ", my_options
36    
37  # generate mesh  # generate mesh
38    
39  # print "\nGenerate mesh: finley.Rectangle(9,12,1)=>"  print "\nGenerate mesh: finley.Rectangle(9,12,1)=>"
40  # mydomain=finley.Rectangle(1,1)  mydomain=finley.Rectangle(9,12,1)
41    
42  # print "\nGenerate mesh: finley.Rectangle(4,4,1)=>"  print "\nGenerate mesh: finley.Rectangle(4,4,1)=>"
43  # mydomain=finley.Rectangle(4,4,1)  mydomain=finley.Rectangle(4,4,1)
44    
45  print "\nGenerate mesh: finley.Rectangle(151,151,1)=>"  print "\nGenerate mesh: finley.Rectangle(151,151,1)=>"
46  mydomain=finley.Rectangle(151,151,1)  mydomain=finley.Rectangle(151,151,1)
# Line 47  x=e.getX() Line 68  x=e.getX()
68  print "norm_u_ex=u_ex.Lsup():"  print "norm_u_ex=u_ex.Lsup():"
69  norm_u_ex=u_ex.Lsup()  norm_u_ex=u_ex.Lsup()
70    
71  print "mypde=LinearPDE( A=[[1.,0.8],[0.4,1.]], D=alpha, Y=alpha, domain=mydomain)"  print "mypde=linearPDE( A=[[1.,0.7],[0.7,1.]], D=alpha, Y=alpha, domain=mydomain)"
72  mypde=LinearPDE(A=[[1.,0.8],[0.4,1.]],D=alpha,Y=alpha,domain=mydomain)  mypde=linearPDE(A=[[1.,0.7],[0.7,1.]],D=alpha,Y=alpha,domain=mydomain)
73  mypde.setDebugOn()  #mypde=linearPDE(A=[[1.,0.],[0.,1.]],D=alpha,Y=alpha,domain=mydomain)
 #mypde=LinearPDE(A=[[1.,0.],[0.,1.]],D=alpha,Y=alpha,domain=mydomain)  
 mypde.getOperator().saveMM("t.msh")  
74    
75  # generate a test solution 1  # generate a test solution 1
76    
77  print "\nGenerate a test solution (1)"  print "\nGenerate a test solution (1)"
78  print "----------------------------"  print "----------------------------"
79    
 print "\nIterative Solver (1)=>"  
   
 u_i=mypde.getSolution()  
   
80  print "\nDirect Solver (1)=>"  print "\nDirect Solver (1)=>"
81    
82  mypde.setSolverMethod(DIRECT)  u_d=mypde.getSolution(iterative=False,**my_options)
83  u_d=mypde.getSolution()  
84    print "\nIterative Solver (1)=>"
85    
86    u_i=mypde.getSolution(iterative=True,**my_options)
87    
88  print "\n***************************************************************"  print "\n***************************************************************"
89  error=u_ex-u_d  error=u_ex-u_d
# Line 86  x=n.getX() Line 103  x=n.getX()
103  print "msk=x[0].whereZero()+(x[0]-1.).whereZero()"  print "msk=x[0].whereZero()+(x[0]-1.).whereZero()"
104  msk=x[0].whereZero()+(x[0]-1.).whereZero()  msk=x[0].whereZero()+(x[0]-1.).whereZero()
105    
106  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)"
107  mypde=LinearPDE(A=[[1.,0.],[0.,1.]],q=msk,r=u_ex)  mypde=linearPDE(A=[[1.,0.],[0.,1.]],q=msk,r=u_ex)
 mypde.setDebugOn()  
108    
109  # generate a test solution 2  # generate a test solution 2
110    
# Line 97  print "----------------------------" Line 113  print "----------------------------"
113    
114  print "\nDirect Solver (2)=>"  print "\nDirect Solver (2)=>"
115    
116  # mypde.setSymmetryOn() : is not woking yet!  u_d=mypde.getSolution(iterative=False,**my_options)
 mypde.setSolverMethod(DIRECT)  
 u_d=mypde.getSolution()  
117    
118  print "\nIterative Solver (2)=>"  print "\nIterative Solver (2)=>"
119    
120  #mypde.setSymmetryOn()  u_i=mypde.getSolution(iterative=True,**my_options)
 mypde.setSolverMethod(DEFAULT_METHOD)  
 u_i=mypde.getSolution()  
121    
122  print "\n******************************************************************"  print "\n******************************************************************"
123  error=u_ex-u_d  error=u_ex-u_d

Legend:
Removed from v.99  
changed lines
  Added in v.100

  ViewVC Help
Powered by ViewVC 1.1.26