# 1 Tensor mathematics

This Chapter describes tensors and their algebraic operations and how they are represented in mathematical text in this book. It then explains how tensors and tensor algebra are programmed in OpenFOAM.

## 1.1 Coordinate system

OpenFOAM is primarily designed to solve problems in continuum mechanics, i.e. the branch of mechanics concerned with the stresses in solids, liquids and gases and the deformation or flow of these materials. OpenFOAM is therefore based in 3 dimensional space and time and deals with physical entities described by tensors. The coordinate system used by OpenFOAM is the right-handed rectangular Cartesian axes as shown in Figure 1.1. This system of axes is constructed by defining an origin *O* from which three lines are drawn at right angles to each other, termed the *Ox, Oy, Oz* axes. A right-handed set of axes is defined such that to an observer looking down the *Oz* axis (with *O* nearest them), the arc from a point on the *Ox* axis to a point on the *Oy* axis is in a clockwise sense.

Figure 1.1: Right handed axes

## 1.2 Tensors

The term tensor describes an entity that belongs to a particular space and obeys certain mathematical rules. Briefly, tensors are represented by a set of *component values* relating to a set of unit base vectors; in OpenFOAM the unit base vectors $ i_x $, $ i_y $ and $ i_z $ are aligned with the right-handed rectangular Cartesian axes *x*, *y* and *z* respectively. The base vectors are therefore orthogonal, i.e. at right-angles to one another. Every tensor has the following attributes:

**Dimension** *d* of the particular space to which they belong, i.e. *d* = 3 in OpenFOAM;

**Rank** An integer $ r >= 0 $, such that the number of component values = $ d^r $.

While OpenFOAM is set to 3 dimensions, it offers tensors of ranks 0 to 3 as standard while being written in such a way to allow this basic set of ranks to be extended indefinitely. Tensors of rank 0 and 1, better known as scalars and vectors, should be familiar to readers; tensors of rank 2 and 3 may not be so familiar. For completeness all ranks of tensor offered as standard in OpenFOAM are reviewed below.

**Rank 0 ‘scalar’** Any property which can be represented by a single real number, denoted by characters in italics, e.g. mass *m*, volume *V* , pressure *p* and viscosity $ \mu $.

**Rank 1 ‘vector’** An entity which can be represented physically by both magnitude and direction. In component form, the vector **a** = $ (a_1, a_2, a_3) $ relates to a set of Cartesian axes *x, y, z* respectively. The *index notation* presents the same vector as $ a_i $, *i* = 1, 2, 3, although the list of indices *i* = 1, 2, 3 will be omitted in this book, as it is intuitive since we are always dealing with 3 dimensions.

**Rank 2 ‘tensor’** or second rank tensor, **T** has 9 components which can be expressed in array notation as:

(1.1) $ \mathbf{T} = T_{ij} = \begin{pmatrix} T_{11} T_{12} T_{13} \\ T_{21} T_{22} T_{23} \\ T_{31} T_{32} T_{33} \\ \end{pmatrix} $

The components $ T_{ij} $ are now represented using 2 indices since *r* = 2 and the list of indices *i, j* = 1, 2, 3 is omitted as before. The components for which $ i = j $ are referred to as the diagonal components, and those for which $ i <> j $ are referred to as the off-diagonal components. The *transpose* of $ \mathbf{T} $ is produced by exchanging components across the diagonal such that

(1.2) $ \mathbf{T}^T = T_{ij} = \begin{pmatrix} T_{11} T_{12} T_{13} \\ T_{21} T_{22} T_{23} \\ T_{31} T_{32} T_{33} \\ \end{pmatrix} $

Note: a rank 2 tensor is often colloquially termed ‘tensor’ since the occurrence of higher order tensors is fairly rare.

**Symmetric rank 2** The term ‘symmetric’ refers to components being symmetric about the diagonal, i.e. $ T_{ij} = T_{ji} $. In this case, there are only 6 independent components since $ T_{12} = T_{21}, T_{13} = T_{31} and T_{23} = T_{32} $. OpenFOAM distinguishes between symmetric and non-symmetric tensors to save memory by storing 6 components rather than 9 if the tensor is symmetric. Most tensors encountered in continuum mechanics are symmetric.

**Rank 3** has 27 components and is represented in index notation as $ P_{ijk} $ which is too long
to represent in array notation as in Equation 1.1.

**Symmetric rank 3** Symmetry of a rank 3 tensor is defined in OpenFOAM to mean that $ P_{ijk} = P_{ikj} = P_{jik} = P_{jki} = P_{kij} = P_{kji} $ and therefore has 10 independent components. More specifically, it is formed by the outer product of 3 identical vectors, where the
outer product operation is described in Section 1.3.4.