typedef Sacado::Fad::DFad<T> type;
};
+
+
+/**
+ * Compute the scalar product $a:b=\sum_{i,j} a_{ij}b_{ij}$ between two
+ * tensors $a,b$ of rank 2. We don't use <code>operator*</code> for this
+ * operation since the product between two tensors is usually assumed to be
+ * the contraction over the last index of the first tensor and the first index
+ * of the second tensor, for example $(a\cdot b)_{ij}=\sum_k a_{ik}b_{kj}$.
+ *
+ * @relates Tensor @relates SymmetricTensor
+ */
+template <int dim, typename Number, typename T>
+inline
+Sacado::Fad::DFad<T>
+scalar_product (const SymmetricTensor<2,dim,Sacado::Fad::DFad<T> > &t1,
+ const Tensor<2,dim,Number> &t2)
+{
+ Sacado::Fad::DFad<T> s = 0;
+ for (unsigned int i=0; i<dim; ++i)
+ for (unsigned int j=0; j<dim; ++j)
+ s += t1[i][j] * t2[i][j];
+ return s;
+}
+
+
+/**
+ * Compute the scalar product $a:b=\sum_{i,j} a_{ij}b_{ij}$ between two
+ * tensors $a,b$ of rank 2. We don't use <code>operator*</code> for this
+ * operation since the product between two tensors is usually assumed to be
+ * the contraction over the last index of the first tensor and the first index
+ * of the second tensor, for example $(a\cdot b)_{ij}=\sum_k a_{ik}b_{kj}$.
+ *
+ * @relates Tensor @relates SymmetricTensor
+ */
+template <int dim, typename Number, typename T >
+inline
+Sacado::Fad::DFad<T>
+scalar_product (const Tensor<2,dim,Number> &t1,
+ const SymmetricTensor<2,dim,Sacado::Fad::DFad<T> > &t2)
+{
+ return scalar_product(t2, t1);
+}
+
+
+/**
+ * Compute the scalar product $a:b=\sum_{i,j} a_{ij}b_{ij}$ between two
+ * tensors $a,b$ of rank 2. We don't use <code>operator*</code> for this
+ * operation since the product between two tensors is usually assumed to be
+ * the contraction over the last index of the first tensor and the first index
+ * of the second tensor, for example $(a\cdot b)_{ij}=\sum_k a_{ik}b_{kj}$.
+ *
+ * @relates Tensor @relates SymmetricTensor
+ */
+template <int dim, typename Number, typename T>
+inline
+Sacado::Fad::DFad<T>
+scalar_product (const SymmetricTensor<2,dim,Number> &t1,
+ const Tensor<2,dim,Sacado::Fad::DFad<T> > &t2)
+{
+ Sacado::Fad::DFad<T> s = 0;
+ for (unsigned int i=0; i<dim; ++i)
+ for (unsigned int j=0; j<dim; ++j)
+ s += t1[i][j] * t2[i][j];
+ return s;
+}
+
+
+/**
+ * Compute the scalar product $a:b=\sum_{i,j} a_{ij}b_{ij}$ between two
+ * tensors $a,b$ of rank 2. We don't use <code>operator*</code> for this
+ * operation since the product between two tensors is usually assumed to be
+ * the contraction over the last index of the first tensor and the first index
+ * of the second tensor, for example $(a\cdot b)_{ij}=\sum_k a_{ik}b_{kj}$.
+ *
+ * @relates Tensor @relates SymmetricTensor
+ */
+template <int dim, typename Number, typename T >
+inline
+Sacado::Fad::DFad<T>
+scalar_product (const Tensor<2,dim,Sacado::Fad::DFad<T> > &t1,
+ const SymmetricTensor<2,dim,Number> &t2)
+{
+ return scalar_product(t2, t1);
+}
+
DEAL_II_NAMESPACE_CLOSE
#endif // DEAL_II_WITH_TRILINOS
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2015 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// test scalar_product between tensors and symmetric tensors with Sacado
+
+#include <iomanip>
+#include <fstream>
+
+#include <deal.II/base/symmetric_tensor.h>
+#include <deal.II/base/sacado_product_type.h>
+
+#include "../tests.h"
+
+
+int main()
+{
+ typedef Sacado::Fad::DFad<double> Sdouble;
+ std::ofstream logfile("output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+
+ // check product with Tensor<2,dim>
+ Tensor<2,2,Sdouble> t;
+ SymmetricTensor<2,2,double> st;
+ Sdouble a(2,0,7.0);
+ Sdouble b(2,1,3.0);
+
+ for (unsigned int i=0; i<2; ++i)
+ for (unsigned int j=0; j<2; ++j)
+ {
+ t[i][j] = 2.*a+i*j*b;
+ st[i][j] = (1.+(i+1)*(j*2));
+ }
+
+ deallog << scalar_product(t,st) << std::endl;
+ deallog << scalar_product(st,t) << std::endl;
+
+}
--- /dev/null
+
+DEAL::127.000 [ 16.0000 5.00000 ]
+DEAL::127.000 [ 16.0000 5.00000 ]
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2015 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// test scalar_product between tensors and symmetric tensors with Sacado
+
+#include <iomanip>
+#include <fstream>
+
+#include <deal.II/base/symmetric_tensor.h>
+#include <deal.II/base/sacado_product_type.h>
+
+#include "../tests.h"
+
+
+int main()
+{
+ typedef Sacado::Fad::DFad<double> Sdouble;
+ typedef Sacado::Fad::DFad<Sdouble> SSdouble;
+ std::ofstream logfile("output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+
+ // check product with Tensor<2,dim>
+ Tensor<2,2,SSdouble> t;
+ SymmetricTensor<2,2,double> st;
+ SSdouble a(2,0,7.0);
+ SSdouble b(2,1,3.0);
+ a.val() = Sdouble(2,0,7.0);
+ b.val() = Sdouble(2,1,3.0);
+
+ for (unsigned int i=0; i<2; ++i)
+ for (unsigned int j=0; j<2; ++j)
+ {
+ t[i][j] = 2.*a+i*j*b;
+ st[i][j] = (1.+(i+1)*(j*2));
+ }
+
+ deallog << scalar_product(t,st) << std::endl;
+ deallog << scalar_product(st,t) << std::endl;
+
+}
--- /dev/null
+
+DEAL::127.000 [ 16.0000 5.00000 ] [ 16.0000 [ ] 5.00000 [ ] ]
+DEAL::127.000 [ 16.0000 5.00000 ] [ 16.0000 [ ] 5.00000 [ ] ]
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2015 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// test scalar_product between tensors and symmetric tensors with Sacado
+
+#include <iomanip>
+#include <fstream>
+
+#include <deal.II/base/symmetric_tensor.h>
+#include <deal.II/base/sacado_product_type.h>
+
+#include "../tests.h"
+
+
+int main()
+{
+ typedef Sacado::Fad::DFad<double> Sdouble;
+ std::ofstream logfile("output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+
+ // check product with Tensor<2,dim>
+ Tensor<2,2,double> t;
+ SymmetricTensor<2,2,Sdouble> st;
+ Sdouble a(2,0,7.0);
+ Sdouble b(2,1,3.0);
+
+ for (unsigned int i=0; i<2; ++i)
+ for (unsigned int j=0; j<2; ++j)
+ {
+ t[i][j] = (1.+(i+1)*(j*2));
+ st[i][j] = 2.*a+i*j*b;
+ }
+
+ deallog << scalar_product(t,st) << std::endl;
+ deallog << scalar_product(st,t) << std::endl;
+
+}
--- /dev/null
+
+DEAL::155.000 [ 20.0000 5.00000 ]
+DEAL::155.000 [ 20.0000 5.00000 ]
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2015 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// test scalar_product between tensors and symmetric tensors with Sacado
+
+#include <iomanip>
+#include <fstream>
+
+#include <deal.II/base/symmetric_tensor.h>
+#include <deal.II/base/sacado_product_type.h>
+
+#include "../tests.h"
+
+
+int main()
+{
+ typedef Sacado::Fad::DFad<double> Sdouble;
+ typedef Sacado::Fad::DFad<Sdouble> SSdouble;
+ std::ofstream logfile("output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+
+ // check product with Tensor<2,dim>
+ Tensor<2,2,double> t;
+ SymmetricTensor<2,2,SSdouble> st;
+ SSdouble a(2,0,7.0);
+ SSdouble b(2,1,3.0);
+ a.val() = Sdouble(2,0,7.0);
+ b.val() = Sdouble(2,1,3.0);
+
+ for (unsigned int i=0; i<2; ++i)
+ for (unsigned int j=0; j<2; ++j)
+ {
+ t[i][j] = (1.+(i+1)*(j*2));
+ st[i][j] = 2.*a+i*j*b;
+ }
+
+ deallog << scalar_product(t,st) << std::endl;
+ deallog << scalar_product(st,t) << std::endl;
+
+}
--- /dev/null
+
+DEAL::155.000 [ 20.0000 5.00000 ] [ 20.0000 [ ] 5.00000 [ ] ]
+DEAL::155.000 [ 20.0000 5.00000 ] [ 20.0000 [ ] 5.00000 [ ] ]