Skip to content

Commit 78363e1

Browse files
authored
Merge pull request #1107 from su2code/heat_solver_fixes
Heat solver fixes for primal and adjoint CHT simulations
2 parents 1261014 + 3437f2b commit 78363e1

29 files changed

Lines changed: 198 additions & 217 deletions

Common/include/CConfig.hpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5137,21 +5137,19 @@ class CConfig {
51375137
bool GetHold_GridFixed(void) const { return Hold_GridFixed; }
51385138

51395139
/*!
5140+
* \author H. Kline
51405141
* \brief Get the kind of objective function. There are several options: Drag coefficient,
51415142
* Lift coefficient, efficiency, etc.
51425143
* \note The objective function will determine the boundary condition of the adjoint problem.
5144+
* \param[in] val_obj
51435145
* \return Kind of objective function.
51445146
*/
5145-
unsigned short GetKind_ObjFunc(void) const { return Kind_ObjFunc[0]; }
5147+
unsigned short GetKind_ObjFunc(unsigned short val_obj = 0) const { return Kind_ObjFunc[val_obj]; }
51465148

51475149
/*!
5148-
* \author H. Kline
5149-
* \brief Get the kind of objective function. There are several options: Drag coefficient,
5150-
* Lift coefficient, efficiency, etc.
5151-
* \note The objective function will determine the boundary condition of the adjoint problem.
5152-
* \return Kind of objective function.
5150+
* \brief Similar to GetKind_ObjFunc but returns the corresponding string.
51535151
*/
5154-
unsigned short GetKind_ObjFunc(unsigned short val_obj) const { return Kind_ObjFunc[val_obj]; }
5152+
string GetName_ObjFunc(unsigned short val_obj = 0) const;
51555153

51565154
/*!
51575155
* \author H. Kline
@@ -5180,12 +5178,6 @@ class CConfig {
51805178
*/
51815179
su2double GetCoeff_ObjChainRule(unsigned short iVar) const { return Obj_ChainRuleCoeff[iVar]; }
51825180

5183-
/*!
5184-
* \author H. Kline
5185-
* \brief Get the flag indicating whether to comput a combined objective.
5186-
*/
5187-
bool GetComboObj(void);
5188-
51895181
/*!
51905182
* \brief Get the kind of sensitivity smoothing technique.
51915183
* \return Kind of sensitivity smoothing technique.

Common/src/CConfig.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9309,6 +9309,13 @@ short CConfig::FindInterfaceMarker(unsigned short iInterface) const {
93099309
return -1;
93109310
}
93119311

9312+
string CConfig::GetName_ObjFunc(unsigned short val_obj) const {
9313+
for (auto item : Objective_Map)
9314+
if (item.second == static_cast<ENUM_OBJECTIVE>(Kind_ObjFunc[val_obj]))
9315+
return item.first;
9316+
return string();
9317+
}
9318+
93129319
void CConfig::Tick(double *val_start_time) {
93139320

93149321
#ifdef PROFILE

Common/src/geometry/CPhysicalGeometry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8425,7 +8425,7 @@ void CPhysicalGeometry::ComputeMeshQualityStatistics(CConfig *config) {
84258425
const unsigned long jPoint = edges->GetNode(iEdge,1);
84268426

84278427
const unsigned long GlobalIndex_i = nodes->GetGlobalIndex(iPoint);
8428-
const unsigned long GlobalIndex_j = nodes->GetGlobalIndex(iPoint);
8428+
const unsigned long GlobalIndex_j = nodes->GetGlobalIndex(jPoint);
84298429

84308430
/*-- Area normal for the current edge. Recall that this normal
84318431
is computed by summing the normals of adjacent faces along

Common/src/linear_algebra/CSysSolve.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ unsigned long CSysSolve<ScalarType>::CG_LinSolver(const CSysVector<ScalarType> &
246246
norm_r = r.norm();
247247
norm0 = b.norm();
248248
if ((norm_r < tol*norm0) || (norm_r < eps)) {
249-
if (master) cout << "CSysSolve::ConjugateGradient(): system solved by initial guess." << endl;
249+
if (master && !mesh_deform) cout << "CSysSolve::ConjugateGradient(): system solved by initial guess." << endl;
250250
return 0;
251251
}
252252

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/include/solvers/CDiscAdjFEASolver.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,9 @@ class CDiscAdjFEASolver final : public CSolver {
176176
/*!
177177
* \brief Extract and set the geometrical sensitivity.
178178
* \param[in] geometry - Geometrical definition of the problem.
179-
* \param[in] solver - The solver container holding all terms of the solution.
180179
* \param[in] config - Definition of the particular problem.
181180
*/
182-
void SetSensitivity(CGeometry *geometry, CSolver **solver, CConfig *config) override;
181+
void SetSensitivity(CGeometry *geometry, CConfig *config, CSolver*) override;
183182

184183
/*!
185184
* \brief Set the objective function.

SU2_CFD/include/solvers/CDiscAdjMeshSolver.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
*/
4040
class CDiscAdjMeshSolver final : public CSolver {
4141
private:
42-
unsigned short KindDirect_Solver;
43-
CSolver *direct_solver;
42+
unsigned short KindDirect_Solver = 0;
43+
CSolver *direct_solver = nullptr;
4444

4545
CDiscAdjMeshBoundVariable* nodes = nullptr; /*!< \brief Variables of the discrete adjoint mesh solver. */
4646

@@ -97,10 +97,10 @@ class CDiscAdjMeshSolver final : public CSolver {
9797
/*!
9898
* \brief Extract and set the geometrical sensitivity.
9999
* \param[in] geometry - Geometrical definition of the problem.
100-
* \param[in] solver - The solver container holding all terms of the solution.
101100
* \param[in] config - Definition of the particular problem.
101+
* \param[in] target_solver - The target solver to store the sensitivities.
102102
*/
103-
void SetSensitivity(CGeometry *geometry, CSolver **solver, CConfig *config) override;
103+
void SetSensitivity(CGeometry *geometry, CConfig *config, CSolver* target_solver) override;
104104

105105
/*!
106106
* \brief Prepare the solver for a new recording.

SU2_CFD/include/solvers/CDiscAdjSolver.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,9 @@ class CDiscAdjSolver final : public CSolver {
156156
/*!
157157
* \brief Extract and set the geometrical sensitivity.
158158
* \param[in] geometry - Geometrical definition of the problem.
159-
* \param[in] solver - The solver container holding all terms of the solution.
160159
* \param[in] config - Definition of the particular problem.
161160
*/
162-
void SetSensitivity(CGeometry *geometry, CSolver **solver, CConfig *config) override;
161+
void SetSensitivity(CGeometry *geometry, CConfig *config, CSolver*) override;
163162

164163
/*!
165164
* \brief Set the objective function.

SU2_CFD/include/solvers/CSolver.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3805,10 +3805,10 @@ class CSolver {
38053805
/*!
38063806
* \brief A virtual member. Extract and set the geometrical sensitivity.
38073807
* \param[in] geometry - Geometrical definition of the problem.
3808-
* \param[in] solver - The solver container holding all terms of the solution.
38093808
* \param[in] config - Definition of the particular problem.
3809+
* \param[in] target_solver - The target solver for the sensitivities, optional, for when the mesh solver is used.
38103810
*/
3811-
inline virtual void SetSensitivity(CGeometry *geometry, CSolver **solver, CConfig *config){ }
3811+
inline virtual void SetSensitivity(CGeometry *geometry, CConfig *config, CSolver *target_solver = nullptr){ }
38123812

38133813
/*!
38143814
* \brief A virtual member. Extract and set the derivative of objective function.

0 commit comments

Comments
 (0)