Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature_tag_debug_tape' into fea…
Browse files Browse the repository at this point in the history
…ture_mz_adjoint_for_turbo
  • Loading branch information
joshkellyjak committed Sep 26, 2024
2 parents c002911 + 13ca3f5 commit 89c95ba
Show file tree
Hide file tree
Showing 40 changed files with 922 additions and 372 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ jobs:
uses: docker://ghcr.io/su2code/su2/test-su2:240320-1536
with:
# -t <Tutorials-branch> -c <Testcases-branch>
args: -b ${{github.ref}} -t feature_solid-solid_cht -c develop -s ${{matrix.testscript}}
args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}}
- name: Cleanup
uses: docker://ghcr.io/su2code/su2/test-su2:240320-1536
with:
Expand Down
49 changes: 47 additions & 2 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class CConfig {
su2double Buffet_lambda; /*!< \brief Offset parameter for buffet sensor.*/
su2double Damp_Engine_Inflow; /*!< \brief Damping factor for the engine inlet. */
su2double Damp_Engine_Exhaust; /*!< \brief Damping factor for the engine exhaust. */
unsigned long Bc_Eval_Freq; /*!< \brief Evaluation frequency for Engine and Actuator disk markers. */
su2double Damp_Res_Restric, /*!< \brief Damping factor for the residual restriction. */
Damp_Correc_Prolong; /*!< \brief Damping factor for the correction prolongation. */
su2double Position_Plane; /*!< \brief Position of the Near-Field (y coordinate 2D, and z coordinate 3D). */
Expand Down Expand Up @@ -236,6 +237,7 @@ class CConfig {
*Marker_MixingPlaneInterface, /*!< \brief MixingPlane interface boundary markers. */
*Marker_TurboBoundIn, /*!< \brief Turbomachinery performance boundary markers. */
*Marker_TurboBoundOut, /*!< \brief Turbomachinery performance boundary donor markers. */
*Marker_Turbomachinery, /*!< \breif Turbomachinery markers */
*Marker_NearFieldBound, /*!< \brief Near Field boundaries markers. */
*Marker_Deform_Mesh, /*!< \brief Deformable markers at the boundary. */
*Marker_Deform_Mesh_Sym_Plane, /*!< \brief Marker with symmetric deformation. */
Expand Down Expand Up @@ -442,6 +444,7 @@ class CConfig {

TURBO_PERF_KIND *Kind_TurboPerf; /*!< \brief Kind of turbomachynery architecture.*/
TURBOMACHINERY_TYPE *Kind_TurboMachinery;
su2vector<TURBO_INTERFACE_KIND> Kind_TurboInterface;

/* Turbomachinery objective functions */
su2double *EntropyGeneration;
Expand Down Expand Up @@ -470,6 +473,7 @@ class CConfig {
unsigned short* nDV_Value; /*!< \brief Number of values for each design variable (might be different than 1 if we allow arbitrary movement). */
unsigned short nFFDBox; /*!< \brief Number of ffd boxes. */
unsigned short nTurboMachineryKind; /*!< \brief Number turbomachinery types specified. */
unsigned short nTurboInterfaces; /*!< \brief Number of turbomachiery interfaces */
unsigned short nParamDV; /*!< \brief Number of parameters of the design variable. */
string DV_Filename; /*!< \brief Filename for providing surface positions from an external parameterization. */
string DV_Unordered_Sens_Filename; /*!< \brief Filename of volume sensitivities in an unordered ASCII format. */
Expand Down Expand Up @@ -750,6 +754,7 @@ class CConfig {
*Marker_All_Turbomachinery, /*!< \brief Global index for Turbomachinery markers using the grid information. */
*Marker_All_TurbomachineryFlag, /*!< \brief Global index for Turbomachinery markers flag using the grid information. */
*Marker_All_MixingPlaneInterface, /*!< \brief Global index for MixingPlane interface markers using the grid information. */
*Marker_All_Giles, /*!< \brief Global index for Giles markers using the grid information. */
*Marker_All_DV, /*!< \brief Global index for design variable markers using the grid information. */
*Marker_All_Moving, /*!< \brief Global index for moving surfaces using the grid information. */
*Marker_All_Deform_Mesh, /*!< \brief Global index for deformable markers at the boundary. */
Expand All @@ -767,6 +772,7 @@ class CConfig {
*Marker_CfgFile_Turbomachinery, /*!< \brief Global index for Turbomachinery using the config information. */
*Marker_CfgFile_TurbomachineryFlag, /*!< \brief Global index for Turbomachinery flag using the config information. */
*Marker_CfgFile_MixingPlaneInterface, /*!< \brief Global index for MixingPlane interface using the config information. */
*Marker_CfgFile_Giles, /*!< \brief Global index for Giles markers flag using the config information. */
*Marker_CfgFile_Moving, /*!< \brief Global index for moving surfaces using the config information. */
*Marker_CfgFile_Deform_Mesh, /*!< \brief Global index for deformable markers at the boundary. */
*Marker_CfgFile_Deform_Mesh_Sym_Plane, /*!< \brief Global index for markers with symmetric deformations. */
Expand Down Expand Up @@ -1051,7 +1057,8 @@ class CConfig {
long ParMETIS_pointWgt; /*!< \brief Load balancing weight given to points. */
long ParMETIS_edgeWgt; /*!< \brief Load balancing weight given to edges. */
unsigned short DirectDiff; /*!< \brief Direct Differentation mode. */
bool DiscreteAdjoint; /*!< \brief AD-based discrete adjoint mode. */
bool DiscreteAdjoint, /*!< \brief AD-based discrete adjoint mode. */
DiscreteAdjointDebug; /*!< \brief Discrete adjoint debug mode using tags. */
su2double Const_DES; /*!< \brief Detached Eddy Simulation Constant. */
WINDOW_FUNCTION Kind_WindowFct; /*!< \brief Type of window (weight) function for objective functional. */
unsigned short Kind_HybridRANSLES; /*!< \brief Kind of Hybrid RANS/LES. */
Expand Down Expand Up @@ -1379,7 +1386,7 @@ class CConfig {
su2double** & RotCenter, su2double** & RotAngles, su2double** & Translation);

void addTurboPerfOption(const string & name, unsigned short & nMarker_TurboPerf,
string* & Marker_TurboBoundIn, string* & Marker_TurboBoundOut);
string* & Marker_TurboBoundIn, string* & Marker_TurboBoundOut, string* & Marker_Turbomachinery);

void addActDiskOption(const string & name,
unsigned short & nMarker_ActDiskInlet, unsigned short & nMarker_ActDiskOutlet, string* & Marker_ActDiskInlet, string* & Marker_ActDiskOutlet,
Expand Down Expand Up @@ -3517,6 +3524,13 @@ class CConfig {
*/
void SetMarker_All_MixingPlaneInterface(unsigned short val_marker, unsigned short val_mixpla_interface) { Marker_All_MixingPlaneInterface[val_marker] = val_mixpla_interface; }

/*!
* \brief Set if a marker <i>val_marker</i> is part of the Giles boundary (read from the config file).
* \param[in] val_marker - Index of the marker in which we are interested.
* \param[in] val_giles - 0 if not part of the Giles boundary or greater than 1 if it is part.
*/
void SetMarker_All_Giles(unsigned short val_marker, unsigned short val_giles) { Marker_All_Giles[val_marker] = val_giles; }

/*!
* \brief Set if a marker <i>val_marker</i> is going to be affected by design variables <i>val_moving</i>
* (read from the config file).
Expand Down Expand Up @@ -3663,6 +3677,13 @@ class CConfig {
*/
unsigned short GetMarker_All_TurbomachineryFlag(unsigned short val_marker) const { return Marker_All_TurbomachineryFlag[val_marker]; }

/*!
* \brief Get the Giles boundary information for a marker <i>val_marker</i>.
* \param[in] val_marker value of the marker on the grid.
* \return 0 if is not part of the MixingPlane Interface and greater than 1 if it is part.
*/
unsigned short GetMarker_All_Giles(unsigned short val_marker) const { return Marker_All_Giles[val_marker]; }

/*!
* \brief Get the number of FSI interface markers <i>val_marker</i>.
* \param[in] void.
Expand Down Expand Up @@ -5339,6 +5360,12 @@ class CConfig {
*/
TURBO_PERF_KIND GetKind_TurboPerf(unsigned short val_iZone) const { return Kind_TurboPerf[val_iZone]; };

/*!
* \brief gets interface kind for an interface marker in turbomachinery problem
* \return interface kind
*/
TURBO_INTERFACE_KIND GetKind_TurboInterface(unsigned short interfaceIndex) const { return Kind_TurboInterface[interfaceIndex]; }

/*!
* \brief get outlet bounds name for Turbomachinery performance calculation.
* \return name of the bound.
Expand Down Expand Up @@ -6402,6 +6429,12 @@ class CConfig {
*/
unsigned short GetMarker_CfgFile_MixingPlaneInterface(const string& val_marker) const;

/*!
* \brief Get the Giles boundary information from the config definition for the marker <i>val_marker</i>.
* \return Plotting information of the boundary in the config information for the marker <i>val_marker</i>.
*/
unsigned short GetMarker_CfgFile_Giles(const string& val_marker) const;

/*!
* \brief Get the DV information from the config definition for the marker <i>val_marker</i>.
* \return DV information of the boundary in the config information for the marker <i>val_marker</i>.
Expand Down Expand Up @@ -6520,6 +6553,12 @@ class CConfig {
*/
su2double GetMinLogResidual(void) const { return MinLogResidual; }

/*!
* \brief Evaluation frequency for Engine and Actuator disk markers.
* \return Value Evaluation frequency .
*/
unsigned long GetBc_Eval_Freq(void) const { return Bc_Eval_Freq; }

/*!
* \brief Value of the damping factor for the engine inlet bc.
* \return Value of the damping factor.
Expand Down Expand Up @@ -8911,6 +8950,12 @@ class CConfig {
*/
bool GetDiscrete_Adjoint(void) const { return DiscreteAdjoint; }

/*!
* \brief Get the indicator whether a debug run for the discrete adjoint solver will be started.
* \return the discrete adjoint debug indicator.
*/
bool GetDiscrete_Adjoint_Debug(void) const { return DiscreteAdjointDebug; }

/*!
* \brief Get the number of subiterations while a ramp is applied.
* \return Number of FSI subiters.
Expand Down
30 changes: 20 additions & 10 deletions Common/include/basic_types/ad_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ inline void SetExtFuncOut(T&& data, const int size_x, const int size_y) {}
*/
inline void SetIndex(int& index, const su2double& data) {}

/*!
* \brief Sets the tag tape to a specific tag.
* \param[in] tag - the number to which the tag is set.
*/
inline void SetTag(int tag) {}

/*!
* \brief Pushes back the current tape position to the tape position's vector.
*/
Expand Down Expand Up @@ -472,6 +478,8 @@ FORCEINLINE void EndUseAdjoints() { AD::getTape().endUseAdjointVector(); }

FORCEINLINE void SetIndex(int& index, const su2double& data) { index = data.getIdentifier(); }

FORCEINLINE void SetTag(int tag) { AD::getTape().setCurTag(tag); }

// WARNING: For performance reasons, this method does not perform bounds checking.
// When using it, please ensure sufficient adjoint vector size by a call to AD::ResizeAdjoints().
// This method does not perform locking either.
Expand Down Expand Up @@ -502,7 +510,8 @@ FORCEINLINE void SetPreaccIn() {}
template <class T, class... Ts, su2enable_if<std::is_same<T, su2double>::value> = 0>
FORCEINLINE void SetPreaccIn(const T& data, Ts&&... moreData) {
if (!PreaccActive) return;
if (IsIdentifierActive(data)) PreaccHelper.addInput(data);
// if (IsIdentifierActive(data))
PreaccHelper.addInput(data);
SetPreaccIn(moreData...);
}

Expand All @@ -515,9 +524,9 @@ template <class T>
FORCEINLINE void SetPreaccIn(const T& data, const int size) {
if (PreaccActive) {
for (int i = 0; i < size; i++) {
if (IsIdentifierActive(data[i])) {
// if (IsIdentifierActive(data[i])) {
PreaccHelper.addInput(data[i]);
}
// }
}
}
}
Expand All @@ -527,9 +536,9 @@ FORCEINLINE void SetPreaccIn(const T& data, const int size_x, const int size_y)
if (!PreaccActive) return;
for (int i = 0; i < size_x; i++) {
for (int j = 0; j < size_y; j++) {
if (IsIdentifierActive(data[i][j])) {
// if (IsIdentifierActive(data[i][j])) {
PreaccHelper.addInput(data[i][j]);
}
// }
}
}
}
Expand All @@ -547,17 +556,18 @@ FORCEINLINE void SetPreaccOut() {}
template <class T, class... Ts, su2enable_if<std::is_same<T, su2double>::value> = 0>
FORCEINLINE void SetPreaccOut(T& data, Ts&&... moreData) {
if (!PreaccActive) return;
if (IsIdentifierActive(data)) PreaccHelper.addOutput(data);
// if (IsIdentifierActive(data))
PreaccHelper.addOutput(data);
SetPreaccOut(moreData...);
}

template <class T>
FORCEINLINE void SetPreaccOut(T&& data, const int size) {
if (PreaccActive) {
for (int i = 0; i < size; i++) {
if (IsIdentifierActive(data[i])) {
// if (IsIdentifierActive(data[i])) {
PreaccHelper.addOutput(data[i]);
}
// }
}
}
}
Expand All @@ -567,9 +577,9 @@ FORCEINLINE void SetPreaccOut(T&& data, const int size_x, const int size_y) {
if (!PreaccActive) return;
for (int i = 0; i < size_x; i++) {
for (int j = 0; j < size_y; j++) {
if (IsIdentifierActive(data[i][j])) {
// if (IsIdentifierActive(data[i][j])) {
PreaccHelper.addOutput(data[i][j]);
}
// }
}
}
}
Expand Down
20 changes: 19 additions & 1 deletion Common/include/option_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1622,6 +1622,7 @@ enum BC_TYPE {
FLUID_INTERFACE = 39, /*!< \brief Domain interface definition. */
DISP_DIR_BOUNDARY = 40, /*!< \brief Boundary displacement definition. */
DAMPER_BOUNDARY = 41, /*!< \brief Damper. */
MIXING_PLANE_INTERFACE = 42, /*< \breif Mxing plane */
CHT_WALL_INTERFACE = 50, /*!< \brief Domain interface definition. */
SMOLUCHOWSKI_MAXWELL = 55, /*!< \brief Smoluchoski/Maxwell wall boundary condition. */
SEND_RECEIVE = 99, /*!< \brief Boundary send-receive definition. */
Expand Down Expand Up @@ -1752,7 +1753,8 @@ enum RIEMANN_TYPE {
TOTAL_CONDITIONS_PT_1D = 11,
STATIC_PRESSURE_1D = 12,
MIXING_IN_1D = 13,
MIXING_OUT_1D =14
MIXING_OUT_1D = 14,
MASS_FLOW_OUTLET = 15
};
static const MapType<std::string, RIEMANN_TYPE> Riemann_Map = {
MakePair("TOTAL_CONDITIONS_PT", TOTAL_CONDITIONS_PT)
Expand All @@ -1769,6 +1771,7 @@ static const MapType<std::string, RIEMANN_TYPE> Riemann_Map = {
MakePair("RADIAL_EQUILIBRIUM", RADIAL_EQUILIBRIUM)
MakePair("TOTAL_CONDITIONS_PT_1D", TOTAL_CONDITIONS_PT_1D)
MakePair("STATIC_PRESSURE_1D", STATIC_PRESSURE_1D)
MakePair("MASS_FLOW_OUTLET", MASS_FLOW_OUTLET)
};

static const MapType<std::string, RIEMANN_TYPE> Giles_Map = {
Expand All @@ -1786,6 +1789,7 @@ static const MapType<std::string, RIEMANN_TYPE> Giles_Map = {
MakePair("RADIAL_EQUILIBRIUM", RADIAL_EQUILIBRIUM)
MakePair("TOTAL_CONDITIONS_PT_1D", TOTAL_CONDITIONS_PT_1D)
MakePair("STATIC_PRESSURE_1D", STATIC_PRESSURE_1D)
MakePair("MASS_FLOW_OUTLET", MASS_FLOW_OUTLET)
};

/*!
Expand Down Expand Up @@ -1862,6 +1866,18 @@ static const MapType<std::string, TURBO_PERF_KIND> TurboPerfKind_Map = {
MakePair("PROPELLOR", TURBO_PERF_KIND::PROPELLOR)
};

/*!
* \brief Types of Turbomachinery interfaces.
*/
enum class TURBO_INTERFACE_KIND{
MIXING_PLANE = ENUM_TRANSFER::MIXING_PLANE,
FROZEN_ROTOR = ENUM_TRANSFER::SLIDING_INTERFACE,
};
static const MapType<std::string, TURBO_INTERFACE_KIND> TurboInterfaceKind_Map = {
MakePair("MIXING_PLANE", TURBO_INTERFACE_KIND::MIXING_PLANE)
MakePair("FROZEN_ROTOR", TURBO_INTERFACE_KIND::FROZEN_ROTOR)
};

/*!
* \brief Types of Turbomachinery performance flag.
*/
Expand Down Expand Up @@ -2483,6 +2499,8 @@ enum class RECORDING {
MESH_COORDS,
MESH_DEFORM,
SOLUTION_AND_MESH,
TAG_INIT_SOLUTION_VARIABLES,
TAG_CHECK_SOLUTION_VARIABLES
};

/*!
Expand Down
16 changes: 14 additions & 2 deletions Common/include/option_structure.inl
Original file line number Diff line number Diff line change
Expand Up @@ -1606,11 +1606,15 @@ class COptionTurboPerformance : public COptionBase {
unsigned short& size;
string*& marker_turboIn;
string*& marker_turboOut;
string*& markers;

public:
COptionTurboPerformance(const string option_field_name, unsigned short& nMarker_TurboPerf,
string*& Marker_TurboBoundIn, string*& Marker_TurboBoundOut)
: size(nMarker_TurboPerf), marker_turboIn(Marker_TurboBoundIn), marker_turboOut(Marker_TurboBoundOut) {
string*& Marker_TurboBoundIn, string*& Marker_TurboBoundOut, string*& Marker_Turbomachinery)
: size(nMarker_TurboPerf),
marker_turboIn(Marker_TurboBoundIn),
marker_turboOut(Marker_TurboBoundOut),
markers(Marker_Turbomachinery) {
this->name = option_field_name;
}

Expand All @@ -1624,6 +1628,7 @@ class COptionTurboPerformance : public COptionBase {
this->size = 0;
this->marker_turboIn = nullptr;
this->marker_turboOut = nullptr;
this->markers = nullptr;
return "";
}

Expand All @@ -1634,10 +1639,16 @@ class COptionTurboPerformance : public COptionBase {
this->size = 0;
this->marker_turboIn = nullptr;
this->marker_turboOut = nullptr;
this->markers = nullptr;
;
return newstring;
}

this->markers = new string[totalVals];
for (unsigned long i = 0; i < totalVals; i++) {
this->markers[i].assign(option_value[i]);
}

unsigned long nVals = totalVals / mod_num;
this->size = nVals;
this->marker_turboIn = new string[nVals];
Expand All @@ -1654,6 +1665,7 @@ class COptionTurboPerformance : public COptionBase {
this->size = 0;
this->marker_turboIn = nullptr;
this->marker_turboOut = nullptr;
this->markers = nullptr;
}
};

Expand Down
Loading

0 comments on commit 89c95ba

Please sign in to comment.