Convergence Monitor

Indicator Fields

class flatiron_tk.solver.convergence_monitor.ConvergenceMonitor(name, verbose=True, report_every=1, record_history=True, comm=petsc4py.PETSc.COMM_WORLD)[source]

Bases: object

Object which reports and records the convergence history of an iterative method. This is meant to be used with PETSc’s iterative method objects.

Parameters:
  • name (str) – Name to identify the iterative method (e.g., ‘ksp’, ‘snes’, ‘ts’).

  • verbose (bool, optional) – If True, prints the iteration number and residual norm to standard output every report_every iterations. Default is True.

  • report_every (int, optional) – Frequency of reporting the iteration number and residual norm. Default is 1 (every iteration).

  • record_history (bool, optional) – If True, records the convergence history (iteration numbers and residual norms). Default is True.

  • comm (MPI.Comm, optional) – MPI communicator for parallel execution. Default is PETSc.COMM_WORLD.

convergence_history()[source]

Returns the recorded convergence history as a list of arrays. Each array corresponds to a segment of the convergence history where the iteration count was monotonically increasing.

reset_convergence_history()[source]

Resets the recorded convergence history.