pyinterp.fill.gauss_seidel(mesh: Grid2D | Grid3D, first_guess: str = 'zonal_average', max_iteration: int | None = None, epsilon: float = 0.0001, relaxation: float | None = None, num_threads: int = 0)[source]#

Replaces all undefined values (NaN) in a grid using the Gauss-Seidel method by relaxation.

  • mesh – Grid function on a uniform 2/3-dimensional grid to be filled.

  • first_guess

    Specifies the type of first guess grid. Supported values are:

    • zero means use 0.0 as an initial guess;

    • zonal_average means that zonal averages (i.e, averages in the X-axis direction) will be used.

    Defaults to zonal_average.

  • max_iterations – Maximum number of iterations to be used by relaxation. The default value is equal to the product of the grid dimensions.

  • epsilon – Tolerance for ending relaxation before the maximum number of iterations limit. Defaults to 1e-4.

  • relaxation – Relaxation constant. If 0 < relaxation < 1, the new value is an average weighted by the old and the one given by the Gauss-Seidel scheme. In this case, convergence is slowed down (under-relaxation). Over-relaxation consists in choosing a value of relaxation strictly greater than 1. For the method to converge, it is necessary that: 1 < relaxation < 2. If this parameter is not set, the method will choose the optimal value that allows the convergence criterion to be achieved in \(O(N)\) iterations, for a grid of size \(N_x=N_y=N\), relaxation = \({2\over{1+{\pi\over{N}}}}\); if the grid is of size \(Nx \times Ny\), \(N = N_{x}N_{y}\sqrt{2\over{N_{x}^2+N_{y}^2}}\)

  • num_threads – The number of threads to use for the computation. If 0 all CPUs are used. If 1 is given, no parallel computing code is used at all, which is useful for debugging. Defaults to 0.


A boolean indicating if the calculation has converged, i. e. if the value of the residues is lower than the epsilon limit set, and the the grid will have the all NaN filled with extrapolated values.