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
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: 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
2 changes: 1 addition & 1 deletion meson_scripts/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def init_submodules(

# This information of the modules is used if projects was not cloned using git
# The sha tag must be maintained manually to point to the correct commit
sha_version_codi = "8ee822a9b0bb8235a2494467b774e27fb64ff14f"
sha_version_codi = "eee1b5eea2ded8126c34c1415e3b9cf15a3e70f2"
github_repo_codi = "https://github.com/scicompkl/CoDiPack"
sha_version_medi = "aafc2d1966ba1233640af737e71c77c1a86183fd"
github_repo_medi = "https://github.com/SciCompKL/MeDiPack"
Expand Down