Trilinos::Sacado example
Sacado-auxiliary_functions.h
Go to the documentation of this file.
1 #ifndef Sacado_auxiliary_functions_H
2 #define Sacado_auxiliary_functions_H
3 
4 #include <deal.II/base/symmetric_tensor.h>
5 #include <iostream>
6 #include <Sacado.hpp>
7 using fad_double = Sacado::Fad::DFad<double>;
8 
9 using namespace dealii;
10 
11 template<int dim>
12 SymmetricTensor<2,dim,fad_double> init_Sacado(const SymmetricTensor<2,dim,double> &SymTensor)
13 {
14  SymmetricTensor<2,dim,fad_double> SymTensor_Sacado;
15  for ( unsigned int i=0; i<dim; ++i)
16  for ( unsigned int j=i; j<dim; ++j )
17  SymTensor_Sacado[i][j] = SymTensor[i][j];
18 
19  return SymTensor_Sacado;
20 }
21 
22 
23 template<int dim>
24 SymmetricTensor<2,dim> extract_value_from_Sacado(const SymmetricTensor<2,dim,fad_double> &SymTensor_Sacado)
25 {
26  SymmetricTensor<2,dim> SymTensor;
27  // .val() extracts the \a double value from the Sacado variable
28  for ( unsigned int i=0; i<dim; ++i)
29  for ( unsigned int j=i; j<dim; ++j )
30  SymTensor[i][j] = SymTensor_Sacado[i][j].val();
31 
32  return SymTensor;
33 }
34 
35 
36 template<int dim>
37 Vector<fad_double> reinit(unsigned int a, bool b)
38 {
39  Vector<fad_double> abc (5);
40  return abc;
41 }
42 
43 #endif //Sacado_auxiliary_functions_H
Vector< fad_double > reinit(unsigned int a, bool b)
Definition: Sacado-auxiliary_functions.h:37
SymmetricTensor< 2, dim, fad_double > init_Sacado(const SymmetricTensor< 2, dim, double > &SymTensor)
Definition: Sacado-auxiliary_functions.h:12
SymmetricTensor< 2, dim > extract_value_from_Sacado(const SymmetricTensor< 2, dim, fad_double > &SymTensor_Sacado)
Definition: Sacado-auxiliary_functions.h:24
Sacado::Fad::DFad< double > fad_double
Definition: Sacado-auxiliary_functions.h:7