Skip to content

Conversation

@bigfooted
Copy link
Contributor

@bigfooted bigfooted commented Dec 6, 2021

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.

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with the '-Wall -Wextra -Wno-unused-parameter -Wno-empty-body' compiler flags, or simply --warnlevel=2 when using meson).
  • My contribution is commented and consistent with SU2 style.
  • [] I have added a test case that demonstrates my contribution, if necessary.
  • [] I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp) , if necessary.

@bigfooted
Copy link
Contributor Author

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?

Copy link
Member

@pcarruscag pcarruscag left a 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?

@bigfooted
Copy link
Contributor Author

Thanks for the comments!

* Never do it for unsteady;

I saw that too, good idea!

* 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 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.

@pcarruscag
Copy link
Member

You can store the iteration number for the next renaming so that the sequence is in sync.
I would rather not rely on symbolic links to ensure we don't run into issues with OS or file system quirks. For maximum peace of mind :)

@bigfooted
Copy link
Contributor Author

bigfooted commented Dec 17, 2021

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.

@lgtm-com
Copy link

lgtm-com bot commented Dec 18, 2021

This pull request introduces 1 alert when merging 08d75ff into 4f85841 - view on LGTM.com

new alerts:

  • 1 for Empty branch of conditional

@bigfooted
Copy link
Contributor Author

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.

bigfooted and others added 5 commits December 20, 2021 23:32
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
@bigfooted
Copy link
Contributor Author

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.

Comment on lines 371 to 374
if (!config->GetWrt_Restart_Overwrite())
(*fileWritingTable) << "SU2 restart with iteration" << filename_iter ;

(*fileWritingTable) << "SU2 restart" << fileName + CSU2BinaryFileWriter::fileExt;
Copy link
Member

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])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +41 to +42
/*--- We append the pre-defined suffix (extension) to the filename (prefix) ---*/
val_filename.append(fileExt);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

@bigfooted
Copy link
Contributor Author

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.

@bigfooted
Copy link
Contributor Author

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.

@bigfooted bigfooted changed the title [WIP] append iteration number to filenames append iteration number to filenames Jan 11, 2022
@bigfooted bigfooted linked an issue Jan 11, 2022 that may be closed by this pull request
@bigfooted bigfooted self-assigned this Jan 11, 2022
@pcarruscag pcarruscag changed the title append iteration number to filenames Options for appending iteration number to filenames (keep solution snapshots) Jan 12, 2022
bigfooted and others added 4 commits January 12, 2022 22:16
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>
Copy link
Member

@pcarruscag pcarruscag left a 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);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

filename = GetUnsteady_FileName(filename, timeIter, ext);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines +203 to +204
/*--- We append the pre-defined suffix (extension) to the filename (prefix) ---*/
val_filename.append(fileExt);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/*--- 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
% 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)

@bigfooted bigfooted merged commit 36be2b8 into su2code:develop Jan 13, 2022
bigfooted added a commit that referenced this pull request Jan 13, 2022
* remove cout line for paraviewVTMFileWriter
* added review suggestions of #1465
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Writing solution data in steady state cases without overwriting them

2 participants