Skip to content

Commit ab8330f

Browse files
authored
Merge pull request #1527 from su2code/massflow_flowmeta
Streamwise Periodic restarts using flow.meta + Multizone PerSurface output
2 parents 2b79590 + fd9a4d5 commit ab8330f

19 files changed

Lines changed: 182 additions & 43 deletions

File tree

Common/include/CConfig.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5989,6 +5989,11 @@ class CConfig {
59895989
*/
59905990
su2double GetStreamwise_Periodic_PressureDrop(void) const { return Streamwise_Periodic_PressureDrop; }
59915991

5992+
/*!
5993+
* \brief Set the value of the pressure delta from which body force vector is computed. Necessary for Restart metadata.
5994+
*/
5995+
void SetStreamwise_Periodic_PressureDrop(su2double Streamwise_Periodic_PressureDrop_) { Streamwise_Periodic_PressureDrop = Streamwise_Periodic_PressureDrop_; }
5996+
59925997
/*!
59935998
* \brief Get the value of the massflow from which body force vector is computed.
59945999
* \return Massflow for body force computation.

Common/src/CConfig.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4788,8 +4788,8 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
47884788
pressure drop objective function is selected. ---*/
47894789

47904790
for (unsigned short iObj = 0; iObj < nObj; iObj++) {
4791-
if ((Kind_ObjFunc[iObj] == SURFACE_PRESSURE_DROP) && (nMarker_Analyze != 2)) {
4792-
SU2_MPI::Error("Must list two markers for the pressure drop objective function.\n Expected format: MARKER_ANALYZE= (outlet_name, inlet_name).", CURRENT_FUNCTION);
4791+
if ((Kind_ObjFunc[iObj] == SURFACE_PRESSURE_DROP) && (nMarker_Analyze < 2)) {
4792+
SU2_MPI::Error("Must list the first two markers for the pressure drop objective function.\n Expected format: MARKER_ANALYZE= (outlet_name, inlet_name, ...).", CURRENT_FUNCTION);
47934793
}
47944794
}
47954795

@@ -5733,8 +5733,16 @@ void CConfig::SetMarkers(SU2_COMPONENT val_software) {
57335733
break;
57345734
}
57355735
}
5736+
57365737
if(!found) {
5737-
SU2_MPI::Error("DV_MARKER contains marker names that do not exist in the lists of BCs in the config file.", CURRENT_FUNCTION);
5738+
if (nZone==1)
5739+
SU2_MPI::Error("DV_MARKER contains marker names that do not exist in the lists of BCs in the config file.", CURRENT_FUNCTION);
5740+
// In case of multiple zones, the markers might appear only in zonal config and not in the Master.
5741+
// A loop over all zones would need to be included which is not straight forward as this can only be
5742+
// checked once all zonal configs are read.
5743+
else if (rank == MASTER_NODE)
5744+
cout << "Warning: DV_MARKER contains marker names that do not exist in the lists of BCs of the master config file.\n"
5745+
"Make sure the marker names exist in the zonal config files" << endl;
57385746
}
57395747
}
57405748

SU2_CFD/include/output/CMultizoneOutput.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,15 @@ class CMultizoneOutput final: public COutput {
6666
/*!
6767
* \brief Load the multizone history output field values
6868
* \param[in] output - Container holding the output instances per zone.
69+
* \param[in] config - Definition of the particular problem.
6970
*/
70-
void LoadMultizoneHistoryData(const COutput* const* output) override;
71+
void LoadMultizoneHistoryData(const COutput* const* output, const CConfig* const* config) override;
7172

7273
/*!
7374
* \brief Set the available multizone history output fields
7475
* \param[in] output - Container holding the output instances per zone.
7576
*/
76-
void SetMultizoneHistoryOutputFields(const COutput* const* output) override;
77+
void SetMultizoneHistoryOutputFields(const COutput* const* output, const CConfig* const* config) override;
7778

7879
/*!
7980
* \brief Determines if the history file output.

SU2_CFD/include/output/COutput.hpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,14 @@ class COutput {
432432
return historyOutput_List;
433433
}
434434

435+
/*!
436+
* \brief Get the list of all per-surface fields
437+
* \return Vector container all output per-surface fields
438+
*/
439+
const vector<string>& GetHistoryOutputPerSurface_List() const {
440+
return historyOutputPerSurface_List;
441+
}
442+
435443
/*!
436444
* \brief Get the map containing all output fields
437445
* \return Map containing all output fields
@@ -440,6 +448,14 @@ class COutput {
440448
return historyOutput_Map;
441449
}
442450

451+
/*!
452+
* \brief Get the map containing all output per-surface fields
453+
* \return Map containing all output per-surface fields
454+
*/
455+
const map<string, vector<HistoryOutputField>>& GetHistoryPerSurfaceFields() const {
456+
return historyOutputPerSurface_Map;
457+
}
458+
443459
/*!
444460
* \brief Monitor the convergence of an output field
445461
* \param[in] config - Definition of the particular problem.
@@ -824,8 +840,9 @@ class COutput {
824840
/*!
825841
* \brief Load the multizone history output field values
826842
* \param[in] output - Container holding the output instances per zone.
843+
* \param[in] config - Definition of the particular problem.
827844
*/
828-
inline virtual void LoadMultizoneHistoryData(const COutput* const* output) {}
845+
inline virtual void LoadMultizoneHistoryData(const COutput* const* output, const CConfig* const* config) {}
829846

830847
/*!
831848
* \brief Set the available history output fields
@@ -837,7 +854,7 @@ class COutput {
837854
* \brief Set the available multizone history output fields
838855
* \param[in] output - Container holding the output instances per zone.
839856
*/
840-
inline virtual void SetMultizoneHistoryOutputFields(const COutput* const* output) {}
857+
inline virtual void SetMultizoneHistoryOutputFields(const COutput* const* output, const CConfig* const* config) {}
841858

842859
/*!
843860
* \brief Write any additional files defined for the current solver.

SU2_CFD/include/solvers/CHeatSolver.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,15 +313,17 @@ class CHeatSolver final : public CSolver {
313313
* \param[in] solver - Container vector with all the solutions.
314314
*/
315315
void Evaluate_ObjFunc(const CConfig *config, CSolver**) override {
316+
const auto weight = config->GetWeight_ObjFunc(0);
317+
316318
switch (config->GetKind_ObjFunc()) {
317319
case TOTAL_HEATFLUX:
318-
Total_ComboObj = Total_HeatFlux;
320+
Total_ComboObj = weight * Total_HeatFlux;
319321
break;
320322
case AVG_TEMPERATURE:
321-
Total_ComboObj = Total_AverageT;
323+
Total_ComboObj = weight * Total_AverageT;
322324
break;
323325
case CUSTOM_OBJFUNC:
324-
Total_ComboObj = Total_Custom_ObjFunc;
326+
Total_ComboObj = weight * Total_Custom_ObjFunc;
325327
break;
326328
default:
327329
Total_ComboObj = 0.0;

SU2_CFD/src/output/CFlowOutput.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ void CFlowOutput::AddAnalyzeSurfaceOutput(const CConfig *config){
6767
/// DESCRIPTION: Average total pressure
6868
AddHistoryOutput("SURFACE_TOTAL_PRESSURE", "Avg_TotalPress", ScreenOutputFormat::SCIENTIFIC, "FLOW_COEFF", "Total average total pressure on all markers set in MARKER_ANALYZE", HistoryFieldType::COEFFICIENT);
6969
/// DESCRIPTION: Pressure drop
70-
if (config->GetnMarker_Analyze() == 2) {
70+
if (config->GetnMarker_Analyze() >= 2) {
7171
AddHistoryOutput("SURFACE_PRESSURE_DROP", "Pressure_Drop", ScreenOutputFormat::SCIENTIFIC, "FLOW_COEFF", "Total pressure drop on all markers set in MARKER_ANALYZE", HistoryFieldType::COEFFICIENT);
7272
} else if (rank == MASTER_NODE) {
73-
cout << "\nWARNING: SURFACE_PRESSURE_DROP can only be computed for 2 surfaces (outlet, inlet)\n" << endl;
73+
cout << "\nWARNING: SURFACE_PRESSURE_DROP can only be computed for at least 2 surfaces (outlet, inlet, ...)\n" << endl;
7474
}
7575
if (config->GetKind_Species_Model() != SPECIES_MODEL::NONE) {
7676
/// DESCRIPTION: Average Species
@@ -530,7 +530,7 @@ void CFlowOutput::SetAnalyzeSurface(const CSolver* const*solver, const CGeometry
530530
which require the outlet to be listed first. This is a simple first version
531531
that could be generalized to a different orders/lists/etc. ---*/
532532

533-
if (nMarker_Analyze == 2) {
533+
if (nMarker_Analyze >= 2) {
534534
su2double PressureDrop = (Surface_Pressure_Total[1] - Surface_Pressure_Total[0]) * config->GetPressure_Ref();
535535
for (iMarker_Analyze = 0; iMarker_Analyze < nMarker_Analyze; iMarker_Analyze++) {
536536
config->SetSurface_PressureDrop(iMarker_Analyze, PressureDrop);
@@ -1736,7 +1736,8 @@ void CFlowOutput::Set_NearfieldInverseDesign(CSolver *solver, const CGeometry *g
17361736

17371737
void CFlowOutput::WriteAdditionalFiles(CConfig *config, CGeometry *geometry, CSolver **solver_container){
17381738

1739-
if (config->GetFixed_CL_Mode()){
1739+
if (config->GetFixed_CL_Mode() ||
1740+
(config->GetKind_Streamwise_Periodic() == ENUM_STREAMWISE_PERIODIC::MASSFLOW)){
17401741
WriteMetaData(config);
17411742
}
17421743

@@ -1757,6 +1758,8 @@ void CFlowOutput::WriteMetaData(const CConfig *config){
17571758
/*--- All processors open the file. ---*/
17581759

17591760
if (rank == MASTER_NODE) {
1761+
cout << "Writing Flow Meta-Data file: " << filename << endl;
1762+
17601763
meta_file.open(filename.c_str(), ios::out);
17611764
meta_file.precision(15);
17621765

@@ -1783,6 +1786,10 @@ void CFlowOutput::WriteMetaData(const CConfig *config){
17831786
config->GetKind_Solver() == MAIN_SOLVER::DISC_ADJ_RANS )) {
17841787
meta_file << "SENS_AOA=" << GetHistoryFieldValue("SENS_AOA") * PI_NUMBER / 180.0 << endl;
17851788
}
1789+
1790+
if(config->GetKind_Streamwise_Periodic() == ENUM_STREAMWISE_PERIODIC::MASSFLOW) {
1791+
meta_file << "STREAMWISE_PERIODIC_PRESSURE_DROP=" << GetHistoryFieldValue("STREAMWISE_DP") << endl;
1792+
}
17861793
}
17871794

17881795
meta_file.close();

SU2_CFD/src/output/CMultizoneOutput.cpp

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ CMultizoneOutput::CMultizoneOutput(const CConfig* driver_config, const CConfig*
7878

7979
}
8080

81-
void CMultizoneOutput::LoadMultizoneHistoryData(const COutput* const* output) {
81+
void CMultizoneOutput::LoadMultizoneHistoryData(const COutput* const* output, const CConfig* const* config) {
8282

8383
string nameMultizone, zoneIndex;
8484
su2double comboValue = 0;
@@ -97,11 +97,31 @@ void CMultizoneOutput::LoadMultizoneHistoryData(const COutput* const* output) {
9797
comboValue += item.second.value;
9898
}
9999
}
100+
101+
/*-- Load the PerSurface values.- ---*/
102+
for (const auto& item : output[iZone]->GetHistoryPerSurfaceFields()) {
103+
const auto& name = item.first;
104+
nameMultizone = name + zoneIndex;
105+
106+
/*--- Determine whether nMaker_Analyze/Monitoring has to be looped. ---*/
107+
const auto& group = item.second[0].outputGroup;
108+
unsigned short nMarker = 0;
109+
if (group == "FLOW_COEFF_SURF")
110+
nMarker = config[iZone]->GetnMarker_Analyze();
111+
else if (group == "AERO_COEFF_SURF")
112+
nMarker = config[iZone]->GetnMarker_Monitoring();
113+
else
114+
SU2_MPI::Error("Per Surface output group unknown: " + group, CURRENT_FUNCTION);
115+
116+
for (unsigned short iMarker = 0; iMarker < nMarker; iMarker++) {
117+
SetHistoryOutputPerSurfaceValue(nameMultizone, item.second[iMarker].value, iMarker);
118+
}// for iMarker
119+
}// for HistPerSurfFields
100120
}
101121
SetHistoryOutputValue("COMBO", comboValue);
102122
}
103123

104-
void CMultizoneOutput::SetMultizoneHistoryOutputFields(const COutput* const* output) {
124+
void CMultizoneOutput::SetMultizoneHistoryOutputFields(const COutput* const* output, const CConfig* const* config) {
105125

106126
string name, header, group, zoneIndex;
107127

@@ -125,6 +145,56 @@ void CMultizoneOutput::SetMultizoneHistoryOutputFields(const COutput* const* out
125145
AddHistoryOutput(name, header, field.screenFormat, group, "", field.fieldType );
126146
}
127147
}
148+
149+
/*--- Prepare Marker lists that are passed to 'AddHistoryOutputPerSurface'. ---*/
150+
vector<string> Marker_Analyze;
151+
for (unsigned short iMarker_Analyze = 0; iMarker_Analyze < config[iZone]->GetnMarker_Analyze(); iMarker_Analyze++) {
152+
Marker_Analyze.push_back(config[iZone]->GetMarker_Analyze_TagBound(iMarker_Analyze));
153+
}
154+
155+
vector<string> Marker_Monitoring;
156+
for (unsigned short iMarker_Monitoring = 0; iMarker_Monitoring < config[iZone]->GetnMarker_Monitoring(); iMarker_Monitoring++) {
157+
Marker_Monitoring.push_back(config[iZone]->GetMarker_Monitoring_TagBound(iMarker_Monitoring));
158+
}
159+
160+
/*--- Add the PerSurface outputs. ---*/
161+
const auto& ZoneHistoryPerSurfaceFields = output[iZone]->GetHistoryPerSurfaceFields();
162+
163+
for (const auto& nameSinglezone : output[iZone]->GetHistoryOutputPerSurface_List()) {
164+
165+
const auto& field = ZoneHistoryPerSurfaceFields.at(nameSinglezone);
166+
167+
name = nameSinglezone + zoneIndex;
168+
169+
/*--- Remove the unnecessary Marker name from the fieldName, i.e. "Avg_Massflow(inlet)"->"Avg_Massflow". ---*/
170+
/*--- Note that index zero in 'field[0]' refers to a specific Marker. Some attributes remain constant over the markers
171+
like the first part of the name, the screenFormat and the fieldType. ---*/
172+
string baseheader;
173+
const auto pos = field[0].fieldName.find('(');
174+
if (pos != std::string::npos)
175+
baseheader = field[0].fieldName.substr(0, pos);
176+
else
177+
SU2_MPI::Error("Cannot process PerSurface *_SURF history output: " + baseheader, CURRENT_FUNCTION);
178+
179+
header = baseheader + zoneIndex;
180+
/*--- Attach zone-index to the group after determining which group it is. ---*/
181+
group = field[0].outputGroup;
182+
183+
/*--- Determine whether Maker_Analyze/Monitoring has to be used. ---*/
184+
vector<string>* Marker;
185+
if (group == "FLOW_COEFF_SURF")
186+
Marker = &Marker_Analyze;
187+
else if (group == "AERO_COEFF_SURF")
188+
Marker = &Marker_Monitoring;
189+
else {
190+
Marker = &Marker_Analyze; // dummy to suppress maybe-uninitialized warning
191+
SU2_MPI::Error("Per Surface output group unknown: " + group, CURRENT_FUNCTION);
192+
}
193+
194+
group += zoneIndex;
195+
196+
AddHistoryOutputPerSurface(name, header, field[0].screenFormat, group, *Marker, field[0].fieldType );
197+
}
128198
}
129199
AddHistoryOutput("COMBO", "ComboObj", ScreenOutputFormat::SCIENTIFIC, "COMBO", "Combined obj. function value.", HistoryFieldType::COEFFICIENT);
130200
}

SU2_CFD/src/output/COutput.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void COutput::SetMultizoneHistory_Output(COutput **output, CConfig **config, CCo
236236

237237
LoadCommonHistoryData(driver_config);
238238

239-
LoadMultizoneHistoryData(output);
239+
LoadMultizoneHistoryData(output, config);
240240

241241
Convergence_Monitoring(driver_config, curOuterIter);
242242

@@ -1365,7 +1365,7 @@ void COutput::PreprocessMultizoneHistoryOutput(COutput **output, CConfig **confi
13651365

13661366
/*--- Set the History output fields using a virtual function call to the child implementation ---*/
13671367

1368-
SetMultizoneHistoryOutputFields(output);
1368+
SetMultizoneHistoryOutputFields(output, config);
13691369

13701370
/*--- Postprocess the history fields. Creates new fields based on the ones set in the child classes ---*/
13711371

SU2_CFD/src/solvers/CEulerSolver.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,10 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config,
9494
else Unst_RestartIter = SU2_TYPE::Int(config->GetRestart_Iter())-1;
9595
}
9696

97-
string filename_ = "flow";
98-
filename_ = config->GetFilename(filename_, ".meta", Unst_RestartIter);
99-
10097
/*--- Read and store the restart metadata. ---*/
10198

99+
string filename_ = "flow";
100+
filename_ = config->GetFilename(filename_, ".meta", Unst_RestartIter);
102101
Read_SU2_Restart_Metadata(geometry, config, adjoint, filename_);
103102

104103
}

SU2_CFD/src/solvers/CIncEulerSolver.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned
4747
ifstream restart_file;
4848
unsigned short nZone = geometry->GetnZone();
4949
bool restart = (config->GetRestart() || config->GetRestart_Flow());
50-
int Unst_RestartIter;
50+
int Unst_RestartIter = 0;
5151
unsigned short iZone = config->GetiZone();
5252
bool dual_time = ((config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) ||
5353
(config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND));
@@ -91,9 +91,16 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned
9191

9292
/*--- Read and store the restart metadata. ---*/
9393

94-
// Read_SU2_Restart_Metadata(geometry, config, false, filename_);
94+
filename_ = "flow";
95+
filename_ = config->GetFilename(filename_, ".meta", Unst_RestartIter);
96+
Read_SU2_Restart_Metadata(geometry, config, adjoint, filename_);
9597

9698
}
99+
if (restart && (config->GetKind_Streamwise_Periodic() == ENUM_STREAMWISE_PERIODIC::MASSFLOW)) {
100+
string filename_ = "flow";
101+
filename_ = config->GetFilename(filename_, ".meta", Unst_RestartIter);
102+
Read_SU2_Restart_Metadata(geometry, config, adjoint, filename_);
103+
}
97104

98105
/*--- Set the gamma value ---*/
99106

0 commit comments

Comments
 (0)