Skip to content

Commit

Permalink
Merge branch 'feature_tag_debug_tape' of https://github.com/su2code/SU2
Browse files Browse the repository at this point in the history
… into feature_tag_debug_tape
  • Loading branch information
joshkellyjak committed Sep 27, 2024
2 parents 9f1b07c + 13ca3f5 commit 1169606
Show file tree
Hide file tree
Showing 42 changed files with 1,015 additions and 383 deletions.
59 changes: 57 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 @@ -192,6 +193,7 @@ class CConfig {
nMarker_Fluid_Load, /*!< \brief Number of markers in which the flow load is computed/employed. */
nMarker_Fluid_InterfaceBound, /*!< \brief Number of fluid interface markers. */
nMarker_CHTInterface, /*!< \brief Number of conjugate heat transfer interface markers. */
nMarker_ContactResistance, /*!< \brief Number of CHT interfaces with contact resistance. */
nMarker_Inlet, /*!< \brief Number of inlet flow markers. */
nMarker_Inlet_Species, /*!< \brief Number of inlet species markers. */
nSpecies_per_Inlet, /*!< \brief Number of species defined per inlet markers. */
Expand Down Expand Up @@ -235,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 @@ -396,6 +399,7 @@ class CConfig {
su2double **Periodic_RotCenter; /*!< \brief Rotational center for each periodic boundary. */
su2double **Periodic_RotAngles; /*!< \brief Rotation angles for each periodic boundary. */
su2double **Periodic_Translation; /*!< \brief Translation vector for each periodic boundary. */
su2double *CHT_ContactResistance; /*!< \brief Contact resistance values for each solid-solid CHT interface. */
string *Marker_CfgFile_TagBound; /*!< \brief Global index for markers using config file. */
unsigned short *Marker_All_KindBC, /*!< \brief Global index for boundaries using grid information. */
*Marker_CfgFile_KindBC; /*!< \brief Global index for boundaries using config file. */
Expand Down Expand Up @@ -440,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 @@ -468,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 @@ -594,6 +600,7 @@ class CConfig {
bool EulerPersson; /*!< \brief Boolean to determine whether this is an Euler simulation with Persson shock capturing. */
bool FSI_Problem = false,/*!< \brief Boolean to determine whether the simulation is FSI or not. */
Multizone_Problem; /*!< \brief Boolean to determine whether we are solving a multizone problem. */
//bool ContactResistance = false; /*!< \brief Apply contact resistance for conjugate heat transfer. */
unsigned short nID_DV; /*!< \brief ID for the region of FEM when computed using direct differentiation. */

bool AD_Mode; /*!< \brief Algorithmic Differentiation support. */
Expand Down Expand Up @@ -747,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 @@ -764,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 @@ -1048,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 @@ -1376,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 @@ -3514,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 @@ -3660,13 +3677,27 @@ 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.
* \return Number of markers belonging to the FSI interface.
*/
unsigned short GetMarker_n_ZoneInterface(void) const { return nMarker_ZoneInterface; }

/*!
* \brief Get the contact resistance value of a specified interface.
* \param[in] val_interface interface index.
* \return Contact resistance value (zero by default).
*/
su2double GetContactResistance(unsigned short val_interface) const { return (nMarker_ContactResistance > 0) ? CHT_ContactResistance[val_interface] : 0.0; }

/*!
* \brief Get the DV information for a marker <i>val_marker</i>.
* \param[in] val_marker - 0 or 1 depending if the the marker is going to be affected by design variables.
Expand Down Expand Up @@ -5329,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 @@ -6392,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 @@ -6510,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 @@ -8901,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 @@ -270,6 +270,12 @@ inline void SetExtFuncOut(T&& data, const int size_x, const int size_y) {}
*/
inline void SetIndex(Identifier& 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 @@ -482,6 +488,8 @@ FORCEINLINE void EndUseAdjoints() { AD::getTape().endUseAdjointVector(); }

FORCEINLINE void SetIndex(Identifier& 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 @@ -514,7 +522,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 @@ -527,9 +536,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 @@ -539,9 +548,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 @@ -559,17 +568,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 @@ -579,9 +589,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
21 changes: 20 additions & 1 deletion Common/include/option_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ enum ENUM_TRANSFER {
CONJUGATE_HEAT_WEAKLY_FS = 17, /*!< \brief Conjugate heat transfer (between incompressible fluids and solids). */
CONJUGATE_HEAT_SF = 18, /*!< \brief Conjugate heat transfer (between solids and compressible fluids). */
CONJUGATE_HEAT_WEAKLY_SF = 19, /*!< \brief Conjugate heat transfer (between solids and incompressible fluids). */
CONJUGATE_HEAT_SS = 20, /*!< \brief Conjugate heat transfer (between two solids). */
};

/*!
Expand Down Expand Up @@ -1621,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 @@ -1751,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 @@ -1768,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 @@ -1785,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 @@ -1861,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 @@ -2482,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 1169606

Please sign in to comment.