Skip to content

Commit 036f479

Browse files
committed
Introduce frozen_visc variable in Comp and inc output.
And fixing a potental error in the inc output wrt that. This way, consistent conditionals can be used between the Set- and Load- methods of the output.
1 parent 1bffaab commit 036f479

File tree

4 files changed

+35
-28
lines changed

4 files changed

+35
-28
lines changed

SU2_CFD/include/output/CAdjFlowCompOutput.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class CAdjFlowCompOutput final: public COutput {
3838
private:
3939

4040
bool cont_adj; /*!< \brief Boolean indicating whether we run a cont. adjoint problem */
41+
bool frozen_visc; /*!< \brief Boolean indicating whether frozen viscosity/turbulence is used. */
4142
unsigned short turb_model; /*!< \brief The kind of turbulence model*/
4243

4344
public:

SU2_CFD/include/output/CAdjFlowIncOutput.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class CAdjFlowIncOutput final: public COutput {
4141
RADIATION_MODEL rad_model; /*!< \brief The kind of radiation model */
4242
bool heat; /*!< \brief Boolean indicating whether have a heat problem*/
4343
bool weakly_coupled_heat; /*!< \brief Boolean indicating whether have a weakly coupled heat equation*/
44+
bool cont_adj; /*!< \brief Boolean indicating whether we run a cont. adjoint problem */
45+
bool frozen_visc; /*!< \brief Boolean indicating whether frozen viscosity/turbulence is used. */
4446

4547
public:
4648

SU2_CFD/src/output/CAdjFlowCompOutput.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ CAdjFlowCompOutput::CAdjFlowCompOutput(CConfig *config, unsigned short nDim) : C
3737

3838
cont_adj = config->GetContinuous_Adjoint();
3939

40+
frozen_visc = (config->GetFrozen_Visc_Disc() && !cont_adj) || (config->GetFrozen_Visc_Cont() && cont_adj);
41+
4042
/*--- Set the default history fields if nothing is set in the config file ---*/
4143

4244
if (nRequestedHistoryFields == 0){
@@ -110,7 +112,7 @@ void CAdjFlowCompOutput::SetHistoryOutputFields(CConfig *config){
110112
AddHistoryOutput("RMS_ADJ_MOMENTUM-Z", "rms[A_RhoW]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint momentum z-component.", HistoryFieldType::RESIDUAL);
111113
/// DESCRIPTION: Root-mean square residual of the adjoint energy.
112114
AddHistoryOutput("RMS_ADJ_ENERGY", "rms[A_E]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint energy.", HistoryFieldType::RESIDUAL);
113-
if ((!config->GetFrozen_Visc_Disc() && !cont_adj) || (!config->GetFrozen_Visc_Cont() && cont_adj)){
115+
if (!frozen_visc) {
114116
switch(turb_model){
115117
case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP:
116118
/// DESCRIPTION: Root-mean square residual of the adjoint nu tilde.
@@ -138,7 +140,7 @@ void CAdjFlowCompOutput::SetHistoryOutputFields(CConfig *config){
138140
AddHistoryOutput("MAX_ADJ_MOMENTUM-Z", "max[A_RhoW]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the adjoint momentum z-component", HistoryFieldType::RESIDUAL);
139141
/// DESCRIPTION: Maximum residual of the adjoint energy.
140142
AddHistoryOutput("MAX_ADJ_ENERGY", "max[A_E]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the adjoint energy.", HistoryFieldType::RESIDUAL);
141-
if (!config->GetFrozen_Visc_Disc()){
143+
if (!frozen_visc){
142144
switch(turb_model){
143145
case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP:
144146
/// DESCRIPTION: Maximum residual of the adjoint nu tilde.
@@ -167,7 +169,7 @@ void CAdjFlowCompOutput::SetHistoryOutputFields(CConfig *config){
167169
AddHistoryOutput("BGS_ADJ_MOMENTUM-Z", "bgs[A_RhoW]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the adjoint momentum z-component", HistoryFieldType::RESIDUAL);
168170
/// DESCRIPTION: BGS residual of the adjoint energy.
169171
AddHistoryOutput("BGS_ADJ_ENERGY", "bgs[A_E]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the adjoint energy.", HistoryFieldType::RESIDUAL);
170-
if (!config->GetFrozen_Visc_Disc()){
172+
if (!frozen_visc){
171173
switch(turb_model){
172174
case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP:
173175
/// DESCRIPTION: BGS residual of the adjoint nu tilde.
@@ -201,7 +203,7 @@ void CAdjFlowCompOutput::SetHistoryOutputFields(CConfig *config){
201203
AddHistoryOutput("LINSOL_ITER", "LinSolIter", ScreenOutputFormat::INTEGER, "LINSOL", "Number of iterations of the linear solver.");
202204
AddHistoryOutput("LINSOL_RESIDUAL", "LinSolRes", ScreenOutputFormat::FIXED, "LINSOL", "Residual of the linear solver.");
203205

204-
if (turb_model) {
206+
if (turb_model && !frozen_visc) {
205207
AddHistoryOutput("LINSOL_ITER_TURB", "LinSolIterTurb", ScreenOutputFormat::INTEGER, "LINSOL", "Number of iterations of the linear solver for turbulence.");
206208
AddHistoryOutput("LINSOL_RESIDUAL_TURB", "LinSolResTurb", ScreenOutputFormat::FIXED, "LINSOL", "Residual of the linear solver for turbulence.");
207209
}
@@ -228,7 +230,7 @@ void CAdjFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, C
228230
} else {
229231
SetHistoryOutputValue("RMS_ADJ_ENERGY", log10(adjflow_solver->GetRes_RMS(3)));
230232
}
231-
if ((!config->GetFrozen_Visc_Disc() && !cont_adj) || (!config->GetFrozen_Visc_Cont() && cont_adj)){
233+
if (!frozen_visc) {
232234
switch(turb_model){
233235
case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP:
234236
SetHistoryOutputValue("RMS_ADJ_NU_TILDE", log10(adjturb_solver->GetRes_RMS(0)));
@@ -249,7 +251,7 @@ void CAdjFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, C
249251
} else {
250252
SetHistoryOutputValue("MAX_ADJ_ENERGY", log10(adjflow_solver->GetRes_Max(3)));
251253
}
252-
if ((!config->GetFrozen_Visc_Disc() && !cont_adj) || (!config->GetFrozen_Visc_Cont() && cont_adj)){
254+
if (!frozen_visc) {
253255
switch(turb_model){
254256
case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP:
255257
SetHistoryOutputValue("MAX_ADJ_NU_TILDE", log10(adjturb_solver->GetRes_Max(0)));
@@ -272,7 +274,7 @@ void CAdjFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, C
272274
} else {
273275
SetHistoryOutputValue("BGS_ADJ_ENERGY", log10(adjflow_solver->GetRes_BGS(3)));
274276
}
275-
if ((!config->GetFrozen_Visc_Disc() && !cont_adj) || (!config->GetFrozen_Visc_Cont() && cont_adj)){
277+
if (!frozen_visc) {
276278
switch(turb_model){
277279
case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP:
278280
SetHistoryOutputValue("BGS_ADJ_NU_TILDE", log10(adjturb_solver->GetRes_BGS(0)));
@@ -295,7 +297,7 @@ void CAdjFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, C
295297
SetHistoryOutputValue("LINSOL_ITER", adjflow_solver->GetIterLinSolver());
296298
SetHistoryOutputValue("LINSOL_RESIDUAL", log10(adjflow_solver->GetResLinSolver()));
297299

298-
if (adjturb_solver) {
300+
if (turb_model && !frozen_visc) {
299301
SetHistoryOutputValue("LINSOL_ITER_TURB", adjturb_solver->GetIterLinSolver());
300302
SetHistoryOutputValue("LINSOL_RESIDUAL_TURB", log10(adjturb_solver->GetResLinSolver()));
301303
}
@@ -327,7 +329,7 @@ void CAdjFlowCompOutput::SetVolumeOutputFields(CConfig *config){
327329
AddVolumeOutput("ADJ_MOMENTUM-Z", "Adjoint_Momentum_z", "SOLUTION", "z-component of the adjoint momentum vector");
328330
/// DESCRIPTION: Adjoint energy.
329331
AddVolumeOutput("ADJ_ENERGY", "Adjoint_Energy", "SOLUTION", "Adjoint energy");
330-
if ((!config->GetFrozen_Visc_Disc() && !cont_adj) || (!config->GetFrozen_Visc_Cont() && cont_adj)){
332+
if (!frozen_visc) {
331333
switch(turb_model){
332334
case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP:
333335
/// DESCRIPTION: Adjoint nu tilde.
@@ -356,7 +358,7 @@ void CAdjFlowCompOutput::SetVolumeOutputFields(CConfig *config){
356358
AddVolumeOutput("RES_ADJ_MOMENTUM-Z", "Residual_Adjoint_Momentum_z", "RESIDUAL", "Residual of the adjoint z-momentum");
357359
/// DESCRIPTION: Residual of the adjoint energy.
358360
AddVolumeOutput("RES_ADJ_ENERGY", "Residual_Adjoint_Energy", "RESIDUAL", "Residual of the adjoint energy");
359-
if ((!config->GetFrozen_Visc_Disc() && !cont_adj) || (!config->GetFrozen_Visc_Cont() && cont_adj)){
361+
if (!frozen_visc) {
360362
switch(turb_model){
361363
case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP:
362364
/// DESCRIPTION: Residual of the nu tilde.
@@ -393,9 +395,7 @@ void CAdjFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CS
393395
CVariable* Node_AdjTurb = nullptr;
394396
CPoint* Node_Geo = geometry->nodes;
395397

396-
if (config->GetKind_Turb_Model() != NONE &&
397-
((!config->GetFrozen_Visc_Disc() && !cont_adj) ||
398-
(!config->GetFrozen_Visc_Cont() && cont_adj))){
398+
if (turb_model && !frozen_visc) {
399399
Node_AdjTurb = solver[ADJTURB_SOL]->GetNodes();
400400
}
401401

@@ -414,7 +414,7 @@ void CAdjFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CS
414414
SetVolumeOutputValue("ADJ_ENERGY", iPoint, Node_AdjFlow->GetSolution(iPoint, 3));
415415
}
416416

417-
if ((!config->GetFrozen_Visc_Disc() && !cont_adj) || (!config->GetFrozen_Visc_Cont() && cont_adj)){
417+
if (!frozen_visc) {
418418
// Turbulent
419419
switch(turb_model){
420420
case SST:
@@ -441,7 +441,7 @@ void CAdjFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CS
441441
SetVolumeOutputValue("RES_ADJ_ENERGY", iPoint, Node_AdjFlow->GetSolution(iPoint, 3) - Node_AdjFlow->GetSolution_Old(iPoint, 3));
442442
}
443443

444-
if ((!config->GetFrozen_Visc_Disc() && !cont_adj) || (!config->GetFrozen_Visc_Cont() && cont_adj)){
444+
if (!frozen_visc) {
445445
switch(config->GetKind_Turb_Model()){
446446
case SST:
447447
SetVolumeOutputValue("RES_ADJ_TKE", iPoint, Node_AdjTurb->GetSolution(iPoint, 0) - Node_AdjTurb->GetSolution_Old(iPoint, 0));

SU2_CFD/src/output/CAdjFlowIncOutput.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ CAdjFlowIncOutput::CAdjFlowIncOutput(CConfig *config, unsigned short nDim) : COu
4141

4242
rad_model = config->GetKind_RadiationModel();
4343

44+
cont_adj = config->GetContinuous_Adjoint();
45+
46+
frozen_visc = (config->GetFrozen_Visc_Disc() && !cont_adj) || (config->GetFrozen_Visc_Cont() && cont_adj);
47+
4448
/*--- Set the default history fields if nothing is set in the config file ---*/
4549

4650
if (nRequestedHistoryFields == 0){
@@ -114,7 +118,7 @@ void CAdjFlowIncOutput::SetHistoryOutputFields(CConfig *config){
114118
AddHistoryOutput("RMS_ADJ_VELOCITY-Z", "rms[A_W]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint Velocity z-component.", HistoryFieldType::RESIDUAL);
115119
/// DESCRIPTION: Maximum residual of the temperature.
116120
AddHistoryOutput("RMS_ADJ_TEMPERATURE", "rms[A_T]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint temperature.", HistoryFieldType::RESIDUAL);
117-
if (!config->GetFrozen_Visc_Disc() || !config->GetFrozen_Visc_Cont()){
121+
if (!frozen_visc) {
118122
switch(turb_model){
119123
case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP:
120124
/// DESCRIPTION: Root-mean square residual of the adjoint nu tilde.
@@ -146,7 +150,7 @@ void CAdjFlowIncOutput::SetHistoryOutputFields(CConfig *config){
146150
AddHistoryOutput("MAX_ADJ_VELOCITY-Z", "max[A_RhoW]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the adjoint Velocity z-component", HistoryFieldType::RESIDUAL);
147151
/// DESCRIPTION: Maximum residual of the temperature.
148152
AddHistoryOutput("MAX_ADJ_TEMPERATURE", "max[A_T]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the temperature.", HistoryFieldType::RESIDUAL);
149-
if (!config->GetFrozen_Visc_Disc() || !config->GetFrozen_Visc_Cont()){
153+
if (!frozen_visc) {
150154
switch(turb_model){
151155
case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP:
152156
/// DESCRIPTION: Maximum residual of the adjoint nu tilde.
@@ -174,7 +178,7 @@ void CAdjFlowIncOutput::SetHistoryOutputFields(CConfig *config){
174178
AddHistoryOutput("BGS_ADJ_VELOCITY-Z", "bgs[A_RhoW]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the adjoint Velocity z-component", HistoryFieldType::RESIDUAL);
175179
/// DESCRIPTION: BGS residual of the temperature.
176180
AddHistoryOutput("BGS_ADJ_TEMPERATURE", "bgs[A_T]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the adjoint temperature.", HistoryFieldType::RESIDUAL);
177-
if (!config->GetFrozen_Visc_Disc() || !config->GetFrozen_Visc_Cont()){
181+
if (!frozen_visc) {
178182
switch(turb_model){
179183
case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP:
180184
/// DESCRIPTION: BGS residual of the adjoint nu tilde.
@@ -211,7 +215,7 @@ void CAdjFlowIncOutput::SetHistoryOutputFields(CConfig *config){
211215
AddHistoryOutput("LINSOL_ITER", "LinSolIter", ScreenOutputFormat::INTEGER, "LINSOL", "Number of iterations of the linear solver.");
212216
AddHistoryOutput("LINSOL_RESIDUAL", "LinSolRes", ScreenOutputFormat::FIXED, "LINSOL", "Residual of the linear solver.");
213217

214-
if (turb_model) {
218+
if (turb_model && !frozen_visc) {
215219
AddHistoryOutput("LINSOL_ITER_TURB", "LinSolIterTurb", ScreenOutputFormat::INTEGER, "LINSOL", "Number of iterations of the linear solver for turbulence.");
216220
AddHistoryOutput("LINSOL_RESIDUAL_TURB", "LinSolResTurb", ScreenOutputFormat::FIXED, "LINSOL", "Residual of the linear solver for turbulence.");
217221
}
@@ -244,7 +248,7 @@ void CAdjFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS
244248
if (nDim == 3) SetHistoryOutputValue("RMS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_RMS(4)));
245249
else SetHistoryOutputValue("RMS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_RMS(3)));
246250
}
247-
if (!config->GetFrozen_Visc_Disc() || !config->GetFrozen_Visc_Cont()){
251+
if (!frozen_visc) {
248252
switch(turb_model){
249253
case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP:
250254
SetHistoryOutputValue("RMS_ADJ_NU_TILDE", log10(adjturb_solver->GetRes_RMS(0)));
@@ -272,7 +276,7 @@ void CAdjFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS
272276
if (nDim == 3) SetHistoryOutputValue("MAX_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_Max(4)));
273277
else SetHistoryOutputValue("MAX_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_Max(3)));
274278
}
275-
if (!config->GetFrozen_Visc_Disc() || !config->GetFrozen_Visc_Cont()){
279+
if (!frozen_visc) {
276280
switch(turb_model){
277281
case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP:
278282
SetHistoryOutputValue("MAX_ADJ_NU_TILDE", log10(adjturb_solver->GetRes_Max(0)));
@@ -299,7 +303,7 @@ void CAdjFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS
299303
if (nDim == 3) SetHistoryOutputValue("BGS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_BGS(4)));
300304
else SetHistoryOutputValue("BGS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_BGS(3)));
301305
}
302-
if (!config->GetFrozen_Visc_Disc() || !config->GetFrozen_Visc_Cont()){
306+
if (!frozen_visc) {
303307
switch(turb_model){
304308
case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP:
305309
SetHistoryOutputValue("BGS_ADJ_NU_TILDE", log10(adjturb_solver->GetRes_BGS(0)));
@@ -325,7 +329,7 @@ void CAdjFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS
325329
SetHistoryOutputValue("LINSOL_ITER", adjflow_solver->GetIterLinSolver());
326330
SetHistoryOutputValue("LINSOL_RESIDUAL", log10(adjflow_solver->GetResLinSolver()));
327331

328-
if (adjturb_solver) {
332+
if (turb_model && !frozen_visc) {
329333
SetHistoryOutputValue("LINSOL_ITER_TURB", adjturb_solver->GetIterLinSolver());
330334
SetHistoryOutputValue("LINSOL_RESIDUAL_TURB", log10(adjturb_solver->GetResLinSolver()));
331335
}
@@ -360,7 +364,7 @@ void CAdjFlowIncOutput::SetVolumeOutputFields(CConfig *config){
360364
AddVolumeOutput("ADJ_TEMPERATURE", "Adjoint_Temperature", "SOLUTION", "Adjoint temperature");
361365

362366

363-
if (!config->GetFrozen_Visc_Disc()){
367+
if (!frozen_visc){
364368
switch(turb_model){
365369
case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP:
366370
/// DESCRIPTION: Adjoint nu tilde.
@@ -401,7 +405,7 @@ void CAdjFlowIncOutput::SetVolumeOutputFields(CConfig *config){
401405
AddVolumeOutput("RES_ADJ_VELOCITY-Z", "Residual_Adjoint_Velocity_z", "RESIDUAL", "Residual of the adjoint z-velocity");
402406
/// DESCRIPTION: Residual of the adjoint energy.
403407
AddVolumeOutput("RES_ADJ_TEMPERATURE", "Residual_Adjoint_Heat", "RESIDUAL", "Residual of the adjoint temperature");
404-
if (!config->GetFrozen_Visc_Disc()){
408+
if (!frozen_visc){
405409
switch(turb_model){
406410
case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP:
407411
/// DESCRIPTION: Residual of the nu tilde.
@@ -443,7 +447,7 @@ void CAdjFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSo
443447
CVariable* Node_AdjRad = nullptr;
444448
CPoint* Node_Geo = geometry->nodes;
445449

446-
if (config->GetKind_Turb_Model() != NONE && !config->GetFrozen_Visc_Disc()){
450+
if (config->GetKind_Turb_Model() != NONE && !frozen_visc){
447451
Node_AdjTurb = solver[ADJTURB_SOL]->GetNodes();
448452
}
449453
if (weakly_coupled_heat){
@@ -473,7 +477,7 @@ void CAdjFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSo
473477
else SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 3));
474478
}
475479
// Turbulent
476-
if (!config->GetFrozen_Visc_Disc()){
480+
if (!frozen_visc){
477481
switch(turb_model){
478482
case SST:
479483
SetVolumeOutputValue("ADJ_TKE", iPoint, Node_AdjTurb->GetSolution(iPoint, 0));
@@ -502,7 +506,7 @@ void CAdjFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSo
502506
} else {
503507
SetVolumeOutputValue("RES_ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 3) - Node_AdjFlow->GetSolution_Old(iPoint, 3));
504508
}
505-
if (!config->GetFrozen_Visc_Disc()){
509+
if (!frozen_visc){
506510
switch(config->GetKind_Turb_Model()){
507511
case SST:
508512
SetVolumeOutputValue("RES_ADJ_TKE", iPoint, Node_AdjTurb->GetSolution(iPoint, 0) - Node_AdjTurb->GetSolution_Old(iPoint, 0));

0 commit comments

Comments
 (0)