Skip to content

Commit 796ed2d

Browse files
authored
Merge pull request #255 from FourierFlows/ncc/on_grid-patch
Fix bug in on_grid() utility function
2 parents 32c0370 + 9bf6174 commit 796ed2d

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = ["Gregory L. Wagner <wagner.greg@gmail.com>", "Navid C. Constantinou <
66
description = "Tools for building fast, hackable, pseudospectral partial differential equation solvers on periodic domains."
77
documentation = "https://fourierflows.github.io/FourierFlowsDocumentation/stable/"
88
repository = "https://github.com/FourierFlows/FourierFlows.jl"
9-
version = "0.6.11"
9+
version = "0.6.12"
1010

1111
[deps]
1212
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ and [Navid C. Constantinou][] (@navidcy).
6161

6262
The code is citable via [zenodo](https://zenodo.org). Please cite as:
6363

64-
> Navid C. Constantinou & Gregory L. Wagner. (2021). FourierFlows/FourierFlows.jl: FourierFlows v0.6.11 (Version v0.6.11). Zenodo. [http://doi.org/10.5281/zenodo.1161724](http://doi.org/10.5281/zenodo.1161724)
64+
> Navid C. Constantinou & Gregory L. Wagner. (2021). FourierFlows/FourierFlows.jl: FourierFlows v0.6.12 (Version v0.6.12). Zenodo. [http://doi.org/10.5281/zenodo.1161724](http://doi.org/10.5281/zenodo.1161724)
6565
6666

6767
[Julia]: https://julialang.org/

src/utils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,16 @@ end
248248
Returns an array, of the ArrayType of the device `grid` lives on, that contains the values of
249249
function `func` evaluated on the `grid`.
250250
"""
251-
on_grid(func, grid::OneDGrid) = @. func(grid.x)
251+
on_grid(func, grid::OneDGrid) = CUDA.@allowscalar func.(grid.x)
252252

253253
function on_grid(func, grid::TwoDGrid)
254254
x, y = gridpoints(grid)
255-
return func.(x, y)
255+
return CUDA.@allowscalar func.(x, y)
256256
end
257257

258258
function on_grid(func, grid::ThreeDGrid)
259259
x, y, z = gridpoints(grid)
260-
return func.(x, y, z)
260+
return CUDA.@allowscalar func.(x, y, z)
261261
end
262262

263263
"""

test/test_utils.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,17 @@ function test_ongrid(dev::Device)
145145
nx, ny, nz = 6, 8, 10
146146
Lx, Ly, Lz = 2π, 2.0, 3.0
147147

148-
g₁ = OneDGrid(nx, Lx)
148+
g₁ = OneDGrid(dev, nx, Lx)
149149
X₁ = ArrayType(dev)(g₁.x)
150150
f₁(x) = x^2
151151

152-
g₂ = TwoDGrid(nx, Lx, ny, Ly)
152+
g₂ = TwoDGrid(dev, nx, Lx, ny, Ly)
153153
X₂, Y₂ = gridpoints(g₂)
154154
f₂(x, y) = x^2 - y^3
155155

156-
g₃ = ThreeDGrid(nx, Lx, ny, Ly, nz, Lz)
156+
g₃ = ThreeDGrid(dev, nx, Lx, ny, Ly, nz, Lz)
157157
X₃, Y₃, Z₃ = gridpoints(g₃)
158158
f₃(x, y, z) = x^2 - y^3 + sin(z)
159159

160-
return CUDA.@allowscalar (FourierFlows.on_grid(f₁, g₁) == f₁.(X₁) && FourierFlows.on_grid(f₂, g₂) == f₂.(X₂, Y₂) && FourierFlows.on_grid(f₃, g₃) == f₃.(X₃, Y₃, Z₃))
160+
return (CUDA.@allowscalar FourierFlows.on_grid(f₁, g₁) == f₁.(X₁) && CUDA.@allowscalar FourierFlows.on_grid(f₂, g₂) == f₂.(X₂, Y₂) && CUDA.@allowscalar FourierFlows.on_grid(f₃, g₃) == f₃.(X₃, Y₃, Z₃))
161161
end

0 commit comments

Comments
 (0)