-
Notifications
You must be signed in to change notification settings - Fork 18
Add space with multiple columns #2525
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -67,7 +67,12 @@ grid = ExtrudedCubedSphereGrid(; | |||||||
| module CommonGrids | ||||||||
|
|
||||||||
| export ExtrudedCubedSphereGrid, | ||||||||
| CubedSphereGrid, ColumnGrid, Box3DGrid, SliceXZGrid, RectangleXYGrid | ||||||||
| CubedSphereGrid, | ||||||||
| ColumnGrid, | ||||||||
| Box3DGrid, | ||||||||
| SliceXZGrid, | ||||||||
| RectangleXYGrid, | ||||||||
| PointColumnEnsembleGrid | ||||||||
|
|
||||||||
| import ClimaComms | ||||||||
| import ..DataLayouts, | ||||||||
|
|
@@ -706,4 +711,77 @@ function RectangleXYGrid( | |||||||
| ) | ||||||||
| end | ||||||||
|
|
||||||||
| """ | ||||||||
| PointColumnEnsembleGrid( | ||||||||
| ::Type{<:AbstractFloat}; # defaults to Float64 | ||||||||
| points::AbstractVector{Geometry.LatLongPoint{FT}}, | ||||||||
| z_elem::Integer, | ||||||||
| z_min::Real, | ||||||||
| z_max::Real, | ||||||||
| radius::Real, | ||||||||
| device::ClimaComms.AbstractDevice = ClimaComms.device(), | ||||||||
| context::ClimaComms.AbstractCommsContext = ClimaComms.SingletonCommsContext(device), | ||||||||
| stretch::Meshes.StretchingRule = Meshes.Uniform(), | ||||||||
| z_mesh::Meshes.IntervalMesh = DefaultZMesh(FT; z_min, z_max, z_elem, stretch), | ||||||||
| ) | ||||||||
|
|
||||||||
| A convenience constructor that builds an | ||||||||
| [`Grids.ExtrudedFiniteDifferenceGrid`](@ref) for N independent columns at | ||||||||
| arbitrary (lat, lon) locations on a sphere, given: | ||||||||
|
|
||||||||
| - `FT` the floating-point type (defaults to `Float64`) [`Float32`, `Float64`], | ||||||||
| - `points` a vector of `Geometry.LatLongPoint` specifying each column | ||||||||
| location, | ||||||||
| - `z_elem` the number of z-points, | ||||||||
| - `z_min` the domain minimum along the z-direction, | ||||||||
| - `z_max` the domain maximum along the z-direction, | ||||||||
| - `radius` the radius of the sphere, | ||||||||
| - `device` the `ClimaComms.device`, | ||||||||
| - `context` the `ClimaComms.context` (must be a `SingletonCommsContext`), | ||||||||
| - `stretch` the mesh `Meshes.StretchingRule` (defaults to | ||||||||
| [`Meshes.Uniform`](@ref)), | ||||||||
| - `z_mesh` the vertical mesh, defaults to an `Meshes.IntervalMesh` along `z` | ||||||||
| with given `stretch`. | ||||||||
|
|
||||||||
| There is no horizontal connectivity between columns. Horizontal operators are | ||||||||
| not supported. Use [`ClimaCore.Fields.bycolumn`](@ref) to iterate over columns. | ||||||||
|
|
||||||||
| # Example usage | ||||||||
|
|
||||||||
| ```julia | ||||||||
| using ClimaCore.CommonGrids, ClimaCore.Geometry | ||||||||
| points = [LatLongPoint(0.0, 0.0), LatLongPoint(10.0, 20.0), LatLongPoint(-5.0, 90.0)] | ||||||||
| grid = PointColumnEnsembleGrid(; | ||||||||
| points = points, | ||||||||
| z_elem = 10, | ||||||||
| z_min = 0, | ||||||||
| z_max = 10_000, | ||||||||
| radius = 6.371229e6, | ||||||||
| ) | ||||||||
| ``` | ||||||||
| """ | ||||||||
| PointColumnEnsembleGrid(; kwargs...) = PointColumnEnsembleGrid(Float64; kwargs...) | ||||||||
| function PointColumnEnsembleGrid( | ||||||||
| ::Type{FT}; | ||||||||
| points::AbstractVector{Geometry.LatLongPoint{FT}}, | ||||||||
| z_elem::Integer, | ||||||||
| z_min::Real, | ||||||||
| z_max::Real, | ||||||||
| radius::Real = 6.371229e6, | ||||||||
| device::ClimaComms.AbstractDevice = ClimaComms.device(), | ||||||||
| context::ClimaComms.AbstractCommsContext = ClimaComms.SingletonCommsContext(device), | ||||||||
| stretch::Meshes.StretchingRule = Meshes.Uniform(), | ||||||||
| z_mesh::Meshes.IntervalMesh = DefaultZMesh(FT; z_min, z_max, z_elem, stretch), | ||||||||
| ) where {FT} | ||||||||
| @assert context isa ClimaComms.SingletonCommsContext "PointColumnEnsembleGrid only supports SingletonCommsContext." | ||||||||
| @assert ClimaComms.device(context) == device "The given device and context device do not match." | ||||||||
|
Comment on lines
+776
to
+777
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
No need to provide a keyword argument for |
||||||||
| h_grid = Grids.PointCloudGrid(points; radius, device, context) | ||||||||
| z_topology = Topologies.IntervalTopology( | ||||||||
| ClimaComms.SingletonCommsContext(device), | ||||||||
| z_mesh, | ||||||||
| ) | ||||||||
| z_grid = Grids.FiniteDifferenceGrid(z_topology) | ||||||||
| return Grids.ExtrudedFiniteDifferenceGrid(h_grid, z_grid) | ||||||||
| end | ||||||||
|
|
||||||||
| end # module | ||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -45,7 +45,7 @@ local_geometry_type( | |||||||||||||||||||||
| ) where {H, V, A, GG, CLG, FLG} = eltype(CLG) # calls eltype from DataLayouts | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| function ExtrudedFiniteDifferenceGrid( | ||||||||||||||||||||||
| horizontal_grid::Union{SpectralElementGrid1D, SpectralElementGrid2D}, | ||||||||||||||||||||||
| horizontal_grid::Union{SpectralElementGrid1D, SpectralElementGrid2D, PointCloudGrid}, | ||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This union appears a lot. Could it just be a const or abstract type?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah aren't these all subtypes of |
||||||||||||||||||||||
| vertical_grid::FiniteDifferenceGrid, | ||||||||||||||||||||||
| hypsography::HypsographyAdaption = Flat(); | ||||||||||||||||||||||
| deep = false, | ||||||||||||||||||||||
|
|
@@ -70,7 +70,7 @@ end | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| # memoized constructor | ||||||||||||||||||||||
| function ExtrudedFiniteDifferenceGrid( | ||||||||||||||||||||||
| horizontal_grid::Union{SpectralElementGrid1D, SpectralElementGrid2D}, | ||||||||||||||||||||||
| horizontal_grid::Union{SpectralElementGrid1D, SpectralElementGrid2D, PointCloudGrid}, | ||||||||||||||||||||||
| vertical_grid::FiniteDifferenceGrid, | ||||||||||||||||||||||
| hypsography::HypsographyAdaption, | ||||||||||||||||||||||
| global_geometry::Geometry.AbstractGlobalGeometry, | ||||||||||||||||||||||
|
|
@@ -96,7 +96,7 @@ end | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Non-memoized constructor. Should not generally be called, but can be defined for other Hypsography types | ||||||||||||||||||||||
| function _ExtrudedFiniteDifferenceGrid( | ||||||||||||||||||||||
| horizontal_grid::Union{SpectralElementGrid1D, SpectralElementGrid2D}, | ||||||||||||||||||||||
| horizontal_grid::Union{SpectralElementGrid1D, SpectralElementGrid2D, PointCloudGrid}, | ||||||||||||||||||||||
| vertical_grid::FiniteDifferenceGrid, | ||||||||||||||||||||||
| hypsography::Flat, | ||||||||||||||||||||||
| global_geometry::Geometry.AbstractGlobalGeometry, | ||||||||||||||||||||||
|
|
@@ -126,6 +126,13 @@ end | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| topology(grid::ExtrudedFiniteDifferenceGrid) = topology(grid.horizontal_grid) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # For PointCloudGrid there is no horizontal topology; route context/device | ||||||||||||||||||||||
| # through the horizontal grid directly (which stores its own context). | ||||||||||||||||||||||
| ClimaComms.context(grid::ExtrudedFiniteDifferenceGrid{<:PointCloudGrid}) = | ||||||||||||||||||||||
| ClimaComms.context(grid.horizontal_grid) | ||||||||||||||||||||||
| ClimaComms.device(grid::ExtrudedFiniteDifferenceGrid{<:PointCloudGrid}) = | ||||||||||||||||||||||
| ClimaComms.device(grid.horizontal_grid) | ||||||||||||||||||||||
|
Comment on lines
+129
to
+134
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This could also be the default for every |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| vertical_topology(grid::ExtrudedFiniteDifferenceGrid) = | ||||||||||||||||||||||
| topology(grid.vertical_grid) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
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.
Would it be better to combine this with the above method