Skip to content

Conversation

@luwang00
Copy link
Contributor

@luwang00 luwang00 commented Sep 23, 2025

Feature or improvement description
This PR adds a new set of generic 3D and 4D uniform grid interpolation tools under nwtc-library. The new interpolation tools:

  • Currently only supports 3D and 4D interpolation. Can add 2D interpolation in the future if needed.
  • Supports interpolation of scalar data, 3-by-1 vector data, and 6-by-1 vector data.
  • Will use C1 continuous cubic interpolation if possible. Toward grid boundary, quadratic interpolation is used. Linear interpolation is used if only two grid points are present.
  • If one of the grid dimensions has only 1 grid point, this dimension is effectively ignored.
  • Each dimension can be treated as either periodic or not.
  • Periodic dimensions will always use cubic interpolation, even if only two grid points are present, because the grid is effectively infinite in this direction.
  • For non-periodic dimensions, an out-of-bound query point will be snapped back to the grid boundary. A warning will be given at the first occurrence.
  • Note that for periodic dimensions, the subroutines assume the first and last grid points are NOT duplicates of each other.
  • Supports a more efficient way to compute surface slopes and normal vectors, replacing the previous method based on central differencing.
  • Are now used by SeaState and HydroDyn for interpolating wave kinematics and potential-flow wave excitation.

The new grid interpolation tools are developed with SeaState and HydroDyn in mind, which previously relied on linear interpolation. The present cubic interpolation is expected to be significantly more accurate even on coarser grids and with larger time steps, saving memory. The new interpolation tools are also generic and can potentially be used by other modules in the future.

There are merge conflicts with dev due to some recent changes by @andrew-platt that need to be resolved.
This PR will also create merge conflicts with dev-tc.

Impacted areas of the software
nwtc-library, seastate, hydrodyn, moordyn

Test results, if applicable
With the switch from linear to cubic interpolation, some r-test cases involving SeaState and HydroDyn now have slightly different results. These were updated.

To-Dos:

  • Resolve conflict with dev
  • Update r-test results

* Currently only supports 3D and 4D interpolation. Can add 2D interpolation in the future if needed.
* Supports interpolation of scalar data, 3-by-1 vector data, and 6-by-1 vector data.
* Will use C1 continuous cubic interpolation if possible. Toward grid boundary, quadratic interpolation is used. Linear interpolation is used if only two grid points are present.
* If one of the grid dimensions has only 1 grid point, this dimension is effectively ignored.
* Each dimension can be indicated as either periodic or not.
* Periodic dimensions will always use cubic interpolation because the grid is effectively infinite in this direction.
* For non-periodic dimensions, a query point will be snapped back to the grid boundary if out of bound. A warning will be given at the first occurrence.
* Note that for periodic dimensions, the subroutines assume the first and last grid points are NOT duplicates of each other.
@luwang00 luwang00 marked this pull request as ready for review September 30, 2025 04:03
@andrew-platt
Copy link
Collaborator

  • Visual Studio updates

@andrew-platt
Copy link
Collaborator

  • merge r-test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants