Skip to content

Commit 51b0b44

Browse files
authored
Merge branch 'develop' into feature_custom_source
2 parents 3429530 + f4cda52 commit 51b0b44

File tree

24 files changed

+302
-192
lines changed

24 files changed

+302
-192
lines changed

Common/include/CConfig.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@ class CConfig {
700700
unsigned long StartConv_Iter; /*!< \brief Start convergence criteria at iteration. */
701701
su2double Cauchy_Eps; /*!< \brief Epsilon used for the convergence. */
702702
bool Restart, /*!< \brief Restart solution (for direct, adjoint, and linearized problems).*/
703+
Wrt_Restart_Compact, /*!< \brief Write compact restart files with minimum nr. of variables. */
703704
Read_Binary_Restart, /*!< \brief Read binary SU2 native restart files.*/
704705
Wrt_Restart_Overwrite, /*!< \brief Overwrite restart files or append iteration number.*/
705706
Wrt_Surface_Overwrite, /*!< \brief Overwrite surface output files or append iteration number.*/
@@ -5503,6 +5504,12 @@ class CConfig {
55035504
*/
55045505
bool GetRead_Binary_Restart(void) const { return Read_Binary_Restart; }
55055506

5507+
/*!
5508+
* \brief Flag for whether restart files contain only necessary variables.
5509+
* \return Flag <code>TRUE</code> then the code will write compact restart files.
5510+
*/
5511+
bool GetWrt_Restart_Compact(void) const { return Wrt_Restart_Compact; }
5512+
55065513
/*!
55075514
* \brief Flag for whether restart solution files are overwritten.
55085515
* \return Flag for overwriting. If Flag=false, iteration nr is appended to filename

Common/include/linear_algebra/CSysMatrix.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,10 +805,10 @@ class CSysMatrix {
805805
void EnforceSolutionAtNode(unsigned long node_i, const OtherType* x_i, CSysVector<OtherType>& b);
806806

807807
/*!
808-
* \brief Version of EnforceSolutionAtNode for a single degree of freedom.
808+
* \brief Similar to EnforceSolutionAtNode, but for 0 projection in a given direction.
809809
*/
810810
template <class OtherType>
811-
void EnforceSolutionAtDOF(unsigned long node_i, unsigned long iVar, OtherType x_i, CSysVector<OtherType>& b);
811+
void EnforceZeroProjection(unsigned long node_i, const OtherType* n, CSysVector<OtherType>& b);
812812

813813
/*!
814814
* \brief Sets the diagonal entries of the matrix as the sum of the blocks in the corresponding column.

Common/src/CConfig.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,8 @@ void CConfig::SetConfig_Options() {
11721172

11731173
/*!\brief RESTART_SOL \n DESCRIPTION: Restart solution from native solution file \n Options: NO, YES \ingroup Config */
11741174
addBoolOption("RESTART_SOL", Restart, false);
1175+
/*!\brief WRT_RESTART_COMPACT \n DESCRIPTION: Minimize the size of restart files \n Options: NO, YES \ingroup Config */
1176+
addBoolOption("WRT_RESTART_COMPACT", Wrt_Restart_Compact, true);
11751177
/*!\brief BINARY_RESTART \n DESCRIPTION: Read binary SU2 native restart files. \n Options: YES, NO \ingroup Config */
11761178
addBoolOption("READ_BINARY_RESTART", Read_Binary_Restart, true);
11771179
/*!\brief WRT_RESTART_OVERWRITE \n DESCRIPTION: overwrite restart files or append iteration number. \n Options: YES, NO \ingroup Config */

Common/src/linear_algebra/CSysMatrix.cpp

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,36 +1027,59 @@ void CSysMatrix<ScalarType>::EnforceSolutionAtNode(const unsigned long node_i, c
10271027

10281028
template <class ScalarType>
10291029
template <class OtherType>
1030-
void CSysMatrix<ScalarType>::EnforceSolutionAtDOF(unsigned long node_i, unsigned long iVar, OtherType x_i,
1031-
CSysVector<OtherType>& b) {
1030+
void CSysMatrix<ScalarType>::EnforceZeroProjection(unsigned long node_i, const OtherType* n, CSysVector<OtherType>& b) {
10321031
for (auto index = row_ptr[node_i]; index < row_ptr[node_i + 1]; ++index) {
10331032
const auto node_j = col_ind[index];
10341033

1035-
/*--- Delete row iVar of block j on row i (bij) and ATTEMPT
1036-
* to delete column iVar block i on row j (bji). ---*/
1034+
/*--- Remove product components of block j on row i (bij) and ATTEMPT
1035+
* to remove solution components of block i on row j (bji).
1036+
* This is identical to symmetry correction applied to gradients
1037+
* but extended to the entire matrix. ---*/
10371038

10381039
auto bij = &matrix[index * nVar * nVar];
10391040
auto bji = GetBlock(node_j, node_i);
10401041

1041-
/*--- The "attempt" part. ---*/
1042+
/*--- Attempt to remove solution components. ---*/
1043+
ScalarType nbn{};
10421044
if (bji != nullptr) {
1043-
for (auto jVar = 0ul; jVar < nVar; ++jVar) {
1044-
/*--- Column product. ---*/
1045-
b[node_j * nVar + jVar] -= bji[jVar * nVar + iVar] * x_i;
1046-
/*--- Delete entries. ---*/
1047-
bji[jVar * nVar + iVar] = 0.0;
1045+
for (auto iVar = 0ul; iVar < nVar; ++iVar) {
1046+
ScalarType proj{};
1047+
for (auto jVar = 0ul; jVar < nVar; ++jVar) {
1048+
proj += bji[iVar * nVar + jVar] * PassiveAssign(n[jVar]);
1049+
}
1050+
for (auto jVar = 0ul; jVar < nVar; ++jVar) {
1051+
bji[iVar * nVar + jVar] -= proj * PassiveAssign(n[jVar]);
1052+
}
1053+
nbn += proj * PassiveAssign(n[iVar]);
10481054
}
10491055
}
10501056

1051-
/*--- Delete row. ---*/
1052-
for (auto jVar = 0ul; jVar < nVar; ++jVar) bij[iVar * nVar + jVar] = 0.0;
1057+
/*--- Product components. ---*/
1058+
for (auto jVar = 0ul; jVar < nVar; ++jVar) {
1059+
ScalarType proj{};
1060+
for (auto iVar = 0ul; iVar < nVar; ++iVar) {
1061+
proj += bij[iVar * nVar + jVar] * PassiveAssign(n[iVar]);
1062+
}
1063+
for (auto iVar = 0ul; iVar < nVar; ++iVar) {
1064+
bij[iVar * nVar + jVar] -= proj * PassiveAssign(n[iVar]);
1065+
}
1066+
}
10531067

1054-
/*--- Set the diagonal entry of the block to 1. ---*/
1055-
if (node_j == node_i) bij[iVar * (nVar + 1)] = 1.0;
1068+
/*--- This part doesn't have the "*2" factor because the product components
1069+
* were removed from the result of removing the solution components
1070+
* instead of from the original block (bji == bij). ---*/
1071+
if (node_i == node_j) {
1072+
for (auto iVar = 0ul; iVar < nVar; ++iVar) {
1073+
for (auto jVar = 0ul; jVar < nVar; ++jVar) {
1074+
bij[iVar * nVar + jVar] += PassiveAssign(n[iVar]) * nbn * PassiveAssign(n[jVar]);
1075+
}
1076+
}
1077+
}
10561078
}
10571079

1058-
/*--- Set known solution in rhs vector. ---*/
1059-
b(node_i, iVar) = x_i;
1080+
OtherType proj{};
1081+
for (auto iVar = 0ul; iVar < nVar; ++iVar) proj += b(node_i, iVar) * n[iVar];
1082+
for (auto iVar = 0ul; iVar < nVar; ++iVar) b(node_i, iVar) -= proj * n[iVar];
10601083
}
10611084

10621085
template <class ScalarType>
@@ -1203,8 +1226,7 @@ void CSysMatrix<ScalarType>::ComputePastixPreconditioner(const CSysVector<Scalar
12031226
#define INSTANTIATE_MATRIX(TYPE) \
12041227
template class CSysMatrix<TYPE>; \
12051228
template void CSysMatrix<TYPE>::EnforceSolutionAtNode(unsigned long, const su2double*, CSysVector<su2double>&); \
1206-
template void CSysMatrix<TYPE>::EnforceSolutionAtDOF(unsigned long, unsigned long, su2double, \
1207-
CSysVector<su2double>&); \
1229+
template void CSysMatrix<TYPE>::EnforceZeroProjection(unsigned long, const su2double*, CSysVector<su2double>&); \
12081230
INSTANTIATE_COMMS(TYPE)
12091231

12101232
#ifdef CODI_FORWARD_TYPE

SU2_CFD/include/output/COutput.hpp

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,16 @@ class COutput {
241241

242242
/*----------------------------- Volume output ----------------------------*/
243243

244-
CParallelDataSorter* volumeDataSorter; //!< Volume data sorter
245-
CParallelDataSorter* surfaceDataSorter; //!< Surface data sorter
244+
CParallelDataSorter* volumeDataSorter; //!< Volume data sorter.
245+
CParallelDataSorter* volumeDataSorterCompact; //!< Volume data sorter for compact files.
246+
CParallelDataSorter* surfaceDataSorter; //!< Surface data sorter.
246247

247-
vector<string> volumeFieldNames; //!< Vector containing the volume field names
248-
unsigned short nVolumeFields; //!< Number of fields in the volume output
248+
vector<string> volumeFieldNames; //!< Vector containing the volume field names.
249+
vector<string> requiredVolumeFieldNames; //!< Vector containing the minimum required volume field names.
249250

250-
string volumeFilename, //!< Volume output filename
251-
surfaceFilename, //!< Surface output filename
252-
restartFilename; //!< Restart output filename
251+
string volumeFilename, //!< Volume output filename.
252+
surfaceFilename, //!< Surface output filename.
253+
restartFilename; //!< Restart output filename.
253254

254255
/** \brief Structure to store information for a volume output field.
255256
*
@@ -259,40 +260,48 @@ class COutput {
259260
/*! \brief The name of the field, i.e. the name that is printed in the file header.*/
260261
string fieldName;
261262
/*! \brief This value identifies the position of the values of this field at each node in the ::Local_Data array. */
262-
short offset;
263+
short offset = -1;
264+
/*! \brief This offset is used for the compact formulation. */
265+
short offsetCompact = -1;
263266
/*! \brief The group this field belongs to. */
264267
string outputGroup;
265-
/*! \brief String containing the description of the field */
268+
/*! \brief String containing the description of the field. */
266269
string description;
267270
/*! \brief Default constructor. */
268-
VolumeOutputField () {}
271+
VolumeOutputField() = default;
269272
/*! \brief Constructor to initialize all members. */
270-
VolumeOutputField(string fieldName_, int offset_, string volumeOutputGroup_, string description_):
271-
fieldName(std::move(fieldName_)), offset(std::move(offset_)),
272-
outputGroup(std::move(volumeOutputGroup_)), description(std::move(description_)){}
273+
VolumeOutputField(string fieldName_, string volumeOutputGroup_, string description_):
274+
fieldName(std::move(fieldName_)),
275+
outputGroup(std::move(volumeOutputGroup_)),
276+
description(std::move(description_)) {}
273277
};
274278

275279
/*! \brief Associative map to access data stored in the volume output fields by a string identifier. */
276-
std::map<string, VolumeOutputField > volumeOutput_Map;
280+
std::map<string, VolumeOutputField > volumeOutput_Map;
277281
/*! \brief Vector that contains the keys of the ::volumeOutput_Map in the order of their insertion. */
278-
std::vector<string> volumeOutput_List;
279-
280-
/*! \brief Vector to cache the positions of the field in the data array */
281-
std::vector<short> fieldIndexCache;
282-
/*! \brief Current value of the cache index */
283-
unsigned short cachePosition;
284-
/*! \brief Boolean to store whether the field index cache should be build. */
285-
bool buildFieldIndexCache;
286-
/*! \brief Vector to cache the positions of the field in the data array */
287-
std::vector<short> fieldGetIndexCache;
288-
/*! \brief Current value of the cache index */
289-
unsigned short curGetFieldIndex;
282+
std::vector<string> volumeOutput_List;
283+
284+
/*! \brief Whether the field index caches should be build. */
285+
bool buildFieldIndexCache;
286+
287+
/*! \brief Vectors to cache the positions of the fields in the data array. */
288+
std::vector<short> fieldIndexCache, fieldIndexCacheCompact;
289+
/*! \brief Current value of the cache indices. */
290+
unsigned short cachePosition;
291+
292+
/*! \brief Vector to cache the positions of the field in the data array. */
293+
std::vector<short> fieldGetIndexCache;
294+
/*! \brief Current value of the cache index. */
295+
unsigned short curGetFieldIndex;
290296

291297
/*! \brief Requested volume field names in the config file. */
292298
std::vector<string> requestedVolumeFields;
293299
/*! \brief Number of requested volume field names in the config file. */
294300
unsigned short nRequestedVolumeFields;
295301

302+
/*! \brief Minimum required volume fields for restart file. */
303+
const std::vector<string> restartVolumeFields = {"COORDINATES", "SOLUTION", "SENSITIVITY", "GRID_VELOCITY"};
304+
296305
/*----------------------------- Convergence monitoring ----------------------------*/
297306

298307
su2double cauchyValue, /*!< \brief Summed value of the convergence indicator. */
@@ -736,8 +745,9 @@ class COutput {
736745
* \param[in] groupname - The name of the group this field belongs to.
737746
* \param[in] description - Description of the volume field.
738747
*/
739-
inline void AddVolumeOutput(string name, string field_name, string groupname, string description){
740-
volumeOutput_Map[name] = VolumeOutputField(field_name, -1, groupname, description);
748+
inline void AddVolumeOutput(const string& name, const string& field_name,
749+
const string& group_name, const string& description) {
750+
volumeOutput_Map[name] = VolumeOutputField(field_name, group_name, description);
741751
volumeOutput_List.push_back(name);
742752
}
743753

@@ -959,14 +969,14 @@ class COutput {
959969

960970
/*!
961971
* \brief Sets the turboperformance screen output
962-
* \param[in] TurboPerf - Turboperformance class
972+
* \param[in] TurboPerf - Turboperformance class
963973
* \param[in] config - Definition of the particular problem
964974
* \param[in] TimeIter - Index of the current time-step
965975
* \param[in] OuterIter - Index of current outer iteration
966976
* \param[in] InnerIter - Index of current inner iteration
967977
*/
968978
inline virtual void SetTurboPerformance_Output(std::shared_ptr<CTurboOutput> TurboPerf, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) {}
969-
979+
970980
/*!
971981
* \brief Sets the multizone turboperformacne screen output
972982
* \param[in] TurboStagePerf - Stage turboperformance class
@@ -982,7 +992,7 @@ class COutput {
982992
* \param[in] config - Definition of the particular problem
983993
*/
984994
inline virtual void LoadTurboHistoryData(std::shared_ptr<CTurbomachineryStagePerformance> TurboStagePerf, std::shared_ptr<CTurboOutput> TurboPerf, CConfig *config) {}
985-
995+
986996
/*!
987997
* \brief Write the kinematic and thermodynamic variables at each spanwise division
988998
* \param[in] solver - The container hold all solution data

SU2_CFD/include/output/filewriter/CParallelDataSorter.hpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ class CParallelDataSorter{
108108
int nSends, //!< Number of sends
109109
nRecvs; //!< Number of receives
110110

111-
vector<string> fieldNames; //!< Vector with names of the output fields
111+
vector<string> fieldNames; //!< Vector with names of all the output fields
112+
vector<string> requiredFieldNames; //!< Vector with names of the required output fields that we write to file
112113

113114
unsigned short nDim; //!< Spatial dimension of the data
114115

@@ -340,6 +341,22 @@ class CParallelDataSorter{
340341
return fieldNames;
341342
}
342343

344+
/*!
345+
* \brief Get the vector containing the names of the required output fields
346+
* \return Vector of strings containing the required field names
347+
*/
348+
const vector<string>& GetRequiredFieldNames() const{
349+
return requiredFieldNames;
350+
}
351+
352+
/*!
353+
* \brief Set the vector of required output fields.
354+
* \return None.
355+
*/
356+
void SetRequiredFieldNames(const vector<string>& req_field_names) {
357+
requiredFieldNames = req_field_names;
358+
}
359+
343360
/*!
344361
* \brief Get the spatial dimension
345362
* \return The spatial dimension

SU2_CFD/src/output/CAdjFlowCompOutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ CAdjFlowCompOutput::CAdjFlowCompOutput(CConfig *config, unsigned short nDim) : C
6161

6262
if (find(requestedVolumeFields.begin(), requestedVolumeFields.end(), string("SENSITIVITY")) == requestedVolumeFields.end()) {
6363
requestedVolumeFields.emplace_back("SENSITIVITY");
64-
nRequestedVolumeFields ++;
64+
nRequestedVolumeFields++;
6565
}
6666

6767
stringstream ss;

SU2_CFD/src/output/CAdjFlowIncOutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ CAdjFlowIncOutput::CAdjFlowIncOutput(CConfig *config, unsigned short nDim) : CAd
6767

6868
if (find(requestedVolumeFields.begin(), requestedVolumeFields.end(), string("SENSITIVITY")) == requestedVolumeFields.end()) {
6969
requestedVolumeFields.emplace_back("SENSITIVITY");
70-
nRequestedVolumeFields ++;
70+
nRequestedVolumeFields++;
7171
}
7272

7373
stringstream ss;

SU2_CFD/src/output/CAdjHeatOutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ CAdjHeatOutput::CAdjHeatOutput(CConfig *config, unsigned short nDim) : COutput(c
5858

5959
if (find(requestedVolumeFields.begin(), requestedVolumeFields.end(), string("SENSITIVITY")) == requestedVolumeFields.end()) {
6060
requestedVolumeFields.emplace_back("SENSITIVITY");
61-
nRequestedVolumeFields ++;
61+
nRequestedVolumeFields++;
6262
}
6363

6464
stringstream ss;

SU2_CFD/src/output/CElasticityOutput.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,21 +235,20 @@ void CElasticityOutput::SetVolumeOutputFields(CConfig *config){
235235
// Grid coordinates
236236
AddVolumeOutput("COORD-X", "x", "COORDINATES", "x-component of the coordinate vector");
237237
AddVolumeOutput("COORD-Y", "y", "COORDINATES", "y-component of the coordinate vector");
238-
if (nDim == 3)
239-
AddVolumeOutput("COORD-Z", "z", "COORDINATES", "z-component of the coordinate vector");
238+
if (nDim == 3) AddVolumeOutput("COORD-Z", "z", "COORDINATES", "z-component of the coordinate vector");
240239

241240
AddVolumeOutput("DISPLACEMENT-X", "Displacement_x", "SOLUTION", "x-component of the displacement vector");
242241
AddVolumeOutput("DISPLACEMENT-Y", "Displacement_y", "SOLUTION", "y-component of the displacement vector");
243242
if (nDim == 3) AddVolumeOutput("DISPLACEMENT-Z", "Displacement_z", "SOLUTION", "z-component of the displacement vector");
244243

245-
if(dynamic){
246-
AddVolumeOutput("VELOCITY-X", "Velocity_x", "VELOCITY", "x-component of the velocity vector");
247-
AddVolumeOutput("VELOCITY-Y", "Velocity_y", "VELOCITY", "y-component of the velocity vector");
248-
if (nDim == 3) AddVolumeOutput("VELOCITY-Z", "Velocity_z", "VELOCITY", "z-component of the velocity vector");
244+
if (dynamic) {
245+
AddVolumeOutput("VELOCITY-X", "Velocity_x", "SOLUTION", "x-component of the velocity vector");
246+
AddVolumeOutput("VELOCITY-Y", "Velocity_y", "SOLUTION", "y-component of the velocity vector");
247+
if (nDim == 3) AddVolumeOutput("VELOCITY-Z", "Velocity_z", "SOLUTION", "z-component of the velocity vector");
249248

250-
AddVolumeOutput("ACCELERATION-X", "Acceleration_x", "ACCELERATION", "x-component of the acceleration vector");
251-
AddVolumeOutput("ACCELERATION-Y", "Acceleration_y", "ACCELERATION", "y-component of the acceleration vector");
252-
if (nDim == 3) AddVolumeOutput("ACCELERATION-Z", "Acceleration_z", "ACCELERATION", "z-component of the acceleration vector");
249+
AddVolumeOutput("ACCELERATION-X", "Acceleration_x", "SOLUTION", "x-component of the acceleration vector");
250+
AddVolumeOutput("ACCELERATION-Y", "Acceleration_y", "SOLUTION", "y-component of the acceleration vector");
251+
if (nDim == 3) AddVolumeOutput("ACCELERATION-Z", "Acceleration_z", "SOLUTION", "z-component of the acceleration vector");
253252
}
254253

255254
AddVolumeOutput("STRESS-XX", "Sxx", "STRESS", "x-component of the normal stress vector");

0 commit comments

Comments
 (0)