# Annotation of /branches/diaplayground/poisson.py

Revision 5095 - (hide annotations)
Fri Jul 11 05:54:25 2014 UTC (4 years, 10 months ago) by caltinay
File MIME type: text/x-python
File size: 1687 byte(s)
```Added implementation of column diagonal storage (CDS) matrix format
and relevant operations within cusp to allow solving for block sizes > 1.
Added exception if trying to solve with more than one rank.
Minor clean up.

```
 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 5095 BLOCKSIZE=3 7 caltinay 4946 8 caltinay 5095 dom = Rectangle(l0=1.,l1=1.,n0=299, n1=299) 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 pde.getSolverOptions().setSolverMethod(SolverOptions.PRES20) 31 pde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB) 32 pde.getSolverOptions().setSolverMethod(SolverOptions.PCG) 33 pde.getSolverOptions().setSolverTarget(target) 34 pde.getSolverOptions().setPreconditioner(SolverOptions.NO_PRECONDITIONER) 35 caltinay 5095 pde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI) 36 caltinay 5065 pde.getSolverOptions().setVerbosityOn() 37 #pde.setDebugOn() 38 #rhs=pde.getRightHandSide() 39 #saveDataCSV('/tmp/rhs.csv',rhs=rhs) 40 #pde.getSystem()[0].saveMM('/tmp/poissonripley.mtx') 41 t0=time() 42 print("pde.getSolution()") 43 x = pde.getSolution() 44 t1=time() 45 print("Solver Time: %s"%(t1-t0)) 46 print("Solution: %s..%s"%(inf(x),sup(x))) 47 print(x) 48 caltinay 4944 49 caltinay 5065 50 for target in SolverOptions.TARGET_CPU,SolverOptions.TARGET_GPU: 51 solve(target) 52 print("-------") 53