Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions Common/include/linear_algebra/CSysSolve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ class CSysSolve {

private:

bool mesh_deform; /*!< \brief Operate in mesh deformation mode, changes the source of solver options. */
ScalarType Residual; /*!< \brief Residual at the end of a call to Solve. */
bool mesh_deform; /*!< \brief Operate in mesh deformation mode, changes the source of solver options. */
ScalarType Residual=1e-20; /*!< \brief Residual at the end of a call to Solve or Solve_b. */
unsigned long Iterations=0;/*!< \brief Iterations done in Solve or Solve_b. */

mutable bool cg_ready; /*!< \brief Indicate if memory used by CG is allocated. */
mutable bool bcg_ready; /*!< \brief Indicate if memory used by BCGSTAB is allocated. */
Expand Down Expand Up @@ -313,9 +314,15 @@ class CSysSolve {
unsigned long Solve_b(MatrixType & Jacobian, const CSysVector<su2double> & LinSysRes, CSysVector<su2double> & LinSysSol,
CGeometry *geometry, CConfig *config);

/*!
* \brief Get the number of iterations.
* \return The number of iterations done by Solve or Solve_b
*/
inline unsigned long GetIterations(void) const { return Iterations; }

/*!
* \brief Get the final residual.
* \return The residual at the end of Solve
* \return The residual at the end of Solve or Solve_b
*/
inline ScalarType GetResidual(void) const { return Residual; }

Expand Down
9 changes: 8 additions & 1 deletion Common/src/linear_algebra/CSysSolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,13 +937,17 @@ unsigned long CSysSolve<ScalarType>::Solve(CSysMatrix<ScalarType> & Jacobian, co
Jacobian.BuildPastixPreconditioner(geometry, config, KindSolver);
Jacobian.ComputePastixPreconditioner(*LinSysRes_ptr, *LinSysSol_ptr, geometry, config);
IterLinSol = 1;
residual = 1e-20;
break;
default:
SU2_MPI::Error("Unknown type of linear solver.",CURRENT_FUNCTION);
}

SU2_OMP_MASTER
Residual = residual;
{
Residual = residual;
Iterations = IterLinSol;
}

HandleTemporariesOut(LinSysSol);

Expand Down Expand Up @@ -1074,6 +1078,7 @@ unsigned long CSysSolve<ScalarType>::Solve_b(CSysMatrix<ScalarType> & Jacobian,
Jacobian.BuildPastixPreconditioner(geometry, config, KindSolver, RequiresTranspose);
Jacobian.ComputePastixPreconditioner(*LinSysRes_ptr, *LinSysSol_ptr, geometry, config);
IterLinSol = 1;
Residual = 1e-20;
break;
default:
SU2_MPI::Error("The specified linear solver is not yet implemented for the discrete adjoint method.", CURRENT_FUNCTION);
Expand All @@ -1084,8 +1089,10 @@ unsigned long CSysSolve<ScalarType>::Solve_b(CSysMatrix<ScalarType> & Jacobian,

delete precond;

Iterations = IterLinSol;
return IterLinSol;
#else
Iterations = 0;
return 0;
#endif
}
Expand Down
6 changes: 6 additions & 0 deletions SU2_CFD/src/output/CAdjElasticityOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ void CAdjElasticityOutput::SetHistoryOutputFields(CConfig *config){

AddHistoryOutput("COMBO", "ObjFun", ScreenOutputFormat::SCIENTIFIC, "COMBO", "", HistoryFieldType::COEFFICIENT);

AddHistoryOutput("LINSOL_ITER", "LinSolIter", ScreenOutputFormat::INTEGER, "LINSOL", "Number of iterations of the linear solver.");
AddHistoryOutput("LINSOL_RESIDUAL", "LinSolRes", ScreenOutputFormat::FIXED, "LINSOL", "Residual of the linear solver.");

}

inline void CAdjElasticityOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolver **solver) {
Expand Down Expand Up @@ -136,6 +139,9 @@ inline void CAdjElasticityOutput::LoadHistoryData(CConfig *config, CGeometry *ge

SetHistoryOutputValue("COMBO", solver[FEA_SOL]->GetTotal_ComboObj());

SetHistoryOutputValue("LINSOL_ITER", solver[ADJFEA_SOL]->GetIterLinSolver());
SetHistoryOutputValue("LINSOL_RESIDUAL", log10(solver[ADJFEA_SOL]->GetResLinSolver()));

}

void CAdjElasticityOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint){
Expand Down
19 changes: 18 additions & 1 deletion SU2_CFD/src/output/CAdjFlowCompOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,21 @@ void CAdjFlowCompOutput::SetHistoryOutputFields(CConfig *config){
AddHistoryOutput("SENS_TEMP", "Sens_Temp", ScreenOutputFormat::SCIENTIFIC, "SENSITIVITY", "Sensitivity of the objective function with respect to the far-field temperature.", HistoryFieldType::COEFFICIENT);
/// END_GROUP

AddHistoryOutput("LINSOL_ITER", "LinSolIter", ScreenOutputFormat::INTEGER, "LINSOL", "Number of iterations of the linear solver.");
AddHistoryOutput("LINSOL_RESIDUAL", "LinSolRes", ScreenOutputFormat::FIXED, "LINSOL", "Residual of the linear solver.");

if (config->GetDeform_Mesh()){
AddHistoryOutput("DEFORM_ITER", "DeformIter", ScreenOutputFormat::INTEGER, "DEFORM", "Linear solver iterations for the mesh deformation");
AddHistoryOutput("DEFORM_RESIDUAL", "DeformRes", ScreenOutputFormat::FIXED, "DEFORM", "Residual of the linear solver for the mesh deformation");
}

}

void CAdjFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolver **solver){

CSolver* adjflow_solver = solver[ADJFLOW_SOL];
CSolver* adjturb_solver = solver[ADJTURB_SOL];
CSolver* mesh_solver = solver[MESH_SOL];

SetHistoryOutputValue("RMS_ADJ_DENSITY", log10(adjflow_solver->GetRes_RMS(0)));
SetHistoryOutputValue("RMS_ADJ_MOMENTUM-X", log10(adjflow_solver->GetRes_RMS(1)));
Expand Down Expand Up @@ -242,7 +251,7 @@ void CAdjFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, C
break;
case SST:
SetHistoryOutputValue("MAX_ADJ_TKE", log10(adjturb_solver->GetRes_Max(0)));
SetHistoryOutputValue("MAX_ADJ_DISSIPATION", log10(adjturb_solver->GetRes_Max(1)));
SetHistoryOutputValue("MAX_ADJ_DISSIPATION", log10(adjturb_solver->GetRes_Max(1)));
break;
default: break;
}
Expand Down Expand Up @@ -278,6 +287,14 @@ void CAdjFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, C
SetHistoryOutputValue("SENS_PRESS", adjflow_solver->GetTotal_Sens_Press());
SetHistoryOutputValue("SENS_TEMP", adjflow_solver->GetTotal_Sens_Temp());

SetHistoryOutputValue("LINSOL_ITER", adjflow_solver->GetIterLinSolver());
SetHistoryOutputValue("LINSOL_RESIDUAL", log10(adjflow_solver->GetResLinSolver()));

if (config->GetDeform_Mesh()) {
SetHistoryOutputValue("DEFORM_ITER", mesh_solver->System.GetIterations());
SetHistoryOutputValue("DEFORM_RESIDUAL", log10(mesh_solver->System.GetResidual()));
}

}

void CAdjFlowCompOutput::SetVolumeOutputFields(CConfig *config){
Expand Down
19 changes: 18 additions & 1 deletion SU2_CFD/src/output/CAdjFlowIncOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,23 @@ void CAdjFlowIncOutput::SetHistoryOutputFields(CConfig *config){
AddHistoryOutput("SENS_PRESS_OUT", "Sens_Pout", ScreenOutputFormat::SCIENTIFIC, "SENSITIVITY", "Sensitivity of the objective function with respect to the outlet pressure.", HistoryFieldType::COEFFICIENT);
/// END_GROUP

AddHistoryOutput("LINSOL_ITER", "LinSolIter", ScreenOutputFormat::INTEGER, "LINSOL", "Number of iterations of the linear solver.");
AddHistoryOutput("LINSOL_RESIDUAL", "LinSolRes", ScreenOutputFormat::FIXED, "LINSOL", "Residual of the linear solver.");

if (config->GetDeform_Mesh()){
AddHistoryOutput("DEFORM_ITER", "DeformIter", ScreenOutputFormat::INTEGER, "DEFORM", "Linear solver iterations for the mesh deformation");
AddHistoryOutput("DEFORM_RESIDUAL", "DeformRes", ScreenOutputFormat::FIXED, "DEFORM", "Residual of the linear solver for the mesh deformation");
}

}

void CAdjFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolver **solver) {

CSolver* adjflow_solver = solver[ADJFLOW_SOL];
CSolver* adjturb_solver = solver[ADJTURB_SOL];
CSolver* adjheat_solver = solver[ADJHEAT_SOL];
CSolver* adjrad_solver = solver[ADJRAD_SOL];
CSolver* adjrad_solver = solver[ADJRAD_SOL];
CSolver* mesh_solver = solver[MESH_SOL];

SetHistoryOutputValue("RMS_ADJ_PRESSURE", log10(adjflow_solver->GetRes_RMS(0)));
SetHistoryOutputValue("RMS_ADJ_VELOCITY-X", log10(adjflow_solver->GetRes_RMS(1)));
Expand Down Expand Up @@ -308,6 +317,14 @@ void CAdjFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS
SetHistoryOutputValue("SENS_VEL_IN", adjflow_solver->GetTotal_Sens_ModVel());
SetHistoryOutputValue("SENS_PRESS_OUT", adjflow_solver->GetTotal_Sens_BPress());

SetHistoryOutputValue("LINSOL_ITER", adjflow_solver->GetIterLinSolver());
SetHistoryOutputValue("LINSOL_RESIDUAL", log10(adjflow_solver->GetResLinSolver()));

if (config->GetDeform_Mesh()) {
SetHistoryOutputValue("DEFORM_ITER", mesh_solver->System.GetIterations());
SetHistoryOutputValue("DEFORM_RESIDUAL", log10(mesh_solver->System.GetResidual()));
}

}

void CAdjFlowIncOutput::SetVolumeOutputFields(CConfig *config){
Expand Down
18 changes: 16 additions & 2 deletions SU2_CFD/src/output/CAdjHeatOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ void CAdjHeatOutput::SetHistoryOutputFields(CConfig *config){
AddHistoryOutput("SENS_GEO", "Sens_Geo", ScreenOutputFormat::SCIENTIFIC, "SENSITIVITY", "Sum of the geometrical sensitivities on all markers set in MARKER_MONITORING.", HistoryFieldType::COEFFICIENT);
/// END_GROUP

AddHistoryOutput("LINSOL_ITER", "LinSolIter", ScreenOutputFormat::INTEGER, "LINSOL", "Number of iterations of the linear solver.");
AddHistoryOutput("LINSOL_RESIDUAL", "LinSolRes", ScreenOutputFormat::FIXED, "LINSOL", "Residual of the linear solver.");

if (config->GetDeform_Mesh()){
AddHistoryOutput("DEFORM_ITER", "DeformIter", ScreenOutputFormat::INTEGER, "DEFORM", "Linear solver iterations for the mesh deformation");
AddHistoryOutput("DEFORM_RESIDUAL", "DeformRes", ScreenOutputFormat::FIXED, "DEFORM", "Residual of the linear solver for the mesh deformation");
}

}

void CAdjHeatOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolver **solver) {
Expand All @@ -126,6 +134,13 @@ void CAdjHeatOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolv

SetHistoryOutputValue("SENS_GEO", adjheat_solver->GetTotal_Sens_Geo());

SetHistoryOutputValue("LINSOL_ITER", adjheat_solver->GetIterLinSolver());
SetHistoryOutputValue("LINSOL_RESIDUAL", log10(adjheat_solver->GetResLinSolver()));

if (config->GetDeform_Mesh()) {
SetHistoryOutputValue("DEFORM_ITER", solver[MESH_SOL]->System.GetIterations());
SetHistoryOutputValue("DEFORM_RESIDUAL", log10(solver[MESH_SOL]->System.GetResidual()));
}

}

Expand Down Expand Up @@ -174,7 +189,7 @@ void CAdjHeatOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve
if (nDim == 3)
SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(iPoint, 2));

SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjHeat->GetSolution(iPoint, 0));
SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjHeat->GetSolution(iPoint, 0));

// Residuals
SetVolumeOutputValue("RES_ADJ_TEMPERATURE", iPoint, Node_AdjHeat->GetSolution(iPoint, 0) - Node_AdjHeat->GetSolution_Old(iPoint, 0));
Expand All @@ -192,4 +207,3 @@ void CAdjHeatOutput::LoadSurfaceData(CConfig *config, CGeometry *geometry, CSolv

}


4 changes: 2 additions & 2 deletions SU2_CFD/src/output/CElasticityOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ void CElasticityOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS

void CElasticityOutput::SetHistoryOutputFields(CConfig *config){

AddHistoryOutput("LINSOL_ITER", "LinSolIter", ScreenOutputFormat::INTEGER, "LINSOL", "Number of iterations of the linear solver.");
AddHistoryOutput("LINSOL_RESIDUAL", "LinSolRes", ScreenOutputFormat::FIXED, "LINSOL", "Residual of the linear solver.");
AddHistoryOutput("LINSOL_ITER", "LinSolIter", ScreenOutputFormat::INTEGER, "LINSOL", "Number of iterations of the linear solver.");
AddHistoryOutput("LINSOL_RESIDUAL", "LinSolRes", ScreenOutputFormat::FIXED, "LINSOL", "Residual of the linear solver.");

// Residuals

Expand Down
4 changes: 0 additions & 4 deletions SU2_CFD/src/output/CFlowCompFEMOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ void CFlowCompFEMOutput::SetHistoryOutputFields(CConfig *config){
AddHistoryOutput("MAX_ENERGY", "max[RhoE]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the energy.", HistoryFieldType::RESIDUAL);
/// END_GROUP

/// DESCRIPTION: Linear solver iterations
AddHistoryOutput("LINSOL_ITER", "Linear_Solver_Iterations", ScreenOutputFormat::INTEGER, "LINSOL_ITER", "Number of iterations of the linear solver.");

AddHistoryOutput("CFL_NUMBER", "CFL number", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current value of the CFL number");

/*--- Add analyze surface history fields --- */
Expand Down Expand Up @@ -263,7 +260,6 @@ void CFlowCompFEMOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, C
}

SetHistoryOutputValue("AOA", config->GetAoA());
SetHistoryOutputValue("LINSOL_ITER", flow_solver->GetIterLinSolver());
SetHistoryOutputValue("CFL_NUMBER", config->GetCFL(MESH_0));

/*--- Set the analyse surface history values --- */
Expand Down
12 changes: 7 additions & 5 deletions SU2_CFD/src/output/CHeatOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,30 +82,32 @@ void CHeatOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolver

CSolver* heat_solver = solver[HEAT_SOL];

SetHistoryOutputValue("TOTAL_HEATFLUX", heat_solver->GetTotal_HeatFlux());
SetHistoryOutputValue("TOTAL_HEATFLUX", heat_solver->GetTotal_HeatFlux());
SetHistoryOutputValue("HEATFLUX_MAX", heat_solver->GetTotal_MaxHeatFlux());
SetHistoryOutputValue("AVG_TEMPERATURE", heat_solver->GetTotal_AvgTemperature());
SetHistoryOutputValue("AVG_TEMPERATURE", heat_solver->GetTotal_AvgTemperature());
SetHistoryOutputValue("RMS_TEMPERATURE", log10(heat_solver->GetRes_RMS(0)));
SetHistoryOutputValue("MAX_TEMPERATURE", log10(heat_solver->GetRes_Max(0)));
if (multiZone)
SetHistoryOutputValue("BGS_TEMPERATURE", log10(heat_solver->GetRes_BGS(0)));

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

}


void CHeatOutput::SetHistoryOutputFields(CConfig *config){

AddHistoryOutput("LINSOL_ITER", "Linear_Solver_Iterations", ScreenOutputFormat::INTEGER, "LINSOL_ITER", "Linear solver iterations");
AddHistoryOutput("LINSOL_ITER", "LinSolIter", ScreenOutputFormat::INTEGER, "LINSOL", "Number of iterations of the linear solver.");
AddHistoryOutput("LINSOL_RESIDUAL", "LinSolRes", ScreenOutputFormat::FIXED, "LINSOL", "Residual of the linear solver.");

AddHistoryOutput("RMS_TEMPERATURE", "rms[T]", ScreenOutputFormat::FIXED, "RMS_RES", "Root mean square residual of the temperature", HistoryFieldType::RESIDUAL);
AddHistoryOutput("MAX_TEMPERATURE", "max[T]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the temperature", HistoryFieldType::RESIDUAL);
AddHistoryOutput("BGS_TEMPERATURE", "bgs[T]", ScreenOutputFormat::FIXED, "BGS_RES", "Block-Gauss seidel residual of the temperature", HistoryFieldType::RESIDUAL);

AddHistoryOutput("TOTAL_HEATFLUX", "HF", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Total heatflux on all surfaces defined in MARKER_MONITORING", HistoryFieldType::COEFFICIENT);
AddHistoryOutput("HEATFLUX_MAX", "MaxHF", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Total maximal heatflux on all surfaces defined in MARKER_MONITORING", HistoryFieldType::COEFFICIENT);
AddHistoryOutput("TOTAL_HEATFLUX", "HF", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Total heatflux on all surfaces defined in MARKER_MONITORING", HistoryFieldType::COEFFICIENT);
AddHistoryOutput("HEATFLUX_MAX", "MaxHF", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Total maximal heatflux on all surfaces defined in MARKER_MONITORING", HistoryFieldType::COEFFICIENT);
AddHistoryOutput("AVG_TEMPERATURE", "AvgTemp", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Total average temperature on all surfaces defined in MARKER_MONITORING", HistoryFieldType::COEFFICIENT);
AddHistoryOutput("CFL_NUMBER", "CFL number", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current value of the CFL number");

Expand Down
3 changes: 3 additions & 0 deletions SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,9 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co

SetResidual_RMS(geometry, config);

SetIterLinSolver(direct_solver->System.GetIterations());
SetResLinSolver(direct_solver->System.GetResidual());

}

void CDiscAdjFEASolver::ExtractAdjoint_Variables(CGeometry *geometry, CConfig *config){
Expand Down
3 changes: 3 additions & 0 deletions SU2_CFD/src/solvers/CDiscAdjSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,9 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi

SetResidual_RMS(geometry, config);

SetIterLinSolver(direct_solver->System.GetIterations());
SetResLinSolver(direct_solver->System.GetResidual());

if (time_n_needed) {
for (auto iPoint = 0u; iPoint < nPoint; iPoint++) {

Expand Down