From 86d159476d750444ab8e092b52d04d280cef0d35 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 28 Mar 2005 21:40:01 +0000 Subject: [PATCH] Add scalar product between symmetric tensors. git-svn-id: https://svn.dealii.org/trunk@10257 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/symmetric_tensor.h | 37 ++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) 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 -- 2.39.5