Skip to content
Open
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
26 changes: 26 additions & 0 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@ class CConfig {
TURBOMACHINERY_TYPE *Kind_TurboMachinery;
su2vector<TURBO_INTERFACE_KIND> Kind_TurboInterface;

/* Turbomachinery objective functions */
su2double *EntropyGeneration;
su2double *TotalPressureLoss;
su2double *KineticEnergyLoss;

/* Gradient smoothing options */
su2double SmoothingEps1; /*!< \brief Parameter for the identity part in gradient smoothing. */
su2double SmoothingEps2; /*!< \brief Parameter for the Laplace part in gradient smoothing. */
Expand Down Expand Up @@ -8164,6 +8169,27 @@ class CConfig {
* \param[in] val_surface_species_variance - Value of the species variance.
*/
void SetSurface_Species_Variance(unsigned short val_marker, su2double val_surface_species_variance) { Surface_Species_Variance[val_marker] = val_surface_species_variance; }

/*!
* \brief Set entropy generation for a turbomachinery zone
* \param[in] val_iZone - zone index
* \param[in] val_entropy_generation - value of entropy generation
*/
void SetEntropyGeneration(unsigned short val_iZone, su2double val_entropy_generation) { EntropyGeneration[val_iZone] = val_entropy_generation; }

/*!
* \brief Get total pressure loss for a turbomachinery zone
* \param[in] val_iZone - zone index
* \param[in] val_total_pressure_loss - value of total pressure loss
*/
void SetTotalPressureLoss(unsigned short val_iZone, su2double val_total_pressure_loss) { TotalPressureLoss[val_iZone] = val_total_pressure_loss; }

/*!
* \brief Get kinetic energy loss for a turbomachinery zone
* \param[in] val_iZone - zone index
* \param[in] val_kinetic_energy_loss - value of kinetic energy loss
*/
void SetKineticEnergyLoss(unsigned short val_iZone, su2double val_kinetic_energy_loss) { KineticEnergyLoss[val_iZone] = val_kinetic_energy_loss; }

/*!
* \brief Get the back pressure (static) at an outlet boundary.
Expand Down
2 changes: 1 addition & 1 deletion Common/include/geometry/CGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ class CGeometry {
inline virtual void GatherInOutAverageValues(CConfig* config, bool allocate) {}

/*!
* \brief Store all the turboperformance in the solver in ZONE_0.
* \brief Store all the turboperformance in the solver in final zone.
* \param[in] donor_geometry - Solution from the donor mesh.
* \param[in] target_geometry - Solution from the target mesh.
* \param[in] donorZone - counter of the donor solution
Expand Down
6 changes: 6 additions & 0 deletions Common/include/option_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2067,6 +2067,9 @@ enum ENUM_OBJECTIVE {
TOPOL_DISCRETENESS = 63, /*!< \brief Measure of the discreteness of the current topology. */
TOPOL_COMPLIANCE = 64, /*!< \brief Measure of the discreteness of the current topology. */
STRESS_PENALTY = 65, /*!< \brief Penalty function of VM stresses above a maximum value. */
ENTROPY_GENERATION = 80, /*!< \brief Entropy generation turbomachinery objective function. */
TOTAL_PRESSURE_LOSS = 81, /*!< \brief Total pressure loss turbomachinery objective function. */
KINETIC_ENERGY_LOSS = 82 /*!< \breif Kinetic energy loss coefficient turbomachinery objective function. */
};
static const MapType<std::string, ENUM_OBJECTIVE> Objective_Map = {
MakePair("DRAG", DRAG_COEFFICIENT)
Expand Down Expand Up @@ -2109,6 +2112,9 @@ static const MapType<std::string, ENUM_OBJECTIVE> Objective_Map = {
MakePair("TOPOL_DISCRETENESS", TOPOL_DISCRETENESS)
MakePair("TOPOL_COMPLIANCE", TOPOL_COMPLIANCE)
MakePair("STRESS_PENALTY", STRESS_PENALTY)
MakePair("ENTROPY_GENERATION", ENTROPY_GENERATION)
MakePair("TOTAL_PRESSURE_LOSS", TOTAL_PRESSURE_LOSS)
MakePair("KINETIC_ENERGY_LOSS", KINETIC_ENERGY_LOSS)
};

/*!
Expand Down
22 changes: 22 additions & 0 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,11 @@ void CConfig::SetPointersNull() {
nBlades = nullptr;
FreeStreamTurboNormal = nullptr;

/*--- Turbomachinery Objective Functions ---*/
EntropyGeneration = nullptr;
TotalPressureLoss = nullptr;
KineticEnergyLoss = nullptr;

top_optim_kernels = nullptr;
top_optim_kernel_params = nullptr;
top_optim_filter_radius = nullptr;
Expand Down Expand Up @@ -3469,6 +3474,10 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
VolumeOutputFrequencies[iVolumeFreq] = Time_Domain ? 1 : 250;
}
}
} else if (Multizone_Problem && DiscreteAdjoint) {
SU2_MPI::Error(string("OUTPUT_WRT_FREQ cannot be specified for this solver "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SU2_MPI::Error(string("OUTPUT_WRT_FREQ cannot be specified for this solver "
SU2_MPI::Error("OUTPUT_WRT_FREQ cannot be specified for this solver "

"(writing of restart and sensitivity files not possible for multizone discrete adjoint during runtime yet).\n"
"Please remove this option from the config file, output files will be written when solver finalizes.\n"), CURRENT_FUNCTION);
Comment on lines +3479 to +3480
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm I'm pretty sure it is possible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one for @oleburghardt

Copy link
Contributor

@oleburghardt oleburghardt Mar 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and no, writing the files is fine, but the continuation of the multi-zone discrete adjoint solver is erratic. My guess is that some indices aren't cleared properly before re-recording the tape. (Writing adjoint solution variables to file only, without re-recording at all and without sensitivities, might give us some hints.)
The debug mode could eventually pin down where exactly things go wrong.

} else if (nVolumeOutputFrequencies < nVolumeOutputFiles) {
/*--- If there are fewer frequencies than files, repeat the last frequency.
* This is useful to define 1 frequency for the restart file and 1 frequency for all the visualization files. ---*/
Expand Down Expand Up @@ -6145,6 +6154,11 @@ void CConfig::SetMarkers(SU2_COMPONENT val_software) {
Marker_CfgFile_ZoneInterface[iMarker_CfgFile] = YES;
}

/*--- Allocate memory for turbomachinery objective functions ---*/
EntropyGeneration = new su2double[nZone] ();
TotalPressureLoss = new su2double[nZone] ();
KineticEnergyLoss = new su2double[nZone] ();

/*--- Identification of Turbomachinery markers and flag them---*/

for (iMarker_CfgFile = 0; iMarker_CfgFile < nMarker_CfgFile; iMarker_CfgFile++) {
Expand Down Expand Up @@ -6929,6 +6943,7 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) {
case TOPOL_DISCRETENESS: cout << "Topology discreteness objective function." << endl; break;
case TOPOL_COMPLIANCE: cout << "Topology compliance objective function." << endl; break;
case STRESS_PENALTY: cout << "Stress penalty objective function." << endl; break;
case ENTROPY_GENERATION: cout << "Entropy generation objective function." << endl; break;
}
}
else {
Expand Down Expand Up @@ -8493,6 +8508,10 @@ CConfig::~CConfig() {

delete [] nBlades;
delete [] FreeStreamTurboNormal;

delete [] EntropyGeneration;
delete [] TotalPressureLoss;
delete [] KineticEnergyLoss;
}

/*--- Input is the filename base, output is the completed filename. ---*/
Expand Down Expand Up @@ -8636,6 +8655,9 @@ string CConfig::GetObjFunc_Extension(string val_filename) const {
case TOPOL_DISCRETENESS: AdjExt = "_topdisc"; break;
case TOPOL_COMPLIANCE: AdjExt = "_topcomp"; break;
case STRESS_PENALTY: AdjExt = "_stress"; break;
case ENTROPY_GENERATION: AdjExt = "_entg"; break;
case TOTAL_PRESSURE_LOSS: AdjExt = "_tot_press_loss"; break;
case KINETIC_ENERGY_LOSS: AdjExt = "_kin_en_loss"; break;
}
}
else{
Expand Down
3 changes: 3 additions & 0 deletions Common/src/geometry/CPhysicalGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
#include "../../include/geometry/primal_grid/CPrism.hpp"
#include "../../include/geometry/primal_grid/CVertexMPI.hpp"

#include "../../../Common/include/tracy_structure.hpp"

#include <sys/types.h>
#include <sys/stat.h>
#include <iterator>
Expand Down Expand Up @@ -6326,6 +6328,7 @@ void CPhysicalGeometry::GatherInOutAverageValues(CConfig* config, bool allocate)

void CPhysicalGeometry::SetAvgTurboGeoValues(const CConfig* donor_config, CGeometry* donor_geometry,
unsigned short donorZone) {

unsigned short iSpan;
unsigned short nSpanMaxAllZones = donor_config->GetnSpanMaxAllZones();

Expand Down
16 changes: 5 additions & 11 deletions SU2_CFD/include/drivers/CDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class CDriver : public CDriverBase {
CInterface*** interface_container; /*!< \brief Definition of the interface of information and physics. */
bool dry_run; /*!< \brief Flag if SU2_CFD was started as dry-run via "SU2_CFD -d <config>.cfg" */

//std::shared_ptr<CTurbomachineryStagePerformance> TurbomachineryStagePerformance; /*!< \brief turbo stage performance calculator. */

public:
/*!
* \brief Constructor of the class.
Expand Down Expand Up @@ -198,13 +200,11 @@ class CDriver : public CDriverBase {
* \param[in] config - Definition of the particular problem.
* \param[in] solver - Container vector with all the solutions.
* \param[in] geometry - Geometrical definition of the problem.
* \param[in] interface_types - Type of coupling between the distinct (physical) zones.
* \param[in] interface - Class defining the physical transfer of information.
* \param[in] interpolation - Object defining the interpolation.
*/
void InitializeInterface(CConfig** config, CSolver***** solver, CGeometry**** geometry,
unsigned short** interface_types, CInterface*** interface,
vector<vector<unique_ptr<CInterpolator>>>& interpolation);
CInterface*** interface, vector<vector<unique_ptr<CInterpolator>>>& interpolation);

/*!
* \brief Definition and allocation of all solver classes.
Expand Down Expand Up @@ -290,17 +290,11 @@ class CDriver : public CDriverBase {
* \param[in] geometry - Geometrical definition of the problem.
* \param[in] solver - Container vector with all the solutions.
* \param[in] interface - Class defining the physical transfer of information.
* \param[in] iteration - Class defining the iteration strcuture.
* \param[in] dummy - Definition of dummy driver
*/
void PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, CSolver***** solver,
CInterface*** interface, bool dummy);

/*!
* \brief Ramp some simulation settings for turbomachinery problems.
* \param[in] iter - Iteration for the ramp (can be outer or time depending on type of simulation).
* \note TODO This is not compatible with inner iterations because they are delegated to the iteration class.
*/
void RampTurbomachineryValues(unsigned long iter);
CInterface*** interface, CIteration*** iteration, bool dummy);

/*!
* \brief A virtual member.
Expand Down
3 changes: 1 addition & 2 deletions SU2_CFD/include/drivers/CDriverBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ class CDriverBase {
nZone, /*!< \brief Total number of zones in the problem. */
nDim, /*!< \brief Number of dimensions. */
iInst, /*!< \brief Iterator on instance levels. */
*nInst, /*!< \brief Total number of instances in the problem (per zone). */
**interface_types; /*!< \brief Type of coupling between the distinct (physical) zones. */
*nInst; /*!< \brief Total number of instances in the problem (per zone). */

CConfig* driver_config = nullptr; /*!< \brief Definition of the driver configuration. */
COutput* driver_output = nullptr; /*!< \brief Definition of the driver output. */
Expand Down
9 changes: 0 additions & 9 deletions SU2_CFD/include/drivers/CMultizoneDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,6 @@ class CMultizoneDriver : public CDriver {
*/
bool TransferData(unsigned short donorZone, unsigned short targetZone);


/*!
* \brief Transfer the local turboperfomance quantities (for each blade row) from all the donorZones to the
* targetZone (ZONE_0).
* \note IMPORTANT: This approach of multi-zone performances rely upon the fact that turbomachinery markers follow
* the natural (stator-rotor) development of the real machine.
*/
void SetTurboPerformance();

/*!
* \brief Check the convergence at the outer level.
*/
Expand Down
13 changes: 13 additions & 0 deletions SU2_CFD/include/interfaces/CInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class CInterface {
su2double *Target_Variable = nullptr;
bool valAggregated = false;

unsigned short InterfaceType; /*!< \brief The type of interface. */

/*--- Mixing Plane interface variable ---*/
su2double *SpanValueCoeffTarget = nullptr;
unsigned short *SpanLevelDonor = nullptr;
Expand Down Expand Up @@ -224,4 +226,15 @@ class CInterface {
* \param[in] val_contact_resistance - Contact resistance value in m^2/W
*/
inline virtual void SetContactResistance(su2double val_contact_resistance) {};

/*!
* \brief Set the type of an interface
* \param[in] interface_type - The type of interface
*/
void SetInterfaceType(unsigned short interface_type) { InterfaceType = interface_type; }

/*!
* \brief Get the type of an interface
*/
unsigned short GetInterfaceType(void) const { return InterfaceType; }
};
2 changes: 1 addition & 1 deletion SU2_CFD/include/iteration/CFluidIteration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class CFluidIteration : public CIteration {
* \param[in] iZone - The current zone
* \param[in] ramp_flag - Flag indicating type of ramp (grid or boundary)
*/
void UpdateRamp(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone, RAMP_TYPE ramp_flag);
void UpdateRamps(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone, RAMP_TYPE ramp_flag);

/*!
* \brief Computes turboperformance.
Expand Down
22 changes: 20 additions & 2 deletions SU2_CFD/include/iteration/CIteration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ class CIteration {
su2double StartTime{0.0}, /*!< \brief Tracking wall time. */
StopTime{0.0}, UsedTime{0.0};

std::shared_ptr<CTurboOutput> TurbomachineryPerformance; /*!< \brief turbo performance calculator. */
std::shared_ptr<CTurbomachineryStagePerformance> TurbomachineryStagePerformance; /*!< \brief turbo stage performance calculator. */

public:
/*!
* \brief Constructor of the class.
Expand Down Expand Up @@ -295,4 +293,24 @@ class CIteration {

virtual void RegisterOutput(CSolver***** solver, CGeometry**** geometry, CConfig** config,
unsigned short iZone, unsigned short iInst) {}

/*!
* \brief Computes turboperformance.
*/
void ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container);

/*!
* \brief Initialises turboperformance classes.
*/
void InitTurboPerformance(CGeometry *geometry, CConfig** config, CFluidModel *fluid, unsigned short val_iZone);

inline vector<std::shared_ptr<CTurboOutput>> GetBladesPerformanceVector(CSolver***** solver, unsigned short nBladeRow){
vector<std::shared_ptr<CTurboOutput>> bladePerformances;
bladePerformances.reserve(nBladeRow);
for (auto iBladeRow = 0u; iBladeRow < nBladeRow; iBladeRow++) {
auto const turboPerf = solver[iBladeRow][INST_0][MESH_0][FLOW_SOL]->GetTurboBladePerformance();
bladePerformances.push_back(turboPerf);
}
return bladePerformances;
}
};
12 changes: 8 additions & 4 deletions SU2_CFD/include/output/CFlowCompOutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class CFlowCompOutput final: public CFlowOutput {
*/
void LoadHistoryData(CConfig *config, CGeometry *geometry, CSolver **solver) override;

void LoadHistoryData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned short iZone);

/*!
* \brief Set the available volume output fields
* \param[in] config - Definition of the particular problem.
Expand All @@ -74,6 +76,8 @@ class CFlowCompOutput final: public CFlowOutput {
*/
void SetHistoryOutputFields(CConfig *config) override;

void SetTurbomachineryObjectiveFunctions(CSolver *solver, CConfig *config);

/*!
* \brief Check whether the base values for relative residuals should be initialized
* \param[in] config - Definition of the particular problem.
Expand Down Expand Up @@ -101,23 +105,23 @@ class CFlowCompOutput final: public CFlowOutput {
* \param[in] OuterIter - Index of current outer iteration
* \param[in] InnerIter - Index of current inner iteration
*/
void SetTurboPerformance_Output(std::shared_ptr<CTurboOutput> TurboPerf, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) override;
void SetTurboPerformance_Output(std::vector<std::shared_ptr<CTurboOutput>> TurboBladePerfs, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) override;

/*!
* \brief Sets the multizone turboperformacne screen output
* \param[in] TurboStagePerf - Stage turboperformance class
* \param[in] TurboPerf - Turboperformance class
* \param[in] config - Definition of the particular problem
*/
void SetTurboMultiZonePerformance_Output(std::shared_ptr<CTurbomachineryStagePerformance> TurboStagePerf, std::shared_ptr<CTurboOutput> TurboPerf, CConfig *config) override;
void SetTurboMultiZonePerformance_Output(std::shared_ptr<CTurbomachineryStagePerformance> TurboStagePerf, std::vector<std::shared_ptr<CTurboOutput>> TurboBladePerfs, CConfig *config) override;

/*!
* \brief Loads the turboperformacne history data
* \param[in] TurboStagePerf - Stage turboperformance class
* \param[in] TurboPerf - Turboperformance class
* \param[in] config - Definition of the particular problem
*/
void LoadTurboHistoryData(std::shared_ptr<CTurbomachineryStagePerformance> TurboStagePerf, std::shared_ptr<CTurboOutput> TurboPerf, CConfig *config) override;
void LoadTurboHistoryData(std::shared_ptr<CTurbomachineryStagePerformance> TurboStagePerf, std::vector<std::shared_ptr<CTurboOutput>> TurboBladePerfs, CConfig *config) override;

/*!
* \brief Write the kinematic and thermodynamic variables at each spanwise division
Expand All @@ -126,6 +130,6 @@ class CFlowCompOutput final: public CFlowOutput {
* \param[in] config - Descripiton of the particular problem
* \param[in] val_iZone - Idientifier of current zone
*/
void WriteTurboSpanwisePerformance(std::shared_ptr<CTurboOutput> TurboPerf, CGeometry *geometry, CConfig **config,
void WriteTurboSpanwisePerformance(std::vector<std::shared_ptr<CTurboOutput>> TurboBladePerfs, CGeometry *geometry, CConfig **config,
unsigned short val_iZone) override;
};
10 changes: 5 additions & 5 deletions SU2_CFD/include/output/COutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ class COutput {
*/
void SetHistoryOutput(CGeometry ****geometry, CSolver *****solver_container, CConfig **config,
std::shared_ptr<CTurbomachineryStagePerformance> TurboStagePerf,
std::shared_ptr<CTurboOutput> TurboPerf, unsigned short val_iZone,
std::vector<std::shared_ptr<CTurboOutput>> TurboBladePerfs, unsigned short val_iZone,
unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter, unsigned short val_iInst);

/*!
Expand Down Expand Up @@ -977,23 +977,23 @@ class COutput {
* \param[in] OuterIter - Index of current outer iteration
* \param[in] InnerIter - Index of current inner iteration
*/
inline virtual void SetTurboPerformance_Output(std::shared_ptr<CTurboOutput> TurboPerf, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) {}
inline virtual void SetTurboPerformance_Output(std::vector<std::shared_ptr<CTurboOutput>> TurboBladePerfs, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) {}

/*!
* \brief Sets the multizone turboperformacne screen output
* \param[in] TurboStagePerf - Stage turboperformance class
* \param[in] TurboPerf - Turboperformance class
* \param[in] config - Definition of the particular problem
*/
inline virtual void SetTurboMultiZonePerformance_Output(std::shared_ptr<CTurbomachineryStagePerformance> TurboStagePerf, std::shared_ptr<CTurboOutput> TurboPerf, CConfig *config) {}
inline virtual void SetTurboMultiZonePerformance_Output(std::shared_ptr<CTurbomachineryStagePerformance> TurboStagePerf, std::vector<std::shared_ptr<CTurboOutput>> TurboPerf, CConfig *config) {}

/*!
* \brief Loads the turboperformacne history data
* \param[in] TurboStagePerf - Stage turboperformance class
* \param[in] TurboPerf - Turboperformance class
* \param[in] config - Definition of the particular problem
*/
inline virtual void LoadTurboHistoryData(std::shared_ptr<CTurbomachineryStagePerformance> TurboStagePerf, std::shared_ptr<CTurboOutput> TurboPerf, CConfig *config) {}
inline virtual void LoadTurboHistoryData(std::shared_ptr<CTurbomachineryStagePerformance> TurboStagePerf, std::vector<std::shared_ptr<CTurboOutput>> TurboPerf, CConfig *config) {}

/*!
* \brief Write the kinematic and thermodynamic variables at each spanwise division
Expand All @@ -1002,7 +1002,7 @@ class COutput {
* \param[in] config - Descripiton of the particular problem
* \param[in] val_iZone - Idientifier of current zone
*/
inline virtual void WriteTurboSpanwisePerformance(std::shared_ptr<CTurboOutput> TurboPerf, CGeometry *geometry, CConfig **config,
inline virtual void WriteTurboSpanwisePerformance(std::vector<std::shared_ptr<CTurboOutput>> TurboBladePerfs, CGeometry *geometry, CConfig **config,
unsigned short val_iZone) {};

/*!
Expand Down
Loading
Loading