Most operators don't like tuples
- Dominant language
- Julia
- Stars
- 117
- Forks
- 19
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 41
Description
## Describe the bug
Everything except for interpolation and 10% of the upwinding code is not implemented with `RecursiveApply`. Sad face. This means that they cannot automatically be applied to Fields of Tuples.
## To Reproduce
See branch `ej/add_cloudy` of `KinematicDriver.jl`. In the file `src/K1DModel/tendency.jl` we compute advection tendencies as a `Field{NTuple}` using the "hacky" dolla-dolla-i `:($$i)`. To see why we are doing it this way, try replacing the function `advection_tendency!(::CO.CloudyPrecip, dY, Y, aux, t)` (last function of the file) with:
```
@inline function advection_tendency!(::CO.CloudyPrecip, dY, Y, aux, t)
FT = eltype(Y.ρq_vap)
Nmom = Int(sum(aux.cloudy_params.NProgMoms))
If = CC.Operators.InterpolateC2F()
∂ = CC.Operators.DivergenceF2C(
bottom = CC.Operators.Extrapolate(),
top = CC.Operators.SetValue(ntuple(_ -> CC.Geometry.WVector(FT(0)), 6)),
)
fcc = CC.Operators.FluxCorrectionC2C(bottom = CC.Operators.Extrapolate(), top = CC.Operators.Extrapolate())
@. dY.moments = -∂(
(
aux.prescribed_velocity.ρw / If(aux.moisture_variables.ρ) +
map(CC.Geometry.WVector, If(aux.cloudy_velocity.weighted_vt) * FT(-1))
) * If(Y.moments),
)
@. dY.moments += fcc(
(
aux.prescribed_velocity.ρw / If(aux.moisture_variables.ρ) +
map(CC.Geometry.WVector, If(aux.cloudy_velocity.weighted_vt) * FT(-1))
),
Y.moments
)
return dY
end
```
and then run the example from the REPL via
```
julia --project=test
julia > include("test/experiments/KiD_driver/KiD_driver.jl")
```
You will see that the recursion is not used in many places where it should be.
Any relevant system information:
- Julia version - 1.10
- operating system - macOS
Talk to @dennisYatunin for more information/knowledge on necessary steps.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading src/K1DModel/tendency.jl, especially advection_tendency!(::CO.CloudyPrecip), then reproduce the issue with the KiD_driver.jl REPL commands. Compare the tuple-field path using RecursiveApply with the existing interpolation and upwinding cases. Done means the relevant operators apply recursively to Fields of Tuples without the hacky dolla-dolla-i approach.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100