NeoPZ
fadType.h
Go to the documentation of this file.
1 #ifndef FADTYPE_H
2 #define FADTYPE_H
3 
4 #ifdef _AUTODIFF
5 
6 
7 //using namespace std;
8 
9 #include "fad.h"
10 #include "tinyfad.h"
11 #include "tfad.h" // tinyFadET
12 
13 
14 #include "pzreal.h"
15 #include "pzvec.h"
16 
17 const int REALdim = 3;
18 
19 typedef TFad<REALdim, REAL> TFADETREAL_;// TinyFAD with Expression templates
20 typedef TinyFad<REALdim, REAL> TFADREAL_;// TinyFAD - the easiest to use
21 typedef Fad<REAL> FADREAL_; // the simplest FAD
22 
23 typedef FADREAL_ FADREAL;
24 
25 typedef Fad< Fad<REAL> > FADFADREAL;
26 typedef Fad< Fad<STATE> > FADFADSTATE;
27 
28 //#define _AUTODIFF
29 
30 #include "pzfmatrix.h"
31 
32 
33 class shapeFAD
34 {
35 public:
36  static void ExplodeDerivatives(TPZVec<FADREAL> & in, TPZFMatrix<REAL> & phiOut, TPZFMatrix<REAL> & dphiOut)
37  {
38  int nphi = in.NElements(), nder = in[0].size();
39  phiOut.Redim(nphi, 1);
40  dphiOut.Redim(nder, nphi);
41 
42  int i, j;
43  for(i = 0; i < nphi; i++)
44  {
45  phiOut(i,0) = in[i].val();
46  for(j = 0; j < nder; j++)
47  {
48  dphiOut(j,i) = in[i].dx(j);
49  }
50  }
51  return;
52  }
53 
54  static REAL val( const int number)
55  {
56  return (REAL)number;
57  }
58  static REAL val( const int64_t number)
59  {
60  return (REAL)number;
61  }
62  static REAL val( const float number)
63  {
64  return (REAL)number;
65  }
66  static REAL val( const double number)
67  {
68  return (REAL)number;
69  }
70  static REAL val( const long double number)
71  {
72  return (REAL)number;
73  }
74  static REAL val( const std::complex<float> number)
75  {
76  return (REAL)number.real();
77  }
78  static REAL val( const std::complex<double> number)
79  {
80  return (REAL)number.real();
81  }
82  static REAL val( const std::complex<long double> number)
83  {
84  return (REAL)number.real();
85  }
86 
87  template <class T>
88  static REAL val(const T number)
89  {
90  return TPZExtractVal::val( number.val() ); // recursively downgrading until REAL type is reached
91  }
92 
93  template<class T>
94  static bool IsZero( const T & a ){
96  }
97 
98 };
99 
100 template class Fad<float>;
101 template class Fad<double>;
102 template class Fad<long double>;
103 
104 #endif // End of _AUTODIFF define
105 
106 #endif
107 
bool IsZero(long double a)
Returns if the value a is close Zero as the allowable tolerance.
Definition: pzreal.h:668
Templated vector implementation.
Definition: fad.h:54
This class implements a simple vector storage scheme for a templated class T. Utility.
Definition: pzgeopoint.h:19
REAL val(STATE &number)
Returns value of the variable.
Definition: pzartdiff.h:23
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
Contains TPZMatrixclass which implements full matrix (using column major representation).
Definition: tfad.h:64
static REAL val(const int number)
Definition: pzextractval.h:21
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
Definition: pzfmatrix.h:616
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
Contains the declaration of TPZFlopCounter class and TPZCounter struct.