From: Wolfgang Bangerth Date: Mon, 28 Mar 2005 21:40:01 +0000 (+0000) Subject: Add scalar product between symmetric tensors. X-Git-Tag: v8.0.0~14290 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86d159476d750444ab8e092b52d04d280cef0d35;p=dealii.git Add scalar product between symmetric tensors. git-svn-id: https://svn.dealii.org/trunk@10257 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/symmetric_tensor.h b/deal.II/base/include/base/symmetric_tensor.h index f2d4986ec3..dbf3239c0f 100644 --- a/deal.II/base/include/base/symmetric_tensor.h +++ b/deal.II/base/include/base/symmetric_tensor.h @@ -270,7 +270,7 @@ class SymmetricTensor<2,dim> * instead since this does not need the * creation of a temporary. */ - SymmetricTensor operator + (const SymmetricTensor &) const; + SymmetricTensor operator + (const SymmetricTensor &s) const; /** * Subtract two tensors. If possible, @@ -278,7 +278,7 @@ class SymmetricTensor<2,dim> * instead since this does not need the * creation of a temporary. */ - SymmetricTensor operator - (const SymmetricTensor &) const; + SymmetricTensor operator - (const SymmetricTensor &s) const; /** * Unary minus operator. Negate all @@ -286,6 +286,18 @@ class SymmetricTensor<2,dim> */ SymmetricTensor operator - () const; + /** + * Scalar product between two symmetric + * tensors. It is the contraction + * aijbij + * over all indices i,j. While + * it is possible to define other scalar + * products (and associated induced + * norms), this one seems to be the most + * appropriate one. + */ + double operator * (const SymmetricTensor &s) const; + /** * Access the elements of a row of this * symmetric tensor. This function is @@ -305,7 +317,9 @@ class SymmetricTensor<2,dim> /** * Return the Frobenius-norm of a tensor, * i.e. the square root of the sum of - * squares of all entries. + * squares of all entries. This norm is + * induced by the scalar product defined + * above for two symmetric tensors. */ double norm () const; @@ -585,6 +599,23 @@ SymmetricTensor<2,dim>::memory_consumption () +template +double +SymmetricTensor<2,dim>::operator * (const SymmetricTensor &s) const +{ + double t = 0; + unsigned int i=0; + for (; i internal::SymmetricTensor::Rank2Accessors::RowAccessor SymmetricTensor<2,dim>::operator [] (const unsigned int row) const