Skip to content

Commit

Permalink
Merge #916
Browse files Browse the repository at this point in the history
916: Add column_state helper func r=charleskawczynski a=charleskawczynski



Co-authored-by: Charles Kawczynski <[email protected]>
  • Loading branch information
bors[bot] and charleskawczynski authored Apr 7, 2022
2 parents 332db64 + d550560 commit f5a11d1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
authors = ["Climate Modeling Alliance"]
name = "TurbulenceConvection"
uuid = "8e072fc4-01f8-44fb-b9dc-f9336c367e6b"
version = "0.17.3"
version = "0.17.4"

[compat]
CLIMAParameters = "0.4"
Expand Down
21 changes: 1 addition & 20 deletions integration_tests/3dBomex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,33 +223,14 @@ function ∑tendencies_3d_bomex!(tendencies, prog, cache, t)

Ni, Nj, _, _, Nh = size(CC.Spaces.local_geometry_data(hv_center_space))
for h in 1:Nh, j in 1:Nj, i in 1:Ni
inds = (i, j, h)
prog_cent_column = CC.column(prog.cent, inds...)
prog_face_column = CC.column(prog.face, inds...)
aux_cent_column = CC.column(aux.cent, inds...)
aux_face_column = CC.column(aux.face, inds...)
tends_cent_column = CC.column(tendencies.cent, inds...)
tends_face_column = CC.column(tendencies.face, inds...)
prog_column = CC.Fields.FieldVector(cent = prog_cent_column, face = prog_face_column)
aux_column = CC.Fields.FieldVector(cent = aux_cent_column, face = aux_face_column)
tends_column = CC.Fields.FieldVector(cent = tends_cent_column, face = tends_face_column)

state = TC.State(prog_column, aux_column, tends_column)

state = TC.column_state(prog, aux, tendencies, i, j, h)
surf = get_surface(case.surf_params, grid, state, t, param_set)
force = case.Fo
radiation = case.Rad

TC.affect_filter!(edmf, grid, state, param_set, surf, case.casename, t)

# Update aux / pre-tendencies filters. TODO: combine these into a function that minimizes traversals
# Some of these methods should probably live in `compute_tendencies`, when written, but we'll
# treat them as auxiliary variables for now, until we disentangle the tendency computations.
Cases.update_forcing(case, grid, state, t, param_set)
Cases.update_radiation(case.Rad, grid, state, param_set)

TC.update_aux!(edmf, grid, state, surf, param_set, t, Δt)

# compute tendencies
TC.compute_turbconv_tendencies!(edmf, grid, state, param_set, surf, Δt)
end
Expand Down
33 changes: 33 additions & 0 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -596,3 +596,36 @@ struct State{P, A, T}
aux::A
tendencies::T
end

"""
column_state(prog, aux, tendencies, inds...)
Create a columnar state given full 3D states
- `prog` prognostic state
- `aux` auxiliary state
- `tendencies` tendencies state
- `inds` `i`, `j`, `h` indices
## Example
```julia
local_geom = ClimaCore.Spaces.local_geometry_data(space)
Ni, Nj, _, _, Nh = size(local_geom)
for h in 1:Nh, j in 1:Nj, i in 1:Ni
inds = (i, j, h)
state = TC.column_state(prog, aux, tendencies, inds...)
...
end
"""
function column_state(prog, aux, tendencies, inds...)
prog_cent_column = CC.column(prog.cent, inds...)
prog_face_column = CC.column(prog.face, inds...)
aux_cent_column = CC.column(aux.cent, inds...)
aux_face_column = CC.column(aux.face, inds...)
tends_cent_column = CC.column(tendencies.cent, inds...)
tends_face_column = CC.column(tendencies.face, inds...)
prog_column = CC.Fields.FieldVector(cent = prog_cent_column, face = prog_face_column)
aux_column = CC.Fields.FieldVector(cent = aux_cent_column, face = aux_face_column)
tends_column = CC.Fields.FieldVector(cent = tends_cent_column, face = tends_face_column)

return State(prog_column, aux_column, tends_column)
end

2 comments on commit f5a11d1

@charleskawczynski
Copy link
Member

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/58119

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.17.4 -m "<description of version>" f5a11d1645312332616696af8a01d1f13d17928f
git push origin v0.17.4

Please sign in to comment.