Skip to content

Commit 4211af3

Browse files
authored
Merge pull request #270 from FourierFlows/ncc/fix-bug-on_grid
Fix bug in `on_grid()`
2 parents 9adde78 + a6dc2bd commit 4211af3

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
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.15"
9+
version = "0.6.16"
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
@@ -91,7 +91,7 @@ and [Navid C. Constantinou][] (@navidcy).
9191

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

94-
> Navid C. Constantinou & Gregory L. Wagner. (2021). FourierFlows/FourierFlows.jl: FourierFlows v0.6.15 (Version v0.6.15). Zenodo. [http://doi.org/10.5281/zenodo.1161724](http://doi.org/10.5281/zenodo.1161724)
94+
> Navid C. Constantinou & Gregory L. Wagner. (2021). FourierFlows/FourierFlows.jl: FourierFlows v0.6.16 (Version v0.6.16). Zenodo. [http://doi.org/10.5281/zenodo.1161724](http://doi.org/10.5281/zenodo.1161724)
9595
9696

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

src/utils.jl

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -248,17 +248,11 @@ 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) = CUDA.@allowscalar func.(grid.x)
251+
on_grid(func, grid::OneDGrid{T, A}) where {T, A} = CUDA.@allowscalar A([func(grid.x[i]) for i=1:grid.nx])
252252

253-
function on_grid(func, grid::TwoDGrid)
254-
x, y = gridpoints(grid)
255-
return CUDA.@allowscalar func.(x, y)
256-
end
257-
258-
function on_grid(func, grid::ThreeDGrid)
259-
x, y, z = gridpoints(grid)
260-
return CUDA.@allowscalar func.(x, y, z)
261-
end
253+
on_grid(func, grid::TwoDGrid{T, A}) where {T, A} = CUDA.@allowscalar A([func(grid.x[i], grid.y[j]) for i=1:grid.nx, j=1:grid.ny])
254+
255+
on_grid(func, grid::ThreeDGrid{T, A}) where {T, A} = CUDA.@allowscalar A([func(grid.x[i], grid.y[j], grid.z[k]) for i=1:grid.nx, j=1:grid.ny, k=1:grid.nz])
262256

263257
"""
264258
ArrayType(::Device)

test/test_utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,5 +157,5 @@ function test_ongrid(dev::Device)
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₁) && CUDA.@allowscalar FourierFlows.on_grid(f₂, g₂) == f₂.(X₂, Y₂) && CUDA.@allowscalar FourierFlows.on_grid(f₃, g₃) == f₃.(X₃, Y₃, Z₃))
160+
return (FourierFlows.on_grid(f₁, g₁) f₁.(X₁) && FourierFlows.on_grid(f₂, g₂) f₂.(X₂, Y₂) && FourierFlows.on_grid(f₃, g₃) f₃.(X₃, Y₃, Z₃))
161161
end

0 commit comments

Comments
 (0)