From: Matthias Maier Date: Tue, 15 Sep 2015 06:18:28 +0000 (-0500) Subject: tensor.h: Deprecate "contract" function X-Git-Tag: v8.4.0-rc2~411^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18f50f33fac8a39d4f266beb0622f53b66083675;p=dealii.git tensor.h: Deprecate "contract" function --- diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index 060f47019a..cc53f565c8 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -1537,27 +1537,6 @@ outer_product(const Tensor &src1, //@{ -/** - * Contract a tensor of rank 1 with a tensor of rank 1. The result is - * sum_j src1[j] src2[j]. - * - * @relates Tensor - */ -template -inline -typename ProductType::type -contract (const Tensor<1,dim,Number> &src1, - const Tensor<1,dim,OtherNumber> &src2) -{ - typename ProductType::type res - = typename ProductType::type(); - for (unsigned int i=0; i sumi,j src1[i][j]*src2[i][j]. @@ -1578,73 +1557,6 @@ Number double_contract (const Tensor<2, dim, Number> &src1, } -/** - * Contract a tensor of rank 2 with a tensor of rank 1. The result is - * dest[i] = sum_j src1[i][j] src2[j]. - * - * @relates Tensor - * @author Wolfgang Bangerth, 1998 - */ -template -inline -void contract (Tensor<1,dim,Number> &dest, - const Tensor<2,dim,Number> &src1, - const Tensor<1,dim,Number> &src2) -{ - for (unsigned int i=0; idest[i] = sum_j src1[j] src2[j][i]. - * - * @relates Tensor - * @author Guido Kanschat, 2001 - */ -template -inline -void contract (Tensor<1,dim,Number> &dest, - const Tensor<1,dim,Number> &src1, - const Tensor<2,dim,Number> &src2) -{ - for (unsigned int i=0; idest[i][k] = sum_j src1[i][j] src2[j][k]. - * - * @relates Tensor - * @author Wolfgang Bangerth, 1998 - */ -template -inline -void contract (Tensor<2,dim,Number> &dest, - const Tensor<2,dim,Number> &src1, - const Tensor<2,dim,Number> &src2) -{ - for (unsigned int i=0; iindex1 of the first tensor, and @@ -1766,28 +1678,6 @@ void contract (Tensor<2,dim,Number> &dest, } -/** - * Contract a tensor of rank 3 with a tensor of rank 2. The result is - * dest[i][j][l] = sum_k src1[i][j][k] src2[k][l]. - * - * @relates Tensor - * @author Wolfgang Bangerth, 1998 - */ -template -inline -void contract (Tensor<3,dim,Number> &dest, - const Tensor<3,dim,Number> &src1, - const Tensor<2,dim,Number> &src2) -{ - dest.clear (); - for (unsigned int i=0; iindex1 of the first tensor, and @@ -1887,28 +1777,6 @@ void contract (Tensor<3,dim,Number> &dest, } -/** - * Contract a tensor of rank 2 with a tensor of rank 3. The result is - * dest[i][j][l] = sum_k src1[i][k] src2[k][j][l]. - * - * @relates Tensor - * @author Wolfgang Bangerth, 1998 - */ -template -inline -void contract (Tensor<3,dim,Number> &dest, - const Tensor<2,dim,Number> &src1, - const Tensor<3,dim,Number> &src2) -{ - dest.clear (); - for (unsigned int i=0; isrc1 with the two indices * src2, creating a rank-2 tensor. This is the matrix-vector product diff --git a/include/deal.II/base/tensor_deprecated.h b/include/deal.II/base/tensor_deprecated.h index f8eab6f503..2aaf1b08e6 100644 --- a/include/deal.II/base/tensor_deprecated.h +++ b/include/deal.II/base/tensor_deprecated.h @@ -28,6 +28,33 @@ DEAL_II_NAMESPACE_OPEN */ //@{ +/** + * Single contraction for tensors: contract the last index of a tensor @p + * src1 of rank @p rank_1 with the first index of a tensor @p src2 of rank + * @p rank_2. + * + * @deprecated Use operator* instead. It denotes a single contraction. + * @relates Tensor + */ +template +inline +void contract (Tensor &dest, + const Tensor &src1, + const Tensor &src2) DEAL_II_DEPRECATED; + +/** + * Contract a tensor of rank 1 with a tensor of rank 1 and return the + * result. + * + * @deprecated Use operator* instead. It denotes a single contraction. + * @relates Tensor + */ +template +inline +typename ProductType::type +contract (const Tensor<1,dim,Number> &src1, + const Tensor<1,dim,OtherNumber> &src2) DEAL_II_DEPRECATED; + /** * The cross-product of 2 vectors in 3d. * @@ -96,6 +123,31 @@ Number determinant (const Tensor<1,1,Number> &t) DEAL_II_DEPRECATED; #ifndef DOXYGEN +template +inline +void contract (Tensor &dest, + const Tensor &src1, + const Tensor &src2) +{ + TensorAccessors::internal::ReorderedIndexView<0, rank_2, const Tensor > + reordered = TensorAccessors::reordered_index_view<0, rank_2>(src2); + TensorAccessors::contract<1, rank_1, rank_2, dim>(dest, src1, reordered); +} + +template +inline +typename ProductType::type +contract (const Tensor<1,dim,Number> &src1, + const Tensor<1,dim,OtherNumber> &src2) +{ + typename ProductType::type res + = typename ProductType::type(); + for (unsigned int i=0; i inline void