v0.14.0
Macros | Functions
ftensor_and_adolc_tapeless.cpp File Reference
#include <ostream>
#include <adolc/adtl.h>
#include <FTensor.hpp>

Go to the source code of this file.

Macros

#define ADOLC_TAPELESS
 
#define NUMBER_DIRECTIONS   6
 
#define FTENSOR_DEBUG
 

Functions

int main (int argc, char *argv[])
 

Macro Definition Documentation

◆ ADOLC_TAPELESS

#define ADOLC_TAPELESS

Definition at line 8 of file ftensor_and_adolc_tapeless.cpp.

◆ FTENSOR_DEBUG

#define FTENSOR_DEBUG

Definition at line 15 of file ftensor_and_adolc_tapeless.cpp.

◆ NUMBER_DIRECTIONS

#define NUMBER_DIRECTIONS   6

Definition at line 9 of file ftensor_and_adolc_tapeless.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 18 of file ftensor_and_adolc_tapeless.cpp.

19 {
20  adtl::setNumDir(6);
23 
24  FTensor::Tensor1<double, 2> t1(1., 1.);
25  FTensor::Tensor2<double, 2, 2> t2(1., 0., 0., 1.);
26 
29 
30  int dd0 = 0;
31  for(int ii = 0; ii != 2; ii++, dd0++)
32  {
33  a_t1(ii).setValue(t1(ii));
34  for(int kk = 0; kk != 6; kk++)
35  {
36  if(dd0 == kk)
37  {
38  a_t1(ii).setADValue(kk, 1);
39  }
40  else
41  {
42  a_t1(ii).setADValue(kk, 0);
43  }
44  }
45  }
46  for(int ii = 0; ii != 2; ii++)
47  {
48  for(int jj = 0; jj != 2; jj++, dd0++)
49  {
50  a_t2(ii, jj).setValue(t2(ii, jj));
51  for(int kk = 0; kk != 6; kk++)
52  {
53  if(kk == dd0)
54  {
55  a_t2(ii, jj).setADValue(kk, 1);
56  }
57  else
58  {
59  a_t2(ii, jj).setADValue(kk, 0);
60  }
61  }
62  }
63  }
64  for(int ii = 0; ii != 2; ii++)
65  {
66  std::cout << "a_t1 ( " << ii << " ) = " << a_t1(ii) << std::endl;
67  }
68  for(int ii = 0; ii != 2; ii++)
69  {
70  for(int jj = 0; jj != 2; jj++)
71  {
72  std::cout << "a_t1 ( " << ii << "," << jj << " ) = " << a_t2(ii, jj)
73  << std::endl;
74  }
75  }
76 
77  adtl::adouble a_t0 = a_t1(I) * a_t2(I, J) * a_t1(J);
78 
79  double t0;
80  t0 = a_t0.getValue();
81  std::cout << "Value: " << t0 << " ( " << a_t0 << " ) " << std::endl;
82 
85 
86  int dd = 0;
87  for(int ii = 0; ii != 2; ii++, dd++)
88  {
89  ad_t0_t1(ii) = a_t0.getADValue(dd);
90  }
91  for(int ii = 0; ii != 2; ii++)
92  {
93  for(int jj = 0; jj != 2; jj++, dd++)
94  {
95  ad_t0_t2(ii, jj) = a_t0.getADValue(dd);
96  }
97  }
98 
99  // 2nd derivative
100  FTensor::Tensor2<double, 2, 2> ad_t0_t1_t1;
101 
102  std::cout << "Derivatives t0_t1" << std::endl;
103  for(int ii = 0; ii != 2; ii++, dd++)
104  {
105  std::cout << ad_t0_t1(ii) << std::endl;
106  if(ad_t0_t1(ii) != 2)
107  {
108  std::cerr << "Wrong result, should be 2" << std::endl;
109  exit(-1);
110  }
111  }
112  std::cout << "Derivatives t0_t2" << std::endl;
113  for(int ii = 0; ii != 2; ii++)
114  {
115  for(int jj = 0; jj != 2; jj++, dd++)
116  {
117  std::cout << ad_t0_t2(ii, jj) << " ";
118  if(ad_t0_t2(ii, ii) != 1)
119  {
120  std::cerr << "Wrong result, should be 1" << std::endl;
121  exit(-1);
122  }
123  }
124  std::cout << "\n";
125  }
126 
127  return 0;
128 }
FTensor::Tensor1
Definition: Tensor1_value.hpp:8
J
FTensor::Index< 'J', DIM1 > J
Definition: level_set.cpp:30
FTensor::Tensor2
Definition: Tensor2_value.hpp:16
I
constexpr IntegrationType I
Definition: operators_tests.cpp:31
FTensor::Index
Definition: Index.hpp:23
FTensor::dd
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: ddTensor0.hpp:33