From 0bcad21fc9ac87fdc1ac883767301a9324fe3be9 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 28 Mar 2005 23:03:32 +0000 Subject: [PATCH] Factor some code out. git-svn-id: https://svn.dealii.org/trunk@10266 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/symmetric_tensor.h | 76 ++++++++++++-------- 1 file changed, 48 insertions(+), 28 deletions(-) diff --git a/deal.II/base/include/base/symmetric_tensor.h b/deal.II/base/include/base/symmetric_tensor.h index 6df5b48870..e8be22cc82 100644 --- a/deal.II/base/include/base/symmetric_tensor.h +++ b/deal.II/base/include/base/symmetric_tensor.h @@ -25,6 +25,49 @@ namespace internal { namespace SymmetricTensor { + /** + * Declaration of typedefs for the type + * of data structures which are used to + * store symmetric tensors. For example, + * for rank-2 symmetric tensors, we use a + * flat vector to store all the + * elements. On the other hand, symmetric + * rank-4 tensors are mappings from + * symmetric rank-2 tensors into + * symmetric rank-2 tensors, so they can + * be represented as matrices, etc. + */ + template + struct StorageType; + + template + struct StorageType<2,dim> + { + /** + * Number of independent components of a + * symmetric tensor of rank 2. We store + * only the upper right half of it. This + * information is probably of little + * interest to all except the accessor + * classes that need it. + */ + static const unsigned int + n_independent_tensor_components = (dim*dim + dim)/2; + + /** + * Declare the type in which we actually + * store the data. This information is + * probably of little interest to all + * except the accessor classes that need + * it. In particular, you shouldn't make + * any assumptions about the storage + * format in your application programs. + */ + typedef Tensor<1,n_independent_tensor_components> base_tensor_type; + }; + + + namespace Rank2Accessors { @@ -49,7 +92,7 @@ namespace internal struct Types { typedef - const typename ::SymmetricTensor<2,dim>::StorageType + const typename StorageType<2,dim>::base_tensor_type base_tensor_type; typedef double reference; @@ -68,7 +111,7 @@ namespace internal struct Types { typedef - typename ::SymmetricTensor<2,dim>::StorageType + typename StorageType<2,dim>::base_tensor_type base_tensor_type; typedef double &reference; @@ -190,29 +233,6 @@ class SymmetricTensor<2,dim> * the outside world. */ static const unsigned int rank = 2; - - /** - * Number of independent components of a - * symmetric tensor of rank 2. We store - * only the upper right half of it. This - * information is probably of little - * interest to all except the accessor - * classes that need it. - */ - static const unsigned int - n_independent_tensor_components = (dim*dim + dim)/2; - - /** - * Declare the type in which we actually - * store the data. This information is - * probably of little interest to all - * except the accessor classes that need - * it. In particular, you shouldn't make - * any assumptions about the storage - * format in your application programs. - */ - typedef Tensor<1,n_independent_tensor_components> StorageType; - /** * Default constructor. Creates a zero @@ -359,7 +379,7 @@ class SymmetricTensor<2,dim> /** * Data storage for a symmetric tensor. */ - StorageType data; + typename internal::SymmetricTensor::StorageType<2,dim>::base_tensor_type data; }; @@ -598,7 +618,7 @@ inline unsigned int SymmetricTensor<2,dim>::memory_consumption () { - return StorageType::memory_consumption (); + return internal::SymmetricTensor::StorageType<2,dim>::memory_consumption (); } @@ -612,7 +632,7 @@ SymmetricTensor<2,dim>::operator * (const SymmetricTensor &s) const for (; i::n_independent_tensor_components; ++i) t += 2 * data[i] * s.data[i]; return t; -- 2.39.5