Skip to content

Commit

Permalink
Fixed bug in NonlinearSolver (#565)
Browse files Browse the repository at this point in the history
* Fixed bug in NonlinearSolver

* Fix broken API for setResTol.
    - This fixes a regression caused by changing the API
      for the linear solvers setResTol function.
  • Loading branch information
Giovanni-Cozzuto-1989 authored and cekees committed Jul 17, 2017
1 parent cf63fcd commit 61475a1
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions proteus/LinearSolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def __init__(self,L,par_L,
self._setMatOperators()
self.ksp.setOperators(self.petsc_L,self.petsc_L)

self.setResTol(rtol_r,atol_r,maxIts)
self.setResTol(rtol_r,atol_r)

convergenceTest = 'r-true'
if convergenceTest == 'r-true':
Expand All @@ -433,16 +433,15 @@ def __init__(self,L,par_L,
if Preconditioner is not None:
self._setPreconditioner(Preconditioner,par_L,prefix)
self.ksp.setPC(self.pc)
self.ksp.max_it = self.maxIts
self.ksp.setFromOptions()

def setResTol(self,rtol,atol,maxIts):
def setResTol(self,rtol,atol):
""" Set the ksp object's residual and maximum interations. """
self.rtol_r = rtol
self.atol_r = atol
self.maxIts = maxIts
self.ksp.rtol = rtol
self.ksp.atol = atol
self.ksp.max_it = maxIts
logEvent("KSP atol %e rtol %e" % (self.ksp.atol,self.ksp.rtol))

def prepare(self,b=None):
Expand Down Expand Up @@ -492,7 +491,6 @@ def solve(self,u,r=None,b=None,par_u=None,par_b=None,initialGuessIsZero=True):

if self.bdyNullSpace==True:
self._setNullSpace(par_b)

self.ksp.solve(par_b,par_u)
logEvent("after ksp.rtol= %s ksp.atol= %s ksp.converged= %s ksp.its= %s ksp.norm= %s reason = %s" % (self.ksp.rtol,
self.ksp.atol,
Expand Down

0 comments on commit 61475a1

Please sign in to comment.