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

Partitioner refactor 1 #49

Merged
merged 33 commits into from
Sep 18, 2024
Merged

Partitioner refactor 1 #49

merged 33 commits into from
Sep 18, 2024

Conversation

jwallwork23
Copy link
Contributor

@jwallwork23 jwallwork23 commented Sep 11, 2024

A first refactoring of the Partitioner class.

Main changes

  • Combine get_top_neighbours, get_bottom_neighbours, etc. into a single method.
  • Combine various variable pairs with names including _0 or _1 into vectors.
  • Use vectors for ids, halos, offsets, etc. across the four directions (left, right, bottom, top) and loop over the directions for conciseness.

These changes cut down duplication and will make it easier to switch direction orderings.

Future work

Some of this gets propagated through to the ZoltanPartitioner class but it will need further refactoring. There is also further refactoring to be done handling the bounding boxes.

@jwallwork23 jwallwork23 self-assigned this Sep 11, 2024
Copy link
Contributor

@TomMelt TomMelt left a comment

Choose a reason for hiding this comment

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

Thanks @jwallwork23 . Looks good so far


// Create 2 dimensions
// The values to be written are associated with the netCDF variable by
// assuming that the last dimension of the netCDF variable varies fastest in
// the C interface
const int NDIMS = 2;
const int NDIMS = 2; // TODO: Why redeclared?
Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. It is also defined in Grid.cpp. I think we will only ever work with a 2D landmask. So I don't know why it's defined so many times.

I am not suggesting to change as part of this PR but perhaps we can factor this out in the second round

}

// There are two neighbours for each dimension
const int NNBRS = NDIMS * 2; // TODO: Why redeclared?
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess when we figure out the other one we can remove this too?

@jwallwork23
Copy link
Contributor Author

Thanks @TomMelt!

@jwallwork23 jwallwork23 merged commit 61bd1df into main Sep 18, 2024
3 checks passed
@jwallwork23 jwallwork23 deleted the partitioner-refactor branch September 18, 2024 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants