Skip to content

Commit a004f5d

Browse files
committed
fix singlezone heat issues, reduce duplication
1 parent 54ee7cc commit a004f5d

5 files changed

Lines changed: 45 additions & 76 deletions

File tree

SU2_CFD/include/drivers/CDiscAdjSinglezoneDriver.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* SU2 Project Website: https://su2code.github.io
99
*
10-
* The SU2 Project is maintained by the SU2 Foundation
10+
* The SU2 Project is maintained by the SU2 Foundation
1111
* (http://su2foundation.org)
1212
*
1313
* Copyright 2012-2020, SU2 Contributors (cf. AUTHORS.md)
@@ -42,6 +42,7 @@ class CDiscAdjSinglezoneDriver : public CSinglezoneDriver {
4242
unsigned short RecordingState; /*!< \brief The kind of recording the tape currently holds.*/
4343
unsigned short MainVariables, /*!< \brief The kind of recording linked to the main variables of the problem.*/
4444
SecondaryVariables; /*!< \brief The kind of recording linked to the secondary variables of the problem.*/
45+
int MainSolver; /*!< \brief Index of the main adjoint solver. */
4546
su2double ObjFunc; /*!< \brief The value of the objective function.*/
4647
CIteration* direct_iteration; /*!< \brief A pointer to the direct iteration.*/
4748

SU2_CFD/include/iteration/CHeatIteration.hpp

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,25 @@ class CHeatIteration : public CFluidIteration {
6060
CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone,
6161
unsigned short val_iInst) override;
6262

63-
/*!
64-
* \brief Iterate the heat system for a number of Inner_Iter iterations.
65-
* \param[in] output - Pointer to the COutput class.
66-
* \param[in] integration - Container vector with all the integration methods.
67-
* \param[in] geometry - Geometrical definition of the problem.
68-
* \param[in] solver - Container vector with all the solutions.
69-
* \param[in] numerics - Description of the numerical method (the way in which the equations are solved).
70-
* \param[in] config - Definition of the particular problem.
71-
* \param[in] surface_movement - Surface movement classes of the problem.
72-
* \param[in] grid_movement - Volume grid movement classes of the problem.
73-
* \param[in] FFDBox - FFD FFDBoxes of the problem.
74-
*/
75-
void Solve(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver,
76-
CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement,
77-
CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone,
78-
unsigned short val_iInst) override;
79-
8063
/*!
8164
* \brief Updates the containers for the heat system.
82-
* \param[in] ??? - Description here.
8365
*/
8466
void Update(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver,
8567
CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement,
8668
CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone,
8769
unsigned short val_iInst) override;
70+
71+
/*!
72+
* \brief Override the preprocessing of CFluidIteration.
73+
*/
74+
inline void Preprocess(COutput*, CIntegration****, CGeometry****, CSolver*****, CNumerics******, CConfig**,
75+
CSurfaceMovement**, CVolumetricMovement***, CFreeFormDefBox***, unsigned short,
76+
unsigned short) override {}
77+
78+
/*!
79+
* \brief Override the postprocessing of CFluidIteration.
80+
*/
81+
inline void Postprocess(COutput*, CIntegration****, CGeometry****, CSolver*****, CNumerics******, CConfig**,
82+
CSurfaceMovement**, CVolumetricMovement***, CFreeFormDefBox***, unsigned short,
83+
unsigned short) override {}
8884
};

SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ CDiscAdjSinglezoneDriver::CDiscAdjSinglezoneDriver(char* confFile,
6969
switch (config->GetKind_Solver()) {
7070

7171
case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES: case DISC_ADJ_RANS:
72-
case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES: case DISC_ADJ_INC_RANS:
72+
case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES: case DISC_ADJ_INC_RANS:
7373
if (rank == MASTER_NODE)
7474
cout << "Direct iteration: Euler/Navier-Stokes/RANS equation." << endl;
7575
if (turbo) {
@@ -82,6 +82,7 @@ CDiscAdjSinglezoneDriver::CDiscAdjSinglezoneDriver(char* confFile,
8282
MainVariables = SOLUTION_VARIABLES;
8383
if (mesh_def) SecondaryVariables = MESH_DEFORM;
8484
else SecondaryVariables = MESH_COORDS;
85+
MainSolver = ADJFLOW_SOL;
8586
break;
8687

8788
case DISC_ADJ_FEM_EULER : case DISC_ADJ_FEM_NS : case DISC_ADJ_FEM_RANS :
@@ -91,6 +92,7 @@ CDiscAdjSinglezoneDriver::CDiscAdjSinglezoneDriver(char* confFile,
9192
direct_output = COutputFactory::CreateOutput(FEM_EULER, config, nDim);
9293
MainVariables = SOLUTION_VARIABLES;
9394
SecondaryVariables = MESH_COORDS;
95+
MainSolver = ADJFLOW_SOL;
9496
break;
9597

9698
case DISC_ADJ_FEM:
@@ -100,6 +102,7 @@ CDiscAdjSinglezoneDriver::CDiscAdjSinglezoneDriver(char* confFile,
100102
direct_output = COutputFactory::CreateOutput(FEM_ELASTICITY, config, nDim);
101103
MainVariables = SOLUTION_VARIABLES;
102104
SecondaryVariables = MESH_COORDS;
105+
MainSolver = ADJFEA_SOL;
103106
break;
104107

105108
case DISC_ADJ_HEAT:
@@ -109,6 +112,7 @@ CDiscAdjSinglezoneDriver::CDiscAdjSinglezoneDriver(char* confFile,
109112
direct_output = COutputFactory::CreateOutput(HEAT_EQUATION, config, nDim);
110113
MainVariables = SOLUTION_VARIABLES;
111114
SecondaryVariables = MESH_COORDS;
115+
MainSolver = ADJHEAT_SOL;
112116
break;
113117

114118
}
@@ -222,6 +226,7 @@ void CDiscAdjSinglezoneDriver::Postprocess() {
222226
{
223227
case DISC_ADJ_EULER : case DISC_ADJ_NAVIER_STOKES : case DISC_ADJ_RANS :
224228
case DISC_ADJ_INC_EULER : case DISC_ADJ_INC_NAVIER_STOKES : case DISC_ADJ_INC_RANS :
229+
case DISC_ADJ_HEAT :
225230

226231
/*--- Compute the geometrical sensitivities ---*/
227232
SecondaryRecording();
@@ -393,8 +398,21 @@ void CDiscAdjSinglezoneDriver::SetObjFunction(){
393398
ObjFunc = solver[FLOW_SOL]->GetTotal_ComboObj();
394399

395400
}
401+
break;
396402

403+
case DISC_ADJ_HEAT:
404+
switch (config->GetKind_ObjFunc()){
405+
case TOTAL_HEATFLUX:
406+
ObjFunc = solver[HEAT_SOL]->GetTotal_HeatFlux();
407+
break;
408+
case TOTAL_AVG_TEMPERATURE:
409+
ObjFunc = solver[HEAT_SOL]->GetTotal_AvgTemperature();
410+
break;
411+
default:
412+
break;
413+
}
397414
break;
415+
398416
case DISC_ADJ_FEM:
399417
switch (config->GetKind_ObjFunc()){
400418
case REFERENCE_GEOMETRY:
@@ -555,14 +573,11 @@ void CDiscAdjSinglezoneDriver::SecondaryRecording(){
555573

556574
/*--- Extract the computed sensitivity values. ---*/
557575

558-
if (config->GetKind_Solver() == DISC_ADJ_FEM) {
559-
solver[ADJFEA_SOL]->SetSensitivity(geometry, config);
560-
}
561-
else if(SecondaryVariables == MESH_COORDS) {
562-
solver[ADJFLOW_SOL]->SetSensitivity(geometry, config);
576+
if (SecondaryVariables == MESH_COORDS) {
577+
solver[MainSolver]->SetSensitivity(geometry, config);
563578
}
564579
else { // MESH_DEFORM
565-
solver[ADJMESH_SOL]->SetSensitivity(geometry, config, solver[ADJFLOW_SOL]);
580+
solver[ADJMESH_SOL]->SetSensitivity(geometry, config, solver[MainSolver]);
566581
}
567582

568583
/*--- Clear the stored adjoint information to be ready for a new evaluation. ---*/

SU2_CFD/src/iteration/CFluidIteration.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,14 @@ void CFluidIteration::Solve(COutput* output, CIntegration**** integration, CGeom
305305
if (multizone && steady) {
306306
Output(output, geometry, solver, config, config[val_iZone]->GetOuterIter(), StopCalc, val_iZone, val_iInst);
307307

308-
/*--- Set the fluid convergence to false (to make sure outer subiterations converge) ---*/
308+
/*--- Set the convergence to false (to make sure outer subiterations converge) ---*/
309309

310-
integration[val_iZone][INST_0][FLOW_SOL]->SetConvergence(false);
310+
if (config[val_iZone]->GetKind_Solver() == HEAT_EQUATION) {
311+
integration[val_iZone][INST_0][HEAT_SOL]->SetConvergence(false);
312+
}
313+
else {
314+
integration[val_iZone][INST_0][FLOW_SOL]->SetConvergence(false);
315+
}
311316
}
312317
}
313318

SU2_CFD/src/iteration/CHeatIteration.cpp

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -40,54 +40,6 @@ void CHeatIteration::Iterate(COutput* output, CIntegration**** integration, CGeo
4040
RUNTIME_HEAT_SYS, val_iZone, val_iInst);
4141
}
4242

43-
void CHeatIteration::Solve(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver,
44-
CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement,
45-
CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone,
46-
unsigned short val_iInst) {
47-
/*--- Boolean to determine if we are running a static or dynamic case ---*/
48-
bool steady = !config[val_iZone]->GetTime_Domain();
49-
50-
unsigned long Inner_Iter, nInner_Iter = config[val_iZone]->GetnInner_Iter();
51-
bool StopCalc = false;
52-
53-
/*--- Synchronization point before a single solver iteration.
54-
Compute the wall clock time required. ---*/
55-
56-
StartTime = SU2_MPI::Wtime();
57-
58-
/*--- For steady-state flow simulations, we need to loop over ExtIter for the number of time steps ---*/
59-
/*--- However, ExtIter is the number of FSI iterations, so nIntIter is used in this case ---*/
60-
61-
for (Inner_Iter = 0; Inner_Iter < nInner_Iter; Inner_Iter++) {
62-
config[val_iZone]->SetInnerIter(Inner_Iter);
63-
64-
/*--- Run a single iteration of the solver ---*/
65-
Iterate(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, FFDBox, val_iZone,
66-
INST_0);
67-
68-
/*--- Monitor the pseudo-time ---*/
69-
StopCalc = Monitor(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, FFDBox,
70-
val_iZone, INST_0);
71-
72-
/*--- Output files at intermediate iterations if the problem is single zone ---*/
73-
74-
if (singlezone && steady) {
75-
Output(output, geometry, solver, config, Inner_Iter, StopCalc, val_iZone, val_iInst);
76-
}
77-
78-
/*--- If the iteration has converged, break the loop ---*/
79-
if (StopCalc) break;
80-
}
81-
82-
if (multizone && steady) {
83-
Output(output, geometry, solver, config, config[val_iZone]->GetOuterIter(), StopCalc, val_iZone, val_iInst);
84-
85-
/*--- Set the fluid convergence to false (to make sure outer subiterations converge) ---*/
86-
87-
integration[val_iZone][INST_0][HEAT_SOL]->SetConvergence(false);
88-
}
89-
}
90-
9143
void CHeatIteration::Update(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver,
9244
CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement,
9345
CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone,

0 commit comments

Comments
 (0)