Skip to content

Commit a1c4e3e

Browse files
committed
Add BeginUseAdjoints and EndUseAdjoints.
1 parent 3df7f8d commit a1c4e3e

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Common/include/basic_types/ad_structure.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@ inline void RegisterOutput(su2double& data) {}
7878
*/
7979
inline void ResizeAdjoints() {}
8080

81+
/*!
82+
* \brief Declare that the adjoints are being used, to protect against resizing.
83+
*
84+
* Should be used together with AD::EndUseAdjoints() to protect AD::SetDerivative() and AD::GetDerivative() calls,
85+
* multiple at once if possible.
86+
*/
87+
inline void BeginUseAdjoints() {}
88+
89+
/*!
90+
* \brief Declare that the adjoints are no longer being used.
91+
*/
92+
inline void EndUseAdjoints() {}
93+
8194
/*!
8295
* \brief Sets the adjoint value at index to val
8396
* \param[in] index - Position in the adjoint vector.
@@ -375,6 +388,10 @@ FORCEINLINE void Reset() {
375388

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

391+
FORCEINLINE void BeginUseAdjoints() { AD::getTape().beginUseAdjointVector(); }
392+
393+
FORCEINLINE void EndUseAdjoints() { AD::getTape().beginUseAdjointVector(); }
394+
378395
FORCEINLINE void SetIndex(int& index, const su2double& data) { index = data.getIdentifier(); }
379396

380397
// WARNING: For performance reasons, this method does not perform bounds checking.

0 commit comments

Comments
 (0)