Skip to content

Commit ed15fd6

Browse files
authored
Merge branch 'main' into xk/enable-array-averagedtimeinterval
2 parents b3f1541 + 030b1b9 commit ed15fd6

11 files changed

+644
-725
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Oceananigans"
22
uuid = "9e8cae18-63c1-5223-a75c-80ca9d6e9a09"
33
authors = ["Climate Modeling Alliance and contributors"]
4-
version = "0.100.6"
4+
version = "0.100.7"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
@@ -66,7 +66,7 @@ Adapt = "4.1.1"
6666
CUDA = "=5.8.5, 5.9.1"
6767
ConstructionBase = "1"
6868
Crayons = "4"
69-
CubedSphere = "0.2, 0.3 - 0.3.2"
69+
CubedSphere = "0.3.4"
7070
Dates = "1.9"
7171
Distances = "0.10"
7272
DocStringExtensions = "0.8, 0.9"

src/Grids/grid_utils.jl

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -329,81 +329,6 @@ coordinate_summary(topo, Δ::Union{AbstractVector, AbstractMatrix}, name) =
329329
@inline column_depthᶜᶠᵃ(i, j, k, grid, η) = static_column_depthᶜᶠᵃ(i, j, grid)
330330
@inline column_depthᶠᶠᵃ(i, j, k, grid, η) = static_column_depthᶠᶠᵃ(i, j, grid)
331331

332-
#####
333-
##### Spherical geometry
334-
#####
335-
336-
"""
337-
spherical_area_triangle(a::Number, b::Number, c::Number)
338-
339-
Return the area of a spherical triangle on the unit sphere with sides `a`, `b`, and `c`.
340-
341-
The area of a spherical triangle on the unit sphere is ``E = A + B + C - π``, where ``A``, ``B``, and ``C``
342-
are the triangle's inner angles.
343-
344-
It has been known since the time of Euler and Lagrange that
345-
``\\tan(E/2) = P / (1 + \\cos a + \\cos b + \\cos c)``, where
346-
``P = (1 - \\cos²a - \\cos²b - \\cos²c + 2 \\cos a \\cos b \\cos c)^{1/2}``.
347-
348-
References
349-
==========
350-
351-
* Euler, L. (1778) De mensura angulorum solidorum, Opera omnia, 26, 204-233 (Orig. in Acta adac. sc. Petrop. 1778)
352-
* Lagrange, J.-L. (1798) Solutions de quilquies problèmes relatifs au triangles sphéruques, Oeuvres, 7, 331-359.
353-
"""
354-
function spherical_area_triangle(a::Number, b::Number, c::Number)
355-
cosa = cos(a)
356-
cosb = cos(b)
357-
cosc = cos(c)
358-
359-
tan½E = sqrt(1 - cosa^2 - cosb^2 - cosc^2 + 2cosa * cosb * cosc)
360-
tan½E /= 1 + cosa + cosb + cosc
361-
362-
return 2atan(tan½E)
363-
end
364-
365-
"""
366-
spherical_area_triangle(a::AbstractVector, b::AbstractVector, c::AbstractVector)
367-
368-
Return the area of a spherical triangle on the unit sphere with vertices given by the 3-vectors
369-
`a`, `b`, and `c` whose origin is the the center of the sphere. The formula was first given by
370-
Eriksson (1990).
371-
372-
If we denote with ``A``, ``B``, and ``C`` the inner angles of the spherical triangle and with
373-
``a``, ``b``, and ``c`` the side of the triangle then, it has been known since Euler and Lagrange
374-
that ``\\tan(E/2) = P / (1 + \\cos a + \\cos b + \\cos c)``, where ``E = A + B + C - π`` is the
375-
triangle's excess and ``P = (1 - \\cos²a - \\cos²b - \\cos²c + 2 \\cos a \\cos b \\cos c)^{1/2}``.
376-
On the unit sphere, ``E`` is precisely the area of the spherical triangle. Erikkson (1990) showed
377-
that ``P`` above is the same as the volume defined by the vectors `a`, `b`, and `c`, that is
378-
``P = |𝐚 \\cdot (𝐛 \\times 𝐜)|``.
379-
380-
References
381-
==========
382-
383-
* Eriksson, F. (1990) On the measure of solid angles, Mathematics Magazine, 63 (3), 184-187, doi:10.1080/0025570X.1990.11977515
384-
"""
385-
function spherical_area_triangle(a₁::AbstractVector, a₂::AbstractVector, a₃::AbstractVector)
386-
(sum(a₁.^2) 1 && sum(a₂.^2) 1 && sum(a₃.^2) 1) || error("a₁, a₂, a₃ must be unit vectors")
387-
388-
tan½E = abs(dot(a₁, cross(a₂, a₃)))
389-
tan½E /= 1 + dot(a₁, a₂) + dot(a₂, a₃) + dot(a₁, a₃)
390-
391-
return 2atan(tan½E)
392-
end
393-
394-
"""
395-
spherical_area_quadrilateral(a₁, a₂, a₃, a₄)
396-
397-
Return the area of a spherical quadrilateral on the unit sphere whose points are given by 3-vectors,
398-
`a`, `b`, `c`, and `d`. The area of the quadrilateral is given as the sum of the ares of the two
399-
non-overlapping triangles. To avoid having to pick the triangles appropriately ensuring they are not
400-
overlapping, we compute the area of the quadrilateral as the half the sum of the areas of all four potential
401-
triangles formed by `a₁`, `a₂`, `a₃`, and `a₄`.
402-
"""
403-
spherical_area_quadrilateral(a::AbstractVector, b::AbstractVector, c::AbstractVector, d::AbstractVector) =
404-
1/2 * (spherical_area_triangle(a, b, c) + spherical_area_triangle(a, b, d) +
405-
spherical_area_triangle(a, c, d) + spherical_area_triangle(b, c, d))
406-
407332
"""
408333
add_halos(data, loc, topo, sz, halo_sz; warnings=true)
409334

src/Grids/orthogonal_spherical_shell_grid.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,6 @@ function fill_metric_halo_regions!(grid)
263263
return nothing
264264
end
265265

266-
function lat_lon_to_cartesian(lat, lon, radius)
267-
abs(lat) > 90 && error("lat must be within -90 ≤ lat ≤ 90")
268-
return [lat_lon_to_x(lat, lon, radius), lat_lon_to_y(lat, lon, radius), lat_lon_to_z(lat, lon, radius)]
269-
end
270-
271-
lat_lon_to_x(lat, lon, radius) = radius * cosd(lon) * cosd(lat)
272-
lat_lon_to_y(lat, lon, radius) = radius * sind(lon) * cosd(lat)
273-
lat_lon_to_z(lat, lon, radius) = radius * sind(lat)
274-
275266
function on_architecture(arch::AbstractSerialArchitecture, grid::OrthogonalSphericalShellGrid)
276267
coordinates = (:λᶜᶜᵃ,
277268
:λᶠᶜᵃ,

src/MultiRegion/cubed_sphere_grid.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ using Oceananigans.Grids: halo_size,
55
topology
66

77
using CubedSphere
8+
using CubedSphere.SphericalGeometry
89
using Oceananigans.OrthogonalSphericalShellGrids: ConformalCubedSpherePanelGrid
910
using Oceananigans.ImmersedBoundaries: ImmersedBoundaryGrid, has_active_cells_map, has_active_z_columns
1011

@@ -31,7 +32,7 @@ const ConformalCubedSphereGridOfSomeKind{FT, TX, TY, TZ, CZ} =
3132
z_topology = Bounded,
3233
radius = Oceananigans.defaults.planet_radius,
3334
non_uniform_conformal_mapping = false,
34-
spacing_type = "geometric",
35+
spacing = GeometricSpacing(),
3536
provided_conformal_mapping = nothing,
3637
partition = CubedSpherePartition(; R = 1))
3738
@@ -194,7 +195,7 @@ function ConformalCubedSphereGrid(arch::AbstractArchitecture=CPU(),
194195
z_topology = Bounded,
195196
radius = Oceananigans.defaults.planet_radius,
196197
non_uniform_conformal_mapping = false,
197-
spacing_type = "geometric",
198+
spacing = GeometricSpacing(),
198199
provided_conformal_mapping = nothing,
199200
partition = CubedSpherePartition(; R = 1))
200201

@@ -242,7 +243,7 @@ function ConformalCubedSphereGrid(arch::AbstractArchitecture=CPU(),
242243
halo = region_halo,
243244
rotation = region_rotation,
244245
non_uniform_conformal_mapping,
245-
spacing_type,
246+
spacing,
246247
provided_conformal_mapping)
247248

248249
# Propagate the vertical coordinate type in the `MultiRegionGrid`.

src/OrthogonalSphericalShellGrids/OrthogonalSphericalShellGrids.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export TripolarGrid, RotatedLatitudeLongitudeGrid, ConformalCubedSpherePanelGrid
66
import Oceananigans
77
import Oceananigans.Architectures: on_architecture
88

9+
using CubedSphere.SphericalGeometry
10+
911
using Oceananigans
1012
using Oceananigans.Grids
1113
using Oceananigans.Architectures: device, on_architecture, AbstractArchitecture, CPU, GPU
@@ -15,8 +17,7 @@ using Oceananigans.Utils
1517
using Oceananigans.BoundaryConditions: Zipper
1618
using Oceananigans.Fields: index_binary_search, convert_to_0_360
1719
using Oceananigans.Grids: RightConnected
18-
using Oceananigans.Grids: halo_size, spherical_area_quadrilateral,
19-
lat_lon_to_cartesian, generate_coordinate, topology
20+
using Oceananigans.Grids: halo_size, generate_coordinate, topology
2021
using Oceananigans.Grids: total_length, add_halos, fill_metric_halo_regions!
2122

2223
using Oceananigans.Operators

0 commit comments

Comments
 (0)