From 0fcf9e378ff1822f1190614ea32edeb92c923889 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Fri, 27 Apr 2018 16:50:35 -0500 Subject: [PATCH 1/2] Change GMRES stall logic to test for lack of residual decrease over stall_iterations iterations --- pytential/solve.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/pytential/solve.py b/pytential/solve.py index 34081d27..e46fa5ea 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 -- GitLab From 39f04732778e72d865c87ab1a36840d7841ce164 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Fri, 27 Apr 2018 16:51:47 -0500 Subject: [PATCH 2/2] Enable QBXLayerPotentialSource.copy to set the FMM backend --- pytential/qbx/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pytential/qbx/__init__.py b/pytential/qbx/__init__.py index 4e03ceca..3fe9071e 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) # }}} -- GitLab