Skip to content

Commit 881ed0c

Browse files
committed
refactor output
1 parent e3fdfc2 commit 881ed0c

File tree

8 files changed

+120
-78
lines changed

8 files changed

+120
-78
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: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,12 @@ class CFEASolver : public CFEASolverBase {
101101
bool body_forces = false; /*!< \brief Whether any body force is active. */
102102

103103
/*!
104-
* \brief Pointer to the heat solver for coupled simulations.
105-
*
106-
* This member stores a pointer to the heat solver, which handles
107-
* the solution of the heat equation in weakly coupled simulations.
108-
* It is initialized during the preprocessing step if the configuration
109-
* enables the weak coupling of heat and elasticity solvers. This solver
110-
* provides temperature information to the finite element elasticity solver
111-
* and contributes to the coupled residuals.
112-
*
113-
* The `heat_solver` pointer remains `nullptr` when the heat solver is not enabled
114-
* in the configuration. Memory for the heat solver is dynamically allocated
115-
* during initialization and released in the destructor to avoid memory leaks.
116-
*/
104+
* \brief Pointer to the heat solver for coupled simulations.
105+
*
106+
* This member stores a pointer to the heat solver, which handles the solution of the heat equation in weakly coupled
107+
* simulations. It is initialized during the preprocessing step if the configuration enables the weak coupling of
108+
* heat and elasticity solvers. This solver provides temperature information to the finite element elasticity solver.
109+
*/
117110
CSolver* heat_solver = nullptr;
118111

119112
/*!

SU2_CFD/src/iteration/CFEAIteration.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ 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()) {
51+
/*--- Add heat solver integration step. ---*/
52+
if (config[val_iZone]->GetWeakly_Coupled_Heat()) {
5353
config[val_iZone]->SetGlobalParam(MAIN_SOLVER::HEAT_EQUATION, RUNTIME_HEAT_SYS);
54-
integration[val_iZone][val_iInst][HEAT_SOL]->SingleGrid_Iteration(
55-
geometry, solver, numerics, config, RUNTIME_HEAT_SYS, val_iZone, val_iInst);
56-
}
54+
integration[val_iZone][val_iInst][HEAT_SOL]->SingleGrid_Iteration(geometry, solver, numerics, config,
55+
RUNTIME_HEAT_SYS, val_iZone, val_iInst);
56+
}
5757

5858
/*--- FEA equations ---*/
5959
config[val_iZone]->SetGlobalParam(MAIN_SOLVER::FEM_ELASTICITY, RUNTIME_FEA_SYS);

SU2_CFD/src/output/CElasticityOutput.cpp

Lines changed: 40 additions & 30 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

@@ -148,20 +146,18 @@ void CElasticityOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS
148146
SetHistoryOutputValue("TOPOL_DISCRETENESS", fea_solver->GetTotal_OFDiscreteness());
149147
}
150148

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+
151156
ComputeSimpleCustomOutputs(config);
152157

153158
/*--- Keep this as last, since it uses the history values that were set. ---*/
154159
SetCustomAndComboObjectives(FEA_SOL, config, solver);
155160

156-
/*--- Add heat solver data if available ---*/
157-
if (heat_solver) {
158-
SetHistoryOutputValue("RMS_TEMPERATURE", log10(heat_solver->GetRes_RMS(0)));
159-
SetHistoryOutputValue("MAX_TEMPERATURE", log10(heat_solver->GetRes_Max(0)));
160-
SetHistoryOutputValue("AVG_TEMPERATURE", heat_solver->GetTotal_AvgTemperature());
161-
SetHistoryOutputValue("TOTAL_HEATFLUX", heat_solver->GetTotal_HeatFlux());
162-
SetHistoryOutputValue("MAXIMUM_HEATFLUX", heat_solver->GetTotal_MaxHeatFlux());
163-
}
164-
165161
}
166162

167163
void CElasticityOutput::SetHistoryOutputFields(CConfig *config) {
@@ -199,14 +195,11 @@ void CElasticityOutput::SetHistoryOutputFields(CConfig *config) {
199195
}
200196
AddHistoryOutput("COMBO", "ComboObj", ScreenOutputFormat::SCIENTIFIC, "COMBO", "Combined obj. function value.", HistoryFieldType::COEFFICIENT);
201197

202-
if (config->GetWeakly_Coupled_Heat()) {
203-
AddHistoryOutput("RMS_TEMPERATURE", "rms[T]", ScreenOutputFormat::FIXED, "RMS_RES", "Root mean square residual of the temperature", HistoryFieldType::RESIDUAL);
204-
AddHistoryOutput("MAX_TEMPERATURE", "max[T]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the temperature", HistoryFieldType::RESIDUAL);
205-
AddHistoryOutput("AVG_TEMPERATURE", "avg[T]", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Average temperature on all surfaces", HistoryFieldType::COEFFICIENT);
206-
AddHistoryOutput("TOTAL_HEATFLUX", "HF", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Total heat flux on all surfaces", HistoryFieldType::COEFFICIENT);
207-
AddHistoryOutput("MAXIMUM_HEATFLUX", "MaxHF", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Maximum heat flux on all surfaces", HistoryFieldType::COEFFICIENT);
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.");
208202
}
209-
210203
}
211204

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

236233
SetVolumeOutputValue("STRESS-XX", iPoint, Node_Struc->GetStress_FEM(iPoint)[0]);
237234
SetVolumeOutputValue("STRESS-YY", iPoint, Node_Struc->GetStress_FEM(iPoint)[1]);
@@ -277,6 +274,10 @@ void CElasticityOutput::SetVolumeOutputFields(CConfig *config){
277274
if (nDim == 3) AddVolumeOutput("ACCELERATION-Z", "Acceleration_z", "SOLUTION", "z-component of the acceleration vector");
278275
}
279276

277+
if (coupled_heat) {
278+
AddVolumeOutput("TEMPERATURE", "Temperature", "SOLUTION", "Temperature");
279+
}
280+
280281
AddVolumeOutput("STRESS-XX", "Sxx", "STRESS", "x-component of the normal stress vector");
281282
AddVolumeOutput("STRESS-YY", "Syy", "STRESS", "y-component of the normal stress vector");
282283
AddVolumeOutput("STRESS-XY", "Sxy", "STRESS", "xy shear stress component");
@@ -293,8 +294,8 @@ void CElasticityOutput::SetVolumeOutputFields(CConfig *config){
293294
AddVolumeOutput("TOPOL_DENSITY", "Topology_Density", "TOPOLOGY", "filtered topology density");
294295
}
295296

296-
if (config->GetWeakly_Coupled_Heat()) {
297-
AddVolumeOutput("TEMPERATURE", "Temperature", "SOLUTION", "Temperature");
297+
if (coupled_heat) {
298+
AddVolumeOutput("HEAT_FLUX", "Heat_Flux", "PRIMITIVE", "Heatflux");
298299
AddVolumeOutput("RES_TEMPERATURE", "Residual_Temperature", "RESIDUAL", "Residual of the temperature");
299300
}
300301

@@ -305,3 +306,12 @@ bool CElasticityOutput::SetInitResiduals(const CConfig *config){
305306
return (config->GetTime_Domain() == NO && (curInnerIter == 0));
306307

307308
}
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: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,42 +72,54 @@ 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("MAXIMUM_HEATFLUX", heat_solver->GetTotal_MaxHeatFlux());
81+
output->SetHistoryOutputValue("AVG_TEMPERATURE", heat_solver->GetTotal_AvgTemperature());
82+
output->SetHistoryOutputValue("RMS_TEMPERATURE", log10(heat_solver->GetRes_RMS(0)));
83+
output->SetHistoryOutputValue("MAX_TEMPERATURE", log10(heat_solver->GetRes_Max(0)));
84+
if (config->GetMultizone_Problem()) {
85+
output->SetHistoryOutputValue("BGS_TEMPERATURE", log10(heat_solver->GetRes_BGS(0)));
86+
}
87+
output->SetHistoryOutputValue("CFL_NUMBER", config->GetCFL(MESH_0));
88+
}
89+
7590
void CHeatOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolver **solver) {
7691

7792
CSolver* heat_solver = solver[HEAT_SOL];
7893

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)));
94+
LoadHistoryDataImpl(config, geometry, solver, this);
8695

8796
SetHistoryOutputValue("LINSOL_ITER", heat_solver->GetIterLinSolver());
8897
SetHistoryOutputValue("LINSOL_RESIDUAL", log10(heat_solver->GetResLinSolver()));
89-
SetHistoryOutputValue("CFL_NUMBER", config->GetCFL(MESH_0));
9098

9199
ComputeSimpleCustomOutputs(config);
92100

93101
/*--- Keep this as last, since it uses the history values that were set. ---*/
94102
SetCustomAndComboObjectives(HEAT_SOL, config, solver);
95103
}
96104

105+
void CHeatOutput::SetHistoryOutputFieldsImpl(CConfig *config, COutput* output) {
97106

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

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.");
111+
output->AddHistoryOutput("TOTAL_HEATFLUX", "HF", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Total heatflux on all surfaces defined in MARKER_MONITORING", HistoryFieldType::COEFFICIENT);
112+
output->AddHistoryOutput("MAXIMUM_HEATFLUX", "MaxHF", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Maximum heatflux on all surfaces defined in MARKER_MONITORING", HistoryFieldType::COEFFICIENT);
113+
output->AddHistoryOutput("AVG_TEMPERATURE", "AvgTemp", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Average temperature on all surfaces defined in MARKER_MONITORING", HistoryFieldType::COEFFICIENT);
114+
output->AddHistoryOutput("CFL_NUMBER", "CFL number", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current value of the CFL number");
115+
}
102116

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);
117+
void CHeatOutput::SetHistoryOutputFields(CConfig *config) {
106118

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");
119+
SetHistoryOutputFieldsImpl(config, this);
120+
121+
AddHistoryOutput("LINSOL_ITER", "LinSolIter", ScreenOutputFormat::INTEGER, "LINSOL", "Number of iterations of the linear solver.");
122+
AddHistoryOutput("LINSOL_RESIDUAL", "LinSolRes", ScreenOutputFormat::FIXED, "LINSOL", "Residual of the linear solver.");
111123

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

0 commit comments

Comments
 (0)