Skip to content

Commit 386d1ef

Browse files
authored
Merge pull request #2429 from su2code/coupled_thermoelasticity
Coupled thermoelasticity
2 parents 02be3f6 + e0354b2 commit 386d1ef

File tree

16 files changed

+225
-45
lines changed

16 files changed

+225
-45
lines changed

SU2_CFD/include/output/CElasticityOutput.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class CElasticityOutput final: public COutput {
4040
unsigned short nVar_FEM; //!< Number of FEM variables
4141
bool linear_analysis, //!< Boolean indicating a linear analysis
4242
nonlinear_analysis, //!< Boolean indicating a nonlinear analysis
43+
coupled_heat, //!< Boolean indicating a thermoelastic analysis
4344
dynamic; //!< Boolean indicating a dynamic analysis
4445

4546
public:
@@ -82,6 +83,11 @@ class CElasticityOutput final: public COutput {
8283
* \param[in] config - Definition of the particular problem.
8384
* \return <TRUE> if the residuals should be initialized.
8485
*/
85-
bool SetInitResiduals(const CConfig *config) override ;
86+
bool SetInitResiduals(const CConfig *config) override;
8687

88+
/*!
89+
* \brief LoadSurfaceData
90+
*/
91+
void LoadSurfaceData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint,
92+
unsigned short iMarker, unsigned long iVertex) override;
8793
};

SU2_CFD/include/output/CHeatOutput.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,22 @@ class CHeatOutput final: public CFVMOutput {
5050
*/
5151
void SetHistoryOutputFields(CConfig *config) override;
5252

53+
/*!
54+
* \brief Set the available history output fields in another output instance.
55+
*/
56+
static void SetHistoryOutputFieldsImpl(CConfig *config, COutput* output);
57+
5358
/*!
5459
* \brief Load the history output field values
5560
* \param[in] config - Definition of the particular problem.
5661
*/
5762
void LoadHistoryData(CConfig *config, CGeometry *geometry, CSolver **solver) override;
5863

64+
/*!
65+
* \brief Set the history output field values in another output instance.
66+
*/
67+
static void LoadHistoryDataImpl(CConfig *config, CGeometry *geometry, CSolver **solver, COutput* output);
68+
5969
/*!
6070
* \brief Set the available volume output fields
6171
* \param[in] config - Definition of the particular problem.

SU2_CFD/include/output/COutput.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class CSolver;
5555
class CFileWriter;
5656
class CParallelDataSorter;
5757
class CConfig;
58+
class CHeatOutput;
5859

5960
using namespace std;
6061

@@ -65,6 +66,7 @@ using namespace std;
6566
*/
6667
class COutput {
6768
protected:
69+
friend class CHeatOutput;
6870

6971
/*----------------------------- General ----------------------------*/
7072

SU2_CFD/include/solvers/CFEASolver.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ class CFEASolver : public CFEASolverBase {
100100
bool initial_calc = true; /*!< \brief Becomes false after first call to Preprocessing. */
101101
bool body_forces = false; /*!< \brief Whether any body force is active. */
102102

103+
/*!
104+
* \brief Pointer to the heat solver nodes to access temperature for coupled simulations.
105+
*/
106+
const CVariable* heat_nodes = nullptr;
107+
103108
/*!
104109
* \brief The highest level in the variable hierarchy this solver can safely use,
105110
* CVariable is the common denominator between the FEA and Mesh deformation variables.

SU2_CFD/include/solvers/CHeatSolver.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class CHeatSolver final : public CScalarSolver<CHeatVariable> {
4242
static constexpr size_t MAXNVAR = 1; /*!< \brief Max number of variables, for static arrays. */
4343

4444
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. */
4645

4746
su2double Global_Delta_Time = 0.0, Global_Delta_UnstTimeND = 0.0;
4847

SU2_CFD/include/solvers/CScalarSolver.inl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,10 +503,10 @@ void CScalarSolver<VariableType>::CompleteImplicitIteration(CGeometry* geometry,
503503
SU2_OMP_FOR_STAT(omp_chunk_size)
504504
for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) {
505505
/*--- Multiply the Solution var with density to get the conservative transported quantity, if necessary. ---*/
506-
/* Note that for consistency with residual and jacobian calaulcations, use of current density for conservative variables
506+
/* Note that for consistency with residual and jacobian calaulcations, use of current density for conservative variables
507507
* of the old solution is used. see pull request https://github.com/su2code/SU2/pull/2458*/
508508
const su2double density = flowNodes->GetDensity(iPoint);
509-
509+
510510
for (unsigned short iVar = 0; iVar < nVar; iVar++) {
511511
nodes->AddClippedSolution(iPoint, iVar, nodes->GetUnderRelaxation(iPoint) * LinSysSol(iPoint, iVar),
512512
lowerlimit[iVar], upperlimit[iVar], density, density);

SU2_CFD/src/drivers/CDriver.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,9 @@ void CDriver::InitializeNumerics(CConfig *config, CGeometry **geometry, CSolver
15271527

15281528
case MAIN_SOLVER::FEM_ELASTICITY:
15291529
case MAIN_SOLVER::DISC_ADJ_FEM:
1530-
fem = true; break;
1530+
fem = true;
1531+
heat = config->GetWeakly_Coupled_Heat();
1532+
break;
15311533

15321534
case MAIN_SOLVER::ADJ_EULER:
15331535
adj_euler = euler = compressible = true; break;

SU2_CFD/src/iteration/CFEAIteration.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ void CFEAIteration::Iterate(COutput* output, CIntegration**** integration, CGeom
4848
CIntegration* feaIntegration = integration[val_iZone][val_iInst][FEA_SOL];
4949
CSolver* feaSolver = solver[val_iZone][val_iInst][MESH_0][FEA_SOL];
5050

51+
/*--- Add heat solver integration step. ---*/
52+
if (config[val_iZone]->GetWeakly_Coupled_Heat()) {
53+
config[val_iZone]->SetGlobalParam(MAIN_SOLVER::HEAT_EQUATION, RUNTIME_HEAT_SYS);
54+
integration[val_iZone][val_iInst][HEAT_SOL]->SingleGrid_Iteration(geometry, solver, numerics, config,
55+
RUNTIME_HEAT_SYS, val_iZone, val_iInst);
56+
}
57+
5158
/*--- FEA equations ---*/
5259
config[val_iZone]->SetGlobalParam(MAIN_SOLVER::FEM_ELASTICITY, RUNTIME_FEA_SYS);
5360

SU2_CFD/src/output/CElasticityOutput.cpp

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@
2424
* You should have received a copy of the GNU Lesser General Public
2525
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
2626
*/
27-
28-
2927
#include "../../include/output/CElasticityOutput.hpp"
28+
#include "../../include/output/CHeatOutput.hpp"
3029

3130
#include "../../../Common/include/geometry/CGeometry.hpp"
3231
#include "../../include/solvers/CSolver.hpp"
3332

3433
CElasticityOutput::CElasticityOutput(CConfig *config, unsigned short nDim) : COutput(config, nDim, false) {
3534

36-
linear_analysis = (config->GetGeometricConditions() == STRUCT_DEFORMATION::SMALL);
37-
nonlinear_analysis = (config->GetGeometricConditions() == STRUCT_DEFORMATION::LARGE);
38-
dynamic = (config->GetTime_Domain());
35+
linear_analysis = config->GetGeometricConditions() == STRUCT_DEFORMATION::SMALL;
36+
nonlinear_analysis = config->GetGeometricConditions() == STRUCT_DEFORMATION::LARGE;
37+
coupled_heat = config->GetWeakly_Coupled_Heat();
38+
dynamic = config->GetTime_Domain();
3939

4040
/*--- Initialize number of variables ---*/
4141
if (linear_analysis) nVar_FEM = nDim;
@@ -48,20 +48,21 @@ CElasticityOutput::CElasticityOutput(CConfig *config, unsigned short nDim) : COu
4848
}
4949

5050
/*--- Default fields for screen output ---*/
51-
if (nRequestedScreenFields == 0){
51+
if (nRequestedScreenFields == 0) {
5252
if (dynamic) requestedScreenFields.emplace_back("TIME_ITER");
5353
if (multiZone) requestedScreenFields.emplace_back("OUTER_ITER");
5454
requestedScreenFields.emplace_back("INNER_ITER");
55-
if(linear_analysis){
55+
if (linear_analysis) {
5656
requestedScreenFields.emplace_back("RMS_DISP_X");
5757
requestedScreenFields.emplace_back("RMS_DISP_Y");
5858
requestedScreenFields.emplace_back("RMS_DISP_Z");
5959
}
60-
if(nonlinear_analysis){
60+
if (nonlinear_analysis) {
6161
requestedScreenFields.emplace_back("RMS_UTOL");
6262
requestedScreenFields.emplace_back("RMS_RTOL");
6363
requestedScreenFields.emplace_back("RMS_ETOL");
6464
}
65+
if (coupled_heat) requestedScreenFields.emplace_back("RMS_TEMPERATURE");
6566
requestedScreenFields.emplace_back("VMS");
6667
nRequestedScreenFields = requestedScreenFields.size();
6768
}
@@ -71,11 +72,8 @@ CElasticityOutput::CElasticityOutput(CConfig *config, unsigned short nDim) : COu
7172
requestedVolumeFields.emplace_back("COORDINATES");
7273
requestedVolumeFields.emplace_back("SOLUTION");
7374
requestedVolumeFields.emplace_back("STRESS");
74-
if (dynamic) {
75-
requestedVolumeFields.emplace_back("VELOCITY");
76-
requestedVolumeFields.emplace_back("ACCELERATION");
77-
}
7875
if (config->GetTopology_Optimization()) requestedVolumeFields.emplace_back("TOPOLOGY");
76+
if (coupled_heat) requestedVolumeFields.emplace_back("PRIMITIVE");
7977
nRequestedVolumeFields = requestedVolumeFields.size();
8078
}
8179

@@ -106,6 +104,7 @@ CElasticityOutput::CElasticityOutput(CConfig *config, unsigned short nDim) : COu
106104
void CElasticityOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolver **solver) {
107105

108106
CSolver* fea_solver = solver[FEA_SOL];
107+
CSolver* heat_solver = solver[HEAT_SOL];
109108

110109
/*--- Residuals: ---*/
111110
/*--- Linear analysis: RMS of the displacements in the nDim coordinates ---*/
@@ -147,6 +146,13 @@ void CElasticityOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS
147146
SetHistoryOutputValue("TOPOL_DISCRETENESS", fea_solver->GetTotal_OFDiscreteness());
148147
}
149148

149+
/*--- Add heat solver data if available. ---*/
150+
if (coupled_heat) {
151+
CHeatOutput::LoadHistoryDataImpl(config, geometry, solver, this);
152+
SetHistoryOutputValue("LINSOL_ITER_HEAT", heat_solver->GetIterLinSolver());
153+
SetHistoryOutputValue("LINSOL_RESIDUAL_HEAT", log10(heat_solver->GetResLinSolver()));
154+
}
155+
150156
ComputeSimpleCustomOutputs(config);
151157

152158
/*--- Keep this as last, since it uses the history values that were set. ---*/
@@ -189,6 +195,11 @@ void CElasticityOutput::SetHistoryOutputFields(CConfig *config) {
189195
}
190196
AddHistoryOutput("COMBO", "ComboObj", ScreenOutputFormat::SCIENTIFIC, "COMBO", "Combined obj. function value.", HistoryFieldType::COEFFICIENT);
191197

198+
if (coupled_heat) {
199+
CHeatOutput::SetHistoryOutputFieldsImpl(config, this);
200+
AddHistoryOutput("LINSOL_ITER_HEAT", "LinSolIterHeat", ScreenOutputFormat::INTEGER, "LINSOL", "Number of iterations of the linear solver.");
201+
AddHistoryOutput("LINSOL_RESIDUAL_HEAT", "LinSolResHeat", ScreenOutputFormat::FIXED, "LINSOL", "Residual of the linear solver.");
202+
}
192203
}
193204

194205
void CElasticityOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint){
@@ -214,6 +225,10 @@ void CElasticityOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSo
214225
SetVolumeOutputValue("ACCELERATION-Y", iPoint, Node_Struc->GetSolution_Accel(iPoint, 1));
215226
if (nDim == 3) SetVolumeOutputValue("ACCELERATION-Z", iPoint, Node_Struc->GetSolution_Accel(iPoint, 2));
216227
}
228+
if (coupled_heat) {
229+
CVariable* Node_Heat = solver[HEAT_SOL]->GetNodes();
230+
SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Heat->GetSolution(iPoint, 0));
231+
}
217232

218233
SetVolumeOutputValue("STRESS-XX", iPoint, Node_Struc->GetStress_FEM(iPoint)[0]);
219234
SetVolumeOutputValue("STRESS-YY", iPoint, Node_Struc->GetStress_FEM(iPoint)[1]);
@@ -228,6 +243,14 @@ void CElasticityOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSo
228243
if (config->GetTopology_Optimization()) {
229244
SetVolumeOutputValue("TOPOL_DENSITY", iPoint, Node_Struc->GetAuxVar(iPoint));
230245
}
246+
247+
CSolver* heat_solver = solver[HEAT_SOL];
248+
if (heat_solver) {
249+
const auto Node_Heat = heat_solver->GetNodes();
250+
SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Heat->GetSolution(iPoint, 0));
251+
SetVolumeOutputValue("RES_TEMPERATURE", iPoint, heat_solver->LinSysRes(iPoint, 0));
252+
}
253+
231254
}
232255

233256
void CElasticityOutput::SetVolumeOutputFields(CConfig *config){
@@ -251,6 +274,10 @@ void CElasticityOutput::SetVolumeOutputFields(CConfig *config){
251274
if (nDim == 3) AddVolumeOutput("ACCELERATION-Z", "Acceleration_z", "SOLUTION", "z-component of the acceleration vector");
252275
}
253276

277+
if (coupled_heat) {
278+
AddVolumeOutput("TEMPERATURE", "Temperature", "SOLUTION", "Temperature");
279+
}
280+
254281
AddVolumeOutput("STRESS-XX", "Sxx", "STRESS", "x-component of the normal stress vector");
255282
AddVolumeOutput("STRESS-YY", "Syy", "STRESS", "y-component of the normal stress vector");
256283
AddVolumeOutput("STRESS-XY", "Sxy", "STRESS", "xy shear stress component");
@@ -266,10 +293,25 @@ void CElasticityOutput::SetVolumeOutputFields(CConfig *config){
266293
if (config->GetTopology_Optimization()) {
267294
AddVolumeOutput("TOPOL_DENSITY", "Topology_Density", "TOPOLOGY", "filtered topology density");
268295
}
296+
297+
if (coupled_heat) {
298+
AddVolumeOutput("HEAT_FLUX", "Heat_Flux", "PRIMITIVE", "Heatflux");
299+
AddVolumeOutput("RES_TEMPERATURE", "Residual_Temperature", "RESIDUAL", "Residual of the temperature");
300+
}
301+
269302
}
270303

271304
bool CElasticityOutput::SetInitResiduals(const CConfig *config){
272305

273306
return (config->GetTime_Domain() == NO && (curInnerIter == 0));
274307

275308
}
309+
310+
void CElasticityOutput::LoadSurfaceData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint,
311+
unsigned short iMarker, unsigned long iVertex) {
312+
if (!coupled_heat || !config->GetViscous_Wall(iMarker)) return;
313+
314+
/* Heat flux value at each surface grid node. */
315+
SetVolumeOutputValue("HEAT_FLUX", iPoint, solver[HEAT_SOL]->GetHeatFlux(iMarker, iVertex));
316+
317+
}

SU2_CFD/src/output/CHeatOutput.cpp

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,42 +72,52 @@ CHeatOutput::CHeatOutput(CConfig *config, unsigned short nDim) : CFVMOutput(conf
7272

7373
}
7474

75+
void CHeatOutput::LoadHistoryDataImpl(CConfig *config, CGeometry *geometry, CSolver **solver, COutput* output) {
76+
77+
CSolver* heat_solver = solver[HEAT_SOL];
78+
79+
output->SetHistoryOutputValue("TOTAL_HEATFLUX", heat_solver->GetTotal_HeatFlux());
80+
output->SetHistoryOutputValue("AVG_TEMPERATURE", heat_solver->GetTotal_AvgTemperature());
81+
output->SetHistoryOutputValue("RMS_TEMPERATURE", log10(heat_solver->GetRes_RMS(0)));
82+
output->SetHistoryOutputValue("MAX_TEMPERATURE", log10(heat_solver->GetRes_Max(0)));
83+
if (config->GetMultizone_Problem()) {
84+
output->SetHistoryOutputValue("BGS_TEMPERATURE", log10(heat_solver->GetRes_BGS(0)));
85+
}
86+
output->SetHistoryOutputValue("CFL_NUMBER", config->GetCFL(MESH_0));
87+
}
88+
7589
void CHeatOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolver **solver) {
7690

7791
CSolver* heat_solver = solver[HEAT_SOL];
7892

79-
SetHistoryOutputValue("TOTAL_HEATFLUX", heat_solver->GetTotal_HeatFlux());
80-
SetHistoryOutputValue("MAXIMUM_HEATFLUX", heat_solver->GetTotal_MaxHeatFlux());
81-
SetHistoryOutputValue("AVG_TEMPERATURE", heat_solver->GetTotal_AvgTemperature());
82-
SetHistoryOutputValue("RMS_TEMPERATURE", log10(heat_solver->GetRes_RMS(0)));
83-
SetHistoryOutputValue("MAX_TEMPERATURE", log10(heat_solver->GetRes_Max(0)));
84-
if (multiZone)
85-
SetHistoryOutputValue("BGS_TEMPERATURE", log10(heat_solver->GetRes_BGS(0)));
93+
LoadHistoryDataImpl(config, geometry, solver, this);
8694

8795
SetHistoryOutputValue("LINSOL_ITER", heat_solver->GetIterLinSolver());
8896
SetHistoryOutputValue("LINSOL_RESIDUAL", log10(heat_solver->GetResLinSolver()));
89-
SetHistoryOutputValue("CFL_NUMBER", config->GetCFL(MESH_0));
9097

9198
ComputeSimpleCustomOutputs(config);
9299

93100
/*--- Keep this as last, since it uses the history values that were set. ---*/
94101
SetCustomAndComboObjectives(HEAT_SOL, config, solver);
95102
}
96103

104+
void CHeatOutput::SetHistoryOutputFieldsImpl(CConfig *config, COutput* output) {
97105

98-
void CHeatOutput::SetHistoryOutputFields(CConfig *config){
106+
output->AddHistoryOutput("RMS_TEMPERATURE", "rms[T]", ScreenOutputFormat::FIXED, "RMS_RES", "Root mean square residual of the temperature", HistoryFieldType::RESIDUAL);
107+
output->AddHistoryOutput("MAX_TEMPERATURE", "max[T]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the temperature", HistoryFieldType::RESIDUAL);
108+
output->AddHistoryOutput("BGS_TEMPERATURE", "bgs[T]", ScreenOutputFormat::FIXED, "BGS_RES", "Block-Gauss-Seidel residual of the temperature", HistoryFieldType::RESIDUAL);
99109

100-
AddHistoryOutput("LINSOL_ITER", "LinSolIter", ScreenOutputFormat::INTEGER, "LINSOL", "Number of iterations of the linear solver.");
101-
AddHistoryOutput("LINSOL_RESIDUAL", "LinSolRes", ScreenOutputFormat::FIXED, "LINSOL", "Residual of the linear solver.");
110+
output->AddHistoryOutput("TOTAL_HEATFLUX", "HF", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Total heatflux on all surfaces defined in MARKER_MONITORING", HistoryFieldType::COEFFICIENT);
111+
output->AddHistoryOutput("AVG_TEMPERATURE", "AvgTemp", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Average temperature on all surfaces defined in MARKER_MONITORING", HistoryFieldType::COEFFICIENT);
112+
output->AddHistoryOutput("CFL_NUMBER", "CFL number", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current value of the CFL number");
113+
}
102114

103-
AddHistoryOutput("RMS_TEMPERATURE", "rms[T]", ScreenOutputFormat::FIXED, "RMS_RES", "Root mean square residual of the temperature", HistoryFieldType::RESIDUAL);
104-
AddHistoryOutput("MAX_TEMPERATURE", "max[T]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the temperature", HistoryFieldType::RESIDUAL);
105-
AddHistoryOutput("BGS_TEMPERATURE", "bgs[T]", ScreenOutputFormat::FIXED, "BGS_RES", "Block-Gauss-Seidel residual of the temperature", HistoryFieldType::RESIDUAL);
115+
void CHeatOutput::SetHistoryOutputFields(CConfig *config) {
106116

107-
AddHistoryOutput("TOTAL_HEATFLUX", "HF", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Total heatflux on all surfaces defined in MARKER_MONITORING", HistoryFieldType::COEFFICIENT);
108-
AddHistoryOutput("MAXIMUM_HEATFLUX", "MaxHF", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Maximum heatflux on all surfaces defined in MARKER_MONITORING", HistoryFieldType::COEFFICIENT);
109-
AddHistoryOutput("AVG_TEMPERATURE", "AvgTemp", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Average temperature on all surfaces defined in MARKER_MONITORING", HistoryFieldType::COEFFICIENT);
110-
AddHistoryOutput("CFL_NUMBER", "CFL number", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current value of the CFL number");
117+
SetHistoryOutputFieldsImpl(config, this);
118+
119+
AddHistoryOutput("LINSOL_ITER", "LinSolIter", ScreenOutputFormat::INTEGER, "LINSOL", "Number of iterations of the linear solver.");
120+
AddHistoryOutput("LINSOL_RESIDUAL", "LinSolRes", ScreenOutputFormat::FIXED, "LINSOL", "Residual of the linear solver.");
111121

112122
AddHistoryOutput("COMBO", "ComboObj", ScreenOutputFormat::SCIENTIFIC, "COMBO", "Combined obj. function value.", HistoryFieldType::COEFFICIENT);
113123
}

0 commit comments

Comments
 (0)