Skip to content
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

AbstractGridArray N-dimensional and GPU ready #520

Merged
merged 41 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2e436d5
First ideas for AbstractGridArray
milankl Apr 10, 2024
2c1786e
AbstractGridArray constructors
milankl Apr 12, 2024
bb19c84
Merge branch 'main' into mk/ringgrids
milankl Apr 12, 2024
28c7134
scaling for AbstractGridArray
milankl Apr 14, 2024
14453c7
similar, eachgrid for AbstractGridArray
milankl Apr 14, 2024
88aa291
Other full gridarrays
milankl Apr 14, 2024
3ab5ed4
Merge branch 'mk/ringgrids' of https://github.com/SpeedyWeather/Speed…
milankl Apr 14, 2024
52c9d27
OctahedralGaussian and ClenshawArrays
milankl Apr 16, 2024
b438625
Tests pass except broadcasting
milankl Apr 16, 2024
0ba0612
N-dimensional broadcasting for RingGrids
milankl Apr 17, 2024
a51164c
only two getindex methods
milankl Apr 17, 2024
652a6d0
Loop indexing tested
milankl Apr 17, 2024
6021467
Export GridArrays too
milankl Apr 17, 2024
5971060
export also eachgrid, eachring
milankl Apr 17, 2024
917b1a0
add Adapt, KernelAbstractions, GPUArrays deps, JLArrays extra
milankl Apr 17, 2024
3ac3b6e
GPU broadcasting first draft
milankl Apr 17, 2024
963988b
using Adapt, JLArrays in ringgrids test
milankl Apr 17, 2024
cfae034
full_grid_type vs full_array_type plus tests
milankl Apr 17, 2024
38d4062
use octahealpix weights for octahealpix not healpix
milankl Apr 17, 2024
891363f
n->nlat_half typo
milankl Apr 17, 2024
f819cc1
docstrings for general and full grids
milankl Apr 18, 2024
5f5db14
GPU broadcast fix?
maximilian-gelbrecht Apr 18, 2024
7b5ad57
Reduced grid documentation
milankl Apr 18, 2024
aada55b
Merge branch 'mk/ringgrids' of https://github.com/SpeedyWeather/Speed…
milankl Apr 18, 2024
d634316
Add JLArrays extension
milankl Apr 19, 2024
9ea9440
I can't close ""
milankl Apr 19, 2024
5b087e9
CUDA.CuArray for nonparametric_type
milankl Apr 19, 2024
fd6d9d8
use nonparametric_type(ArrayType) to avoid conversion
milankl Apr 20, 2024
30ba3ce
JLArrays extension was incorrectly named
milankl Apr 20, 2024
0282308
quadrature weights of size nlat
milankl Apr 22, 2024
ac8d336
Merge branch 'main' into mk/ringgrids
milankl Apr 22, 2024
dc8fa56
AbstractGridArray methods to avoid scalar indexing, @propagate_inboun…
milankl Apr 22, 2024
23dd533
Merge branch 'mk/ringgrids' of https://github.com/SpeedyWeather/Speed…
milankl Apr 22, 2024
61dc760
more setindex tests for AbstractGridArray
milankl Apr 22, 2024
1ca3a90
SpectralTransform uses nonparametric type of AbstractGridArray
milankl Apr 22, 2024
b9bd961
corrected quadrature weights for full healpix grids
milankl Apr 22, 2024
77a7592
any(::AbstractGridArray) added
milankl Apr 23, 2024
6254f70
Merge branch 'main' into mk/ringgrids
milankl Apr 25, 2024
7f4bf38
nonparametric_type in LTA for JLArrays moved to extension
milankl Apr 25, 2024
7a96c92
rm 2nd JLArrays in [extrax] in Project.toml
milankl Apr 25, 2024
1d5a1a7
::Type{<:JLArray} in JLArrays extension
milankl Apr 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"

[weakdeps]
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"

[extensions]
SpeedyWeatherMakieExt = "Makie"
SpeedyWeatherJLArraysExt = "JLArrays"

[compat]
AbstractFFTs = "1"
Expand All @@ -47,7 +49,9 @@ DocStringExtensions = "0.9"
FFTW = "1"
FLoops = "0.2"
FastGaussQuadrature = "0.4, 0.5, 1"
GPUArrays = "10"
GenericFFT = "0.1"
JLArrays = "0.1.4"
JLD2 = "0.4"
KernelAbstractions = "0.9"
LinearAlgebra = "1.9"
Expand All @@ -63,8 +67,8 @@ UnicodePlots = "3.3"
julia = "1.9"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "JLArrays"]
6 changes: 3 additions & 3 deletions docs/src/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ for the model integration.
```julia
my_output_writer = OutputWriter(spectral_grid, ShallowWater, output_Grid=FullClenshawGrid, nlat_half=48)
```
Note that by default the output is on the corresponding full of the grid used in the dynamical core
Note that by default the output is on the corresponding full type of the grid type used in the dynamical core
so that interpolation only happens at most in the zonal direction as they share the location of the
latitude rings. You can check this by
```@example netcdf
RingGrids.full_grid(OctahedralGaussianGrid)
RingGrids.full_grid_type(OctahedralGaussianGrid)
```
So the corresponding full grid of an `OctahedralGaussianGrid` is the `FullGaussiangrid` and the same resolution
So the corresponding full grid of an `OctahedralGaussianGrid` is the `FullGaussianGrid` and the same resolution
`nlat_half` is chosen by default in the output writer (which you can change though as shown above).
Overview of the corresponding full grids

Expand Down
10 changes: 10 additions & 0 deletions ext/SpeedyWeatherJLArraysExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module SpeedyWeatherJLArraysExt

using SpeedyWeather, JLArrays

# for RingGrids and LowerTriangularMatrices:
# every Array needs this method to strip away the parameters
SpeedyWeather.RingGrids.nonparametric_type(::Type{<:JLArray}) = JLArray
SpeedyWeather.LowerTriangularMatrices.nonparametric_type(::Type{<:JLArray}) = JLArray

end # module
2 changes: 1 addition & 1 deletion ext/SpeedyWeatherMakieExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function Makie.heatmap(
title::String = "$(RingGrids.get_nlat(grid))-ring $(typeof(grid))",
kwargs... # pass on to Makie.heatmap
)
full_grid = RingGrids.interpolate(RingGrids.full_grid(typeof(grid)), grid.nlat_half, grid)
full_grid = RingGrids.interpolate(RingGrids.full_grid_type(grid), grid.nlat_half, grid)
heatmap(full_grid; title, kwargs...)
end

Expand Down
89 changes: 64 additions & 25 deletions src/RingGrids/RingGrids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,77 @@ import Statistics: mean
import FastGaussQuadrature
import LinearAlgebra

# GRIDS
# GPU
import Adapt
import GPUArrays
import CUDA

# ABSTRACT GRIDS (2D) AND GRIDARRAYS (3D+)
export AbstractGridArray,
AbstractFullGridArray,
AbstractReducedGridArray

export AbstractGrid,
AbstractFullGrid,
AbstractOctahedralGrid,
AbstractHEALPixGrid,
AbstractOctaHEALPixGrid
AbstractReducedGrid

# CONCRETE GRIDS (2D) AND GRIDARRAYS (3D+)
export FullGaussianArray,
FullClenshawArray,
FullHEALPixArray,
FullOctaHEALPixArray

export FullGaussianGrid,
FullClenshawGrid,
FullHEALPixGrid,
FullOctaHEALPixGrid

export OctahedralGaussianArray,
OctahedralClenshawArray,
HEALPixArray,
OctaHEALPixArray

export OctahedralGaussianGrid,
OctahedralClenshawGrid,
HEALPixGrid,
OctaHEALPixGrid

# GRID FUNCTIONS
# SIZE
export grids_match,
get_truncation,
get_resolution,
get_nlat,
get_nlat_half,
get_npoints,
get_latdlonds,
get_npoints2D

# COORDINATES
export get_latdlonds,
get_lat,
get_colat,
get_latd,
get_lond,
each_index_in_ring,
each_index_in_ring!,
eachgridpoint,
eachring,
whichring,
get_nlons,
get_nlon_max,
get_quadrature_weights,
get_nlon_max

# INTEGRATION
export get_quadrature_weights,
get_solid_angles

# ITERATORS
export eachgrid,
eachring,
whichring,
eachgridpoint,
each_index_in_ring,
each_index_in_ring!

# SCALING
export scale_coslat!,
scale_coslat²!,
scale_coslat⁻¹!,
scale_coslat⁻²!
scale_coslat⁻²!,
scale_coslat,
scale_coslat²,
scale_coslat⁻¹,
scale_coslat⁻²

# INTERPOLATION
export AbstractInterpolator,
Expand All @@ -67,19 +94,31 @@ export interpolate,
update_locator,
update_locator!

# export plot

include("utility_functions.jl")

include("grids_general.jl")
# GENERAL
include("general.jl")
include("full_grids.jl")
include("octahedral.jl")
include("healpix.jl")
include("octahealpix.jl")
include("reduced_grids.jl")
include("scaling.jl")

# FULL GRIDS
include("grids/full_gaussian.jl")
include("grids/full_clenshaw.jl")
include("grids/full_healpix.jl")
include("grids/full_octahealpix.jl")

# REDUCED GRIDS
include("grids/octahedral_gaussian.jl")
include("grids/octahedral_clenshaw.jl")
include("grids/healpix.jl")
include("grids/octahealpix.jl")

# INTEGRATION AND INTERPOLATION
include("quadrature_weights.jl")
include("interpolation.jl")

# OUTPUT
include("show.jl")
include("similar.jl")
include("scaling.jl")

end
Loading