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

Contents of /branches/diaplayground/poisson.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5136 - (show annotations)
Tue Sep 9 07:13:55 2014 UTC (4 years, 6 months ago) by caltinay
File MIME type: text/x-python
File size: 1806 byte(s)
ripley now supports paso solvers again and returns an appropriate matrix type
id. Changed the getSystemMatrixTypeId() method to take a full SolverBuddy
instance and made some other simplifications.

1 from esys.escript import *
2 from esys.escript.linearPDEs import LinearPDE,SolverOptions
3 from esys.ripley import Rectangle, Brick
4 from time import time
5
6 BLOCKSIZE=1
7
8 dom = Rectangle(l0=1.,l1=1.,n0=99, n1=99)
9 #dom = Brick(l0=1.,l1=1.,n0=51, n1=51, n2=17)
10 x = dom.getX()
11 gammaD = whereZero(x[0])+whereZero(x[1])
12
13 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
19 if BLOCKSIZE == 1:
20 A = kronecker(dom)
21 q = gammaD
22 Y_reduced = 1.
23 else:
24 for i in range(BLOCKSIZE):
25 A[i,:,i,:] = kronecker(dom)*(i+1)
26 q[i] = gammaD
27 Y_reduced[i] = 1.
28
29 pde.setValue(A=A, Y_reduced=Y_reduced, q=q)
30 pde.getSolverOptions().setPackage(SolverOptions.PASO)
31 pde.getSolverOptions().setSolverTarget(target)
32 pde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
33 pde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
34 pde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
35 pde.getSolverOptions().setSolverMethod(SolverOptions.LSQR)
36 pde.getSolverOptions().setPreconditioner(SolverOptions.JACOBI)
37 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
51
52 for target in SolverOptions.TARGET_CPU,SolverOptions.TARGET_GPU:
53 solve(target)
54 print("-------")
55

  ViewVC Help
Powered by ViewVC 1.1.26