diff --git a/pytential/qbx/__init__.py b/pytential/qbx/__init__.py index 4e03ceca60980f5bf0fccc01df3e9f01df127b5f..3fe9071e629d79fe15b283d5097d8022763e948a 100644 --- a/pytential/qbx/__init__.py +++ b/pytential/qbx/__init__.py @@ -199,6 +199,7 @@ class QBXLayerPotentialSource(LayerPotentialSourceBase): _expansion_stick_out_factor=_not_provided, _tree_kind=None, geometry_data_inspector=None, + fmm_backend=None, debug=_not_provided, _refined_for_global_qbx=_not_provided, @@ -279,7 +280,7 @@ class QBXLayerPotentialSource(LayerPotentialSourceBase): _tree_kind=_tree_kind or self._tree_kind, geometry_data_inspector=( geometry_data_inspector or self.geometry_data_inspector), - fmm_backend=self.fmm_backend, + fmm_backend=fmm_backend or self.fmm_backend, **kwargs) # }}} diff --git a/pytential/solve.py b/pytential/solve.py index 34081d27e95195a41a1eec9a15de732c88316bd9..e46fa5ea5e57b4d7f77510e5ea7b70fea6e4798a 100644 --- a/pytential/solve.py +++ b/pytential/solve.py @@ -169,7 +169,6 @@ def _gmres(A, b, restart=None, tol=None, x0=None, dot=None, # noqa norm_b = norm(b) last_resid_norm = None - stall_count = 0 residual_norms = [] for iteration in range(maxiter): @@ -209,21 +208,20 @@ def _gmres(A, b, restart=None, tol=None, x0=None, dot=None, # noqa else: print("*** WARNING: non-monotonic residuals in GMRES") - if stall_iterations and \ - norm_r > last_resid_norm/no_progress_factor: - stall_count += 1 + if (stall_iterations and + len(residual_norms) > stall_iterations and + norm_r > ( + residual_norms[-stall_iterations] + / no_progress_factor)): - if stall_count >= stall_iterations: - state = "stalled" - if hard_failure: - raise GMRESError(state) - else: - return GMRESResult(solution=x, - residual_norms=residual_norms, - iteration_count=iteration, success=False, - state=state) - else: - stall_count = 0 + state = "stalled" + if hard_failure: + raise GMRESError(state) + else: + return GMRESResult(solution=x, + residual_norms=residual_norms, + iteration_count=iteration, success=False, + state=state) last_resid_norm = norm_r