Skip to content

Commit 47ad914

Browse files
authored
Merge pull request #329 from FourierFlows/ncc/only-save-computed-diagnostic
Only save computed diagnostic
2 parents bb4664f + 3fea94e commit 47ad914

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
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.9.2"
9+
version = "0.9.3"
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
@@ -102,7 +102,7 @@ and [Navid C. Constantinou][] (@navidcy).
102102

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

105-
> Gregory L. Wagner, Navid C. Constantinou, and contributors. (2022). FourierFlows/FourierFlows.jl: FourierFlows v0.9.1 (Version v0.9.1). Zenodo. [http://doi.org/10.5281/zenodo.1161724](http://doi.org/10.5281/zenodo.1161724)
105+
> Gregory L. Wagner, Navid C. Constantinou, and contributors. (2022). FourierFlows/FourierFlows.jl: FourierFlows v0.9.3 (Version v0.9.3). Zenodo. [http://doi.org/10.5281/zenodo.1161724](http://doi.org/10.5281/zenodo.1161724)
106106
107107

108108
## Contributing

src/output.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,16 @@ end
145145
saveproblem(out::Output) = saveproblem(out.prob, out.path)
146146

147147
"""
148-
savediagnostic(diag, diagname, filename)
148+
savediagnostic(diagnostic, diagname, filename)
149149
150-
Save diagnostics in `diag` to `filename`, labeled by `diagname`.
150+
Save `diagnostic` to `filename` under name `diagname`. Only the computed diagnostic
151+
is saved, that is, everything up to diagnostic's iteration `diagnostic.i`.
151152
"""
152-
function savediagnostic(diag, diagname, filename)
153+
function savediagnostic(diagnostic, diagname, filename)
153154
jldopen(filename, "a+") do file
154-
file["diags/$diagname/steps"] = diag.steps
155-
file["diags/$diagname/t"] = diag.t
156-
file["diags/$diagname/data"] = diag.data
155+
file["diagnostics/$diagname/steps"] = diagnostic.steps[1:diagnostic.i]
156+
file["diagnostics/$diagname/t"] = diagnostic.t[1:diagnostic.i]
157+
file["diagnostics/$diagname/data"] = diagnostic.data[1:diagnostic.i]
157158
end
158159

159160
return nothing

test/test_output.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,15 @@ end
108108
function test_savediagnostic(dev::Device=CPU())
109109
filename = joinpath(".", "testoutput.jld2")
110110
if isfile(filename); GC.gc(); rm(filename); end
111-
111+
112112
prob = Problem(dev; nx=6, Lx=2π)
113113
getone(prob) = 1
114114
nsteps = 100
115-
freq = 1
115+
freq = 2
116116
ndata = ceil(Int, (nsteps+1)/freq)
117117
d = Diagnostic(getone, prob; nsteps, freq, ndata)
118+
119+
nsteps += 5 #to check what happens if we time-step a bit longer than the size of the diagnostic
118120
stepforward!(prob, d, nsteps)
119121
expectedsteps = cat([0], freq:freq:nsteps, dims=1)
120122

@@ -125,7 +127,9 @@ function test_savediagnostic(dev::Device=CPU())
125127

126128
file = jldopen(filename)
127129

128-
return isfile(filename) && file["diags"]["mydiagnostic"]["steps"] == expectedsteps
130+
return isfile(filename) &&
131+
file["diagnostics"]["mydiagnostic"]["steps"] == expectedsteps &&
132+
file["diagnostics"]["mydiagnostic"]["data"] == d.data[1:d.i]
129133
end
130134

131135
struct TestbedParams{T, Trfft} <: AbstractParams

0 commit comments

Comments
 (0)