ecmwf / atlas

A library for numerical weather prediction and climate modelling
https://sites.ecmwf.int/docs/atlas
Apache License 2.0
115 stars 42 forks source link

Add regional interpolation #215

Closed benjaminmenetrier closed 1 month ago

benjaminmenetrier commented 3 months ago

This PR adds a new interpolation for regional structured source grids, available with the factory tag "regional-linear-2d". It uses a generic sparse matrix element class InterpElement added in interpolation/element, that might also be used for vertical interpolation in the future.

An associated test has been added, which defines field values on a coarse source grid, interpolates on a refined target grid, and compute the target field hash on each MPI task (2 tasks requested for this test).

The PR also includes a bugfix in functionspace/detail/StructuredColumns_setup.cc: it seems that the field xy is actually corresponding to the lonlat values for all structured grids. However, this was not true in develop for regional grids. I have implemented a minimal bugfix where the correct values of lonlat are specified in the xy field for regional grids too.

benjaminmenetrier commented 3 months ago

It seems the hash test is failing depending on the compiler, I'll do it differently.

benjaminmenetrier commented 3 months ago

The new test is working.

benjaminmenetrier commented 3 months ago

I have extended the regional interpolation test : accuracy and adjoint tests, for both 1D and 2D fields.

benjaminmenetrier commented 2 months ago

Thank you very much @wdeconinck for your very relevant comments. I realize that I am not well aware of memory usage in C++ and should be more careful about it.