Skip to content
Snippets Groups Projects
Commit 6389a000 authored by patavirt's avatar patavirt
Browse files

solver: count excess time to determine when recompute jac

parent aeb99be9
No related branches found
No related tags found
No related merge requests found
......@@ -113,6 +113,7 @@ class Solver:
self._M = None
self._t_jac = 0.0
self._t_solve = 0.0
self._t_solve_min = np.inf
def set_shape(self, nx, ny=1):
self._core.set_shape(nx, ny)
......@@ -202,6 +203,7 @@ class Solver:
if M is None:
self._t_jac = 0.0
self._t_solve = 0.0
self._t_solve_min = np.inf
self._core.fix_terminals(Phi)
......@@ -224,6 +226,7 @@ class Solver:
frozen_M = False
self._t_jac = time.time() - t0 if not first_jac else 0.0
self._t_solve = 0.0
self._t_solve_min = np.inf
else:
# Don't update preconditioner
frozen_M = True
......@@ -322,9 +325,11 @@ class Solver:
else:
raise ValueError(f"Unknown {solver=}")
self._t_solve += time.time() - t0
dt = time.time() - t0
self._t_solve_min = min(dt, self._t_solve_min)
self._t_solve += dt - self._t_solve_min
if count >= l_maxiter * l_inner_m // 2 and self._t_solve > 2 * self._t_jac:
if count >= l_maxiter * l_inner_m // 2 and self._t_solve > self._t_jac:
M = None
# Update
......@@ -470,7 +475,7 @@ class Solver:
def _eval_jac(self, Phi):
if not self._core.hess_computed:
est = 1e-4 * (self.shape[0] * self.shape[1]) ** 2
est = 1.3e-4 * (self.shape[0] * self.shape[1]) ** 2
_log_solve.info(
f"Forming Jacobian (probably takes around {est/60:.0f} min)..."
)
......@@ -553,6 +558,7 @@ class Solver:
self._t_jac = 0.0
self._t_solve = 0.0
self._t_solve_min = np.inf
self._M = None
self._Phi[...] = 0
self._core.fix_terminals(Phi)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment