Skip to content

Commit c100612

Browse files
Allow different OUTPUT_WRT_FREQ for each output file (#1552)
* added file dependent writing frequency * use OUTPUT_WRT_FREQ instead of new config option * removed *volumeoutputfrequencies * save freeformdefbox for another PR. print list of writing frequencies * only print file frequency when there are output files * Apply suggestions from code review Co-authored-by: Pedro Gomes <[email protected]>
1 parent 3f3cb55 commit c100612

File tree

22 files changed

+171
-123
lines changed

22 files changed

+171
-123
lines changed

Common/include/CConfig.hpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,9 +1119,10 @@ class CConfig {
11191119

11201120
unsigned long HistoryWrtFreq[3], /*!< \brief Array containing history writing frequencies for timer iter, outer iter, inner iter */
11211121
ScreenWrtFreq[3]; /*!< \brief Array containing screen writing frequencies for timer iter, outer iter, inner iter */
1122-
unsigned long VolumeWrtFreq; /*!< \brief Writing frequency for solution files. */
11231122
OUTPUT_TYPE* VolumeOutputFiles; /*!< \brief File formats to output */
1124-
unsigned short nVolumeOutputFiles; /*!< \brief Number of File formats to output */
1123+
unsigned short nVolumeOutputFiles=0;/*!< \brief Number of File formats to output */
1124+
unsigned short nVolumeOutputFrequencies; /*!< \brief Number of frequencies for the volume outputs */
1125+
unsigned long *VolumeOutputFrequencies; /*!< \brief list containing the writing frequencies */
11251126

11261127
bool Multizone_Mesh; /*!< \brief Determines if the mesh contains multiple zones. */
11271128
bool SinglezoneDriver; /*!< \brief Determines if the single-zone driver is used. (TEMPORARY) */
@@ -1256,6 +1257,8 @@ class CConfig {
12561257

12571258
void addUShortListOption(const string name, unsigned short & size, unsigned short * & option_field);
12581259

1260+
void addULongListOption(const string name, unsigned short & size, unsigned long * & option_field);
1261+
12591262
void addStringListOption(const string name, unsigned short & num_marker, string* & option_field);
12601263

12611264
void addConvectOption(const string name, unsigned short & space_field, unsigned short & centered_field, unsigned short & upwind_field);
@@ -9438,11 +9441,6 @@ class CConfig {
94389441
*/
94399442
void SetScreen_Wrt_Freq(unsigned short iter, unsigned long nIter) { ScreenWrtFreq[iter] = nIter; }
94409443

9441-
/*!
9442-
* \brief GetScreen_Wrt_Freq_Inner
9443-
*/
9444-
unsigned long GetVolume_Wrt_Freq() const { return VolumeWrtFreq; }
9445-
94469444
/*!
94479445
* \brief GetVolumeOutputFiles
94489446
*/
@@ -9453,6 +9451,12 @@ class CConfig {
94539451
*/
94549452
unsigned short GetnVolumeOutputFiles() const { return nVolumeOutputFiles; }
94559453

9454+
/*!
9455+
* \brief GetVolumeOutputFrequency
9456+
* \param[in] iFile: index of file number for which the writing frequency needs to be returned.
9457+
*/
9458+
unsigned long GetVolumeOutputFrequency(unsigned short iFile) const { return VolumeOutputFrequencies[iFile]; }
9459+
94569460
/*!
94579461
* \brief Get the desired factorization frequency for PaStiX
94589462
* \return Number of calls to 'Build' that trigger re-factorization.

Common/include/adt/CADTElemClass.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class CADTElemClass : public CADTBaseClass {
9797
* \param[out] rankID Rank on which element containing the coordinate is stored.
9898
* \param[out] parCoor Parametric coordinates of coor inside the element,
9999
which contains the coordinate.
100-
* \param[out] weightsInterpol Interpolation weigts of of coor inside the element,
100+
* \param[out] weightsInterpol Interpolation weights of coor inside the element,
101101
which contains the coordinate.
102102
* \return True if an element is found, false if not.
103103
*/

Common/include/grid_movement/CFreeFormDefBox.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ class CFreeFormDefBox : public CGridMovement {
4141
unsigned short nCornerPoints, /*!< \brief Number of corner points of the FFDBox. */
4242
nControlPoints, nControlPoints_Copy; /*!< \brief Number of control points of the FFDBox. */
4343
su2double **Coord_Corner_Points, /*!< \brief Coordinates of the corner points. */
44-
****Coord_Control_Points, /*!< \brief Coordinates of the control points. */
44+
****Coord_Control_Points, /*!< \brief Coordinates of the control points. */
4545
****ParCoord_Control_Points, /*!< \brief Coordinates of the control points. */
4646
****Coord_Control_Points_Copy, /*!< \brief Coordinates of the control points (copy). */
47-
****Coord_SupportCP; /*!< \brief Coordinates of the support control points. */
47+
****Coord_SupportCP{nullptr}; /*!< \brief Coordinates of the support control points. */
4848
unsigned short lOrder, lOrder_Copy, /*!< \brief Order of the FFDBox in the i direction. */
4949
mOrder, mOrder_Copy, /*!< \brief Order of the FFDBox in the j direction. */
5050
nOrder, nOrder_Copy; /*!< \brief Order of the FFDBox in the k direction. */
@@ -625,6 +625,7 @@ class CFreeFormDefBox : public CGridMovement {
625625
* \param[in] config - Definition of the particular problem.
626626
* \param[in] iFFDBox - Index of the FFDBox.
627627
*/
628+
// this routine is not used. We should consider deleting it.
628629
void SetDeformationZone(CGeometry *geometry, CConfig *config, unsigned short iFFDBox) const;
629630

630631
/*!

Common/include/option_structure.inl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,14 @@ public:
387387
}
388388
};
389389

390+
class COptionULongList final : public COptionScalarList<unsigned long> {
391+
public:
392+
template<class... Ts>
393+
COptionULongList(Ts&&... args) :
394+
COptionScalarList<unsigned long>("unsigned long", args...) {
395+
}
396+
};
397+
390398
class COptionStringList final : public COptionScalarList<string> {
391399
public:
392400
template<class... Ts>

Common/src/CConfig.cpp

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,13 @@ void CConfig::addUShortListOption(const string name, unsigned short & size, unsi
400400
option_map.insert(pair<string, COptionBase *>(name, val));
401401
}
402402

403+
void CConfig::addULongListOption(const string name, unsigned short & size, unsigned long * & option_field) {
404+
assert(option_map.find(name) == option_map.end());
405+
all_options.insert(pair<string, bool>(name, true));
406+
COptionBase* val = new COptionULongList(name, size, option_field);
407+
option_map.insert(pair<string, COptionBase *>(name, val));
408+
}
409+
403410
void CConfig::addStringListOption(const string name, unsigned short & num_marker, string* & option_field) {
404411
assert(option_map.find(name) == option_map.end());
405412
all_options.insert(pair<string, bool>(name, true));
@@ -1018,6 +1025,7 @@ void CConfig::SetPointersNull(void) {
10181025
HistoryOutput = nullptr;
10191026
VolumeOutput = nullptr;
10201027
VolumeOutputFiles = nullptr;
1028+
VolumeOutputFrequencies = nullptr;
10211029
ConvField = nullptr;
10221030

10231031
/*--- Variable initialization ---*/
@@ -1173,7 +1181,6 @@ void CConfig::SetConfig_Options() {
11731181
addBoolOption("VT_RESIDUAL_LIMITING", vt_transfer_res_limit, false);
11741182
/* DESCRIPTION: List of catalytic walls */
11751183
addStringListOption("CATALYTIC_WALL", nWall_Catalytic, Wall_Catalytic);
1176-
/*!\brief MARKER_MONITORING\n DESCRIPTION: Marker(s) of the surface where evaluate the non-dimensional coefficients \ingroup Config*/
11771184

11781185

11791186
/*--- Options related to VAN der WAALS MODEL and PENG ROBINSON ---*/
@@ -1405,6 +1412,7 @@ void CConfig::SetConfig_Options() {
14051412
addStringListOption("MARKER_PLOTTING", nMarker_Plotting, Marker_Plotting);
14061413
/*!\brief MARKER_MONITORING\n DESCRIPTION: Marker(s) of the surface where evaluate the non-dimensional coefficients \ingroup Config*/
14071414
addStringListOption("MARKER_MONITORING", nMarker_Monitoring, Marker_Monitoring);
1415+
14081416
/*!\brief MARKER_CONTROL_VOLUME\n DESCRIPTION: Marker(s) of the surface in the surface flow solution file \ingroup Config*/
14091417
addStringListOption("MARKER_ANALYZE", nMarker_Analyze, Marker_Analyze);
14101418
/*!\brief MARKER_DESIGNING\n DESCRIPTION: Marker(s) of the surface where objective function (design problem) will be evaluated \ingroup Config*/
@@ -2444,7 +2452,8 @@ void CConfig::SetConfig_Options() {
24442452
/*!\par CONFIG_CATEGORY: Multizone definition \ingroup Config*/
24452453
/*--- Options related to multizone problems ---*/
24462454

2447-
/*!\brief MARKER_PLOTTING\n DESCRIPTION: Marker(s) of the surface in the surface flow solution file \ingroup Config*/
2455+
/* DESCRIPTION List of config files for each zone in a multizone setup with SOLVER=MULTIPHYSICS
2456+
* Order here has to match the order in the meshfile if just one is used. */
24482457
addStringListOption("CONFIG_LIST", nConfig_Files, Config_Filenames);
24492458

24502459
/* DESCRIPTION: Determines if the multizone problem is solved for time-domain. */
@@ -2814,8 +2823,9 @@ void CConfig::SetConfig_Options() {
28142823
addUnsignedLongOption("SCREEN_WRT_FREQ_OUTER", ScreenWrtFreq[1], 1);
28152824
/* DESCRIPTION: Screen writing frequency (TIME_ITER) */
28162825
addUnsignedLongOption("SCREEN_WRT_FREQ_TIME", ScreenWrtFreq[0], 1);
2817-
/* DESCRIPTION: Volume solution writing frequency */
2818-
addUnsignedLongOption("OUTPUT_WRT_FREQ", VolumeWrtFreq, 250);
2826+
/* DESCRIPTION: list of writing frequencies for each file type (length same as nVolumeOutputFiles) */
2827+
addULongListOption("OUTPUT_WRT_FREQ", nVolumeOutputFrequencies, VolumeOutputFrequencies);
2828+
28192829
/* DESCRIPTION: Volume solution files */
28202830
addEnumListOption("OUTPUT_FILES", nVolumeOutputFiles, VolumeOutputFiles, Output_Map);
28212831

@@ -3302,6 +3312,30 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
33023312
VolumeOutputFiles[2] = OUTPUT_TYPE::SURFACE_PARAVIEW_XML;
33033313
}
33043314

3315+
/*--- Set the default output frequencies ---*/
3316+
if (!OptionIsSet("OUTPUT_WRT_FREQ")){
3317+
nVolumeOutputFrequencies = nVolumeOutputFiles;
3318+
VolumeOutputFrequencies = new unsigned long [nVolumeOutputFrequencies];
3319+
3320+
/*--- Using default frequency of 250 for all files when steady, and 1 for unsteady. ---*/
3321+
for (auto iVolumeFreq = 0; iVolumeFreq < nVolumeOutputFrequencies; iVolumeFreq++){
3322+
VolumeOutputFrequencies[iVolumeFreq] = Time_Domain ? 1 : 250;
3323+
}
3324+
} else if (nVolumeOutputFrequencies < nVolumeOutputFiles) {
3325+
/*--- If there are fewer frequencies than files, repeat the last frequency.
3326+
* This is useful to define 1 frequency for the restart file and 1 frequency for all the visualization files. ---*/
3327+
auto* newFrequencies = new unsigned long[nVolumeOutputFiles];
3328+
for (unsigned short i = 0; i < nVolumeOutputFrequencies; ++i) {
3329+
newFrequencies[i] = VolumeOutputFrequencies[i];
3330+
}
3331+
for (auto i = nVolumeOutputFrequencies; i < nVolumeOutputFiles; ++i) {
3332+
newFrequencies[i] = newFrequencies[i-1];
3333+
}
3334+
delete [] VolumeOutputFrequencies;
3335+
VolumeOutputFrequencies = newFrequencies;
3336+
nVolumeOutputFrequencies = nVolumeOutputFiles;
3337+
}
3338+
33053339
/*--- Check if SU2 was build with TecIO support, as that is required for Tecplot Binary output. ---*/
33063340
#ifndef HAVE_TECIO
33073341
for (unsigned short iVolumeFile = 0; iVolumeFile < nVolumeOutputFiles; iVolumeFile++){
@@ -3577,9 +3611,6 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
35773611

35783612
if (TimeMarching == TIME_MARCHING::TIME_STEPPING){ InnerIter = 1; }
35793613

3580-
/*--- Set the default write frequency to 1 if unsteady instead of 250 ---*/
3581-
if (!OptionIsSet("OUTPUT_WRT_FREQ")) { VolumeWrtFreq = 1; }
3582-
35833614
/*--- Set History write freq for inner and outer iteration to zero by default, so only time iterations write. ---*/
35843615
if (!OptionIsSet("HISTORY_WRT_FREQ_INNER")) { HistoryWrtFreq[2] = 0; }
35853616
if (!OptionIsSet("HISTORY_WRT_FREQ_OUTER")) { HistoryWrtFreq[1] = 0; }
@@ -6824,7 +6855,27 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) {
68246855

68256856
if (val_software == SU2_COMPONENT::SU2_CFD) {
68266857

6827-
cout << "Writing solution files every " << VolumeWrtFreq <<" iterations."<< endl;
6858+
if (nVolumeOutputFiles != 0) {
6859+
cout << "File writing frequency: " << endl;
6860+
PrintingToolbox::CTablePrinter FileFreqTable(&std::cout);
6861+
FileFreqTable.AddColumn("File", 25);
6862+
FileFreqTable.AddColumn("Frequency", 10);
6863+
FileFreqTable.SetAlign(PrintingToolbox::CTablePrinter::RIGHT);
6864+
FileFreqTable.PrintHeader();
6865+
6866+
for (auto iFreq = 0; iFreq < nVolumeOutputFiles; iFreq++){
6867+
/*--- find the key belonging to the value in the map---*/
6868+
for (auto& it : Output_Map) {
6869+
if (it.second == VolumeOutputFiles[iFreq]) {
6870+
FileFreqTable << it.first << VolumeOutputFrequencies[iFreq];
6871+
break;
6872+
}
6873+
}
6874+
}
6875+
6876+
FileFreqTable.PrintFooter();
6877+
}
6878+
68286879
cout << "Writing the convergence history file every " << HistoryWrtFreq[2] <<" inner iterations."<< endl;
68296880
if (Multizone_Problem){
68306881
cout << "Writing the convergence history file every " << HistoryWrtFreq[1] <<" outer iterations."<< endl;
@@ -7419,10 +7470,10 @@ unsigned short CConfig::GetMarker_CfgFile_TagBound(string val_marker) const {
74197470

74207471
unsigned short iMarker_CfgFile;
74217472

7422-
for (iMarker_CfgFile = 0; iMarker_CfgFile < nMarker_CfgFile; iMarker_CfgFile++)
7473+
for (iMarker_CfgFile = 0; iMarker_CfgFile < nMarker_CfgFile; iMarker_CfgFile++) {
74237474
if (Marker_CfgFile_TagBound[iMarker_CfgFile] == val_marker)
74247475
return iMarker_CfgFile;
7425-
7476+
}
74267477
SU2_MPI::Error(string("The configuration file doesn't have any definition for marker ") + val_marker, CURRENT_FUNCTION);
74277478
return 0;
74287479
}
@@ -7821,7 +7872,6 @@ CConfig::~CConfig() {
78217872

78227873
delete [] nBlades;
78237874
delete [] FreeStreamTurboNormal;
7824-
78257875
}
78267876

78277877
string CConfig::GetFilename(string filename, string ext, int timeIter) const {

Common/src/grid_movement/CSurfaceMovement.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,7 @@ void CSurfaceMovement::SetParametricCoord(CGeometry *geometry, CConfig *config,
784784
TotalVertex++;
785785

786786
for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {
787-
788787
if (config->GetMarker_All_DV(iMarker) == YES) {
789-
790788
for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) {
791789

792790
/*--- Get the cartesian coordinates ---*/

QuickStart/inv_NACA0012.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ SOLUTION_FILENAME= solution_flow.dat
272272
% Restart adjoint input file
273273
SOLUTION_ADJ_FILENAME= solution_adj.dat
274274
%
275-
% Output file format (TECPLOT, PARAVIEW, TECPLOT_BINARY)
275+
% Output file format (TECPLOT, CSV)
276276
TABULAR_FORMAT= CSV
277277
%
278278
% Output file convergence history (w/o extension)

SU2_CFD/include/numerics/CNumerics.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,11 +1187,11 @@ class CNumerics {
11871187
void GetLMatrix(su2double val_soundspeed, su2double val_density, su2double **L_Matrix) const;
11881188

11891189
/*!
1190-
* \brief Computation of the flow Residual Jacoboan Matrix for Non Reflecting BC.
1190+
* \brief Computation of the flow Residual Jacobian Matrix for Non Reflecting BC.
11911191
* \param[in] val_soundspeed - value of the sound speed.
11921192
* \param[in] val_density - value of the density.
11931193
* \param[out] R_c - Residual Jacoboan Matrix
1194-
* \param[out] R_c_inv- inverse of the Residual Jacoboan Matrix .
1194+
* \param[out] R_c_inv- inverse of the Residual Jacobian Matrix .
11951195
*/
11961196
void ComputeResJacobianGiles(CFluidModel *FluidModel, su2double pressure, su2double density, const su2double *turboVel,
11971197
su2double alphaInBC, su2double gammaInBC, su2double **R_c, su2double **R_c_inv);

SU2_CFD/include/output/CFlowOutput.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,9 @@ class CFlowOutput : public CFVMOutput{
257257
* \param[in] config - Definition of the particular problem.
258258
* \param[in] Iter - Current iteration index.
259259
* \param[in] force_writing - boolean that forces writing of volume output
260+
* \param[in] iFile - index to the file that we need to consider for volume output
260261
*/
261-
bool WriteVolume_Output(CConfig *config, unsigned long Iter, bool force_writing) override;
262+
bool WriteVolume_Output(CConfig *config, unsigned long Iter, bool force_writing, unsigned short iFile) override;
262263

263264
/*!
264265
* \brief Write the forces breakdown file

SU2_CFD/include/output/COutput.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ class COutput {
8989
curInnerIter; /*!< \brief Current value of the inner iteration index */
9090

9191
string historyFilename; /*!< \brief The history filename*/
92-
char char_histfile[200]; /*! \brief Temporary variable to store the history filename */
93-
ofstream histFile; /*! \brief Output file stream for the history */
94-
92+
ofstream histFile; /*!< \brief Output file stream for the history */
93+
9594
bool cauchyTimeConverged; /*! \brief: Flag indicating that solver is already converged. Needed for writing restart files. */
9695

9796
/** \brief Enum to identify the screen output format. */
@@ -778,8 +777,9 @@ class COutput {
778777
* \param[in] config - Definition of the particular problem.
779778
* \param[in] Iter - Current iteration index.
780779
* \param[in] force_writing - boolean that forces writing of volume output
780+
* \param[in] iFile - index to the file that we need to consider for volume output
781781
*/
782-
virtual bool WriteVolume_Output(CConfig *config, unsigned long Iter, bool force_writing);
782+
virtual bool WriteVolume_Output(CConfig *config, unsigned long Iter, bool force_writing, unsigned short iFile);
783783

784784
/*!
785785
* \brief Set the values of the volume output fields for a point.

0 commit comments

Comments
 (0)