SU2
ad_structure.hpp
Go to the documentation of this file.
1 
34 #pragma once
35 
36 #include "../include/datatype_structure.hpp"
37 
44 namespace AD{
50  void StartRecording();
51 
55  void StopRecording();
56 
61  void RegisterInput(su2double &data);
62 
67  void RegisterOutput(su2double &data);
68 
72  void ClearAdjoints();
73 
77  void ComputeAdjoint();
78 
82  void Reset();
83 
88  void ResetInput(su2double &data);
89 
94  void SetPreaccIn(const su2double &data);
95 
101  void SetPreaccIn(const su2double* data, const int size);
102 
109  void SetPreaccIn(const su2double* const *data, const int size_x, const int size_y);
110 
121  void StartPreacc();
122 
127  void SetPreaccOut(su2double &data);
128 
133  void SetPreaccOut(su2double* data, const int size);
134 
139  void SetPreaccOut(su2double** data, const int size_x, const int size_y);
140 
146  void EndPreacc();
147 
148 }
149 
150 /*--- Macro to begin and end sections with a passive tape ---*/
151 
152 #ifdef CODI_REVERSE_TYPE
153 #define AD_BEGIN_PASSIVE \
154  if(AD::globalTape.isActive()) {\
155  AD::globalTape.setPassive();\
156  AD::Status = true; \
157  }
158 #define AD_END_PASSIVE \
159  if(AD::Status) { \
160  AD::globalTape.setActive(); \
161  AD::Status = false; \
162  }
163 #else
164 #define AD_BEGIN_PASSIVE
165 #define AD_END_PASSIVE
166 #endif
167 
168 /*--- If we compile under OSX we have to overload some of the operators for
169  * complex numbers to avoid the use of the standard operators
170  * (they use a lot of functions that are only defined for doubles) ---*/
171 
172 #ifdef __APPLE__
173 
174 namespace std{
175  template<>
176  su2double abs(const complex<su2double>& x);
177 
178  template<>
179  complex<su2double> operator/(const complex<su2double>& x, const complex<su2double>& y);
180 
181  template<>
182  complex<su2double> operator*(const complex<su2double>& x, const complex<su2double>& y);
183 }
184 #endif
185 #include "ad_structure.inl"
void ClearAdjoints()
Clears the currently stored adjoints but keeps the computational graph.
Definition: ad_structure.inl:172
void ComputeAdjoint()
Computes the adjoints, i.e. the derivatives of the output with respect to the input variables...
Definition: ad_structure.inl:174
CSysVector operator*(const su2double &val, const CSysVector &u)
Definition: vector_structure.cpp:303
void ResetInput(su2double &data)
Reset the variable (set index to zero).
Definition: ad_structure.inl:178
void SetPreaccIn(const su2double &data)
Sets the scalar input of a preaccumulation section.
Definition: ad_structure.inl:180
void SetPreaccOut(su2double &data)
Sets the scalar output of a preaccumulation section.
Definition: ad_structure.inl:186
void StartPreacc()
Starts a new preaccumulation section and sets the input variables.
Definition: ad_structure.inl:192
void EndPreacc()
Ends a preaccumulation section and computes the local Jacobi matrix of a code section using the varia...
Definition: ad_structure.inl:194
Contains routines for the reverse mode of AD. In case there is no reverse type configured, they have no effect at all.
void Reset()
Reset the tape structure to be ready for a new recording.
Definition: ad_structure.inl:176
void RegisterOutput(su2double &data)
Registers the variable as an output. I.e. as the root of the computational graph. ...
Definition: ad_structure.inl:166
void StartRecording()
Start the recording of the operations and involved variables. If called, the computational graph of a...
Definition: ad_structure.inl:168
void StopRecording()
Stops the recording of the operations and variables.
Definition: ad_structure.inl:170
Main routines for the algorithmic differentiation (AD) structure.
void RegisterInput(su2double &data)
Registers the variable as an input. I.e. as a leaf of the computational graph.
Definition: ad_structure.inl:164