Skip to content

Conversation

haakon-e
Copy link
Member

@haakon-e haakon-e commented Oct 9, 2025

This pull request refactors and streamlines the hyperdiffusion logic in src/prognostic_equations/hyperdiffusion.jl, focusing on code clarity, maintainability, and consistency.

Key improvements and changes:

  • extract components from parent structs (e.g. moisture_model from atmos, or ᶜu from p.precomputed) to simplify and shorten their inline usage
  • combined multi-line assignments and expressions, making code more concise.
  • give new names to 4th order derivatives to clarify their usage.
    For example, instead of the (somewhat confusing) expression
@. ᶜ∇²u =
        divergence_damping_factor * C123(wgradₕ(divₕ(ᶜ∇²u))) -
        C123(wcurlₕ(C123(curlₕ(ᶜ∇²u))))
@. Yₜ.c.uₕ -= ν₄_vorticity * C12(ᶜ∇²u)

I propose assigning a new name to the resulting calculation. Importantly, this does not affect the underlying memory of the data

ᶜ∇⁴u = @. ᶜ∇²u =
        divergence_damping_factor * C123(wgradₕ(divₕ(ᶜ∇²u))) -
        C123(wcurlₕ(C123(curlₕ(ᶜ∇²u))))
@. Yₜ.c.uₕ -= ν₄_vorticity * C12(ᶜ∇⁴u)

These changes collectively improve the maintainability and readability of the hyperdiffusion implementation, while ensuring consistent and correct use of model parameters throughout the codebase.

@haakon-e
Copy link
Member Author

haakon-e commented Oct 9, 2025

This change is part of the following stack:

Change managed by git-spice.

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.

1 participant