Skip to content

Commit

Permalink
Merge branch 'develop' into feature_signal_handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bigfooted authored Oct 26, 2023
2 parents 16bf9cd + 41d2522 commit 8932eed
Show file tree
Hide file tree
Showing 30 changed files with 222 additions and 30 deletions.
2 changes: 2 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Kedar Naik
Kürşat Yurt
LaSerpe
Lennaert Tol
Liang Cheng
Lisa Kusch
Matteo Pini
Max Aehle
Expand Down Expand Up @@ -137,6 +138,7 @@ VivaanKhatri
Wally Maier
Y. Chandukrishna
Zan Xu
Zcaic
aaronyicongfu
aeroamit
anilvar
Expand Down
17 changes: 17 additions & 0 deletions Common/include/basic_types/ad_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ inline void RegisterOutput(su2double& data) {}
*/
inline void ResizeAdjoints() {}

/*!
* \brief Declare that the adjoints are being used, to protect against resizing.
*
* Should be used together with AD::EndUseAdjoints() to protect AD::SetDerivative() and AD::GetDerivative() calls,
* multiple at once if possible.
*/
inline void BeginUseAdjoints() {}

/*!
* \brief Declare that the adjoints are no longer being used.
*/
inline void EndUseAdjoints() {}

/*!
* \brief Sets the adjoint value at index to val
* \param[in] index - Position in the adjoint vector.
Expand Down Expand Up @@ -375,6 +388,10 @@ FORCEINLINE void Reset() {

FORCEINLINE void ResizeAdjoints() { AD::getTape().resizeAdjointVector(); }

FORCEINLINE void BeginUseAdjoints() { AD::getTape().beginUseAdjointVector(); }

FORCEINLINE void EndUseAdjoints() { AD::getTape().endUseAdjointVector(); }

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

// WARNING: For performance reasons, this method does not perform bounds checking.
Expand Down
2 changes: 1 addition & 1 deletion Common/include/option_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ static const MapType<std::string, ENUM_INIT_OPTION> InitOption_Map = {
};

/*!
* \brief Types of initialization option
* \brief Types of freestream specification
*/
enum class FREESTREAM_OPTION {
TEMPERATURE_FS, /*!< \brief Temperature initialization. */
Expand Down
4 changes: 2 additions & 2 deletions Common/include/parallelization/omp_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,14 @@ void omp_finalize();
*/

#define BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS \
SU2_OMP_BARRIER \
SU2_OMP_BARRIER; \
if (omp_in_parallel()) AD::StartNoSharedReading(); \
SU2_OMP_MASTER

#define END_SU2_OMP_SAFE_GLOBAL_ACCESS \
END_SU2_OMP_MASTER \
if (omp_in_parallel()) AD::EndNoSharedReading(); \
SU2_OMP_BARRIER
SU2_OMP_BARRIER;

#define SU2_OMP_SAFE_GLOBAL_ACCESS(...) BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS{__VA_ARGS__} END_SU2_OMP_SAFE_GLOBAL_ACCESS

Expand Down
2 changes: 1 addition & 1 deletion Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7351,7 +7351,7 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) {
if (nMarker_Inlet_Species != 0) {
BoundaryTable << "Species Inlet boundary";
for (iMarker_Inlet = 0; iMarker_Inlet < nMarker_Inlet_Species; iMarker_Inlet++) {
BoundaryTable << Marker_Inlet[iMarker_Inlet];
BoundaryTable << Marker_Inlet_Species[iMarker_Inlet];
if (iMarker_Inlet < nMarker_Inlet_Species-1) BoundaryTable << " ";
}
BoundaryTable.PrintFooter();
Expand Down
11 changes: 10 additions & 1 deletion Common/src/grid_movement/CSurfaceMovement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,8 @@ vector<vector<su2double> > CSurfaceMovement::SetSurface_Deformation(CGeometry* g

else if ((config->GetDesign_Variable(0) == ROTATION) || (config->GetDesign_Variable(0) == TRANSLATION) ||
(config->GetDesign_Variable(0) == SCALE) || (config->GetDesign_Variable(0) == HICKS_HENNE) ||
(config->GetDesign_Variable(0) == SURFACE_BUMP) || (config->GetDesign_Variable(0) == ANGLE_OF_ATTACK)) {
(config->GetDesign_Variable(0) == SURFACE_BUMP) || (config->GetDesign_Variable(0) == ANGLE_OF_ATTACK) ||
(config->GetDesign_Variable(0) == CST)) {
/*--- Apply rotation, displacement and stretching design variables (this
should be done before the bump function design variables) ---*/

Expand Down Expand Up @@ -586,6 +587,14 @@ vector<vector<su2double> > CSurfaceMovement::SetSurface_Deformation(CGeometry* g

/*--- Apply the design variables to the control point position ---*/

for (iDV = 0; iDV < config->GetnDV(); iDV++) {
if (config->GetDesign_Variable(iDV) == CST) {
SetCST(geometry, config, iDV, false);
}
}

/*--- Apply the design variables to the control point position ---*/

for (iDV = 0; iDV < config->GetnDV(); iDV++) {
switch (config->GetDesign_Variable(iDV)) {
case SURFACE_BUMP:
Expand Down
5 changes: 5 additions & 0 deletions SU2_CFD/include/output/COutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,11 @@ class COutput {
*/
void SetCommonHistoryFields();

/*!
* \brief Request the history fields common for all solvers.
*/
void RequestCommonHistory(bool dynamic);

/*!
* \brief Parses user-defined outputs.
*/
Expand Down
2 changes: 2 additions & 0 deletions SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,9 @@ void CDiscAdjMultizoneDriver::SetAdjObjFunction() {
}
if (rank == MASTER_NODE) {
AD::ResizeAdjoints();
AD::BeginUseAdjoints();
AD::SetDerivative(ObjFunc_Index, SU2_TYPE::GetValue(seeding));
AD::EndUseAdjoints();
}
}

Expand Down
2 changes: 2 additions & 0 deletions SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ void CDiscAdjFEAIteration::InitializeAdjoint(CSolver***** solver, CGeometry****
/*--- Initialize the adjoints the conservative variables ---*/

AD::ResizeAdjoints();
AD::BeginUseAdjoints();
solver[iZone][iInst][MESH_0][ADJFEA_SOL]->SetAdjoint_Output(geometry[iZone][iInst][MESH_0], config[iZone]);
AD::EndUseAdjoints();
}

bool CDiscAdjFEAIteration::Monitor(COutput* output, CIntegration**** integration, CGeometry**** geometry,
Expand Down
3 changes: 3 additions & 0 deletions SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ void CDiscAdjFluidIteration::InitializeAdjoint(CSolver***** solver, CGeometry***
auto geometry0 = geometry[iZone][iInst][MESH_0];

AD::ResizeAdjoints();
AD::BeginUseAdjoints();

SU2_OMP_PARALLEL_(if(solvers0[ADJFLOW_SOL]->GetHasHybridParallel())) {

Expand Down Expand Up @@ -392,6 +393,8 @@ void CDiscAdjFluidIteration::InitializeAdjoint(CSolver***** solver, CGeometry***

}
END_SU2_OMP_PARALLEL

AD::EndUseAdjoints();
}

void CDiscAdjFluidIteration::RegisterInput(CSolver***** solver, CGeometry**** geometry, CConfig** config,
Expand Down
2 changes: 2 additions & 0 deletions SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ void CDiscAdjHeatIteration::InitializeAdjoint(CSolver***** solver, CGeometry****
/*--- Initialize the adjoints the solution variables ---*/

AD::ResizeAdjoints();
AD::BeginUseAdjoints();
solver[iZone][iInst][MESH_0][ADJHEAT_SOL]->SetAdjoint_Output(geometry[iZone][iInst][MESH_0], config[iZone]);
AD::EndUseAdjoints();
}

void CDiscAdjHeatIteration::RegisterInput(CSolver***** solver, CGeometry**** geometry, CConfig** config,
Expand Down
3 changes: 1 addition & 2 deletions SU2_CFD/src/output/CAdjFlowCompOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ CAdjFlowCompOutput::CAdjFlowCompOutput(CConfig *config, unsigned short nDim) : C
/*--- Set the default history fields if nothing is set in the config file ---*/

if (nRequestedHistoryFields == 0) {
requestedHistoryFields.emplace_back("ITER");
requestedHistoryFields.emplace_back("RMS_RES");
RequestCommonHistory(config->GetTime_Domain());
requestedHistoryFields.emplace_back("SENSITIVITY");
nRequestedHistoryFields = requestedHistoryFields.size();
}
Expand Down
3 changes: 1 addition & 2 deletions SU2_CFD/src/output/CAdjFlowIncOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ CAdjFlowIncOutput::CAdjFlowIncOutput(CConfig *config, unsigned short nDim) : CAd
/*--- Set the default history fields if nothing is set in the config file ---*/

if (nRequestedHistoryFields == 0) {
requestedHistoryFields.emplace_back("ITER");
requestedHistoryFields.emplace_back("RMS_RES");
RequestCommonHistory(config->GetTime_Domain());
requestedHistoryFields.emplace_back("SENSITIVITY");
nRequestedHistoryFields = requestedHistoryFields.size();
}
Expand Down
3 changes: 1 addition & 2 deletions SU2_CFD/src/output/CAdjHeatOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ CAdjHeatOutput::CAdjHeatOutput(CConfig *config, unsigned short nDim) : COutput(c
/*--- Set the default history fields if nothing is set in the config file ---*/

if (nRequestedHistoryFields == 0){
requestedHistoryFields.emplace_back("ITER");
requestedHistoryFields.emplace_back("RMS_RES");
RequestCommonHistory(config->GetTime_Domain());
requestedHistoryFields.emplace_back("SENSITIVITY");
nRequestedHistoryFields = requestedHistoryFields.size();
}
Expand Down
3 changes: 1 addition & 2 deletions SU2_CFD/src/output/CElasticityOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ CElasticityOutput::CElasticityOutput(CConfig *config, unsigned short nDim) : COu

/*--- Default fields for screen output ---*/
if (nRequestedHistoryFields == 0){
requestedHistoryFields.emplace_back("ITER");
requestedHistoryFields.emplace_back("RMS_RES");
RequestCommonHistory(dynamic);
nRequestedHistoryFields = requestedHistoryFields.size();
}

Expand Down
3 changes: 1 addition & 2 deletions SU2_CFD/src/output/CFlowCompFEMOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ CFlowCompFEMOutput::CFlowCompFEMOutput(CConfig *config, unsigned short nDim) : C
/*--- Set the default history fields if nothing is set in the config file ---*/

if (nRequestedHistoryFields == 0){
requestedHistoryFields.emplace_back("ITER");
requestedHistoryFields.emplace_back("RMS_RES");
RequestCommonHistory(config->GetTime_Domain());
nRequestedHistoryFields = requestedHistoryFields.size();
}
if (nRequestedScreenFields == 0){
Expand Down
3 changes: 1 addition & 2 deletions SU2_CFD/src/output/CFlowCompOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ CFlowCompOutput::CFlowCompOutput(const CConfig *config, unsigned short nDim) : C
/*--- Set the default history fields if nothing is set in the config file ---*/

if (nRequestedHistoryFields == 0){
requestedHistoryFields.emplace_back("ITER");
requestedHistoryFields.emplace_back("RMS_RES");
RequestCommonHistory(config->GetTime_Domain());
nRequestedHistoryFields = requestedHistoryFields.size();
}
if (nRequestedScreenFields == 0){
Expand Down
3 changes: 1 addition & 2 deletions SU2_CFD/src/output/CFlowIncOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ CFlowIncOutput::CFlowIncOutput(CConfig *config, unsigned short nDim) : CFlowOutp
/*--- Set the default history fields if nothing is set in the config file ---*/

if (nRequestedHistoryFields == 0){
requestedHistoryFields.emplace_back("ITER");
requestedHistoryFields.emplace_back("RMS_RES");
RequestCommonHistory(config->GetTime_Domain());
nRequestedHistoryFields = requestedHistoryFields.size();
}

Expand Down
3 changes: 1 addition & 2 deletions SU2_CFD/src/output/CHeatOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ CHeatOutput::CHeatOutput(CConfig *config, unsigned short nDim) : CFVMOutput(conf
/*--- Set the default history fields if nothing is set in the config file ---*/

if (nRequestedHistoryFields == 0){
requestedHistoryFields.emplace_back("ITER");
requestedHistoryFields.emplace_back("RMS_RES");
RequestCommonHistory(config->GetTime_Domain());
nRequestedHistoryFields = requestedHistoryFields.size();
}
if (nRequestedScreenFields == 0){
Expand Down
1 change: 1 addition & 0 deletions SU2_CFD/src/output/CMultizoneOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ CMultizoneOutput::CMultizoneOutput(const CConfig* driver_config, const CConfig*

if (nRequestedHistoryFields == 0){
requestedHistoryFields.emplace_back("ITER");
if (config[ZONE_0]->GetTime_Domain()) requestedHistoryFields.emplace_back("CUR_TIME");
for (iZone = 0; iZone < nZone; iZone++){
requestedHistoryFields.emplace_back(bgs_res_name + "[" + PrintingToolbox::to_string(iZone) + "]");
requestedHistoryFields.emplace_back("AVG_RES[" + PrintingToolbox::to_string(iZone) + "]");
Expand Down
3 changes: 1 addition & 2 deletions SU2_CFD/src/output/CNEMOCompOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ CNEMOCompOutput::CNEMOCompOutput(const CConfig *config, unsigned short nDim) : C
/*--- Set the default history fields if nothing is set in the config file ---*/

if (nRequestedHistoryFields == 0){
requestedHistoryFields.emplace_back("ITER");
requestedHistoryFields.emplace_back("RMS_RES");
RequestCommonHistory(config->GetTime_Domain());
nRequestedHistoryFields = requestedHistoryFields.size();
}
if (nRequestedScreenFields == 0){
Expand Down
7 changes: 7 additions & 0 deletions SU2_CFD/src/output/COutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2034,6 +2034,13 @@ void COutput::SetCommonHistoryFields() {

}

void COutput::RequestCommonHistory(bool dynamic) {

requestedHistoryFields.emplace_back("ITER");
if (dynamic) requestedHistoryFields.emplace_back("CUR_TIME");
requestedHistoryFields.emplace_back("RMS_RES");
}

void COutput::SetCustomOutputs(const CConfig* config) {

const auto& inputString = config->GetCustomOutputs();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions TestCases/deformation/cst/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
run ```SU2_DEF naca0012.cfg``` or ```mpiexec -n 4 SU2_DEF naca0012.cfg``` <br>
the **CST** deformation result as below: <br>
![cst result](Mesh%20Deformation%20Comparison.png "mesh")
Loading

0 comments on commit 8932eed

Please sign in to comment.