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

New cubed sphere 2 grid #245

Draft
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

mo-jonasganderton
Copy link

Description

Initial implementation of a new cubed sphere grid.

@odlomax and @wdeconinck can both have a look over to recommend any changes - I expect this will have changed once everything else has also been implemented.

Using this implementation generates the following lonlat points - n=12, red=tile0, purple=tile5, darkest point of each colour is tij=0, lightest point is tij=143. This matches the sequence of the points in the LFRic cubed sphere.
CubedSphere_3_0_2

Impact

Once everything else is also implemented, this makes the cubed sphere more maintainable.

Checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have run the unit tests before creating the PR

@FussyDuck
Copy link

FussyDuck commented Nov 22, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@odlomax odlomax left a comment

Choose a reason for hiding this comment

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

Looks good to see a much simpler CS grid! I've added some changes. It's mostly style related. I'm sure @wdeconinck can make some more comments/suggestions.

After this, we should probably plumb the grid into the grid builder.

@wdeconinck, what do you think?

src/atlas/grid/detail/grid/CubedSphere2.cc Show resolved Hide resolved
src/atlas/grid/detail/grid/CubedSphere2.cc Show resolved Hide resolved
src/atlas/grid/detail/grid/CubedSphere2.cc Show resolved Hide resolved
src/atlas/grid/detail/grid/CubedSphere2.h Show resolved Hide resolved
src/atlas/grid/detail/grid/CubedSphere2.h Show resolved Hide resolved

// Get point between [-pi/4..pi/4] given index and number of points along edge
// Applies offset to get from prime to dual mesh
double CubedSphere2::index_to_curvilinear(idx_t index) const {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the intent is clearer if we define:

using PointAlphaBeta = Point2;

PointAlphaBeta CubedSphere2::ij_to_curvilinear_coord(idx_t i, idx_t j) {
  const auto get_coord = [&](idx_t idx){
    return M_PI / 2 * (-0.5 + (0.5 + idx) / N());
  };
  return {get_coord(i), get_coord(j)};
}

PointXY CubedSphere2::curvilinear_to_tangent_coord(const PointAlphaBeta& curvi_coord) {
  return {std::tan(curvi_coord[0]), std::tan(curvi_coord[1])};
}

PointXYZ CubedSphere2::tangent_to_xyz_coord(const PointXY& tan_coord) {
  /// Perform coordinate rotations...
}

src/atlas/grid/detail/grid/CubedSphere2.h Show resolved Hide resolved
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