Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpolate from cubedsphere mesh to structured columns #146

Conversation

odlomax
Copy link
Contributor

@odlomax odlomax commented Jun 7, 2023

Hi @wdeconinck,

I've been working on a test to demonstrate functionality that will help @MayeulDestouches with some of his SABER work. It demonstrates how to interpolate from an arbitrarily partitioned CubedSphere mesh (and possibly others) to a StructuredColumns functionspace. This is historically quite tricky, due to the constraints on placed on StructuredColumns. I basically cheat and use a couple of intermediate PointCloud functionspaces to sort out all the redistribution stuff.

One of the things I needed to write was this lambda:

    const auto makePointCloud = [](const Grid& grid, const grid::Partitioner partitioner) {

        const auto distribution = grid::Distribution(grid, partitioner);

        auto lonLats = std::vector<PointXY>{};
        auto idx = gidx_t{0};
        for (const auto& lonLat : grid.lonlat()) {
            if (distribution.partition(idx++) == mpi::rank()) {
                lonLats.emplace_back(lonLat.data());
            }
        }
        return functionspace::PointCloud(lonLats);
    };

Seems to me like there should be a constructor in PointCloud for this. Perhaps two: a Partitioner version and a Distribution version.

Do you agree? If so, it's pretty easy for me to add them.

@odlomax odlomax changed the title Feature/cubedsphere to structuredcolumns interp Interpolate from cubedsphere mesh to structured columns Jun 7, 2023
}
sourceField.haloExchange();

// Interpolate from source field to targetCubedSpherePointCloud field.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ytremolet @fmahebert

FYI, this is how you can do a global interpolation with Atlas. It's even simpler if it's a NodeColumns to NodeColumns interpolation as you don't have to make the intermediate PointCloud functionspaces.

@odlomax odlomax marked this pull request as ready for review June 22, 2023 13:50
@odlomax
Copy link
Contributor Author

odlomax commented Jun 22, 2023

Hi @wdeconinck,

This PR fixes a crash that @MayeulDestouches was experiencing when using the "cubedsphere" matching mesh partitioner in SABER. @MayeulDestouches, could you add a link to the issue here.

Cheers!

@wdeconinck
Copy link
Member

@odlomax thanks for this. The only problem seems to have been the "listSize"?

I agree with a PointCloud constructor as you proposed as well, this could be in a following PR.

@MayeulDestouches
Copy link

The bug solved by this PR is documented here. I copy it here in case people don't have access to it:

As another limitation of this three-step atlas interpolation, code will fail on 1, 2 and 3 PEs for some combination of grids (eg from CS-LFR-12 to F15). For any CS-LFR grid, we can find a Gaussian grid fine enough to make the cubed-sphere matching mesh partitioning fail.

@odlomax
Copy link
Contributor Author

odlomax commented Jun 22, 2023

@odlomax thanks for this. The only problem seems to have been the "listSize"?

I agree with a PointCloud constructor as you proposed as well, this could be in a following PR.

That's correct. Ideally, I'd like a cubed-sphere mesh generator that creates non-disjoint meshes. Then we could use the standard matching mesh tools. A dream for Cubed-Sphere 2.0 perhaps...

@wdeconinck wdeconinck merged commit 5437eb2 into ecmwf:develop Jun 22, 2023
wdeconinck added a commit that referenced this pull request Jul 10, 2023
* release/0.34.0: (78 commits)
  Version 0.34.0
  Fix global indexing for meshes from structured grids with pole patch
  Fix cells().global_index() metadata for RegularLonLat grids in StructuredMeshGenerator
  BuildHalo: mark interior added cells as ghost
  Add example-plugin in doc
  Introduce colon-separated environment variable ATLAS_PLUGIN_PATH to simplify plugin detection
  Interpolate from cubedsphere mesh to structured columns (#146)
  Fix FieldSet::field(std::string) when field has been renamed (fixes #147)
  Further separate compilation features
  Field with functionspace optional
  Introduce features to disable compilation of structural components
  Remove interdependencies between structural components
  CMake cleanup
  Move files to correct places
  Introduce atlas::mdspan, contributed from github.com/kokkos/mdspan
  Disable GHA "nvhpc-22.11" as there are random compilation errors, probably related to insufficient disk or memory space
  atlas_io: fix test command in standalone build
  Fix and test some use cases with / without calling atlas::initialise()
  Access to atlas::Library::dataPath without initialising
  Enable latitude normalisation in KDTree coordinate transform (#140)
  ...
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.

3 participants