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 coupler_push! and coupler_pull! to Sea Breeze #83

Merged
merged 2 commits into from
Jul 13, 2022
Merged

Conversation

jb-mackay
Copy link
Contributor

@jb-mackay jb-mackay commented Jul 9, 2022

Purpose and Content

Adds coupler_push! and coupler_pull! methods for each component in the sea breeze demo. These methods wrap how each component interacts with the coupler (sending & receiving via coupler_put and coupler_get).

This PR also moves the coupled time-step into the CouplerState struct so that it is accessible in the push/pull calls.

Benefits and Risks

Push/pull: A major benefit is the conciseness of the main driver loop - which now consists of only coupler_push!, step! and coupler_pull! calls. This means we can standardize the simulation run loop and develop a set of general coupled timesteppers that take some inputted component order. This may not be a high priority as custom coupled steppers and schemes will be useful.

Coupled timestep storage: As the coupled timestepping info becomes more well defined, this may need to be refined (e.g. a CoupledTimestepper struct that could pair with the CouplerState struct as a full Coupler). This will likely be determined by how accumulation is ultimately handled.

Linked Issues

Part of #44

PR Checklist

  • This PR has a corresponding issue OR is linked to an SDI.
  • I have followed CliMA's codebase contribution and style guidelines OR N/A.
  • I have followed CliMA's documentation policy.
  • I have checked all issues and PRs and I certify that this PR does not duplicate an open PR.
  • I linted my code on my local machine prior to submission OR N/A.
  • Unit tests are included OR N/A.
  • Code used in an integration test OR N/A.
  • All tests ran successfully on my local machine OR N/A.
  • All classes, modules, and function contain docstrings OR N/A.
  • Documentation has been added/updated OR N/A.

@jb-mackay jb-mackay requested a review from LenkaNovak July 9, 2022 06:33
@jb-mackay jb-mackay self-assigned this Jul 9, 2022
@jb-mackay jb-mackay added the enhancement New feature or request label Jul 9, 2022
@jb-mackay
Copy link
Contributor Author

Will add more docs in #75

Comment on lines +244 to +246
T_sfc_ocean = coupler_get(coupler, :T_sfc_ocean, atmos)
T_sfc_land = coupler_get(coupler, :T_sfc_land, atmos)
atmos.integrator.p.T_sfc .= T_sfc_land .+ T_sfc_ocean
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@LenkaNovak this is a good example of why we would want a coupler_get rather than coupler_get! - because the atmos boundary is shared by land and ocean we can't just use .= directly as in coupler_get!.

@@ -38,7 +38,7 @@ end

simA = SimulationA(ones(spaceA))
simB = SimulationB(zeros(spaceB))
coupler = CouplerState()
coupler = CouplerState(1.0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Coupled timestep storage: As the coupled timestepping info becomes more well defined, this may need to be refined (e.g. a CoupledTimestepper struct that could pair with the CouplerState struct as a full Coupler). This will likely be determined by how accumulation is ultimately handled.

This is one reason that having a separation here might be useful! You shouldn't really need time information when testing these CouplerState put and get methods. On the other hand, push and pull are more tied into the time coordination (since they would be part of a coupled step method). I still think we can punt on this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with the separation between put/get and push/pull. But I would expect Δt_coupled to be in the CoupledSimulation to mimic the model simulations. There seems to be quite a bit of cross-over between the CoupledSimulation and CoupledState. Any thoughts on combining these?

Copy link
Collaborator

@LenkaNovak LenkaNovak Jul 13, 2022

Choose a reason for hiding this comment

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

If we do this, it would be a separate PR anyway, so I'm happy to go ahead with merging this one. Thanks for pushing this through! 🚀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with the separation between put/get and push/pull. But I would expect Δt_coupled to be in the CoupledSimulation to mimic the model simulations. There seems to be quite a bit of cross-over between the CoupledSimulation and CoupledState. Any thoughts on combining these?

I think there is a separation - CoupledSimulation should fit the Simulations interface and deals with packing up component simulations and the coupler (currently just a CouplerState) and deals with how to execute things. More on the time stepper side as a whole.

CouplerState deals with the actual coupled fields and passing them around. This is the part that will deal with MPI and how things get distributed.

@jb-mackay jb-mackay mentioned this pull request Jul 11, 2022
10 tasks
@jb-mackay
Copy link
Contributor Author

bors r+

@bors
Copy link
Contributor

bors bot commented Jul 13, 2022

@bors bors bot merged commit f0d9aaf into main Jul 13, 2022
@bors bors bot deleted the bm/seabreeze_pushpull branch July 13, 2022 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants