# Annotation of /branches/diaplayground/poisson.py

Revision 5147 - (hide annotations)
Fri Sep 12 00:33:02 2014 UTC (4 years, 8 months ago) by caltinay
File MIME type: text/x-python
File size: 1806 byte(s)
```merge to latest trunk.

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