-
Notifications
You must be signed in to change notification settings - Fork 191
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
CubedSphere grid construction + tests #2871
Conversation
….jl into ncc/cubed-sphere-grid
this is ready for review :) |
@@ -127,28 +127,28 @@ function ConformalCubedSphereGrid(arch = CPU(), FT=Float64; face_size, z, face_h | |||
|
|||
size, halo = face_size, face_halo | |||
|
|||
# +z face (face 1) | |||
z⁺_face_grid = OrthogonalSphericalShellGrid(arch, FT; size, z, halo, radius, rotation=nothing) | |||
# +x face (face 1) |
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.
We need a sketch with lat-lon lines overlaying the cube so we understand the "+z", etc terminology!
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.
Yeap, I plan to add some figures in the docs. For now, is the figures at https://clima.github.io/CubedSphere.jl/stable/conformal_cubed_sphere/ helpful? +z is the face that looks in the positive z direction.
Co-authored-by: Gregory L. Wagner <[email protected]>
@glwagner asked why there was a warning saying that the metrics near the edge of the I explain here: To compute the areas near the edge we actually need to know the node locations of the halos, and to do that we need to implement proper halo filling. Why is that? Take for For example, consider a face near the edge, then: Δxᶠᶠᵃ[1, j, k] = xᶜᶠᵃ[1, j, k] - xᶜᶠᵃ[0, j, k] but we can't compute the lat-lon position of Δxᶠᶠᵃ[1, j, k] = 2 * (xᶜᶠᵃ[1, j, k] - xᶠᶠᵃ[1, j, k]) So that's that. The distance metrics are actually correct, even near the edges. How do we compute now areas? An approximation is @. Azᶜᶜᵃ = Δxᶜᶜᵃ * Δyᶜᶜᵃ
@. Azᶠᶜᵃ = Δxᶠᶜᵃ * Δyᶠᶜᵃ
@. Azᶜᶠᵃ = Δxᶜᶠᵃ * Δyᶜᶠᵃ
@. Azᶠᶠᵃ = Δxᶠᶠᵃ * Δyᶠᶠᵃ But that's only an approximation because these quadrilaterals are not symmetrical. Anywhere in the interior of the grid we can improve on this by computing the exact area of the spherical quadrilateral given that we know the location of each of its vertices. But for a quadrilateral that touches the edge some of its vertices would belong to the next panels, i.e., to get their location we'd need proper halo filling. E.g., (φᶜᶠᵃ[i-1, j ], λᶜᶠᵃ[i-1, j ])
(φᶜᶠᵃ[ i , j ], λᶜᶠᵃ[ i , j ])
(φᶜᶠᵃ[ i , j+1], λᶜᶠᵃ[ i , j+1])
(φᶜᶠᵃ[i-1, j+1], λᶜᶠᵃ[i-1, j+1]) thus But now that I'm thinking about it, again from symmetry and also due to the fact that these are right next to the edge, we would expect that the area of quadrilateral with vertices at (φᶜᶠᵃ[ 0 , j ], λᶜᶠᵃ[ 0 , j ])
(φᶜᶠᵃ[ 1 , j ], λᶜᶠᵃ[ 1 , j ])
(φᶜᶠᵃ[ 1 , j+1], λᶜᶠᵃ[ 1 , j+1])
(φᶜᶠᵃ[ 0 , j+1], λᶜᶠᵃ[ 0 , j+1]) should be double the area of the quadrilateral with vertices (φᶠᶠᵃ[ 1 , j ], λᶠᶠᵃ[ 1 , j ])
(φᶜᶠᵃ[ 1 , j ], λᶜᶠᵃ[ 1 , j ])
(φᶜᶠᵃ[ 1 , j+1], λᶜᶠᵃ[ 1 , j+1])
(φᶠᶠᵃ[ 1 , j+1], λᶠᶠᵃ[ 1 , j+1]) I'll fix this and remove the warning! |
….jl into ncc/cubed-sphere-grid
The cubed sphere grid from the MIT as read from DataDeps has the faces ordered:
+ x
direction+ y
direction+ z
direction (Arctic)- x
direction- y
direction- z
direction (Antarctica)So to avoid confusion for (users and developers!) I thought I make sure that the ConformalCubedSphere follows the same convention.
This PR does that + it adds tests to check whether the ConformalCubedSphereGrid metrics from the grid read from file and the grid constructed in Oceananigans.jl are the same.
After this is merged we'll move on to #2867 to constructing
ConformalCubedSphereGrid
using MultiRegion (an possibly nuke theCubedSpheres
module completely). We will have aConformalCubedSphereGrid
(which is the same as thecs32
grid read from file) to bench our MultiRegion implementation with!(This PR also moves some of the spherical trigonometry utility function to
grid_utils.jl
.)Closes #1586