Skip to content

Commit 7b1ad11

Browse files
authored
Merge pull request #1281 from su2code/chore_heatsolver
Chore in CHeatSolver.cpp
2 parents 2782983 + 92ee5ef commit 7b1ad11

File tree

10 files changed

+230
-386
lines changed

10 files changed

+230
-386
lines changed

SU2_CFD/include/solvers/CHeatSolver.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ class CHeatSolver final : public CSolver {
4141
static constexpr size_t MAXNDIM = 3; /*!< \brief Max number of space dimensions, used in some static arrays. */
4242
static constexpr size_t MAXNVAR = 1; /*!< \brief Max number of variables, for static arrays. */
4343

44-
unsigned short nVarFlow, nMarker, CurrentMesh;
44+
const bool flow; /*!< \brief Use solver as a scalar transport equation of Temperature for the inc solver. */
45+
const bool heat_equation; /*!< \brief use solver for heat conduction in solids. */
46+
47+
unsigned short nVarFlow, nMarker;
4548
vector<vector<su2double> > HeatFlux;
4649
vector<su2double> HeatFlux_per_Marker;
4750
su2double Total_HeatFlux;
@@ -65,11 +68,6 @@ class CHeatSolver final : public CSolver {
6568

6669
public:
6770

68-
/*!
69-
* \brief Constructor of the class.
70-
*/
71-
CHeatSolver(void);
72-
7371
/*!
7472
* \brief Constructor of the class.
7573
*/

SU2_CFD/src/SU2_CFD.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "libxsmm.h"
3333
#endif
3434

35-
/* Include file, needed for the runtime NaN catching. */
35+
/* Include file, needed for the runtime NaN catching. You also have to include feenableexcept(...) below. */
3636
//#include <fenv.h>
3737

3838
using namespace std;
@@ -79,7 +79,7 @@ int main(int argc, char *argv[]) {
7979
#endif
8080

8181
/*--- Uncomment the following line if runtime NaN catching is desired. ---*/
82-
// feenableexcept(FE_INVALID | FE_OVERFLOW);
82+
// feenableexcept(FE_INVALID | FE_OVERFLOW | FE_DIVBYZERO );
8383

8484
/*--- Initialize libxsmm, if supported. ---*/
8585
#ifdef HAVE_LIBXSMM

SU2_CFD/src/drivers/CDriver.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2921,18 +2921,6 @@ void CFluidDriver::Preprocess(unsigned long Iter) {
29212921
config_container[iZone]->SetPhysicalTime(0.0);
29222922
}
29232923

2924-
// /*--- Read the target pressure ---*/
2925-
2926-
// if (config_container[ZONE_0]->GetInvDesign_Cp() == YES)
2927-
// output[ZONE_0]->SetCp_InverseDesign(solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL],
2928-
// geometry_container[ZONE_0][INST_0][MESH_0], config_container[ZONE_0], ExtIter);
2929-
2930-
// /*--- Read the target heat flux ---*/
2931-
2932-
// if (config_container[ZONE_0]->GetInvDesign_HeatFlux() == YES)
2933-
// output[ZONE_0]->SetHeatFlux_InverseDesign(solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL],
2934-
// geometry_container[ZONE_0][INST_0][MESH_0], config_container[ZONE_0], ExtIter);
2935-
29362924
/*--- Set the initial condition for EULER/N-S/RANS and for a non FSI simulation ---*/
29372925

29382926
if(!fsi) {

SU2_CFD/src/drivers/CMultizoneDriver.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void CMultizoneDriver::StartSolver() {
171171
if (rank == MASTER_NODE){
172172
cout << endl <<"Simulation Run using the Multizone Driver" << endl;
173173
if (driver_config->GetTime_Domain())
174-
cout << "The simulation will run until time step " << driver_config->GetnTime_Iter() << "." << endl;
174+
cout << "The simulation will run until time step " << driver_config->GetnTime_Iter() - driver_config->GetRestart_Iter() << "." << endl;
175175
}
176176

177177
/*--- Set the initial time iteration to the restart iteration. ---*/
@@ -244,6 +244,12 @@ void CMultizoneDriver::Preprocess(unsigned long TimeIter) {
244244
solver_container[iZone][INST_0],
245245
config_container[iZone], TimeIter);
246246
}
247+
else if (!fsi && !config_container[iZone]->GetDiscrete_Adjoint() && config_container[iZone]->GetHeatProblem()) {
248+
/*--- Set the initial condition for HEAT equation ---------------------------------------------*/
249+
solver_container[iZone][INST_0][MESH_0][HEAT_SOL]->SetInitialCondition(geometry_container[iZone][INST_0],
250+
solver_container[iZone][INST_0],
251+
config_container[iZone], TimeIter);
252+
}
247253
}
248254

249255
SU2_MPI::Barrier(SU2_MPI::GetComm());

SU2_CFD/src/drivers/CSinglezoneDriver.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ void CSinglezoneDriver::Preprocess(unsigned long TimeIter) {
129129
solver_container[ZONE_0][INST_0],
130130
config_container[ZONE_0], TimeIter);
131131
}
132+
else if ( config_container[ZONE_0]->GetHeatProblem()) {
133+
/*--- Set the initial condition for HEAT equation ---------------------------------------------*/
134+
solver_container[ZONE_0][INST_0][MESH_0][HEAT_SOL]->SetInitialCondition(geometry_container[ZONE_0][INST_0],
135+
solver_container[ZONE_0][INST_0],
136+
config_container[ZONE_0], TimeIter);
137+
}
132138

133139
SU2_MPI::Barrier(SU2_MPI::GetComm());
134140

SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ void CDiscAdjFluidIteration::LoadUnsteady_Solution(CGeometry**** geometry, CSolv
298298
auto solvers = solver[iZone][iInst];
299299

300300
if (DirectIter >= 0) {
301-
if (rank == MASTER_NODE && iZone == ZONE_0)
302-
cout << " Loading flow solution from direct iteration " << DirectIter << "." << endl;
301+
if (rank == MASTER_NODE)
302+
cout << " Loading flow solution from direct iteration " << DirectIter << " for zone " << iZone << "." << endl;
303303

304304
solvers[MESH_0][FLOW_SOL]->LoadRestart(geometry[iZone][iInst], solvers, config[iZone], DirectIter, true);
305305

@@ -311,8 +311,8 @@ void CDiscAdjFluidIteration::LoadUnsteady_Solution(CGeometry**** geometry, CSolv
311311
}
312312
} else {
313313
/*--- If there is no solution file we set the freestream condition ---*/
314-
if (rank == MASTER_NODE && iZone == ZONE_0)
315-
cout << " Setting freestream conditions at direct iteration " << DirectIter << "." << endl;
314+
if (rank == MASTER_NODE)
315+
cout << " Setting freestream conditions at direct iteration " << DirectIter << " for zone " << iZone << "." << endl;
316316

317317
for (auto iMesh = 0u; iMesh <= config[iZone]->GetnMGLevels(); iMesh++) {
318318
solvers[iMesh][FLOW_SOL]->SetFreeStream_Solution(config[iZone]);

SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ void CDiscAdjHeatIteration::Preprocess(COutput* output, CIntegration**** integra
7676

7777
LoadUnsteady_Solution(geometry, solver, config, val_iZone, val_iInst, Direct_Iter);
7878
}
79-
8079
if ((TimeIter > 0) && dual_time) {
8180
/*--- Load solution timestep n - 2 ---*/
8281

@@ -126,9 +125,11 @@ void CDiscAdjHeatIteration::Preprocess(COutput* output, CIntegration**** integra
126125
/*--- Store flow solution also in the adjoint solver in order to be able to reset it later ---*/
127126

128127
if (TimeIter == 0 || dual_time) {
129-
for (auto iPoint = 0ul; iPoint < geometry[val_iZone][val_iInst][MESH_0]->GetnPoint(); iPoint++) {
130-
solvers[MESH_0][ADJHEAT_SOL]->GetNodes()->SetSolution_Direct(
131-
iPoint, solvers[MESH_0][HEAT_SOL]->GetNodes()->GetSolution(iPoint));
128+
for (auto iMesh = 0u; iMesh <= config[val_iZone]->GetnMGLevels(); iMesh++) {
129+
for (auto iPoint = 0ul; iPoint < geometry[val_iZone][val_iInst][iMesh]->GetnPoint(); iPoint++) {
130+
solvers[iMesh][ADJHEAT_SOL]->GetNodes()->SetSolution_Direct(
131+
iPoint, solvers[iMesh][HEAT_SOL]->GetNodes()->GetSolution(iPoint));
132+
}
132133
}
133134
}
134135

@@ -141,16 +142,16 @@ void CDiscAdjHeatIteration::LoadUnsteady_Solution(CGeometry**** geometry, CSolve
141142
int val_DirectIter) {
142143

143144
if (val_DirectIter >= 0) {
144-
if (rank == MASTER_NODE && val_iZone == ZONE_0)
145-
cout << " Loading heat solution from direct iteration " << val_DirectIter << "." << endl;
145+
if (rank == MASTER_NODE)
146+
cout << " Loading heat solution from direct iteration " << val_DirectIter << " for zone " << val_iZone << "." << endl;
146147

147148
solver[val_iZone][val_iInst][MESH_0][HEAT_SOL]->LoadRestart(
148149
geometry[val_iZone][val_iInst], solver[val_iZone][val_iInst], config[val_iZone], val_DirectIter, false);
149150
}
150151
else {
151152
/*--- If there is no solution file we set the freestream condition ---*/
152-
if (rank == MASTER_NODE && val_iZone == ZONE_0)
153-
cout << " Setting freestream conditions at direct iteration " << val_DirectIter << "." << endl;
153+
if (rank == MASTER_NODE)
154+
cout << " Setting freestream conditions at direct iteration " << val_DirectIter << " for zone " << val_iZone << "." << endl;
154155

155156
for (auto iMesh = 0u; iMesh <= config[val_iZone]->GetnMGLevels(); iMesh++) {
156157
solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->SetFreeStream_Solution(config[val_iZone]);

SU2_CFD/src/iteration/CHeatIteration.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void CHeatIteration::Iterate(COutput* output, CIntegration**** integration, CGeo
3232
CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement,
3333
CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone,
3434
unsigned short val_iInst) {
35+
3536
/*--- Update global parameters ---*/
3637

3738
config[val_iZone]->SetGlobalParam(HEAT_EQUATION, RUNTIME_HEAT_SYS);
@@ -44,15 +45,12 @@ void CHeatIteration::Update(COutput* output, CIntegration**** integration, CGeom
4445
CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement,
4546
CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone,
4647
unsigned short val_iInst) {
47-
unsigned short iMesh;
48-
49-
/*--- Dual time stepping strategy ---*/
5048

49+
/*--- Update dual time solver ---*/
5150
if ((config[val_iZone]->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) ||
5251
(config[val_iZone]->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND)) {
53-
/*--- Update dual time solver ---*/
5452

55-
for (iMesh = 0; iMesh <= config[val_iZone]->GetnMGLevels(); iMesh++) {
53+
for (auto iMesh = 0u; iMesh <= config[val_iZone]->GetnMGLevels(); iMesh++) {
5654
integration[val_iZone][val_iInst][HEAT_SOL]->SetDualTime_Solver(geometry[val_iZone][val_iInst][iMesh],
5755
solver[val_iZone][val_iInst][iMesh][HEAT_SOL],
5856
config[val_iZone], iMesh);

0 commit comments

Comments
 (0)