Skip to content

Commit aa5d8f2

Browse files
committed
Exclude max variables from recording (follow-up from fixing preaccumulation error).
1 parent 3f25e60 commit aa5d8f2

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Common/include/basic_types/ad_structure.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ using Identifier = int;
4848
*/
4949
inline void StartRecording() {}
5050

51+
/*!
52+
* \brief Pause the recording of the operations and involved variables.
53+
* If called, all operations occuring after the call will not be stored on the computational graph.
54+
*/
55+
inline void PauseRecording() {}
56+
57+
/*!
58+
* \brief Resume the recording of the operations and variables after the recording had been paused.
59+
*/
60+
inline void ResumeRecording() {}
61+
5162
/*!
5263
* \brief Stops the recording of the operations and variables.
5364
*/
@@ -402,6 +413,10 @@ FORCEINLINE void ResetInput(su2double& data) { data = data.getValue(); }
402413

403414
FORCEINLINE void StartRecording() { AD::getTape().setActive(); }
404415

416+
FORCEINLINE void PauseRecording() { AD::getTape().setPassive(); }
417+
418+
FORCEINLINE void ResumeRecording() { AD::getTape().setActive(); }
419+
405420
FORCEINLINE void StopRecording() { AD::getTape().setPassive(); }
406421

407422
FORCEINLINE bool TapeActive() { return AD::getTape().isActive(); }

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,9 +673,11 @@ void CFVMFlowSolverBase<V, R>::ComputeVorticityAndStrainMag(const CConfig& confi
673673
AD::SetPreaccOut(StrainMag(iPoint));
674674
AD::EndPreacc();
675675

676-
/*--- Max is not differentiable, so we not register them for preacc. ---*/
676+
/*--- We don't need to record strainMax and omegaMax. ---*/
677+
AD::PauseRecording();
677678
strainMax = max(strainMax, StrainMag(iPoint));
678679
omegaMax = max(omegaMax, GeometryToolbox::Norm(3, Vorticity));
680+
AD::ResumeRecording();
679681

680682
}
681683
END_SU2_OMP_FOR

0 commit comments

Comments
 (0)