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

Physics use GridData #46

Merged
merged 7 commits into from
Dec 4, 2021
Merged

Physics use GridData #46

merged 7 commits into from
Dec 4, 2021

Conversation

elynnwu
Copy link
Collaborator

@elynnwu elynnwu commented Dec 3, 2021

In this PR, we replace the use of Grid in Physics with GridIndexing and GridData.

  • In update_dwind_phys.py, references to missing Grid functions are added here since this is the only spot that uses them. E.g., global_to_local_1d

@@ -146,8 +151,20 @@ def __call__(
self._dt,
)
# [TODO] needs a better solution to handle u_dt, v_dt quantity
u_dt_quantity = self.grid.make_quantity(u_dt)
v_dt_quantity = self.grid.make_quantity(v_dt)
u_dt_quantity = fv3gfs.util.Quantity(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Still a TODO for later but yeah, we should really not have to make a quantity to turn into a storage and then back into a quantity.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This should go away when we have proper PhysicsState, and each variable has a quantity and storage.

Copy link
Collaborator

@mcgibbon mcgibbon left a comment

Choose a reason for hiding this comment

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

Looks great! Not much to improve, just a couple nits. I'm commenting just because I should read through this again after the pace.util PR is merged in.

namelist,
comm: fv3gfs.util.CubedSphereCommunicator,
partitioner: TilePartitioner,
rank,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
rank,
rank: int,

partitioner: TilePartitioner,
rank,
namelist,
grid_info,
Copy link
Collaborator

Choose a reason for hiding this comment

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

For my reference, what is grid_info and why is it everywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the missing grid info that is currently provided by serialized data. We just haven't gotten around using MetricTerms in physics, will do that in a separate PR.

self,
stencil_factory: StencilFactory,
partitioner: TilePartitioner,
rank,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
rank,
rank: int,

What's the type hint on namelist? It can't be Namelist since that will be owned by pace.driver.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need to make config classes for Physics, so this is the old global spec.namelist. Need another PR for this.

)
self._update_vwind_stencil = stencil_factory.from_origin_domain(
update_vwind_stencil,
origin=(self.grid.halo, self.grid.halo, 0),
domain=(self.grid.nic + 1, self.grid.njc, self.grid.npz),
origin=(grid_indexing.n_halo, grid_indexing.n_halo, 0),
Copy link
Collaborator

Choose a reason for hiding this comment

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

So much indexing logic we have to do here! At least it gets cached since it's done on init.

@@ -68,7 +68,9 @@ def compute(self, inputs):
inputs["va_t1"] = copy.deepcopy(storage)
inputs["omga"] = copy.deepcopy(storage)
physics_state = PhysicsState(**inputs)
microph = Microphysics(self.grid.stencil_factory, self.grid, spec.namelist)
microph = Microphysics(
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Might as well spell out microphysics?

Copy link
Collaborator

@mcgibbon mcgibbon left a comment

Choose a reason for hiding this comment

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

LGTM! This should help a lot in decoupling.

@@ -1,6 +1,7 @@
import numpy as np

import fv3core._config as spec
import pace.util as util
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: it's a bit clearer to just import pace.util, there are a variety of things util means in our different modules.

@elynnwu elynnwu enabled auto-merge (squash) December 4, 2021 00:18
@elynnwu elynnwu merged commit ce043e1 into main Dec 4, 2021
@elynnwu elynnwu deleted the feature/physics-use-GridData branch December 4, 2021 00:47
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