-
Notifications
You must be signed in to change notification settings - Fork 15
Write metadata to a dedicated JSON file #737
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: dev
Are you sure you want to change the base?
Changes from all commits
db89067
d8906ee
8558b13
86e491c
8803ef9
1ebda82
b86e2d6
164b56e
2165d37
51317e3
8f6eda9
7825eb9
e3cd5ca
251eaf2
fecc01f
3a399ff
9868c4a
45940d9
f6b605e
479e35c
3ed23c5
bb81f90
7d34fe5
ff5651f
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 |
---|---|---|
|
@@ -216,6 +216,8 @@ function initialize_postprocess_callback!(cb::PostprocessCallback, u, t, integra | |
# Apply the callback | ||
cb(integrator) | ||
|
||
write_meta_data(cb, integrator) | ||
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. So this is called both by the postprocess and the savesolution callback? Do they both create the file and the second overwrites the first? 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.
Yes |
||
|
||
return cb | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,7 @@ | |
SolutionSavingCallback(; interval::Integer=0, dt=0.0, save_times=Array{Float64, 1}([]), | ||
save_initial_solution=true, save_final_solution=true, | ||
output_directory="out", append_timestamp=false, prefix="", | ||
verbose=false, write_meta_data=true, max_coordinates=2^15, | ||
custom_quantities...) | ||
verbose=false, max_coordinates=2^15, custom_quantities...) | ||
|
||
|
||
Callback to save the current numerical solution in VTK format in regular intervals. | ||
|
@@ -28,7 +27,6 @@ To ignore a custom quantity for a specific system, return `nothing`. | |
- `append_timestamp=false`: Append current timestamp to the output directory. | ||
- 'prefix=""': Prefix added to the filename. | ||
- `custom_quantities...`: Additional user-defined quantities. | ||
- `write_meta_data=true`: Write meta data. | ||
- `verbose=false`: Print to standard IO when a file is written. | ||
- `max_coordinates=2^15`: The coordinates of particles will be clipped if their | ||
absolute values exceed this threshold. | ||
|
@@ -70,7 +68,6 @@ mutable struct SolutionSavingCallback{I, CQ} | |
save_times :: Vector{Float64} | ||
save_initial_solution :: Bool | ||
save_final_solution :: Bool | ||
write_meta_data :: Bool | ||
verbose :: Bool | ||
output_directory :: String | ||
prefix :: String | ||
|
@@ -84,8 +81,8 @@ function SolutionSavingCallback(; interval::Integer=0, dt=0.0, | |
save_times=Float64[], | ||
save_initial_solution=true, save_final_solution=true, | ||
output_directory="out", append_timestamp=false, | ||
prefix="", verbose=false, write_meta_data=true, | ||
max_coordinates=Float64(2^15), custom_quantities...) | ||
prefix="", verbose=false, max_coordinates=Float64(2^15), | ||
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 is a breaking change! |
||
custom_quantities...) | ||
if (dt > 0 && interval > 0) || (length(save_times) > 0 && (dt > 0 || interval > 0)) | ||
throw(ArgumentError("Setting multiple save times for the same solution " * | ||
"callback is not possible. Use either `dt`, `interval` or `save_times`.")) | ||
|
@@ -101,8 +98,8 @@ function SolutionSavingCallback(; interval::Integer=0, dt=0.0, | |
|
||
solution_callback = SolutionSavingCallback(interval, Float64.(save_times), | ||
save_initial_solution, save_final_solution, | ||
write_meta_data, verbose, output_directory, | ||
prefix, max_coordinates, custom_quantities, | ||
verbose, output_directory, prefix, | ||
max_coordinates, custom_quantities, | ||
-1, Ref("UnknownVersion")) | ||
|
||
if length(save_times) > 0 | ||
|
@@ -133,6 +130,8 @@ function initialize_save_cb!(solution_callback::SolutionSavingCallback, u, t, in | |
solution_callback.latest_saved_iter = -1 | ||
solution_callback.git_hash[] = compute_git_hash() | ||
|
||
write_meta_data(solution_callback, integrator) | ||
|
||
# Save initial solution | ||
if solution_callback.save_initial_solution | ||
solution_callback(integrator) | ||
|
@@ -151,8 +150,8 @@ end | |
|
||
# `affect!` | ||
function (solution_callback::SolutionSavingCallback)(integrator) | ||
(; interval, output_directory, custom_quantities, write_meta_data, git_hash, | ||
verbose, prefix, latest_saved_iter, max_coordinates) = solution_callback | ||
(; interval, output_directory, custom_quantities, git_hash, verbose, | ||
prefix, latest_saved_iter, max_coordinates) = solution_callback | ||
|
||
vu_ode = integrator.u | ||
semi = integrator.p | ||
|
@@ -175,8 +174,8 @@ function (solution_callback::SolutionSavingCallback)(integrator) | |
|
||
@trixi_timeit timer() "save solution" trixi2vtk(vu_ode, semi, integrator.t; | ||
iter, output_directory, prefix, | ||
write_meta_data, git_hash=git_hash[], | ||
max_coordinates, custom_quantities...) | ||
git_hash=git_hash[], max_coordinates, | ||
custom_quantities...) | ||
|
||
# Tell OrdinaryDiffEq that `u` has not been modified | ||
u_modified!(integrator, false) | ||
|
Uh oh!
There was an error while loading. Please reload this page.