Skip to content

Commit 4ee45e0

Browse files
authored
Reorganize module and notations (#204)
1 parent 5512355 commit 4ee45e0

28 files changed

+1325
-985
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
TEST_GROUP: "tracer_diagnostics"
6666

6767
ke_diagnostics:
68-
name: KE and TKE diagnostics - Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
68+
name: KE diagnostics - Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
6969
runs-on: ${{ matrix.os }}
7070
timeout-minutes: 120
7171
strategy:
@@ -89,6 +89,31 @@ jobs:
8989
env:
9090
TEST_GROUP: "ke_diagnostics"
9191

92+
tke_diagnostics:
93+
name: TKE diagnostics - Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
94+
runs-on: ${{ matrix.os }}
95+
timeout-minutes: 120
96+
strategy:
97+
fail-fast: false
98+
matrix:
99+
version:
100+
- '1.10'
101+
os:
102+
- ubuntu-latest
103+
arch:
104+
- x64
105+
steps:
106+
- uses: actions/checkout@v4
107+
- uses: julia-actions/setup-julia@v2
108+
with:
109+
version: ${{ matrix.version }}
110+
arch: ${{ matrix.arch }}
111+
- uses: julia-actions/cache@v2
112+
- uses: julia-actions/julia-buildpkg@v1
113+
- uses: julia-actions/julia-runtest@v1
114+
env:
115+
TEST_GROUP: "tke_diagnostics"
116+
92117
pe_diagnostics:
93118
name: PE diagnostics - Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
94119
runs-on: ${{ matrix.os }}

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Oceanostics"
22
uuid = "d0ccf422-c8fb-49b5-a76d-74acdde946ac"
33
authors = ["tomchor <[email protected]>"]
4-
version = "0.15.3"
4+
version = "0.16.0"
55

66
[deps]
77
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
@@ -11,7 +11,7 @@ SeawaterPolynomials = "d496a93d-167e-4197-9f49-d3af4ff8fe40"
1111

1212
[compat]
1313
DocStringExtensions = "0.9"
14-
Oceananigans = "^0.96.30"
14+
Oceananigans = "^0.96.30, 0.97"
1515
SeawaterPolynomials = "0.3"
1616
julia = "1.9"
1717

docs/examples/kelvin_helmholtz.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ Q = QVelocityGradientTensorInvariant(model)
7878
# variance dissipation rate and diffusive term. When volume-integrated, these two quantities should
7979
# be equal.
8080

81-
∫χᴰ = Integral(TracerVarianceDissipationRate(model, :b))
82-
∫χ = Integral(TracerVarianceDiffusiveTerm(model, :b))
81+
∫χᴰ = Integral(TracerVarianceEquation.DissipationRate(model, :b))
82+
∫χ = Integral(TracerVarianceEquation.Diffusion(model, :b))
8383

8484

8585
# Now we write these quantities, along with `b`, to a NetCDF:
@@ -163,6 +163,6 @@ end
163163
# ![](kelvin_helmholtz.mp4)
164164
#
165165
# Similarly to the kinetic energy dissipation rate (see the [Two-dimensional turbulence example](@ref two_d_turbulence_example)),
166-
# `TracerVarianceDissipationRate` and `TracerVarianceDiffusiveTerm` are implemented
166+
# `TracerVarianceDissipationRate` and `TracerVarianceDiffusion` are implemented
167167
# with a energy-conserving formulation, which means that (for `NoFlux` boundary conditions) their
168168
# volume-integral should be exactly (up to machine precision) the same.

docs/examples/tilted_bottom_boundary_layer.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,7 @@ run!(simulation)
177177

178178
# Now we'll read the results and plot an animation
179179

180-
using Rasters
181-
182-
ds = RasterStack(simulation.output_writers[:nc].filepath)
180+
ds = NCDataset(simulation.output_writers[:nc].filepath)
183181

184182
# We now use Makie to create the figure and its axes
185183

@@ -198,31 +196,31 @@ ax3 = Axis(fig[2, 3]; title = "PV", kwargs...);
198196

199197
n = Observable(1)
200198

201-
x_caa = Array(dims(ds, :x_caa))
202-
x_faa = Array(dims(ds, :x_faa))
203-
z_aac = Array(dims(ds, :z_aac))
204-
z_aaf = Array(dims(ds, :z_aaf))
199+
x_caa = ds["x_caa"][:]
200+
x_faa = ds["x_faa"][:]
201+
z_aac = ds["z_aac"][:]
202+
z_aaf = ds["z_aaf"][:]
205203

206-
bₙ = @lift Array(ds.b[Ti=$n, y_aca=Near(0)])
204+
bₙ = @lift ds["b"][:, :, $n]
207205

208-
Riₙ = @lift Array(ds.Ri[Ti=$n, y_aca=Near(0)])
206+
Riₙ = @lift ds["Ri"][:, :, $n]
209207
hm1 = heatmap!(ax1, x_caa, z_aaf, Riₙ; colormap = :coolwarm, colorrange = (-1, +1))
210208
contour!(ax1, x_caa, z_aac, bₙ; levels=10, color=:white, linestyle=:dash, linewidth=0.5)
211209
Colorbar(fig[3, 1], hm1, vertical=false, height=8, ticklabelsize=14)
212210

213-
Roₙ = @lift Array(ds.Ro[Ti=$n, y_afa=Near(0)])
211+
Roₙ = @lift ds["Ro"][:, :, $n]
214212
hm2 = heatmap!(ax2, x_faa, z_aaf, Roₙ; colormap = :balance, colorrange = (-10, +10))
215213
contour!(ax2, x_caa, z_aac, bₙ; levels=10, color=:black, linestyle=:dash, linewidth=0.5)
216214
Colorbar(fig[3, 2], hm2, vertical=false, height=8, ticklabelsize=14)
217215

218-
PVₙ = @lift Array(ds.PV[Ti=$n, y_afa=Near(0)])
216+
PVₙ = @lift ds["PV"][:, :, $n]
219217
hm3 = heatmap!(ax3, x_faa, z_aaf, PVₙ; colormap = :coolwarm, colorrange =*f₀.*(-1.5, +1.5))
220218
contour!(ax3, x_caa, z_aac, bₙ; levels=10, color=:white, linestyle=:dash, linewidth=0.5)
221219
Colorbar(fig[3, 3], hm3, vertical=false, height=8, ticklabelsize=14);
222220

223221
# Now we mark the time by placing a vertical line in the bottom panel and adding a helpful title
224222

225-
times = dims(ds, :Ti)
223+
times = ds["time"][:]
226224
title = @lift "Time = " * string(prettytime(times[$n]))
227225
fig[1, 1:3] = Label(fig, title, fontsize=24, tellwidth=false);
228226

@@ -235,6 +233,8 @@ record(fig, filename * ".mp4", 1:length(times), framerate=10) do i
235233
n[] = i
236234
end
237235

236+
close(ds)
237+
238238
# ![](tilted_bottom_boundary_layer.mp4)
239239
#
240240
# The animation shows negative PV being produced at the bottom due to drag, which leads to the

docs/examples/two_dimensional_turbulence.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,24 @@ simulation.callbacks[:progress] = Callback(progress, IterationInterval(100))
6161
# Using Oceanostics we can easily calculate two important diagnostics, the kinetic energy KE and
6262
# its dissipation rate ε
6363

64-
KE = KineticEnergy(model)
65-
ε = KineticEnergyDissipationRate(model)
64+
KE = KineticEnergyEquation.KineticEnergy(model)
65+
ε = KineticEnergyEquation.DissipationRate(model)
6666

6767
# And we can define their volume-integrals
6868

6969
∫KE = Integral(KE)
7070
∫ε = Integral(ε)
7171

7272
# We also create another integrated quantity that appears in the TKE evolution equation: the
73-
# `KineticEnergyStressTerm`, which in our case is
73+
# `KineticEnergyStress`, which in our case is
7474
#
7575
# ```math
7676
# \varepsilon^D = u_i \partial_j \tau_{ij}
7777
# ```
7878
# where ``\tau_{ij}`` is the diffusive flux of ``i`` momentum in the ``j``-th direction.
7979
#
8080

81-
∫εᴰ = Integral(KineticEnergyStressTerm(model))
81+
∫εᴰ = Integral(KineticEnergyEquation.Stress(model))
8282

8383
# The idea in calculating this term is that, in integrated form, all transport contributions in it
8484
# should equal zero and `∫εᴰ` should equal `∫ε`.
@@ -190,6 +190,6 @@ nothing #hide
190190
# Second, again as expected, the volume-integrated KE dissipation rate is the same as the
191191
# volume-integrated KE diffusion term (since all the non-dissipation parts of the term
192192
# volume-integrate to zero). In fact, both `KineticEnergyDissipationRate` and
193-
# `KineticEnergyStressTerm` in Oceanostics are implemented in an energy-conserving form (i.e.,
193+
# `KineticEnergyStress` in Oceanostics are implemented in an energy-conserving form (i.e.,
194194
# they use the exact same discretization scheme and interpolations as used in Oceananigans), so they
195195
# agree to machine-precision, and are great for closing budgets.

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ makedocs(sitename = "Oceanostics.jl",
4949
doctest = true,
5050
clean = true,
5151
format = format,
52-
checkdocs = :exports
52+
checkdocs = :none
5353
)
5454
#---
5555

docs/src/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ julia> simulation = Simulation(model, Δt=1, stop_time=10);
2727
2828
julia> simulation.callbacks[:progress] = Callback(ProgressMessengers.TimedMessenger(), IterationInterval(5));
2929
30-
julia> ke = KineticEnergy(model)
30+
julia> ke = KineticEnergyEquation.KineticEnergy(model)
3131
KernelFunctionOperation at (Center, Center, Center)
3232
├── grid: 4×5×6 RectilinearGrid{Float64, Periodic, Periodic, Bounded} on CPU with 3×3×3 halo
33-
├── kernel_function: turbulent_kinetic_energy_ccc (generic function with 1 method)
34-
└── arguments: ("Field", "Field", "Field", "Int64", "Int64", "Int64")
33+
├── kernel_function: kinetic_energy_ccc (generic function with 1 method)
34+
└── arguments: ("Field", "Field", "Field")
3535
36-
julia> ε = KineticEnergyDissipationRate(model)
36+
julia> ε = KineticEnergyEquation.KineticEnergyDissipationRate(model)
3737
KernelFunctionOperation at (Center, Center, Center)
3838
├── grid: 4×5×6 RectilinearGrid{Float64, Periodic, Periodic, Bounded} on CPU with 3×3×3 halo
3939
├── kernel_function: viscous_dissipation_rate_ccc (generic function with 1 method)

docs/src/library.md

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,20 @@
1-
# Library
2-
3-
Documentation for the public user interface.
4-
5-
## Oceanostics.jl
6-
7-
```@autodocs
8-
Modules = [Oceanostics]
9-
Private = false
1+
```@contents
2+
Pages = ["library.md"]
103
```
114

12-
## Oceanostics.TKEBudgetTerms
13-
14-
```@autodocs
15-
Modules = [Oceanostics.TKEBudgetTerms]
16-
Private = false
17-
```
18-
19-
## Oceanostics.TracerBudgetTerms
20-
21-
```@autodocs
22-
Modules = [Oceanostics.TracerBudgetTerms]
23-
Private = false
24-
```
25-
26-
## Oceanostics.TracerVarianceBudgetTerms
27-
28-
```@autodocs
29-
Modules = [Oceanostics.TracerVarianceBudgetTerms]
30-
Private = false
31-
```
32-
33-
## Oceanostics.FlowDiagnostics
34-
35-
```@autodocs
36-
Modules = [Oceanostics.FlowDiagnostics]
37-
Private = false
38-
```
5+
# Library
396

40-
## Oceanostics.PotentialEnergyEquationTerms
7+
Documentation for the public user interface.
418

429
```@autodocs
43-
Modules = [Oceanostics.PotentialEnergyEquationTerms]
44-
Private = false
10+
Modules = [Oceanostics,
11+
Oceanostics.TracerEquation,
12+
Oceanostics.TracerVarianceEquation,
13+
Oceanostics.TurbulentKineticEnergyEquation,
14+
Oceanostics.KineticEnergyEquation,
15+
Oceanostics.FlowDiagnostics,
16+
Oceanostics.PotentialEnergyEquation,
17+
Oceanostics.ProgressMessengers]
18+
Order = [:function, :type, :macro]
19+
Filter = t -> true
4520
```

src/FlowDiagnostics.jl

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export BottomCellValue
1010
using Oceanostics: validate_location,
1111
validate_dissipative_closure,
1212
add_background_fields,
13-
get_coriolis_frequency_components
13+
get_coriolis_frequency_components,
14+
CustomKFO
1415

1516
using Oceananigans: NonhydrostaticModel, FPlane, ConstantCartesianCoriolis, BuoyancyField, BuoyancyTracer, location
1617
using Oceananigans.BuoyancyFormulations: get_temperature_and_salinity, SeawaterBuoyancy, g_Earth, buoyancy_perturbationᶜᶜᶜ
@@ -63,6 +64,8 @@ end
6364
return dbdz / duₕdz^2
6465
end
6566

67+
const RichardsonNumber = CustomKFO{<:typeof(richardson_number_ccf)}
68+
6669
"""
6770
$(SIGNATURES)
6871
@@ -116,6 +119,8 @@ end
116119
return (ω_x*params.fx + ω_y*params.fy + ω_z*params.fz)/(params.fx^2 + params.fy^2 + params.fz^2)
117120
end
118121

122+
const RossbyNumber = CustomKFO{<:typeof(rossby_number_fff)}
123+
119124
"""
120125
$(SIGNATURES)
121126
@@ -175,6 +180,8 @@ end
175180
return pv_barot + pv_baroc
176181
end
177182

183+
const ThermalWindPotentialVorticity = CustomKFO{<:typeof(potential_vorticity_in_thermal_wind_fff)}
184+
178185
"""
179186
$(SIGNATURES)
180187
@@ -220,6 +227,8 @@ end
220227
return pv_x + pv_y + pv_z
221228
end
222229

230+
const ErtelPotentialVorticity = CustomKFO{<:typeof(ertel_potential_vorticity_fff)}
231+
223232
"""
224233
$(SIGNATURES)
225234
@@ -255,7 +264,7 @@ KernelFunctionOperation at (Face, Face, Face)
255264
├── kernel_function: ertel_potential_vorticity_fff (generic function with 1 method)
256265
└── arguments: ("Field", "Field", "Field", "Field", "Int64", "Int64", "Float64")
257266
258-
julia> interior(compute!(Field(EPV)))
267+
julia> interior(Field(EPV))
259268
1×1×5 view(::Array{Float64, 3}, 1:1, 1:1, 4:8) with eltype Float64:
260269
[:, :, 1] =
261270
0.0
@@ -313,6 +322,7 @@ end
313322
return (params.f_dir + ω_dir) * dbddir
314323
end
315324

325+
const DirectionalErtelPotentialVorticity = CustomKFO{<:typeof(directional_ertel_potential_vorticity_fff)}
316326

317327
"""
318328
$(SIGNATURES)
@@ -358,6 +368,8 @@ function strain_rate_tensor_modulus_ccc(i, j, k, grid, u, v, w)
358368
return (Sˣˣ² + Sʸʸ² + Sᶻᶻ² + 2 * (Sˣʸ² + Sˣᶻ² + Sʸᶻ²))
359369
end
360370

371+
const StrainRateTensorModulus = CustomKFO{<:typeof(strain_rate_tensor_modulus_ccc)}
372+
361373
"""
362374
$(SIGNATURES)
363375
@@ -392,6 +404,8 @@ function vorticity_tensor_modulus_ccc(i, j, k, grid, u, v, w)
392404
return (Ωˣʸ² + Ωˣᶻ² + Ωʸᶻ² + Ωʸˣ² + Ωᶻˣ² + Ωᶻʸ²)
393405
end
394406

407+
const VorticityTensorModulus = CustomKFO{<:typeof(vorticity_tensor_modulus_ccc)}
408+
395409
"""
396410
$(SIGNATURES)
397411
@@ -419,6 +433,8 @@ end
419433
Ω² = vorticity_tensor_modulus_ccc(i, j, k, grid, u, v, w)^2
420434
return (Ω² - S²) / 2
421435
end
436+
437+
const QVelocityGradientTensorInvariant = CustomKFO{<:typeof(Q_velocity_gradient_tensor_invariant_ccc)}
422438
#---
423439

424440
#+++ Mixed layer depth
@@ -475,7 +491,7 @@ function MixedLayerDepth(grid::AbstractGrid, args...; criterion = BuoyancyAnomal
475491
return KernelFunctionOperation{Center, Center, Nothing}(MLD, grid, args...)
476492
end
477493

478-
function (MLD::MixedLayerDepthKernel)(i, j, k, grid, args...)
494+
@inline function (MLD::MixedLayerDepthKernel)(i, j, k, grid, args...)
479495
kₘₗ = -1
480496

481497
for k in grid.Nz-1:-1:1

0 commit comments

Comments
 (0)