OpenLB 1.7
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
olb::util::ADf< T, DIM > Class Template Reference

Definition of a description of a algoritmic differentiation data type using the forward method. More...

#include <aDiff.h>

+ Inheritance diagram for olb::util::ADf< T, DIM >:
+ Collaboration diagram for olb::util::ADf< T, DIM >:

Public Types

using base_t = T
 

Public Member Functions

constexpr ADf ()
 
constexpr ADf (const ADf &a)
 
constexpr ADf (const T &v)
 
constexpr ADf (const T &v, const Vector< T, DIM > &d)
 
constexpr ADf (ADf &&a)
 
constexpr T & v ()
 
constexpr T & d (unsigned i)
 
constexpr const T & d (unsigned i) const
 
constexpr Vector< T, DIM > & d ()
 
constexpr ADfoperator= (const ADf &a)
 
constexpr ADfoperator= (ADf &&a)
 
constexpr ADfoperator= (const T &v)
 
constexpr ADfoperator+= (const ADf &a)
 
constexpr ADfoperator+= (const T &v)
 
constexpr ADfoperator-= (const ADf &a)
 
constexpr ADfoperator-= (const T &v)
 
constexpr ADfoperator*= (const ADf &a)
 
constexpr ADfoperator*= (const T &v)
 
constexpr ADfoperator/= (const ADf &a)
 
constexpr ADfoperator/= (const T &v)
 
constexpr void setDiffVariable (unsigned iD)
 
constexpr bool hasZeroDerivative () const
 tests if ADf has only zero derivatives
 
constexpr operator base_t () const
 

Public Attributes

_v = T()
 value
 
Vector< T, DIM > _d = ( T( 0 ) )
 derivatives
 

Static Public Attributes

static constexpr unsigned dim = DIM
 

Detailed Description

template<class T, unsigned DIM>
class olb::util::ADf< T, DIM >

Definition of a description of a algoritmic differentiation data type using the forward method.

An ADf is a data type which enables the calculation of derivatives by means of algorithmic differentiation.

This class is not intended to be derived from. See olb::meta::is_arithmetic

Definition at line 64 of file aDiff.h.

Member Typedef Documentation

◆ base_t

template<class T , unsigned DIM>
using olb::util::ADf< T, DIM >::base_t = T

Definition at line 68 of file aDiff.h.

Constructor & Destructor Documentation

◆ ADf() [1/5]

template<class T , unsigned DIM>
constexpr olb::util::ADf< T, DIM >::ADf ( )
inlineconstexpr

Definition at line 128 of file aDiff.h.

128 :ADf<T,DIM>( T() )
129{ }

◆ ADf() [2/5]

template<class T , unsigned DIM>
constexpr olb::util::ADf< T, DIM >::ADf ( const ADf< T, DIM > & a)
inlineconstexpr

Definition at line 132 of file aDiff.h.

132 :ADf<T,DIM>(a._v, a._d)
133{ }

◆ ADf() [3/5]

template<class T , unsigned DIM>
constexpr olb::util::ADf< T, DIM >::ADf ( const T & v)
inlineconstexpr

Definition at line 136 of file aDiff.h.

136 :ADf<T,DIM>(v,Vector<T,DIM> {})
137{ }
constexpr T & v()
Definition aDiff.h:246

◆ ADf() [4/5]

template<class T , unsigned DIM>
constexpr olb::util::ADf< T, DIM >::ADf ( const T & v,
const Vector< T, DIM > & d )
inlineconstexpr

Definition at line 140 of file aDiff.h.

140 : _v(v), _d(d)
141{
142 checkDataType();
143}
T _v
value
Definition aDiff.h:72
Vector< T, DIM > _d
derivatives
Definition aDiff.h:74
constexpr Vector< T, DIM > & d()
Definition aDiff.h:264

◆ ADf() [5/5]

template<class T , unsigned DIM>
constexpr olb::util::ADf< T, DIM >::ADf ( ADf< T, DIM > && a)
inlineconstexpr

Definition at line 146 of file aDiff.h.

146 :ADf<T,DIM>(a._v, a._d)
147{ }

Member Function Documentation

◆ d() [1/3]

template<class T , unsigned DIM>
constexpr Vector< T, DIM > & olb::util::ADf< T, DIM >::d ( )
inlineconstexpr

Definition at line 264 of file aDiff.h.

265{
266 return _d;
267}

◆ d() [2/3]

template<class T , unsigned DIM>
constexpr T & olb::util::ADf< T, DIM >::d ( unsigned i)
inlineconstexpr

Definition at line 252 of file aDiff.h.

253{
254 return _d[i];
255}
+ Here is the caller graph for this function:

◆ d() [3/3]

template<class T , unsigned DIM>
constexpr const T & olb::util::ADf< T, DIM >::d ( unsigned i) const
inlineconstexpr

Definition at line 258 of file aDiff.h.

259{
260 return _d[i];
261}

◆ hasZeroDerivative()

template<class T , unsigned DIM>
constexpr bool olb::util::ADf< T, DIM >::hasZeroDerivative ( ) const
inlineconstexpr

tests if ADf has only zero derivatives

Definition at line 731 of file aDiff.h.

732{
733 T sum = 0;
734 for (unsigned i=0; i<DIM; i++) {
735 sum += std::fabs(_d[i]);
736 }
737 return sum==0;
738}

◆ operator base_t()

template<class T , unsigned DIM>
constexpr olb::util::ADf< T, DIM >::operator base_t ( ) const
inlineconstexpr

◆ operator*=() [1/2]

template<class T , unsigned DIM>
constexpr ADf< T, DIM > & olb::util::ADf< T, DIM >::operator*= ( const ADf< T, DIM > & a)
inlineconstexpr

Definition at line 212 of file aDiff.h.

213{
214 _d=_d*a._v+_v*a._d;
215 _v*=a._v;
216 return *this;
217}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

◆ operator*=() [2/2]

template<class T , unsigned DIM>
constexpr ADf< T, DIM > & olb::util::ADf< T, DIM >::operator*= ( const T & v)
inlineconstexpr

Definition at line 220 of file aDiff.h.

221{
222 _v*=v;
223 _d*=v;
224 return *this;
225}

◆ operator+=() [1/2]

template<class T , unsigned DIM>
constexpr ADf< T, DIM > & olb::util::ADf< T, DIM >::operator+= ( const ADf< T, DIM > & a)
inlineconstexpr

Definition at line 182 of file aDiff.h.

183{
184 _v+=a._v;
185 _d+=a._d;
186 return *this;
187}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

◆ operator+=() [2/2]

template<class T , unsigned DIM>
constexpr ADf< T, DIM > & olb::util::ADf< T, DIM >::operator+= ( const T & v)
inlineconstexpr

Definition at line 190 of file aDiff.h.

191{
192 _v+=v;
193 return *this;
194}

◆ operator-=() [1/2]

template<class T , unsigned DIM>
constexpr ADf< T, DIM > & olb::util::ADf< T, DIM >::operator-= ( const ADf< T, DIM > & a)
inlineconstexpr

Definition at line 197 of file aDiff.h.

198{
199 _v-=a._v;
200 _d-=a._d;
201 return *this;
202}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

◆ operator-=() [2/2]

template<class T , unsigned DIM>
constexpr ADf< T, DIM > & olb::util::ADf< T, DIM >::operator-= ( const T & v)
inlineconstexpr

Definition at line 205 of file aDiff.h.

206{
207 _v-=v;
208 return *this;
209}

◆ operator/=() [1/2]

template<class T , unsigned DIM>
constexpr ADf< T, DIM > & olb::util::ADf< T, DIM >::operator/= ( const ADf< T, DIM > & a)
inlineconstexpr

Definition at line 228 of file aDiff.h.

229{
230 T tmp(T(1)/a._v);
231 _v*=tmp;
232 _d=tmp*(_d-_v*a._d);
233 return *this;
234}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

◆ operator/=() [2/2]

template<class T , unsigned DIM>
constexpr ADf< T, DIM > & olb::util::ADf< T, DIM >::operator/= ( const T & v)
inlineconstexpr

Definition at line 237 of file aDiff.h.

238{
239 T tmp(T(1)/v);
240 _v*=tmp;
241 _d*=tmp;
242 return *this;
243}

◆ operator=() [1/3]

template<class T , unsigned DIM>
constexpr ADf< T, DIM > & olb::util::ADf< T, DIM >::operator= ( ADf< T, DIM > && a)
inlineconstexpr

Definition at line 166 of file aDiff.h.

167{
168 _v=a._v;
169 _d=a._d;
170 return *this;
171}

References olb::util::ADf< T, DIM >::_v.

◆ operator=() [2/3]

template<class T , unsigned DIM>
constexpr ADf< T, DIM > & olb::util::ADf< T, DIM >::operator= ( const ADf< T, DIM > & a)
inlineconstexpr

Definition at line 158 of file aDiff.h.

159{
160 _v=a._v;
161 _d=a._d;
162 return *this;
163}

References olb::util::ADf< T, DIM >::_d, and olb::util::ADf< T, DIM >::_v.

◆ operator=() [3/3]

template<class T , unsigned DIM>
constexpr ADf< T, DIM > & olb::util::ADf< T, DIM >::operator= ( const T & v)
inlineconstexpr

Definition at line 174 of file aDiff.h.

175{
176 _v=v;
177 _d = ( T() );
178 return *this;
179}

◆ setDiffVariable()

template<class T , unsigned DIM>
constexpr void olb::util::ADf< T, DIM >::setDiffVariable ( unsigned iD)
inlineconstexpr

Definition at line 270 of file aDiff.h.

271{
272 _d =( T(0) );
273 _d[iD] = T(1);
274}
+ Here is the caller graph for this function:

◆ v()

template<class T , unsigned DIM>
constexpr T & olb::util::ADf< T, DIM >::v ( )
inlineconstexpr

Definition at line 246 of file aDiff.h.

247{
248 return _v;
249}
+ Here is the caller graph for this function:

Member Data Documentation

◆ _d

template<class T , unsigned DIM>
Vector<T,DIM> olb::util::ADf< T, DIM >::_d = ( T( 0 ) )

derivatives

Definition at line 74 of file aDiff.h.

◆ _v

template<class T , unsigned DIM>
T olb::util::ADf< T, DIM >::_v = T()

value

Definition at line 72 of file aDiff.h.

◆ dim

template<class T , unsigned DIM>
constexpr unsigned olb::util::ADf< T, DIM >::dim = DIM
staticconstexpr

Definition at line 69 of file aDiff.h.


The documentation for this class was generated from the following files: