Nabla Logo programmer
  Advanced Search
  
  Send us a comment/query
 
  Back to main web site
 
  OpenFOAM guides
  - User guide
  - Programmer’s guide
 
  Index
 
  Changes from OpenFOAM 2.2 to 2.3
 
  Trademarks in the guides
  ©2000-2007 Nabla Ltd.

1.3 Algebraic tensor operations

This section describes all the algebraic operations for tensors that are available in OpenFOAM. Let us first review the most simple tensor operations: addition, subtraction, and scalar multiplication and division. Addition and subtraction are both commutative and associative and are only valid between tensors of the same rank. The operations are performed by addition/subtraction of respective components of the tensors, e.g. the subtraction of two vectors a  \special {t4ht= and b  \special {t4ht= is

a - b =  ai- bi = (a1-  b1,a2- b2,a3 - b3)
\special {t4ht=
(1.4)

Multiplication of any tensor a  \special {t4ht= by a scalar s  \special {t4ht= is also commutative and associative and is performed by multiplying all the tensor components by the scalar. For example,

sa = sa  = (sa ,sa ,sa )
       i      1   2   3
\special {t4ht=
(1.5)

Division between a tensor a  \special {t4ht= and a scalar is only relevant when the scalar is the second argument of the operation, i.e.

a/s = ai/s = (a1/s, a2/s,a3/s)
\special {t4ht=
(1.6)

Following these operations are a set of more complex products between tensors of rank 1 and above, described in the following Sections.

1.3.1 The inner product

The inner product operates on any two tensors of rank r1   \special {t4ht= and r2   \special {t4ht= such that the rank of the result r = r1 + r2- 2  \special {t4ht=. Inner product operations with tensors up to rank 3 are described below:

  • The inner product of two vectors a  \special {t4ht= and b  \special {t4ht= is commutative and produces a scalar s = a •b  \special {t4ht= where
    s = aibi = a1b1 + a2b2 + a3b3
      \special {t4ht=
    (1.7)

  • The inner product of a tensor T  \special {t4ht= and vector a  \special {t4ht= produces a vector b = T • a  \special {t4ht=, represented below as a column array for convenience
                (                        )
               T11a1 + T12a2 + T13a3
bi = Tijaj =    T21a1 + T22a2 + T23a3
               T31a1 + T32a2 + T33a3
      \special {t4ht=
    (1.8)

    It is non-commutative if T  \special {t4ht= is non-symmetric such that b =  a• T = TT  •a  \special {t4ht= is

                (  a T   + a T   + a T   )
                 1 11   2  21    3 31
bi = ajTji =   a1T12 + a2T22 + a3T32
               a1T13 + a2T23 + a3T33
      \special {t4ht=
    (1.9)

  • The inner product of two tensors T  \special {t4ht= and S  \special {t4ht= produces a tensor P = T  •S  \special {t4ht= whose components are evaluated as:
    Pij = TikSkj
      \special {t4ht=
    (1.10)

    It is non-commutative such that         (       )T
T •S =   ST •TT   \special {t4ht=

  • The inner product of a vector a  \special {t4ht= and third rank tensor P  \special {t4ht= produces a second rank tensor T =  a•P  \special {t4ht= whose components are
    Tij = akPkij
      \special {t4ht=
    (1.11)

    Again this is non-commutative so that        •
T  = P  a  \special {t4ht= is

    Tij = Pijkak
      \special {t4ht=
    (1.12)

  • The inner product of a second rank tensor T  \special {t4ht= and third rank tensor P  \special {t4ht= produces a third rank tensor Q =  T •P  \special {t4ht= whose components are
    Q    = T  P
  ijk    il ljk
      \special {t4ht=
    (1.13)

    Again this is non-commutative so that Q  = P •T  \special {t4ht= is

    Qijk = PijlTlk
                                                                          

                                                                          
      \special {t4ht=
    (1.14)

1.3.2 The double inner product of two tensors

The double inner product of two second-rank tensors T  \special {t4ht= and S  \special {t4ht= produces a scalar s = T ••S  \special {t4ht= which can be evaluated as the sum of the 9 products of the tensor components

s = TijSij =  T11S11 + T12S12 + T13S13 +
             T21S21 + T22S22 + T23S23 +
             T31S31 + T32S32 + T33S33
\special {t4ht=
(1.15)

The double inner product between a second rank tensor T  \special {t4ht= and third rank tensor P  \special {t4ht= produces a vector a = T ••P  \special {t4ht= with components

ai = TjkPjki
\special {t4ht=
(1.16)

This is non-commutative so that a = P ••T  \special {t4ht= is

ai = PijkTjk
\special {t4ht=
(1.17)

1.3.3 The triple inner product of two third rank tensors

The triple inner product of two third rank tensors P  \special {t4ht= and Q  \special {t4ht= produces a scalar       3
s = P • Q  \special {t4ht= which can be evaluated as the sum of the 27 products of the tensor components

s = PijkQijk
\special {t4ht=
(1.18)

1.3.4 The outer product

The outer product operates between vectors and tensors as follows:

  • The outer product of two vectors a  \special {t4ht= and b  \special {t4ht= is non-commutative and produces a tensor T =  ab = (ba)T   \special {t4ht= whose components are evaluated as:
                (                   )
               a1b1  a1b2  a1b3
T  = a b  =    a b   a b   a b
 ij    ij       2 1   2 2   2 3
               a3b1  a3b2  a3b3
      \special {t4ht=
    (1.19)

  • An outer product of a vector a  \special {t4ht= and second rank tensor T  \special {t4ht= produces a third rank tensor P  = aT  \special {t4ht= whose components are
    Pijk = aiTjk
      \special {t4ht=
    (1.20)

    This is non-commutative so that P = T a  \special {t4ht= produces

    Pijk = Tijak
      \special {t4ht=
    (1.21)

1.3.5 The cross product of two vectors

The cross product operation is exclusive to vectors only. For two vectors a  \special {t4ht= with b  \special {t4ht=, it produces a vector c = a  b  \special {t4ht= whose components are

c = e   a b =  (a  b - a b ,a b  - a b ,a b -  a b)
 i   ijk j k     23    3 2  3 1    1 3  1 2    2 1
\special {t4ht=
(1.22)

where the permutation symbol is defined by

      { 0    when  any two  indices are equal
eijk =   +1   when  i,j,k are an even permutation  of 1,2,3

        - 1  when  i,j,k are an odd permutation  of 1,2,3
\special {t4ht=
(1.23)

in which the even permutations are 123  \special {t4ht=, 231  \special {t4ht= and 312  \special {t4ht= and the odd permutations are 132  \special {t4ht=, 213  \special {t4ht= and 321  \special {t4ht=.

1.3.6 Other general tensor operations

Some less common tensor operations and terminology used by OpenFOAM are described below.

Square
of a tensor is defined as the outer product of the tensor with itself, e.g. for a vector a  \special {t4ht=, the square a2 = aa  \special {t4ht=.
n  \special {t4ht=th power
of a tensor is evaluated by n  \special {t4ht= outer products of the tensor, e.g. for a vector a  \special {t4ht=, the 3rd power a3 =  aaa  \special {t4ht=.
Magnitude squared
of a tensor is the r  \special {t4ht=th inner product of the tensor of rank r  \special {t4ht= with itself, to produce a scalar. For example, for a second rank tensor T  \special {t4ht=,    2     •
|T | =  T •T  \special {t4ht=.
Magnitude
is the square root of the magnitude squared, e.g. for a tensor T  \special {t4ht=,        V~ ------
|T| =   T ••T  \special {t4ht=. Vectors of unit magnitude are referred to as unit vectors.
Component maximum
is the component of the tensor with greatest value, inclusive of sign, i.e. not the largest magnitude.
Component minimum
is the component of the tensor with smallest value.
Component average
is the mean of all components of a tensor.
Scale
As the name suggests, the scale function is a tool for scaling the components of one tensor by the components of another tensor of the same rank. It is evaluated as the product of corresponding components of 2 tensors, e.g., scaling vector a  \special {t4ht= by vector b  \special {t4ht= would produce vector c  \special {t4ht= whose components are
ci = scale(a,b) =  (a1b1,a2b2,a3b3)
      \special {t4ht=
(1.24)

1.3.7 Geometric transformation and the identity tensor

A second rank tensor T  \special {t4ht= is strictly defined as a linear vector function, i.e. it is a function which associates an argument vector a  \special {t4ht= to another vector b  \special {t4ht= by the inner product b =  T •a  \special {t4ht=. The components of T  \special {t4ht= can be chosen to perform a specific geometric transformation of a tensor from the x  \special {t4ht=, y  \special {t4ht=, z  \special {t4ht= coordinate system to a new coordinate system  *
x \special {t4ht=,  *
y \special {t4ht=,  *
z \special {t4ht=; T  \special {t4ht= is then referred to as the transformation tensor. While a scalar remains unchanged under a transformation, the vector a  \special {t4ht= is transformed to a* \special {t4ht= by

a* = T  •a
\special {t4ht=
(1.25)

A second rank tensor S  \special {t4ht= is transformed to  *
S \special {t4ht= according to

 *           T
S  = T •S •T
\special {t4ht=
(1.26)

The identity tensor I  \special {t4ht= is defined by the requirement that it transforms another tensor onto itself. For all vectors a  \special {t4ht=

a = I •a
\special {t4ht=
(1.27)

and therefore

         (          )
            1  0  0
I = dij =    0  1  0
            0  0  1
\special {t4ht=
(1.28)

where d
 ij  \special {t4ht= is known as the Kronecker delta symbol.

1.3.8 Useful tensor identities

Several identities are listed below which can be verified by under the assumption that all the relevant derivatives exist and are continuous. The identities are expressed for scalar s  \special {t4ht= and vector a  \special {t4ht=.

 \~/  •( \~/   a)  =_  0
 \~/   ( \~/ s)  =_  0

 \~/  •(sa)  =_  s \~/  •a + a• \~/ s
 \~/   (sa)  =_  s \~/   a +  \~/ s  a
 \~/ (a •b)  =_  a ( \~/    b) + b  ( \~/   a) + (a•  \~/ )b + (b • \~/ )a
 \~/  •(a  b)  =_  b •( \~/   a)- a• ( \~/   b)
                   •          •        •         •
 \~/   (a  b)  =_  a( \~/  b) - b(\ ~/ 2 a) + (b  \~/ )a - (a  \~/ )b
 \~/   ( \~/   a)  =_   \~/ (\ ~/  •a) -  \~/  a
( \~/   a)  a  =_  a•( \~/ a) -  \~/ (a •a)
\special {t4ht=
(1.29)

It is sometimes useful to know the e - d  \special {t4ht= identity to help to manipulate equations in index notation:

e  e   = d  d  - d  d
 ijk irs    jr ks   js kr
\special {t4ht=
(1.30)

1.3.9 Operations exclusive to tensors of rank 2

There are several operations that manipulate the components of tensors of rank 2 that are listed below:

Transpose
of a tensor T = Tij  \special {t4ht= is TT  = Tji  \special {t4ht= as described in Equation 1.2.
Symmetric and skew (antisymmetric) tensors
As discussed in section 1.2, a tensor is said to be symmetric if its components are symmetric about the diagonal, i.e. T =  TT   \special {t4ht=. A skew or antisymmetric tensor has T = - TT   \special {t4ht= which intuitively implies that T11 = T22 = T33 = 0  \special {t4ht=. Every second order tensor can be decomposed into symmetric and skew parts by
     1       T    1        T
T =  -(T +  T  )+ --(T  - T  ) = symm  T +  skew T
     2---- ----   2---- ----
      symmetric        skew
      \special {t4ht=
(1.31)

Trace
The trace of a tensor T  \special {t4ht= is a scalar, evaluated by summing the diagonal components
trT  = T11 + T22 + T33
                                                                          

                                                                          
      \special {t4ht=
(1.32)

Diagonal
returns a vector whose components are the diagonal components of the second rank tensor T  \special {t4ht=
diagT  = (T11,T22,T33)
      \special {t4ht=
(1.33)

Deviatoric and hydrostatic tensors
Every second rank tensor T  \special {t4ht= can be decomposed into a deviatoric component, for which tr T = 0  \special {t4ht= and a hydrostatic component of the form T = sI  \special {t4ht= where s  \special {t4ht= is a scalar. Every second rank tensor can be decomposed into deviatoric and hydrostatic parts as follows:
          1-         1-
T  = T -  3 (trT) I+ 3 (trT) I = dev T + hyd T
      -----  -----    --- ---
        deviatoric     hydrostatic
      \special {t4ht=
(1.34)

Determinant
The determinant of a second rank tensor is evaluated by
        ||               ||
        | T11  T12  T13 |
detT  = || T21  T22  T23 ||=  T11(T22T33 - T23T32) -
        | T31  T32  T33 |   T12(T21T33 - T23T31) +
                            T13(T21T32 - T22T31)

      = 1-eijkepqrTipTjqTkr
        6
      \special {t4ht=
(1.35)

Cofactors

The minors of a tensor are evaluated for each component by deleting the row and column in which the component is situated and evaluating the resulting entries as a 2  2  \special {t4ht= determinant. For example, the minor of T12   \special {t4ht= is

||-T---T-|--T---||   |          |
||  11   12   13 ||   || T21  T23 ||
| T21 T22  T23 | = | T31  T33 |=  T21T33- T23T31
| T31 T32  T33 |
      \special {t4ht=
(1.36)

The cofactors are signed minors where each minor is component is given a sign based on the rule

+ve  if i + j is even
- ve if i + j is odd
      \special {t4ht=
(1.37)

The cofactors of T  \special {t4ht= can be evaluated as

        1-
cof T = 2ejkreistTskTtr
      \special {t4ht=
(1.38)

Inverse
The inverse of a tensor can be evaluated as
              T
inv T =  cof T--
         det T
      \special {t4ht=
(1.39)

Hodge dual
of a tensor is a vector whose components are
*T  =  (T23,-T13,T12)
      \special {t4ht=
(1.40)

1.3.10 Operations exclusive to scalars

OpenFOAM supports most of the well known functions that operate on scalars, e.g. square root, exponential, logarithm, sine, cosine etc.., a list of which can be found in Table  1.2. There are 3 additional functions defined within OpenFOAM that are described below:

Sign
of a scalar s  \special {t4ht= is
         {
          1     if s > 0,
sgn(s) =
          - 1   if s < 0.
      \special {t4ht=
(1.41)

Positive
of a scalar s  \special {t4ht= is
          {
pos(s) =   1   if s > 0,
           0   if s < 0.
      \special {t4ht=
(1.42)

Limit
of a scalar s  \special {t4ht= by the scalar n  \special {t4ht=
             {

limit(s,n) =   s  if s < n,
               0  if s > n.
      \special {t4ht=
(1.43)