Lines Matching refs:self

11     def setup(self, pc):  argument
14 def reset(self, pc): argument
17 def apply(self, pc, x, y): argument
20 def applyT(self, pc, x, y): argument
21 self.apply(pc, x, y)
23 def applyS(self, pc, x, y): argument
24 self.apply(pc, x, y)
26 def applySL(self, pc, x, y): argument
27 self.applyS(pc, x, y)
29 def applySR(self, pc, x, y): argument
30 self.applyS(pc, x, y)
32 def applyRich(self, pc, x, y, w, tols): argument
33 self.apply(pc, x, y)
35 def applyM(self, pc, x, y): argument
40 def apply(self, pc, x, y): argument
43 def applyM(self, pc, x, y): argument
48 def setup(self, pc): argument
50 self.diag = P.getDiagonal()
51 self.diag.reciprocal()
53 def reset(self, pc): argument
54 self.diag.destroy()
55 del self.diag
57 def apply(self, pc, x, y): argument
58 y.pointwiseMult(self.diag, x)
60 def applyS(self, pc, x, y): argument
61 self.diag.copy(y)
65 def applyM(self, pc, x, y): argument
67 y.diagonalScale(L=self.diag)
71 def __init__(self): argument
72 self.impl = None
73 self.log = {}
75 def _log(self, method, *args): argument
76 self.log.setdefault(method, 0)
77 self.log[method] += 1
79 def create(self, pc): argument
80 self._log('create', pc)
82 def destroy(self, pc): argument
83 self._log('destroy')
84 self.impl = None
86 def reset(self, pc): argument
87 self._log('reset', pc)
89 def view(self, pc, vw): argument
90 self._log('view', pc, vw)
92 def setFromOptions(self, pc): argument
93 self._log('setFromOptions', pc)
97 self.impl = klass()
99 def setUp(self, pc): argument
100 self._log('setUp', pc)
101 self.impl.setup(pc)
103 def preSolve(self, pc, ksp, b, x): argument
104 self._log('preSolve', pc, ksp, b, x)
106 def postSolve(self, pc, ksp, b, x): argument
107 self._log('postSolve', pc, ksp, b, x)
109 def apply(self, pc, x, y): argument
110 self._log('apply', pc, x, y)
111 self.impl.apply(pc, x, y)
113 def applySymmetricLeft(self, pc, x, y): argument
114 self._log('applySymmetricLeft', pc, x, y)
115 self.impl.applySL(pc, x, y)
117 def applySymmetricRight(self, pc, x, y): argument
118 self._log('applySymmetricRight', pc, x, y)
119 self.impl.applySR(pc, x, y)
121 def applyTranspose(self, pc, x, y): argument
122 self._log('applyTranspose', pc, x, y)
123 self.impl.applyT(pc, x, y)
125 def matApply(self, pc, x, y): argument
126 self._log('matApply', pc, x, y)
127 self.impl.applyM(pc, x, y)
129 def applyRichardson(self, pc, x, y, w, tols): argument
130 self._log('applyRichardson', pc, x, y, w, tols)
131 self.impl.applyRich(pc, x, y, w, tols)
138 def setUp(self): argument
139 pc = self.pc = PETSc.PC()
141 pc.setType(self.PC_TYPE)
144 self.pc.prefix = self.PC_PREFIX
145 OptDB = PETSc.Options(self.pc)
146 self.assertTrue(OptDB.prefix == self.pc.prefix)
148 self.pc.setFromOptions()
150 self.assertTrue(self._getCtx().log['create'] == 1)
151 self.assertTrue(self._getCtx().log['setFromOptions'] == 1)
152 self.assertEqual(getrefcount(self._getCtx()), 2)
154 def testGetType(self): argument
155 ctx = self.pc.getPythonContext()
157 self.assertTrue(self.pc.getPythonType() == pytype)
159 def tearDown(self): argument
160 ctx = self._getCtx()
161 self.pc.destroy() # XXX
162 self.pc = None
164 self.assertTrue(ctx.log['destroy'] == 1)
166 def _prepare(self): argument
173 self.pc.setOperators(A, A)
178 self.assertTrue((A, A) == self.pc.getOperators())
181 def _getCtx(self): argument
182 return self.pc.getPythonContext()
184 def _applyMeth(self, meth): argument
185 A, x, y, X, Y = self._prepare()
187 getattr(self.pc, meth)(X, Y)
190 getattr(self.pc, meth)(x, y)
192 if 'reset' not in self._getCtx().log:
193 self.assertTrue(self._getCtx().log['setUp'] == 1)
194 self.assertTrue(self._getCtx().log[meth] == 1)
196 nreset = self._getCtx().log['reset']
197 nsetup = self._getCtx().log['setUp']
198 nmeth = self._getCtx().log[meth]
199 self.assertTrue(nreset == nsetup)
200 self.assertTrue(nreset == nmeth)
201 if isinstance(self._getCtx().impl, MyPCNone):
202 self.assertTrue(y.equal(x))
203 self.assertTrue(Y.equal(X))
205 def testApply(self): argument
206 self._applyMeth('apply')
208 def testApplySymmetricLeft(self): argument
209 self._applyMeth('applySymmetricLeft')
211 def testApplySymmetricRight(self): argument
212 self._applyMeth('applySymmetricRight')
214 def testApplyTranspose(self): argument
215 self._applyMeth('applyTranspose')
217 def testApplyMat(self): argument
218 self._applyMeth('matApply')
237 def testResetAndApply(self): argument
238 self.pc.reset()
239 self.testApply()
240 self.pc.reset()
241 self.testApply()
242 self.pc.reset()
244 def testKSPSolve(self): argument
245 A, x, y, _, _ = self._prepare()
246 ksp = PETSc.KSP().create(self.pc.comm)
248 self.assertTrue(self.pc.getRefCount() == 1)
249 ksp.setPC(self.pc)
250 self.assertTrue(self.pc.getRefCount() == 2)
253 self.assertTrue(self._getCtx().log['setUp'] == 1)
254 self.assertTrue(self._getCtx().log['apply'] == 1)
255 self.assertTrue(self._getCtx().log['preSolve'] == 1)
256 self.assertTrue(self._getCtx().log['postSolve'] == 1)
258 self.assertTrue(self._getCtx().log['setUp'] == 1)
259 self.assertTrue(self._getCtx().log['apply'] == 2)
260 self.assertTrue(self._getCtx().log['preSolve'] == 2)
261 self.assertTrue(self._getCtx().log['postSolve'] == 2)
264 self.assertTrue(self._getCtx().log['setUp'] == 1)
265 self.assertTrue(self._getCtx().log['applyTranspose'] == 1)
267 self.assertTrue(self._getCtx().log['setUp'] == 1)
268 self.assertTrue(self._getCtx().log['applyTranspose'] == 2)
271 self.assertEqual(self.pc.getRefCount(), 1)
273 def testGetSetContext(self): argument
274 self.pc.setPythonContext(self._getCtx())
275 self.assertEqual(getrefcount(self.pc.getPythonContext()), 2)
279 def setUp(self): argument
280 OptDB = PETSc.Options(self.PC_PREFIX)
283 clsname = type(self._getCtx().impl).__name__
284 self.assertTrue(clsname == OptDB['impl'])
289 def setUp(self): argument
290 pc = self.pc = PETSc.PC()
293 self.pc.prefix = self.PC_PREFIX
294 self.pc.setFromOptions()
295 self.assertTrue(self._getCtx().log['create'] == 1)
296 self.assertTrue(self._getCtx().log['setFromOptions'] == 1)
300 def setUp(self): argument
301 OptDB = PETSc.Options(self.PC_PREFIX)
304 clsname = type(self._getCtx().impl).__name__
305 self.assertTrue(clsname == OptDB['impl'])