RegularGridProlongator

class emg3d.solver.RegularGridProlongator(x, y, cxy)[source]

Bases: object

Prolongate field from coarse to fine grid.

This is a heavily modified and adapted version of scipy.interpolate.RegularGridInterpolator.

The main difference (besides the pre-sets) is that this version allows to initiate an instance with the coarse and fine grids. This initialize will compute the required weights, and it has therefore only to be done once.

After this, interpolating values from the coarse to the fine grid can be carried out much faster.

Simplifications in comparison to scipy.interpolate.RegularGridInterpolator:

  • No sanity checks what-so-ever.
  • Only 2D data;
  • method='linear';
  • bounds_error=False;
  • fill_value=None.

It results in a speed-up factor of about 2, independent of grid size, for this particular case. The prolongation is the second-most expensive part of multigrid after the smoothing. Trying to improve this further might therefore be useful.

Parameters:
x, y : ndarray

The x/y-coordinates defining the coarse grid.

cxy : ndarray of shape (…, 2)

The ([[x], [y]]).T-coordinates defining the fine grid.

Methods Summary

__call__(values) Return values of coarse grid on fine grid locations.

Methods Documentation

__call__(values)[source]

Return values of coarse grid on fine grid locations.

Parameters:
values : ndarray

Values corresponding to x/y-coordinates.

Returns:
result : ndarray

Values corresponding to cxy-coordinates.