Skip to content

Commit

Permalink
Remove conversion from FiPy forms to petsc4py forms
Browse files Browse the repository at this point in the history
Matrices and vectors have already been converted by the time we get to
`_solve_()`.

Addresses usnistgov#644
  • Loading branch information
guyer committed Sep 24, 2019
1 parent eb989ad commit 7fc2920
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions fipy/solvers/petsc/petscKrylovSolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ###################################################################
# FiPy - Python-based finite volume PDE solver
#
# FILE: "trilinosAztecOOSolver.py"
# FILE: "petscKrylovSolver.py"
#
# Author: Jonathan Guyer <guyer@nist.gov>
# Author: Daniel Wheeler <daniel.wheeler@nist.gov>
Expand Down Expand Up @@ -70,14 +70,8 @@ def _solve_(self, L, x, b):
if self.preconditioner is not None:
ksp.getPC().setType(self.preconditioner)
ksp.setTolerances(rtol=self.tolerance, max_it=self.iterations)
# obtain sol & rhs vectors
xVec, bVec = L.matrix.getVecs()
xVec[:] = x
bVec[:] = b
L.matrix.assemblyBegin()
L.matrix.assemblyEnd()
# and next solve
ksp.setOperators(L.matrix)
L.assemblyBegin()
L.assemblyEnd()
ksp.setOperators(L)
ksp.setFromOptions()
ksp.solve(bVec, xVec)
x[:] = xVec.array
ksp.solve(b, x)

0 comments on commit 7fc2920

Please sign in to comment.