-
Notifications
You must be signed in to change notification settings - Fork 913
Options for appending iteration number to filenames (keep solution snapshots) #1465
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
Conversation
|
Currently I have added the keywords WRT_RESTART_OVERWRITE and WRT_VOLUME_OVERWRITE. I think it is best to switch this on/off per type of file because of the large amount of data. There is also inner iterations and outer iterations that we need to take into account when appending the iteration number. Anything else? How to generalize this? |
pcarruscag
left a comment
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.
Like this, this will probably not be compatible with any other feature of SU2, what about:
- Never do it for unsteady;
- Instead of outputting with the iteration appended, output with the normal name. However, if the file already exists, rename (move) the existing file with the "previous" iteration number, and then continue with the normal output.
This way none of the existing feature should break, and we get the desired feature of having checkpointed files we can go back to if the solver blows up?
|
Thanks for the comments!
I saw that too, good idea!
This approach does mean that the file sequence is always behind by OUTPUT_WRT_FREQ. We could also create a symbolic link where restart.dat points to the latest restart_xxx.dat if the existence of restart.dat is necessary for existing workflows. |
|
You can store the iteration number for the next renaming so that the sequence is in sync. |
|
OK, I focus on the binary restart for now. What I do now is that with write frequency of 10, at iteration 20 I rename the restart.dat to restart_0010.dat etc. and then at the final iteration 100 I rename the old restart.dat from iteration 90 to restart_0090.dat, I write the new restart.dat. and then I write it a second time, naming it restart_0099.dat. |
|
This pull request introduces 1 alert when merging 08d75ff into 4f85841 - view on LGTM.com new alerts:
|
|
OK, code is now functional and cleaned up. If the approach for binary restart is fixed, I can will extend it to other outputs. I think the most interesting are the outputs that are used for visualization. |
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
… into feature_file_writing
|
Simplest is to just copy the saved file again, with an iteration number appended. No keeping track of what the iteration number at the previous write was, no copying of the final saved file with manually appending the final iteration number, no lag of WRT_FREQ in the availability of the restart_xxx.dat file. It does mean that we do a copy instead of a rename. But I think this is the better (because the simplest) solution. I will extend it to the other file options. |
SU2_CFD/src/output/COutput.cpp
Outdated
| if (!config->GetWrt_Restart_Overwrite()) | ||
| (*fileWritingTable) << "SU2 restart with iteration" << filename_iter ; | ||
|
|
||
| (*fileWritingTable) << "SU2 restart" << fileName + CSU2BinaryFileWriter::fileExt; |
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.
Before you apply this to the other types, put this block in a private function, to which you pass part of the description ("SU2 restart") and the file extension.
| FFDBox[iFFDBox]->SetParaview(geometry, iFFDBox, false); | ||
| } | ||
| } else if (isTecplot(static_cast<ENUM_OUTPUT>(FileFormat[iFile]))) { | ||
| } else if (isTecplot(FileFormat[iFile])) { |
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.
👍
| /*--- We append the pre-defined suffix (extension) to the filename (prefix) ---*/ | ||
| val_filename.append(fileExt); |
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.
good idea
|
The testcases contain many comments for OUTPUT_FILES and TABULAR_FORMAT that were outdated descriptions. I have removed all comments for these keywords in the testcases. Actually all testcases need to be stripped from descriptive comments and keywords that are not used or use the default value. This will be a cleanup chore for another PR. |
|
paraview multiblock is a special case, since it writes a collection of files to a folder. I have now placed the code that was in COutput::WriteToFile into a separate function in CParaviewVTMFileWriter::WriteFolderData. Because the multiblock files need to know abound the mesh and boundary conditions, it needs CConfig and CGeometry as input. But I think all this multiblock code is best placed in this file instead of in COutput. |
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
pcarruscag
left a comment
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.
LGTM the feature and the other config fixes.
In the future remember to use the su2code repo for your branches, otherwise it's a pain if someone wants to checkout the branch...
| /* DESCRIPTION: Volume solution files */ | ||
| addEnumListOption("OUTPUT_FILES", nVolumeOutputFiles, VolumeOutputFiles, Output_Map); | ||
|
|
||
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.
| filename = GetUnsteady_FileName(filename, timeIter, ext); | ||
| } | ||
|
|
||
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.
| /*--- We append the pre-defined suffix (extension) to the filename (prefix) ---*/ | ||
| val_filename.append(fileExt); |
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.
| /*--- We append the pre-defined suffix (extension) to the filename (prefix) ---*/ | |
| val_filename.append(fileExt); | |
| /*--- We append the pre-defined suffix (extension) to the filename (prefix) ---*/ | |
| val_filename.append(fileExt); |
| % SURFACE_PARAVIEW_BINARY, MESH, RESTART_BINARY, RESTART_ASCII, CGNS, SURFACE_CGNS, STL) | ||
| % Possible formats : (TECPLOT_ASCII, TECPLOT, SURFACE_TECPLOT_ASCII, | ||
| % SURFACE_TECPLOT, CSV, SURFACE_CSV, PARAVIEW_ASCII, PARAVIEW_LEGACY, SURFACE_PARAVIEW_ASCII, | ||
| % SURFACE_PARAVIEW_LEGACY, PARAVIEW, SURFACE_PARAVIEW, RESTART_ASCII, RESTART, CGNS, SURFACE_CGNS, STL_ASCII, STL) |
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.
| % SURFACE_PARAVIEW_LEGACY, PARAVIEW, SURFACE_PARAVIEW, RESTART_ASCII, RESTART, CGNS, SURFACE_CGNS, STL_ASCII, STL) | |
| % SURFACE_PARAVIEW_LEGACY, PARAVIEW, SURFACE_PARAVIEW, RESTART_ASCII, RESTART, CGNS, SURFACE_CGNS, STL_ASCII, STL_BINARY) |
* remove cout line for paraviewVTMFileWriter * added review suggestions of #1465
Proposed Changes
Give a brief overview of your contribution here in a few sentences.
WRT_RESTART_OVERWRITE= NO
WRT_VOLUME_OVERWRITE= NO
WRT_SURFACE_OVERWRITE= NO
will create, every WRT_FREQ iterations, output files with the iteration number appended. This is additional to the normal output, so the restart.dat, etc files will always contain the most recent results.
Other features that we can add:
WRT_RESTART_MAX_FILES_TO_KEEP= 5
will keep only the 5 most recently written restart_xxxx.dat files, throwing away older ones.
Related Work
Resolve any issues (bug fix or feature request), note any related PRs, or mention interactions with the work of others, if any.
related to the issue #1463
PR Checklist
Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.