-
Notifications
You must be signed in to change notification settings - Fork 90
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
Allow descriptions of output variables; save some diagnostics for solvers #2064
Conversation
Allows output dump files to be more self-documenting.
Cannot just call setAttribute() in Solver::outputVars() because DataFile might not be open at that point. Instead need to pass through and set at the same point that the Field attributes are written.
This PR implements descriptions for output variables, which would be useful for #2065, because I wanted to add descriptions of the diagnostic variables here. The description-handling parts (09b5fa2 and 6fbf9cb) could be split into a separate PR easily if that helps. BTW the way this is implemented means |
Datafile::setAttribute() opens the DataFormat object and then calls its setAttribute() method. Don't want to do this inside Datafile::write() where the DataFormat is already opened.
Poiner to the int or BoutReal is stored in a VarStr, so need to pass by reference and not by value, otherwise the pointer ends up pointing to some random place.
I think I fixed the memory errors. Had accidentally passed |
If solver type is changed, diagnostic variables will change and so might cause errors if they are added to restart files but cannot be read. So do not add diagnostic variables to the restart files.
Previously used '0' and '1' which are correct but less explicit.
Pass description through to solver->add()
I've added the This PR is ready for review now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
@@ -409,6 +410,24 @@ protected: | |||
std::vector<VarStr<Vector2D>> v2d; | |||
std::vector<VarStr<Vector3D>> v3d; | |||
|
|||
/// Vectors of diagnostic variables to save | |||
std::vector<VarStr<int>> diagnostic_int; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: member variable diagnostic_int
has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]
std::vector<VarStr<int>> diagnostic_int;
^
@@ -409,6 +410,24 @@ protected: | |||
std::vector<VarStr<Vector2D>> v2d; | |||
std::vector<VarStr<Vector3D>> v3d; | |||
|
|||
/// Vectors of diagnostic variables to save | |||
std::vector<VarStr<int>> diagnostic_int; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: member variable diagnostic_int
has protected visibility [misc-non-private-member-variables-in-classes]
@@ -409,6 +410,24 @@ protected: | |||
std::vector<VarStr<Vector2D>> v2d; | |||
std::vector<VarStr<Vector3D>> v3d; | |||
|
|||
/// Vectors of diagnostic variables to save | |||
std::vector<VarStr<int>> diagnostic_int; | |||
std::vector<VarStr<BoutReal>> diagnostic_BoutReal; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: member variable diagnostic_BoutReal
has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]
std::vector<VarStr<BoutReal>> diagnostic_BoutReal;
^
@@ -409,6 +410,24 @@ protected: | |||
std::vector<VarStr<Vector2D>> v2d; | |||
std::vector<VarStr<Vector3D>> v3d; | |||
|
|||
/// Vectors of diagnostic variables to save | |||
std::vector<VarStr<int>> diagnostic_int; | |||
std::vector<VarStr<BoutReal>> diagnostic_BoutReal; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: member variable diagnostic_BoutReal
has protected visibility [misc-non-private-member-variables-in-classes]
@@ -506,15 +518,22 @@ int ArkodeSolver::run() { | |||
throw BoutException("ARKode timestep failed\n"); | |||
} | |||
|
|||
// Get additional diagnostics | |||
long int temp_long_int, temp_long_int2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
long int temp_long_int, temp_long_int2;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -506,15 +518,22 @@ int ArkodeSolver::run() { | |||
throw BoutException("ARKode timestep failed\n"); | |||
} | |||
|
|||
// Get additional diagnostics | |||
long int temp_long_int, temp_long_int2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable temp_long_int
is not initialized [cppcoreguidelines-init-variables]
long int temp_long_int, temp_long_int2;
^
= 0
@@ -506,15 +518,22 @@ int ArkodeSolver::run() { | |||
throw BoutException("ARKode timestep failed\n"); | |||
} | |||
|
|||
// Get additional diagnostics | |||
long int temp_long_int, temp_long_int2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable temp_long_int2
is not initialized [cppcoreguidelines-init-variables]
long int temp_long_int, temp_long_int2;
^
= 0
@@ -385,16 +404,39 @@ int CvodeSolver::run() { | |||
throw BoutException("SUNDIALS CVODE timestep failed\n"); | |||
} | |||
|
|||
// Get additional diagnostics | |||
long int temp_long_int; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable temp_long_int
is not initialized [cppcoreguidelines-init-variables]
long int temp_long_int;
^
= 0
d6c50d2
to
280fed5
Compare
What's the clang-tidy bot supposed to do if you 'fix' the things it suggests? It doesn't seem to have removed the comments like I'd hope. The changes I made weren't directly what it suggested though (I passed by reference instead of using a |
No, I'm afraid it's not as clever as that. For now you can just click
"resolve" on the comment. I can probably make it do that automatically if
there's an API for it though
…On Thu, 10 Dec 2020, 23:58 johnomotani, ***@***.***> wrote:
What's the clang-tidy bot supposed to do if you 'fix' the things it
suggests? It doesn't seem to have removed the comments like I'd hope. The
changes I made weren't directly what it suggested though (I passed by
reference instead of using a std::move), so that might be why?
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#2064 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALLAXTYGC7S3WLU5NNBVIDSUFODLANCNFSM4PW3C37A>
.
|
Thanks @ZedThree! The PEP8 bot somehow does this, but I don't know how. Would be nice, but clicking 'resolve' on addressed issues is fine with me - I was just wondering if there was a feature that wasn't working right. |
I will investigate the PEP8 bot and steal features from it 😄
…On Fri, 11 Dec 2020, 08:44 johnomotani, ***@***.***> wrote:
No, I'm afraid it's not as clever as that. For now you can just click
"resolve" on the comment. I can probably make it do that automatically if
there's an API for it though
Thanks @ZedThree <https://github.com/ZedThree>! The PEP8 bot somehow does
this, but I don't know how. Would be nice, but clicking 'resolve' on
addressed issues is fine with me - I was just wondering if there was a
feature that wasn't working right.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2064 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALLAXTAUDNCGUGUIG25KJ3SUHLWVANCNFSM4PW3C37A>
.
|
Descriptions of output variables
Adds an optional argument to
Datafile::add()
,Solver::add()
andbout_solve()
which can be passed a description as astd::string
. The description is then added to the output files as an attribute of the variable. This should be useful for making the output files self-documenting. This PR adds the mechanism, but variables written by BOUT++ still need adescription
adding in a future PR (apart from the new solver diagnostic variables described below).Save some diagnostics for solvers
When
solver:diagnose=true
is set, CVODE and ARKODE print out some useful information. This PR saves those numbers to the dump files to make them easier to access in post-processing.The diagnostics are always saved, regardless of
solver:diagnose
setting. The setting is useful to avoid cluttering up stdout, but I don't see any benefit to not saving into dump files - the diagnostics are scalars so don't take up much space, and it's nice to be able to go back and look at them without having decided to set the setting before the run.The diagnostic variables have descriptions copied from the CVODE and ARKODE manuals which are written as attributes using the new
description
argument described above. These help make the output files a little less cryptic, since SUNDIALS variable names are not very descriptive (e.g.nliters
).Datafile::add()
andSolver::add()
to the manual.