-
Notifications
You must be signed in to change notification settings - Fork 19
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
Improve design of nonorographic gravity wave parameterization #3226
Conversation
src/parameterized_tendencies/gravity_wave_drag/non_orographic_gravity_wave.jl
Outdated
Show resolved
Hide resolved
FT = eltype(ᶜρ) | ||
ρ_end = Fields.level(ᶜρ, Spaces.nlevels(axes(ᶜρ))) | ||
ρ_endm1 = Fields.level(ᶜρ, Spaces.nlevels(axes(ᶜρ)) - 1) | ||
Boundary_value = Fields.Field( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we give this a more specific name? And use snake_case
for the name?
u_end = Fields.level(ᶜu, Spaces.nlevels(axes(ᶜu))) | ||
u_endm1 = Fields.level(ᶜu, Spaces.nlevels(axes(ᶜu)) - 1) | ||
Boundary_value = Fields.Field( | ||
FT(2) .* Fields.field_values(u_end) .- Fields.field_values(u_endm1), | ||
axes(u_end), | ||
) | ||
R1 = Operators.RightBiasedC2F(; top = Operators.SetValue(Boundary_value)) | ||
R2 = Operators.RightBiasedF2C(;) | ||
ᶜu_p1 .= R2.(R1.(ᶜu)) | ||
|
||
v_end = Fields.level(ᶜv, Spaces.nlevels(axes(ᶜv))) | ||
v_endm1 = Fields.level(ᶜv, Spaces.nlevels(axes(ᶜv)) - 1) | ||
Boundary_value = Fields.Field( | ||
FT(2) .* Fields.field_values(v_end) .- Fields.field_values(v_endm1), | ||
axes(v_end), | ||
) | ||
R1 = Operators.RightBiasedC2F(; top = Operators.SetValue(Boundary_value)) | ||
R2 = Operators.RightBiasedF2C(;) | ||
ᶜv_p1 .= R2.(R1.(ᶜv)) | ||
|
||
Boundary_value = Fields.level(ᶜbf, Spaces.nlevels(axes(ᶜbf))) | ||
R1 = Operators.RightBiasedC2F(; top = Operators.SetValue(Boundary_value)) | ||
R2 = Operators.RightBiasedF2C(;) | ||
ᶜbf_p1 .= R2.(R1.(ᶜbf)) | ||
|
||
z_end = Fields.level(ᶜz, Spaces.nlevels(axes(ᶜz))) | ||
z_endm1 = Fields.level(ᶜz, Spaces.nlevels(axes(ᶜz)) - 1) | ||
Boundary_value = Fields.Field( | ||
FT(2) .* Fields.field_values(z_end) .- Fields.field_values(z_endm1), | ||
axes(z_end), | ||
) | ||
R1 = Operators.RightBiasedC2F(; top = Operators.SetValue(Boundary_value)) | ||
R2 = Operators.RightBiasedF2C(;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there's a lot of code duplication here, can we somehow reduce it?
c1f5529
to
acd7398
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we split off the manifest changes from the others? (e.g., we can upgrade to the latest ClimaCore in a separate PR)
I need to update some other packages too. I can update dependencies. |
3161a64
to
453fa3b
Compare
), | ||
Val(nc), | ||
) | ||
Bsum = sum(abs.(B0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will allocate, but I think we can write this in a non-allocating way
Hb = (z_kp1 - z_k) / log(ρ_k / ρ_kp1) # density scale height | ||
alp2 = FT1(0.25) / (Hb * Hb) | ||
ω_r = sqrt((bf_kp1 * bf_kp1 * k2) / (k2 + alp2)) # omc: (critical frequency that marks total internal reflection) | ||
fm = 0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use FT
to make sure that we have type-stable results for Float32. (here and everywhere in src/
)
e6d2cb6
to
a0bd8f0
Compare
a0bd8f0
to
3df4b53
Compare
Purpose
Part of #897
Content
1.The function non_orographic_gravity_wave_forcing function has been entirely refactored, now it is more efficient with much less allocations.
2. All three tests for non_orographic_gravity_wave in "/Users/xiexiaoya/ClimaAtmos.jl/test/parameterized_tendencies/gravity_wave/non_orographic_gravity_wave" have been rewriten.
To-do
Change the type of the variable "mask" to be Static Bitvector (This is a newly defined data type), since a vector frequently modified within the column_accumulate function will significantly impact the performance of the program on the GPU.