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

Add distributed_remapping.jl #1475

Merged
merged 4 commits into from
Oct 5, 2023
Merged

Add distributed_remapping.jl #1475

merged 4 commits into from
Oct 5, 2023

Conversation

Sbozzolo
Copy link
Member

@Sbozzolo Sbozzolo commented Sep 26, 2023

This pull request introduces a new way to interpolate a field onto a given set of points that works for distributed simulations.

This change introduces a new object, a Remapper. Remappers are process-local and are defined starting from the target points where we want to interpolate and the Space. Remappers contain all the information necessary to perform interpolations of all the fields that are defined on the same Space.

Once a Remapper is defined, it can be used as many times as needed. To use a Remapper, just call the new interpolate function with the field you want to remap:

remapper = Remapper(hcoords, zcoords, space)
interpolate(remapper, field) 
# => Array of values interpolated on hcoords × zcoords

Internally, interpolate computes the process-local points and then calls a MPI.reduce to return the final value in the root process.

@Sbozzolo
Copy link
Member Author

bors try

bors bot added a commit that referenced this pull request Sep 27, 2023
@bors
Copy link
Contributor

bors bot commented Sep 27, 2023

try

Build failed:

@Sbozzolo
Copy link
Member Author

bors try

bors bot added a commit that referenced this pull request Sep 27, 2023
@bors
Copy link
Contributor

bors bot commented Sep 28, 2023

try

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@Sbozzolo Sbozzolo force-pushed the gb/interpolate_mpi branch 2 times, most recently from 5177405 to 694e3eb Compare September 29, 2023 23:42
@Sbozzolo Sbozzolo marked this pull request as ready for review October 2, 2023 16:35
@Sbozzolo Sbozzolo force-pushed the gb/interpolate_mpi branch 2 times, most recently from c464007 to adb5fbb Compare October 2, 2023 21:22
@Sbozzolo
Copy link
Member Author

Sbozzolo commented Oct 2, 2023

bors try

bors bot added a commit that referenced this pull request Oct 2, 2023
@bors
Copy link
Contributor

bors bot commented Oct 2, 2023

try

Build failed:

@Sbozzolo
Copy link
Member Author

Sbozzolo commented Oct 3, 2023

bors try

@Sbozzolo Sbozzolo force-pushed the gb/interpolate_mpi branch from 796e659 to 089f1e4 Compare October 3, 2023 17:41
bors bot added a commit that referenced this pull request Oct 3, 2023
@bors
Copy link
Contributor

bors bot commented Oct 3, 2023

try

Build failed:

@Sbozzolo Sbozzolo force-pushed the gb/interpolate_mpi branch 2 times, most recently from 3a9d76e to 6b40a07 Compare October 3, 2023 20:19

coords = Fields.coordinate_field(hv_center_space)

xpts = range(-500.0, 500.0, length = 21)
Copy link
Member

Choose a reason for hiding this comment

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

I think you should be able to just do

Suggested change
xpts = range(-500.0, 500.0, length = 21)
xpts = range(-Geometry.XPoint(500.0), Geometry.XPoint(500.0), length = 21)

Copy link
Member Author

Choose a reason for hiding this comment

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

I can do this only in the case of a plane.

I need to build hcoords with the correct type, and I cannot easily assemble, e.g., XYPoints from XPoints and YPoints (see #1476).

@Sbozzolo Sbozzolo force-pushed the gb/interpolate_mpi branch 2 times, most recently from c329941 to 13ba6be Compare October 3, 2023 23:49
@Sbozzolo
Copy link
Member Author

Sbozzolo commented Oct 4, 2023

bors try

bors bot added a commit that referenced this pull request Oct 4, 2023
@bors
Copy link
Contributor

bors bot commented Oct 4, 2023

try

Build failed:

@Sbozzolo Sbozzolo force-pushed the gb/interpolate_mpi branch from 13ba6be to 3904a2a Compare October 4, 2023 16:58
@Sbozzolo
Copy link
Member Author

Sbozzolo commented Oct 4, 2023

bors try

bors bot added a commit that referenced this pull request Oct 4, 2023
@bors
Copy link
Contributor

bors bot commented Oct 4, 2023

try

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@Sbozzolo
Copy link
Member Author

Sbozzolo commented Oct 4, 2023

@charleskawczynski if you want to have another look, I think that this is ready to be merged

@simonbyrne
Copy link
Member

bors r+

bors bot added a commit that referenced this pull request Oct 4, 2023
1464: Check if "ClimaCore version" is already attribute r=simonbyrne a=Sbozzolo

HDF5.jl complains if you try writing an attribute that already exists, so that appending to `ClimaCore`-generated files can be a problem 



1475: Add distributed_remapping.jl r=simonbyrne a=Sbozzolo

This pull request introduces a new way to interpolate a field onto a given set of points that works for distributed simulations.

This change introduces a new object, a `Remapper`. `Remapper`s are process-local and are defined starting from the target points where we want to interpolate and the `Space`. `Remapper`s contain all the information necessary to perform interpolations of all the fields that are defined on the same `Space`. 

Once a `Remapper` is defined, it can be used as many times as needed. To use a `Remapper`, just call the new `interpolate` function with the field you want to remap:
```julia
remapper = Remapper(hcoords, zcoords, space)
interpolate(remapper, field) 
# => Array of values interpolated on hcoords × zcoords
```
Internally, `interpolate` computes the process-local points and then calls a `MPI.reduce` to return the final value in the root process.

Co-authored-by: Gabriele Bozzola <[email protected]>
@bors
Copy link
Contributor

bors bot commented Oct 5, 2023

This PR was included in a batch that timed out, it will be automatically retried

end

function interpolation_weights(
horz_mesh::Meshes.AbstractMesh1D,
Copy link
Member

Choose a reason for hiding this comment

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

At some point I’d like to rename this variable, maybe just use hmesh?

@bors
Copy link
Contributor

bors bot commented Oct 5, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit 6e07029 into main Oct 5, 2023
@bors bors bot deleted the gb/interpolate_mpi branch October 5, 2023 03:23
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