From: leicht Date: Wed, 27 Sep 2006 09:08:53 +0000 (+0000) Subject: new version of function contract(), contracting a tensor of rank three with one of... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=959fd4ed89daa435ae7f86ecba34509f8269a3e9;p=dealii-svn.git new version of function contract(), contracting a tensor of rank three with one of rank two over given indices git-svn-id: https://svn.dealii.org/trunk@13967 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/tensor.h b/deal.II/base/include/base/tensor.h index d452bfe248..f10be25e6f 100644 --- a/deal.II/base/include/base/tensor.h +++ b/deal.II/base/include/base/tensor.h @@ -880,6 +880,106 @@ void contract (Tensor<3,dim> &dest, +/** + * Contract a tensor of rank 3 with a tensor of rank 2. The + * contraction is performed over index index1 of the first tensor, + * and index2 of the second tensor. Thus, if index1==3, + * index2==1, the result is the usual contraction, but if for + * example index1==1, index2==2, then the result is + * dest[i][j][k] = sum_l src1[l][i][j] src2[k][l]. + * + * Note that the number of the index is counted from 1 on, not from + * zero as usual. + * + * @relates Tensor + */ +template +inline +void contract (Tensor<3,dim> &dest, + const Tensor<3,dim> &src1, const unsigned int index1, + const Tensor<2,dim> &src2, const unsigned int index2) +{ + dest.clear (); + + switch (index1) + { + case 1: + switch (index2) + { + case 1: + for (unsigned int i=0; i::ExcInvalidTensorIndex (index2))); + } + + break; + case 2: + switch (index2) + { + case 1: + for (unsigned int i=0; i::ExcInvalidTensorIndex (index2))); + } + + break; + case 3: + switch (index2) + { + case 1: + for (unsigned int i=0; i::ExcInvalidTensorIndex (index2))); + } + + break; + default: + Assert (false, + (typename Tensor<3,dim>::ExcInvalidTensorIndex (index1))); + } +} + + + /** * Multiplication operator performing a contraction of the last index * of the first argument and the first index of the second diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html index b2103d03ff..c4f3711fc6 100644 --- a/deal.II/doc/news/changes.html +++ b/deal.II/doc/news/changes.html @@ -359,6 +359,15 @@ inconvenience this causes.

base

    +
  1. Extended: The contract function family contracts two + tensors. There is now a new version of this function, that contracts a + tensor of rank three with a second one of rank two over given indices + index1 and index2 of the first and second tensor, + respectively, resulting in a tensor of rank three. +
    + (Tobias Leicht 2006/09/27) +

    +
  2. Fixed: The DataOutBase::write_deal_II_intermediate function did not check whether it can actually write to the stream