Fix functionality of 'WRT_*_OVERWRITE' flags. #2036
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed Changes
The flags 'WRT_VOLUME_OVERWRITE', 'WRT_SURFACE_OVERWRITE', and 'WRT_RESTART_OVERWRITE' are not working correctly. This commit fixes this.
The expected behavior is this:
The user specifies what kind of output files should be written using the OUTPUT_FILES flag. These output files can be volume or surface files for visualization like Tecplot or Paraview files, volumetric restart files to be used as initial conditions for another SU2 run, or mesh format files like CGNS or STL files.
Furthermore, the user can choose to not overwrite these files, but rather add the current iteration number to the file name and keep dumping such files during the calculation. This is done using the three WRT_*_OVERWRITE flags mentioned above.
However, the current implementation in develop only works correctly for PARAVIEW_MULTIBLOCK and for RESTART type output files. This is because in the case of PARAVIEW_MULTIBLOCK, the additional file output using the iteration number in the filename, is performed in the switch case block directly.
For all other output files, the switch case block only generates the correct filename with the iteration number appended. After the switch block, it is (wrongly) checked if (and only if) the WRT_RESTART_OVERWRITE flag is set to NO. If so, the additional file is written. Therefore, this logic only works correctly for RESTART files (and PARAVIEW_MULTIBLOCK files, because for that format, the file dump is independent of the file dump after the switch block.
The proposed fix here introduces a local boolean (doWriteIterFile) that acts as a switch for the additional file dump. It is set in the switch case block and afterwards it is checked if this variable is true or false. Based on this value, the file dump is executed or not. Furthermore, the fix introduces and corrects some comments to make the function easier to understand.
Related Work
The flags are already available in the develop branch as config options but they don't work as expected.
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.