16 #ifndef _d2k_sacado_tools_h 17 #define _d2k_sacado_tools_h 19 #include <deal2lkit/config.h> 30 #ifdef DEAL_II_WITH_TRILINOS 34 typedef Sacado::Fad::DFad<double> Sdouble;
35 typedef Sacado::Fad::DFad<Sdouble> SSdouble;
52 template<
int dim,
typename Number>
57 for (
unsigned int i=0; i<dim; ++i)
69 template<
int dim,
typename Number>
73 return SacadoTools::scalar_product(T2,T1);
95 template<
int dim,
typename Number>
100 for (
unsigned int i=0; i<dim; ++i)
101 for (
unsigned int j=0; j<dim; ++j)
102 ret += T1[i][j]*T2[i][j];
113 template<
int dim,
typename Number>
117 return SacadoTools::scalar_product(T2,T1);
129 return dealii::scalar_product(T1,T2);
139 double val(
const double &n)
149 template <
typename number>
150 number val(
const Sacado::Fad::DFad<number> &n)
160 template <
int index,
int dim,
typename number>
164 for (
unsigned int i=0; i<dim; ++i)
175 template <
int index,
int dim,
typename number>
176 std::vector<Tensor<index,dim,number> > val(
const std::vector<
Tensor<index,dim,Sacado::Fad::DFad<number> > > &T)
178 std::vector<Tensor<index,dim,number> > ret(T.size());
179 for (
unsigned int q=0; q<T.size(); ++q)
189 template <
typename number>
190 std::vector<number> val(
const std::vector<Sacado::Fad::DFad<number> > v)
192 std::vector<number> ret(v.size());
193 for (
unsigned int i=0; i<v.size(); ++i)
205 double to_double(
const double &s)
215 double to_double(
const Sdouble &s)
225 double to_double(
const SSdouble &s)
227 return s.val().val();
235 template <
int index,
int dim>
247 template <
int index,
int dim,
typename number>
251 for (
unsigned int i=0; i<dim; ++i)
252 ret[i] = to_double(t[i]);
263 template <
int index,
int dim,
typename number>
264 std::vector<Tensor<index,dim> > to_double(
const std::vector<
Tensor<index,dim,Sacado::Fad::DFad<number> > > &v)
266 std::vector<Tensor<index,dim> > ret(v.size());
267 for (
unsigned int q=0; q<v.size(); ++q)
268 ret[q] = to_double(v[q]);
279 template <
typename number>
280 std::vector<double> to_double(
const std::vector<number> &v)
282 std::vector<double> ret(v.size());
283 for (
unsigned int q=0; q<v.size(); ++q)
284 ret[q] = to_double(v[q]);
294 #endif // DEAL_II_WITH_TRILINOS