/[escript]/branches/diaplayground/poisson.py
ViewVC logotype

Diff of /branches/diaplayground/poisson.py

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

revision 5064 by caltinay, Tue May 20 04:33:15 2014 UTC revision 5065 by caltinay, Fri Jun 20 05:49:52 2014 UTC
# Line 3  from esys.escript.linearPDEs import Line Line 3  from esys.escript.linearPDEs import Line
3  from esys.ripley import Rectangle, Brick  from esys.ripley import Rectangle, Brick
4  from time import time  from time import time
5    
6  BLOCKSIZE=3  BLOCKSIZE=1
7    
8  #dom = Rectangle(l0=1.,l1=1.,n0=99, n1=99)  dom = Rectangle(l0=1.,l1=1.,n0=599, n1=599)
9  dom = Brick(l0=1.,l1=1.,n0=51, n1=51, n2=17)  #dom = Brick(l0=1.,l1=1.,n0=51, n1=51, n2=17)
10  x = dom.getX()  x = dom.getX()
11  gammaD = whereZero(x[0])+whereZero(x[1])  gammaD = whereZero(x[0])+whereZero(x[1])
12    
13  pde = LinearPDE(dom, numEquations=BLOCKSIZE, numSolutions=BLOCKSIZE)  def solve(target):
14  A = pde.createCoefficient("A")      pde = LinearPDE(dom, numEquations=BLOCKSIZE, numSolutions=BLOCKSIZE)
15  q = pde.createCoefficient("q")      A = pde.createCoefficient("A")
16  Y_reduced = pde.createCoefficient("Y_reduced")      q = pde.createCoefficient("q")
17        Y_reduced = pde.createCoefficient("Y_reduced")
18  if BLOCKSIZE == 1:  
19      A = kronecker(dom)      if BLOCKSIZE == 1:
20      q = gammaD          A = kronecker(dom)
21      Y_reduced = 1.          q = gammaD
22  else:          Y_reduced = 1.
23      for i in range(BLOCKSIZE):      else:
24          A[i,:,i,:] = kronecker(dom)          for i in range(BLOCKSIZE):
25          q[i] = gammaD              A[i,:,i,:] = kronecker(dom)
26          Y_reduced[i] = 1.              q[i] = gammaD
27                Y_reduced[i] = 1.
28  pde.setValue(A=A, Y_reduced=Y_reduced, q=q)  
29  pde.getSolverOptions().setSolverMethod(SolverOptions.PCG)      pde.setValue(A=A, Y_reduced=Y_reduced, q=q)
30  pde.getSolverOptions().setPreconditioner(SolverOptions.NO_PRECONDITIONER)      pde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
31  pde.getSolverOptions().setVerbosityOn()      pde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
32  #pde.setDebugOn()      pde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
33  #rhs=pde.getRightHandSide()      pde.getSolverOptions().setSolverTarget(target)
34  #saveDataCSV('/tmp/rhs.csv',rhs=rhs)      pde.getSolverOptions().setPreconditioner(SolverOptions.NO_PRECONDITIONER)
35  #pde.getSystem()[0].saveMM('/tmp/poissonripley.mtx')      pde.getSolverOptions().setVerbosityOn()
36  t0=time()      #pde.setDebugOn()
37  x = pde.getSolution()      #rhs=pde.getRightHandSide()
38  t1=time()      #saveDataCSV('/tmp/rhs.csv',rhs=rhs)
39  print "Solver Time: ", t1-t0      #pde.getSystem()[0].saveMM('/tmp/poissonripley.mtx')
40  print "Solution: %s..%s"%(inf(x),sup(x))      t0=time()
41  print x      print("pde.getSolution()")
42        x = pde.getSolution()
43        t1=time()
44        print("Solver Time: %s"%(t1-t0))
45        print("Solution: %s..%s"%(inf(x),sup(x)))
46        print(x)
47    
48    
49    for target in SolverOptions.TARGET_CPU,SolverOptions.TARGET_GPU:
50        solve(target)
51        print("-------")
52    

Legend:
Removed from v.5064  
changed lines
  Added in v.5065

  ViewVC Help
Powered by ViewVC 1.1.26