From 2027059b63a617dcae86f5ddf6a5b636a1519127 Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Wed, 9 Mar 2016 10:10:28 +0000
Subject: [PATCH] src/OpenFOAM: changed template rank type from int to
 Foam::direction

Foam::direction is an unsigned type which makes it easier for the
compiler to pickup and report errors in the instantiation of
VectorSpaces and associated types.
---
 .../dimensionedType/dimensionedType.C         |   6 +-
 .../dimensionedType/dimensionedType.H         |   6 +-
 .../DimensionedFieldFunctions.C               |  12 +-
 .../DimensionedFieldFunctions.H               |  12 +-
 .../FieldField/FieldFieldFunctions.C          |  54 ++++++--
 .../FieldField/FieldFieldFunctions.H          |  54 ++++++--
 src/OpenFOAM/fields/Fields/Field/Field.C      |   2 +-
 src/OpenFOAM/fields/Fields/Field/Field.H      |   2 +-
 .../fields/Fields/Field/FieldFunctions.C      |  18 +--
 .../fields/Fields/Field/FieldFunctions.H      |  20 +--
 .../GeometricField/GeometricFieldFunctions.C  |  32 ++++-
 .../GeometricField/GeometricFieldFunctions.H  |  32 ++++-
 .../pointPatchFieldFunctions.H                |   6 +-
 .../primitives/DiagTensor/DiagTensor.H        |   6 +-
 src/OpenFOAM/primitives/Scalar/Scalar.H       |  17 ++-
 .../SphericalTensor/SphericalTensor.H         |   6 +-
 .../SphericalTensor2D/SphericalTensor2D.H     |   6 +-
 .../primitives/SymmTensor/SymmTensor.H        |   6 +-
 .../primitives/SymmTensor2D/SymmTensor2D.H    |   6 +-
 src/OpenFOAM/primitives/Tensor/Tensor.H       |   6 +-
 src/OpenFOAM/primitives/Tensor2D/Tensor2D.H   |   6 +-
 src/OpenFOAM/primitives/Vector/Vector.H       |   6 +-
 src/OpenFOAM/primitives/Vector2D/Vector2D.H   |   6 +-
 .../primitives/VectorSpace/VectorSpace.C      |  25 ++--
 .../primitives/VectorSpace/VectorSpace.H      |  13 +-
 .../primitives/VectorSpace/VectorSpaceI.H     | 123 +++++++++---------
 .../primitives/VectorSpace/VectorSpaceOps.H   |   4 +-
 .../primitives/VectorSpace/products.H         |  16 +--
 src/OpenFOAM/primitives/bools/bool/bool.H     |  15 ++-
 src/OpenFOAM/primitives/ints/int32/int32.H    |  15 ++-
 src/OpenFOAM/primitives/ints/int64/int64.H    |  15 ++-
 src/OpenFOAM/primitives/ints/uint32/uint32.H  |  15 ++-
 src/OpenFOAM/primitives/ints/uint64/uint64.H  |  15 ++-
 .../primitives/quaternion/quaternion.H        |   9 +-
 34 files changed, 355 insertions(+), 237 deletions(-)

diff --git a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C
index 220b7256c67..f110dd803db 100644
--- a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C
+++ b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C
@@ -447,7 +447,7 @@ void Foam::dimensioned<Type>::operator/=
 
 // * * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * //
 
-template<class Type, int r>
+template<class Type, Foam::direction r>
 Foam::dimensioned<typename Foam::powProduct<Type, r>::type>
 Foam::pow(const dimensioned<Type>& dt, typename powProduct<Type, r>::type)
 {
@@ -747,7 +747,7 @@ Foam::operator op                                                              \
     );                                                                         \
 }                                                                              \
                                                                                \
-template<class Type, class Form, class Cmpt, int nCmpt>                        \
+template<class Type, class Form, class Cmpt, Foam::direction nCmpt>            \
 Foam::dimensioned<typename Foam::product<Type, Form>::type>                    \
 Foam::operator op                                                              \
 (                                                                              \
@@ -763,7 +763,7 @@ Foam::operator op                                                              \
     );                                                                         \
 }                                                                              \
                                                                                \
-template<class Type, class Form, class Cmpt, int nCmpt>                        \
+template<class Type, class Form, class Cmpt, Foam::direction nCmpt>            \
 Foam::dimensioned<typename Foam::product<Form, Type>::type>                    \
 Foam::operator op                                                              \
 (                                                                              \
diff --git a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H
index f94aa39829c..7d1549f4b2e 100644
--- a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H
+++ b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H
@@ -231,7 +231,7 @@ public:
 
 // * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
 
-template<class Type, int r>
+template<class Type, direction r>
 dimensioned<typename powProduct<Type, r>::type>
 pow
 (
@@ -306,7 +306,7 @@ template<class Type1, class Type2>                                             \
 dimensioned<typename product<Type1, Type2>::type>                              \
 operator op(const dimensioned<Type1>&, const dimensioned<Type2>&);             \
                                                                                \
-template<class Type, class Form, class Cmpt, int nCmpt>                        \
+template<class Type, class Form, class Cmpt, direction nCmpt>                  \
 dimensioned<typename product<Type, Form>::type>                                \
 operator op                                                                    \
 (                                                                              \
@@ -314,7 +314,7 @@ operator op                                                                    \
     const VectorSpace<Form,Cmpt,nCmpt>&                                        \
 );                                                                             \
                                                                                \
-template<class Type, class Form, class Cmpt, int nCmpt>                        \
+template<class Type, class Form, class Cmpt, direction nCmpt>                  \
 dimensioned<typename product<Form, Type>::type>                                \
 operator op                                                                    \
 (                                                                              \
diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctions.C b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctions.C
index dc2a68de389..f1bd35b9d29 100644
--- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctions.C
+++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctions.C
@@ -35,7 +35,7 @@ namespace Foam
 
 // * * * * * * * * * * * * * * * Global functions  * * * * * * * * * * * * * //
 
-template<class Type, class GeoMesh, int r>
+template<class Type, class GeoMesh, direction r>
 tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh>>
 pow
 (
@@ -66,7 +66,7 @@ pow
 }
 
 
-template<class Type, class GeoMesh, int r>
+template<class Type, class GeoMesh, direction r>
 tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh>>
 pow
 (
@@ -510,7 +510,7 @@ operator op                                                                    \
     return tRes;                                                               \
 }                                                                              \
                                                                                \
-template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh>         \
+template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh>   \
 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>>             \
 operator op                                                                    \
 (                                                                              \
@@ -549,7 +549,7 @@ operator op                                                                    \
     return tRes;                                                               \
 }                                                                              \
                                                                                \
-template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh>         \
+template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh>   \
 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>>             \
 operator op                                                                    \
 (                                                                              \
@@ -590,7 +590,7 @@ operator op                                                                    \
     return tRes;                                                               \
 }                                                                              \
                                                                                \
-template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh>         \
+template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh>   \
 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>>             \
 operator op                                                                    \
 (                                                                              \
@@ -628,7 +628,7 @@ operator op                                                                    \
     return tRes;                                                               \
 }                                                                              \
                                                                                \
-template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh>         \
+template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh>   \
 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>>             \
 operator op                                                                    \
 (                                                                              \
diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctions.H b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctions.H
index 6501bcf51f7..f39dff925d9 100644
--- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctions.H
+++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctions.H
@@ -35,7 +35,7 @@ namespace Foam
 
 // * * * * * * * * * * * * * * * Global functions  * * * * * * * * * * * * * //
 
-template<class Type, class GeoMesh, int r>
+template<class Type, class GeoMesh, direction r>
 tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh>>
 pow
 (
@@ -43,7 +43,7 @@ pow
     typename powProduct<Type, r>::type
 );
 
-template<class Type, class GeoMesh, int r>
+template<class Type, class GeoMesh, direction r>
 tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh>>
 pow
 (
@@ -191,7 +191,7 @@ operator op                                                                    \
     const dimensioned<Form>& dvs                                               \
 );                                                                             \
                                                                                \
-template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh>         \
+template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh>   \
 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>>             \
 operator op                                                                    \
 (                                                                              \
@@ -207,7 +207,7 @@ operator op                                                                    \
     const dimensioned<Form>& dvs                                               \
 );                                                                             \
                                                                                \
-template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh>         \
+template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh>   \
 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>>             \
 operator op                                                                    \
 (                                                                              \
@@ -223,7 +223,7 @@ operator op                                                                    \
     const DimensionedField<Type, GeoMesh>& df1                                 \
 );                                                                             \
                                                                                \
-template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh>         \
+template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh>   \
 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>>             \
 operator op                                                                    \
 (                                                                              \
@@ -239,7 +239,7 @@ operator op                                                                    \
     const tmp<DimensionedField<Type, GeoMesh>>& tdf1                           \
 );                                                                             \
                                                                                \
-template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh>         \
+template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh>   \
 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>>             \
 operator op                                                                    \
 (                                                                              \
diff --git a/src/OpenFOAM/fields/FieldFields/FieldField/FieldFieldFunctions.C b/src/OpenFOAM/fields/FieldFields/FieldField/FieldFieldFunctions.C
index 14e1d79ff31..affb77661b2 100644
--- a/src/OpenFOAM/fields/FieldFields/FieldField/FieldFieldFunctions.C
+++ b/src/OpenFOAM/fields/FieldFields/FieldField/FieldFieldFunctions.C
@@ -61,7 +61,7 @@ void T(FieldField<Field, Type>& f1, const FieldField<Field, Type>& f2)
 }
 
 
-template<template<class> class Field, class Type, int r>
+template<template<class> class Field, class Type, direction r>
 void pow
 (
     FieldField<Field, typename powProduct<Type, r>::type>& f,
@@ -74,7 +74,7 @@ void pow
     }
 }
 
-template<template<class> class Field, class Type, int r>
+template<template<class> class Field, class Type, direction r>
 tmp<FieldField<Field, typename powProduct<Type, r>::type>>
 pow
 (
@@ -90,7 +90,7 @@ pow
     return tRes;
 }
 
-template<template<class> class Field, class Type, int r>
+template<template<class> class Field, class Type, direction r>
 tmp<FieldField<Field, typename powProduct<Type, r>::type>>
 pow
 (
@@ -761,7 +761,13 @@ operator op                                                                    \
 }                                                                              \
                                                                                \
 template                                                                       \
-<template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>   \
+<                                                                              \
+    template<class> class Field,                                               \
+    class Type,                                                                \
+    class Form,                                                                \
+    class Cmpt,                                                                \
+    direction nCmpt                                                            \
+>                                                                              \
 void opFunc                                                                    \
 (                                                                              \
     FieldField<Field, typename product<Type, Form>::type>& f,                  \
@@ -776,7 +782,13 @@ void opFunc                                                                    \
 }                                                                              \
                                                                                \
 template                                                                       \
-<template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>   \
+<                                                                              \
+    template<class> class Field,                                               \
+    class Type,                                                                \
+    class Form,                                                                \
+    class Cmpt,                                                                \
+    direction nCmpt                                                            \
+>                                                                              \
 tmp<FieldField<Field, typename product<Type, Form>::type>>                     \
 operator op                                                                    \
 (                                                                              \
@@ -794,7 +806,13 @@ operator op                                                                    \
 }                                                                              \
                                                                                \
 template                                                                       \
-<template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>   \
+<                                                                              \
+    template<class> class Field,                                               \
+    class Type,                                                                \
+    class Form,                                                                \
+    class Cmpt,                                                                \
+    direction nCmpt                                                            \
+>                                                                              \
 tmp<FieldField<Field, typename product<Type, Form>::type>>                     \
 operator op                                                                    \
 (                                                                              \
@@ -813,7 +831,13 @@ operator op                                                                    \
 }                                                                              \
                                                                                \
 template                                                                       \
-<template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>   \
+<                                                                              \
+    template<class> class Field,                                               \
+    class Type,                                                                \
+    class Form,                                                                \
+    class Cmpt,                                                                \
+    direction nCmpt                                                            \
+>                                                                              \
 void opFunc                                                                    \
 (                                                                              \
     FieldField<Field, typename product<Form, Type>::type>& f,                  \
@@ -828,7 +852,13 @@ void opFunc                                                                    \
 }                                                                              \
                                                                                \
 template                                                                       \
-<template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>   \
+<                                                                              \
+    template<class> class Field,                                               \
+    class Type,                                                                \
+    class Form,                                                                \
+    class Cmpt,                                                                \
+    direction nCmpt                                                            \
+>                                                                              \
 tmp<FieldField<Field, typename product<Form, Type>::type>>                     \
 operator op                                                                    \
 (                                                                              \
@@ -846,7 +876,13 @@ operator op                                                                    \
 }                                                                              \
                                                                                \
 template                                                                       \
-<template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>   \
+<                                                                              \
+    template<class> class Field,                                               \
+    class Type,                                                                \
+    class Form,                                                                \
+    class Cmpt,                                                                \
+    direction nCmpt                                                            \
+>                                                                              \
 tmp<FieldField<Field, typename product<Form, Type>::type>>                     \
 operator op                                                                    \
 (                                                                              \
diff --git a/src/OpenFOAM/fields/FieldFields/FieldField/FieldFieldFunctions.H b/src/OpenFOAM/fields/FieldFields/FieldField/FieldFieldFunctions.H
index 0800ab98694..7934f860921 100644
--- a/src/OpenFOAM/fields/FieldFields/FieldField/FieldFieldFunctions.H
+++ b/src/OpenFOAM/fields/FieldFields/FieldField/FieldFieldFunctions.H
@@ -47,14 +47,14 @@ template<template<class> class Field, class Type>
 void T(FieldField<Field, Type>& f1, const FieldField<Field, Type>& f2);
 
 
-template<template<class> class Field, class Type, int r>
+template<template<class> class Field, class Type, direction r>
 void pow
 (
     FieldField<Field, typename powProduct<Type, r>::type>& f,
     const FieldField<Field, Type>& vf
 );
 
-template<template<class> class Field, class Type, int r>
+template<template<class> class Field, class Type, direction r>
 tmp<FieldField<Field, typename powProduct<Type, r>::type>>
 pow
 (
@@ -62,7 +62,7 @@ pow
         = pTraits<typename powProduct<Type, r>::type>::zero
 );
 
-template<template<class> class Field, class Type, int r>
+template<template<class> class Field, class Type, direction r>
 tmp<FieldField<Field, typename powProduct<Type, r>::type>>
 pow
 (
@@ -346,7 +346,13 @@ operator op                                                                    \
 );                                                                             \
                                                                                \
 template                                                                       \
-<template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>   \
+<                                                                              \
+    template<class> class Field,                                               \
+    class Type,                                                                \
+    class Form,                                                                \
+    class Cmpt,                                                                \
+    direction nCmpt                                                            \
+>                                                                              \
 void opFunc                                                                    \
 (                                                                              \
     FieldField<Field, typename product<Type, Form>::type>& f,                  \
@@ -355,7 +361,13 @@ void opFunc                                                                    \
 );                                                                             \
                                                                                \
 template                                                                       \
-<template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>   \
+<                                                                              \
+    template<class> class Field,                                               \
+    class Type,                                                                \
+    class Form,                                                                \
+    class Cmpt,                                                                \
+    direction nCmpt                                                            \
+>                                                                              \
 tmp<FieldField<Field, typename product<Type, Form>::type>>                     \
 operator op                                                                    \
 (                                                                              \
@@ -364,7 +376,13 @@ operator op                                                                    \
 );                                                                             \
                                                                                \
 template                                                                       \
-<template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>   \
+<                                                                              \
+    template<class> class Field,                                               \
+    class Type,                                                                \
+    class Form,                                                                \
+    class Cmpt,                                                                \
+    direction nCmpt                                                            \
+>                                                                              \
 tmp<FieldField<Field, typename product<Type, Form>::type>>                     \
 operator op                                                                    \
 (                                                                              \
@@ -373,7 +391,13 @@ operator op                                                                    \
 );                                                                             \
                                                                                \
 template                                                                       \
-<template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>   \
+<                                                                              \
+    template<class> class Field,                                               \
+    class Type,                                                                \
+    class Form,                                                                \
+    class Cmpt,                                                                \
+    direction nCmpt                                                            \
+>                                                                              \
 void opFunc                                                                    \
 (                                                                              \
     FieldField<Field, typename product<Form, Type>::type>& f,                  \
@@ -382,7 +406,13 @@ void opFunc                                                                    \
 );                                                                             \
                                                                                \
 template                                                                       \
-<template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>   \
+<                                                                              \
+    template<class> class Field,                                               \
+    class Type,                                                                \
+    class Form,                                                                \
+    class Cmpt,                                                                \
+    direction nCmpt                                                            \
+>                                                                              \
 tmp<FieldField<Field, typename product<Form, Type>::type>>                     \
 operator op                                                                    \
 (                                                                              \
@@ -391,7 +421,13 @@ operator op                                                                    \
 );                                                                             \
                                                                                \
 template                                                                       \
-<template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>   \
+<                                                                              \
+    template<class> class Field,                                               \
+    class Type,                                                                \
+    class Form,                                                                \
+    class Cmpt,                                                                \
+    direction nCmpt                                                            \
+>                                                                              \
 tmp<FieldField<Field, typename product<Form, Type>::type>>                     \
 operator op                                                                    \
 (                                                                              \
diff --git a/src/OpenFOAM/fields/Fields/Field/Field.C b/src/OpenFOAM/fields/Fields/Field/Field.C
index 4a7569bc019..0ca41e54a0f 100644
--- a/src/OpenFOAM/fields/Fields/Field/Field.C
+++ b/src/OpenFOAM/fields/Fields/Field/Field.C
@@ -701,7 +701,7 @@ void Foam::Field<Type>::operator=(const Type& t)
 
 
 template<class Type>
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, Foam::direction nCmpt>
 void Foam::Field<Type>::operator=(const VectorSpace<Form,Cmpt,nCmpt>& vs)
 {
     TFOR_ALL_F_OP_S(Type, *this, =, VSType, vs)
diff --git a/src/OpenFOAM/fields/Fields/Field/Field.H b/src/OpenFOAM/fields/Fields/Field/Field.H
index a5d01b47f7d..6f08f059262 100644
--- a/src/OpenFOAM/fields/Fields/Field/Field.H
+++ b/src/OpenFOAM/fields/Fields/Field/Field.H
@@ -345,7 +345,7 @@ public:
         void operator=(const tmp<Field<Type>>&);
         void operator=(const Type&);
 
-        template<class Form, class Cmpt, int nCmpt>
+        template<class Form, class Cmpt, direction nCmpt>
         void operator=(const VectorSpace<Form,Cmpt,nCmpt>&);
 
         void operator+=(const UList<Type>&);
diff --git a/src/OpenFOAM/fields/Fields/Field/FieldFunctions.C b/src/OpenFOAM/fields/Fields/Field/FieldFunctions.C
index d2b3e2d6b13..c75a045f5d5 100644
--- a/src/OpenFOAM/fields/Fields/Field/FieldFunctions.C
+++ b/src/OpenFOAM/fields/Fields/Field/FieldFunctions.C
@@ -59,7 +59,7 @@ void T(Field<Type>& res, const UList<Type>& f)
 }
 
 
-template<class Type, int r>
+template<class Type, direction r>
 void pow
 (
     Field<typename powProduct<Type, r>::type>& res,
@@ -74,7 +74,7 @@ void pow
     )
 }
 
-template<class Type, int r>
+template<class Type, direction r>
 tmp<Field<typename powProduct<Type, r>::type>>
 pow
 (
@@ -91,7 +91,7 @@ pow
     return tRes;
 }
 
-template<class Type, int r>
+template<class Type, direction r>
 tmp<Field<typename powProduct<Type, r>::type>>
 pow
 (
@@ -692,7 +692,7 @@ operator Op(const tmp<Field<Type1>>& tf1, const tmp<Field<Type2>>& tf2)        \
     return tRes;                                                               \
 }                                                                              \
                                                                                \
-template<class Type, class Form, class Cmpt, int nCmpt>                        \
+template<class Type, class Form, class Cmpt, direction nCmpt>                  \
 void OpFunc                                                                    \
 (                                                                              \
     Field<typename product<Type, Form>::type>& res,                            \
@@ -705,7 +705,7 @@ void OpFunc                                                                    \
         (productType, res, =,Type, f1, Op, Form, static_cast<const Form&>(vs)) \
 }                                                                              \
                                                                                \
-template<class Type, class Form, class Cmpt, int nCmpt>                        \
+template<class Type, class Form, class Cmpt, direction nCmpt>                  \
 tmp<Field<typename product<Type, Form>::type>>                                 \
 operator Op(const UList<Type>& f1, const VectorSpace<Form,Cmpt,nCmpt>& vs)     \
 {                                                                              \
@@ -715,7 +715,7 @@ operator Op(const UList<Type>& f1, const VectorSpace<Form,Cmpt,nCmpt>& vs)     \
     return tRes;                                                               \
 }                                                                              \
                                                                                \
-template<class Type, class Form, class Cmpt, int nCmpt>                        \
+template<class Type, class Form, class Cmpt, direction nCmpt>                  \
 tmp<Field<typename product<Type, Form>::type>>                                 \
 operator Op                                                                    \
 (                                                                              \
@@ -730,7 +730,7 @@ operator Op                                                                    \
     return tRes;                                                               \
 }                                                                              \
                                                                                \
-template<class Form, class Cmpt, int nCmpt, class Type>                        \
+template<class Form, class Cmpt, direction nCmpt, class Type>                  \
 void OpFunc                                                                    \
 (                                                                              \
     Field<typename product<Form, Type>::type>& res,                            \
@@ -743,7 +743,7 @@ void OpFunc                                                                    \
         (productType, res, =,Form,static_cast<const Form&>(vs), Op, Type, f1)  \
 }                                                                              \
                                                                                \
-template<class Form, class Cmpt, int nCmpt, class Type>                        \
+template<class Form, class Cmpt, direction nCmpt, class Type>                  \
 tmp<Field<typename product<Form, Type>::type>>                                 \
 operator Op(const VectorSpace<Form,Cmpt,nCmpt>& vs, const UList<Type>& f1)     \
 {                                                                              \
@@ -753,7 +753,7 @@ operator Op(const VectorSpace<Form,Cmpt,nCmpt>& vs, const UList<Type>& f1)     \
     return tRes;                                                               \
 }                                                                              \
                                                                                \
-template<class Form, class Cmpt, int nCmpt, class Type>                        \
+template<class Form, class Cmpt, direction nCmpt, class Type>                  \
 tmp<Field<typename product<Form, Type>::type>>                                 \
 operator Op                                                                    \
 (                                                                              \
diff --git a/src/OpenFOAM/fields/Fields/Field/FieldFunctions.H b/src/OpenFOAM/fields/Fields/Field/FieldFunctions.H
index 56c422a5fd1..29f52c49e04 100644
--- a/src/OpenFOAM/fields/Fields/Field/FieldFunctions.H
+++ b/src/OpenFOAM/fields/Fields/Field/FieldFunctions.H
@@ -47,7 +47,7 @@ template<class Type>
 void T(Field<Type>& res, const UList<Type>& f);
 
 
-template<class Type, int r>
+template<class Type, direction r>
 void pow
 (
     Field<typename powProduct<Type, r>::type>& res,
@@ -55,7 +55,7 @@ void pow
 );
 
 
-template<class Type, int r>
+template<class Type, direction r>
 tmp<Field<typename powProduct<Type, r>::type>>
 pow
 (
@@ -64,7 +64,7 @@ pow
       = pTraits<typename powProduct<Type, r>::type>::zero
 );
 
-template<class Type, int r>
+template<class Type, direction r>
 tmp<Field<typename powProduct<Type, r>::type>>
 pow
 (
@@ -307,7 +307,7 @@ template<class Type1, class Type2>                                             \
 tmp<Field<typename product<Type1, Type2>::type>>                               \
 operator Op(const tmp<Field<Type1>>& tf1, const tmp<Field<Type2>>& tf2);       \
                                                                                \
-template<class Type, class Form, class Cmpt, int nCmpt>                        \
+template<class Type, class Form, class Cmpt, direction nCmpt>                  \
 void OpFunc                                                                    \
 (                                                                              \
     Field<typename product<Type, Form>::type>& res,                            \
@@ -315,15 +315,15 @@ void OpFunc                                                                    \
     const VectorSpace<Form,Cmpt,nCmpt>& vs                                     \
 );                                                                             \
                                                                                \
-template<class Type, class Form, class Cmpt, int nCmpt>                        \
+template<class Type, class Form, class Cmpt, direction nCmpt>                  \
 tmp<Field<typename product<Type, Form>::type>>                                 \
 operator Op(const UList<Type>& f1, const VectorSpace<Form,Cmpt,nCmpt>& vs);    \
                                                                                \
-template<class Type, class Form, class Cmpt, int nCmpt>                        \
+template<class Type, class Form, class Cmpt, direction nCmpt>                  \
 tmp<Field<typename product<Type, Form>::type>>                                 \
-operator Op(const tmp<Field<Type>>&tf1,const VectorSpace<Form,Cmpt,nCmpt>&vs);\
+operator Op(const tmp<Field<Type>>&tf1,const VectorSpace<Form,Cmpt,nCmpt>&vs); \
                                                                                \
-template<class Form, class Cmpt, int nCmpt, class Type>                        \
+template<class Form, class Cmpt, direction nCmpt, class Type>                  \
 void OpFunc                                                                    \
 (                                                                              \
     Field<typename product<Form, Type>::type>& res,                            \
@@ -331,11 +331,11 @@ void OpFunc                                                                    \
     const UList<Type>& f1                                                      \
 );                                                                             \
                                                                                \
-template<class Form, class Cmpt, int nCmpt, class Type>                        \
+template<class Form, class Cmpt, direction nCmpt, class Type>                  \
 tmp<Field<typename product<Form, Type>::type>>                                 \
 operator Op(const VectorSpace<Form,Cmpt,nCmpt>& vs, const UList<Type>& f1);    \
                                                                                \
-template<class Form, class Cmpt, int nCmpt, class Type>                        \
+template<class Form, class Cmpt, direction nCmpt, class Type>                  \
 tmp<Field<typename product<Form, Type>::type>>                                 \
 operator Op(const VectorSpace<Form,Cmpt,nCmpt>&vs,const tmp<Field<Type>>&tf1);
 
diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C
index cb723b0aeda..e04a1588b56 100644
--- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C
+++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C
@@ -66,7 +66,13 @@ void T
 }
 
 
-template<class Type, template<class> class PatchField, class GeoMesh, int r>
+template
+<
+    class Type,
+    template<class> class PatchField,
+    class GeoMesh,
+    direction r
+>
 void pow
 (
     GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh>& gf,
@@ -77,7 +83,13 @@ void pow
     pow(gf.boundaryField(), gf1.boundaryField(), r);
 }
 
-template<class Type, template<class> class PatchField, class GeoMesh, int r>
+template
+<
+    class Type,
+    template<class> class PatchField,
+    class GeoMesh,
+    direction r
+>
 tmp<GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh>>
 pow
 (
@@ -110,7 +122,13 @@ pow
 }
 
 
-template<class Type, template<class> class PatchField, class GeoMesh, int r>
+template
+<
+    class Type,
+    template<class> class PatchField,
+    class GeoMesh,
+    direction r
+>
 tmp<GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh>>
 pow
 (
@@ -768,7 +786,7 @@ template                                                                       \
 <                                                                              \
     class Form,                                                                \
     class Cmpt,                                                                \
-    int nCmpt,                                                                 \
+    direction nCmpt,                                                           \
     class Type, template<class> class PatchField,                              \
     class GeoMesh                                                              \
 >                                                                              \
@@ -815,7 +833,7 @@ template                                                                       \
 <                                                                              \
     class Form,                                                                \
     class Cmpt,                                                                \
-    int nCmpt,                                                                 \
+    direction nCmpt,                                                           \
     class Type, template<class> class PatchField,                              \
     class GeoMesh                                                              \
 >                                                                              \
@@ -880,7 +898,7 @@ template                                                                       \
 <                                                                              \
     class Form,                                                                \
     class Cmpt,                                                                \
-    int nCmpt,                                                                 \
+    direction nCmpt,                                                           \
     class Type, template<class> class PatchField,                              \
     class GeoMesh                                                              \
 >                                                                              \
@@ -926,7 +944,7 @@ template                                                                       \
 <                                                                              \
     class Form,                                                                \
     class Cmpt,                                                                \
-    int nCmpt,                                                                 \
+    direction nCmpt,                                                           \
     class Type, template<class> class PatchField,                              \
     class GeoMesh                                                              \
 >                                                                              \
diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.H
index 51205ba2925..a98f4a60834 100644
--- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.H
+++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.H
@@ -56,14 +56,26 @@ void T
      const GeometricField<Type, PatchField, GeoMesh>& gf1
 );
 
-template<class Type, template<class> class PatchField, class GeoMesh, int r>
+template
+<
+    class Type,
+    template<class> class PatchField,
+    class GeoMesh,
+    direction r
+>
 void pow
 (
     GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh>& gf,
     const GeometricField<Type, PatchField, GeoMesh>& gf1
 );
 
-template<class Type, template<class> class PatchField, class GeoMesh, int r>
+template
+<
+    class Type,
+    template<class> class PatchField,
+    class GeoMesh,
+    direction r
+>
 tmp
 <
     GeometricField
@@ -75,7 +87,13 @@ pow
     typename powProduct<Type, r>::type
 );
 
-template<class Type, template<class> class PatchField, class GeoMesh, int r>
+template
+<
+    class Type,
+    template<class> class PatchField,
+    class GeoMesh,
+    direction r
+>
 tmp
 <
     GeometricField
@@ -353,7 +371,7 @@ template                                                                       \
 <                                                                              \
     class Form,                                                                \
     class Cmpt,                                                                \
-    int nCmpt,                                                                 \
+    direction nCmpt,                                                           \
     class Type, template<class> class PatchField,                              \
     class GeoMesh                                                              \
 >                                                                              \
@@ -385,7 +403,7 @@ template                                                                       \
 <                                                                              \
     class Form,                                                                \
     class Cmpt,                                                                \
-    int nCmpt,                                                                 \
+    direction nCmpt,                                                           \
     class Type, template<class> class PatchField,                              \
     class GeoMesh                                                              \
 >                                                                              \
@@ -427,7 +445,7 @@ template                                                                       \
 <                                                                              \
     class Form,                                                                \
     class Cmpt,                                                                \
-    int nCmpt,                                                                 \
+    direction nCmpt,                                                           \
     class Type, template<class> class PatchField,                              \
     class GeoMesh                                                              \
 >                                                                              \
@@ -459,7 +477,7 @@ template                                                                       \
 <                                                                              \
     class Form,                                                                \
     class Cmpt,                                                                \
-    int nCmpt,                                                                 \
+    direction nCmpt,                                                           \
     class Type, template<class> class PatchField,                              \
     class GeoMesh                                                              \
 >                                                                              \
diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldFunctions.H b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldFunctions.H
index 02ed0d8736a..f5216355468 100644
--- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldFunctions.H
+++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldFunctions.H
@@ -47,7 +47,7 @@ inline void T
 {}
 
 
-template<class Type, int r>
+template<class Type, direction r>
 inline void pow
 (
     Field<typename powProduct<Type, r>::type>& f,
@@ -206,7 +206,7 @@ template                                                                       \
     class Type,                                                                \
     class Form,                                                                \
     class Cmpt,                                                                \
-    int nCmpt                                                                  \
+    direction nCmpt                                                            \
 >                                                                              \
 inline void opFunc                                                             \
 (                                                                              \
@@ -221,7 +221,7 @@ template                                                                       \
 <                                                                              \
     class Form,                                                                \
     class Cmpt,                                                                \
-    int nCmpt,                                                                 \
+    direction nCmpt,                                                           \
     class Type                                                                 \
 >                                                                              \
 inline void opFunc                                                             \
diff --git a/src/OpenFOAM/primitives/DiagTensor/DiagTensor.H b/src/OpenFOAM/primitives/DiagTensor/DiagTensor.H
index 0a2138cea44..cd61a57988a 100644
--- a/src/OpenFOAM/primitives/DiagTensor/DiagTensor.H
+++ b/src/OpenFOAM/primitives/DiagTensor/DiagTensor.H
@@ -64,10 +64,8 @@ public:
 
     // Member constants
 
-        enum
-        {
-            rank = 2 // Rank of DiagTensor is 2
-        };
+        //- Rank of DiagTensor is 2
+        static const direction rank = 2;
 
 
     //- Component labeling enumeration
diff --git a/src/OpenFOAM/primitives/Scalar/Scalar.H b/src/OpenFOAM/primitives/Scalar/Scalar.H
index 54b8ec57850..502a57c3b2f 100644
--- a/src/OpenFOAM/primitives/Scalar/Scalar.H
+++ b/src/OpenFOAM/primitives/Scalar/Scalar.H
@@ -53,14 +53,18 @@ public:
     //- Equivalent type of labels used for valid component indexing
     typedef label labelType;
 
+
     // Member constants
 
-        enum
-        {
-            dim = 3,         //!< Dimensionality of space
-            rank = 0,        //!< Rank of Scalar is 0
-            nComponents = 1  //!< Number of components in Scalar is 1
-        };
+        //- Dimensionality of space
+        static const direction dim = 3;
+
+        //- Rank of Scalar is 0
+        static const direction rank = 0;
+
+        //- Number of components in Scalar is 1
+        static const direction nComponents = 1;
+
 
     // Static data members
 
@@ -73,6 +77,7 @@ public:
         static const Scalar rootMax;
         static const Scalar rootMin;
 
+
     // Constructors
 
         //- Construct from primitive
diff --git a/src/OpenFOAM/primitives/SphericalTensor/SphericalTensor.H b/src/OpenFOAM/primitives/SphericalTensor/SphericalTensor.H
index cd16d3026eb..2fa7b9b4ed6 100644
--- a/src/OpenFOAM/primitives/SphericalTensor/SphericalTensor.H
+++ b/src/OpenFOAM/primitives/SphericalTensor/SphericalTensor.H
@@ -62,10 +62,8 @@ public:
 
     // Member constants
 
-        enum
-        {
-            rank = 2 // Rank of SphericalTensor is 2
-        };
+        //- Rank of SphericalTensor is 2
+        static const direction rank = 2;
 
 
     // Static data members
diff --git a/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2D.H b/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2D.H
index 474777c1c3d..ecebdf26257 100644
--- a/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2D.H
+++ b/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2D.H
@@ -58,10 +58,8 @@ public:
 
     // Member constants
 
-        enum
-        {
-            rank = 2 // Rank of SphericalTensor2D is 2
-        };
+        //- Rank of SphericalTensor2D is 2
+        static const direction rank = 2;
 
 
     // Static data members
diff --git a/src/OpenFOAM/primitives/SymmTensor/SymmTensor.H b/src/OpenFOAM/primitives/SymmTensor/SymmTensor.H
index 952536ac8cc..58eca1da22f 100644
--- a/src/OpenFOAM/primitives/SymmTensor/SymmTensor.H
+++ b/src/OpenFOAM/primitives/SymmTensor/SymmTensor.H
@@ -64,10 +64,8 @@ public:
 
     // Member constants
 
-        enum
-        {
-            rank = 2 // Rank of SymmTensor is 2
-        };
+        //- Rank of SymmTensor is 2
+        static const direction rank = 2;
 
 
     // Static data members
diff --git a/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H b/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H
index 1d747caa2d0..55a455ddc3c 100644
--- a/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H
+++ b/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H
@@ -64,10 +64,8 @@ public:
 
     // Member constants
 
-        enum
-        {
-            rank = 2 // Rank of SymmTensor2D is 2
-        };
+        //- Rank of SymmTensor2D is 2
+        static const direction rank = 2;
 
 
     // Static data members
diff --git a/src/OpenFOAM/primitives/Tensor/Tensor.H b/src/OpenFOAM/primitives/Tensor/Tensor.H
index 9cd83fd09b0..cf92644c16d 100644
--- a/src/OpenFOAM/primitives/Tensor/Tensor.H
+++ b/src/OpenFOAM/primitives/Tensor/Tensor.H
@@ -67,10 +67,8 @@ public:
 
     // Member constants
 
-        enum
-        {
-            rank = 2 // Rank of Tensor is 2
-        };
+        //- Rank of Tensor is 2
+        static const direction rank = 2;
 
 
     // Static data members
diff --git a/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H b/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H
index bc1f3906e56..098f52ef9d0 100644
--- a/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H
+++ b/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H
@@ -67,10 +67,8 @@ public:
 
     // Member constants
 
-        enum
-        {
-            rank = 2 // Rank of Tensor2D is 2
-        };
+        //- Rank of Tensor2D is 2
+        static const direction rank = 2;
 
 
     // Static data members
diff --git a/src/OpenFOAM/primitives/Vector/Vector.H b/src/OpenFOAM/primitives/Vector/Vector.H
index e4ba4c1feda..d80e5790fc1 100644
--- a/src/OpenFOAM/primitives/Vector/Vector.H
+++ b/src/OpenFOAM/primitives/Vector/Vector.H
@@ -68,10 +68,8 @@ public:
 
     // Member constants
 
-        enum
-        {
-            rank = 1 // Rank of Vector is 1
-        };
+        //- Rank of Vector is 1
+        static const direction rank = 1;
 
 
     //- Component labeling enumeration
diff --git a/src/OpenFOAM/primitives/Vector2D/Vector2D.H b/src/OpenFOAM/primitives/Vector2D/Vector2D.H
index ca77ed8ce10..d1c7852b8f3 100644
--- a/src/OpenFOAM/primitives/Vector2D/Vector2D.H
+++ b/src/OpenFOAM/primitives/Vector2D/Vector2D.H
@@ -62,10 +62,8 @@ public:
 
     // Member constants
 
-        enum
-        {
-            rank = 1 // Rank of Vector2D is 1
-        };
+        //- Rank of Vector2D is 1
+        static const direction rank = 1;
 
 
     //- Component labeling enumeration
diff --git a/src/OpenFOAM/primitives/VectorSpace/VectorSpace.C b/src/OpenFOAM/primitives/VectorSpace/VectorSpace.C
index 49c855fcde4..d634b78adea 100644
--- a/src/OpenFOAM/primitives/VectorSpace/VectorSpace.C
+++ b/src/OpenFOAM/primitives/VectorSpace/VectorSpace.C
@@ -30,7 +30,7 @@ License
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, Foam::direction nCmpt>
 Foam::VectorSpace<Form, Cmpt, nCmpt>::VectorSpace
 (
     Istream& is
@@ -39,7 +39,7 @@ Foam::VectorSpace<Form, Cmpt, nCmpt>::VectorSpace
     // Read beginning of VectorSpace<Cmpt>
     is.readBegin("VectorSpace<Form, Cmpt, nCmpt>");
 
-    for (int i=0; i<nCmpt; i++)
+    for (direction i=0; i<nCmpt; i++)
     {
         is >> v_[i];
     }
@@ -52,9 +52,8 @@ Foam::VectorSpace<Form, Cmpt, nCmpt>::VectorSpace
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
-Foam::word
-Foam::name
+template<class Form, class Cmpt, Foam::direction nCmpt>
+Foam::word Foam::name
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs
 )
@@ -63,7 +62,7 @@ Foam::name
 
     buf << '(';
 
-    for (int i=0; i<nCmpt-1; i++)
+    for (direction i=0; i<nCmpt-1; i++)
     {
         buf << vs.v_[i] << ',';
     }
@@ -76,7 +75,7 @@ Foam::name
 
 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, Foam::direction nCmpt>
 Foam::Istream& Foam::operator>>
 (
     Istream& is,
@@ -86,7 +85,7 @@ Foam::Istream& Foam::operator>>
     // Read beginning of VectorSpace<Cmpt, nCmpt>
     is.readBegin("VectorSpace<Form, Cmpt, nCmpt>");
 
-    for (int i=0; i<nCmpt; i++)
+    for (direction i=0; i<nCmpt; i++)
     {
         is >> vs.v_[i];
     }
@@ -101,21 +100,21 @@ Foam::Istream& Foam::operator>>
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, Foam::direction nCmpt>
 Foam::Ostream& Foam::operator<<
 (
     Ostream& os,
     const VectorSpace<Form, Cmpt, nCmpt>& vs
 )
 {
-    os << token::BEGIN_LIST;
+    os << token::BEGIN_LIST << vs.v_[0];
 
-    for (int i=0; i<nCmpt-1; i++)
+    for (direction i=1; i<nCmpt; i++)
     {
-        os << vs.v_[i] << token::SPACE;
+        os << token::SPACE << vs.v_[i];
     }
 
-    os << vs.v_[nCmpt-1] << token::END_LIST;
+    os << token::END_LIST;
 
     // Check state of Ostream
     os.check("operator<<(Ostream&, const VectorSpace<Form, Cmpt, nCmpt>&)");
diff --git a/src/OpenFOAM/primitives/VectorSpace/VectorSpace.H b/src/OpenFOAM/primitives/VectorSpace/VectorSpace.H
index 2d650f43ae5..e8c4cbf16a9 100644
--- a/src/OpenFOAM/primitives/VectorSpace/VectorSpace.H
+++ b/src/OpenFOAM/primitives/VectorSpace/VectorSpace.H
@@ -51,16 +51,16 @@ namespace Foam
 
 // Forward declaration of friend functions and operators
 
-template<class Form, class Cmpt, int nCmpt> class VectorSpace;
+template<class Form, class Cmpt, direction nCmpt> class VectorSpace;
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 Istream& operator>>
 (
     Istream&,
     VectorSpace<Form, Cmpt, nCmpt>&
 );
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 Ostream& operator<<
 (
     Ostream&,
@@ -72,7 +72,7 @@ Ostream& operator<<
                            Class VectorSpace Declaration
 \*---------------------------------------------------------------------------*/
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 class VectorSpace
 {
 
@@ -115,6 +115,9 @@ public:
         //- Construct null
         inline VectorSpace();
 
+        //- Construct initialized to zero
+        inline VectorSpace(const Foam::zero);
+
         //- Construct from Istream
         VectorSpace(Istream&);
 
@@ -174,7 +177,7 @@ public:
 // * * * * * * * * * * * * * * Global functions  * * * * * * * * * * * * * * //
 
 //- Return a string representation of a VectorSpace
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 word name(const VectorSpace<Form, Cmpt, nCmpt>&);
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H b/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H
index e1c88e61d86..1b9c62798a4 100644
--- a/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H
+++ b/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H
@@ -35,12 +35,19 @@ namespace Foam
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline VectorSpace<Form, Cmpt, nCmpt>::VectorSpace()
 {}
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
+inline VectorSpace<Form, Cmpt, nCmpt>::VectorSpace(const Foam::zero z)
+{
+    VectorSpaceOps<nCmpt,0>::eqOpS(*this, 0, eqOp<Cmpt>());
+}
+
+
+template<class Form, class Cmpt, direction nCmpt>
 inline VectorSpace<Form, Cmpt, nCmpt>::VectorSpace
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs
@@ -50,7 +57,7 @@ inline VectorSpace<Form, Cmpt, nCmpt>::VectorSpace
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 template<class Form2, class Cmpt2>
 inline VectorSpace<Form, Cmpt, nCmpt>::VectorSpace
 (
@@ -63,14 +70,14 @@ inline VectorSpace<Form, Cmpt, nCmpt>::VectorSpace
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline label VectorSpace<Form, Cmpt, nCmpt>::size() const
 {
     return nCmpt;
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline const Cmpt& VectorSpace<Form, Cmpt, nCmpt>::component
 (
     const direction d
@@ -89,7 +96,7 @@ inline const Cmpt& VectorSpace<Form, Cmpt, nCmpt>::component
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Cmpt& VectorSpace<Form, Cmpt, nCmpt>::component
 (
     const direction d
@@ -108,7 +115,7 @@ inline Cmpt& VectorSpace<Form, Cmpt, nCmpt>::component
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline void VectorSpace<Form, Cmpt, nCmpt>::component
 (
     Cmpt& c,
@@ -128,7 +135,7 @@ inline void VectorSpace<Form, Cmpt, nCmpt>::component
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline void VectorSpace<Form, Cmpt, nCmpt>::replace
 (
     const direction d,
@@ -148,7 +155,7 @@ inline void VectorSpace<Form, Cmpt, nCmpt>::replace
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Form VectorSpace<Form, Cmpt, nCmpt>::uniform(const Cmpt& s)
 {
     Form v;
@@ -159,7 +166,7 @@ inline Form VectorSpace<Form, Cmpt, nCmpt>::uniform(const Cmpt& s)
 
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline const Cmpt& VectorSpace<Form, Cmpt, nCmpt>::operator[]
 (
     const direction d
@@ -178,7 +185,7 @@ inline const Cmpt& VectorSpace<Form, Cmpt, nCmpt>::operator[]
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Cmpt& VectorSpace<Form, Cmpt, nCmpt>::operator[]
 (
     const direction d
@@ -197,7 +204,7 @@ inline Cmpt& VectorSpace<Form, Cmpt, nCmpt>::operator[]
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline void VectorSpace<Form, Cmpt, nCmpt>::operator=
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs
@@ -207,7 +214,7 @@ inline void VectorSpace<Form, Cmpt, nCmpt>::operator=
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline void VectorSpace<Form, Cmpt, nCmpt>::operator+=
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs
@@ -217,7 +224,7 @@ inline void VectorSpace<Form, Cmpt, nCmpt>::operator+=
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline void VectorSpace<Form, Cmpt, nCmpt>::operator-=
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs
@@ -227,14 +234,14 @@ inline void VectorSpace<Form, Cmpt, nCmpt>::operator-=
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline void VectorSpace<Form, Cmpt, nCmpt>::operator=(const Foam::zero)
 {
     VectorSpaceOps<nCmpt,0>::eqOpS(*this, 0, eqOp<Cmpt>());
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline void VectorSpace<Form, Cmpt, nCmpt>::operator*=
 (
     const scalar s
@@ -244,7 +251,7 @@ inline void VectorSpace<Form, Cmpt, nCmpt>::operator*=
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline void VectorSpace<Form, Cmpt, nCmpt>::operator/=
 (
     const scalar s
@@ -256,7 +263,7 @@ inline void VectorSpace<Form, Cmpt, nCmpt>::operator/=
 
 // * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Cmpt& setComponent
 (
     VectorSpace<Form, Cmpt, nCmpt>& vs,
@@ -267,7 +274,7 @@ inline Cmpt& setComponent
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline const Cmpt& component
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs,
@@ -281,7 +288,7 @@ inline const Cmpt& component
 // Powers of a Form
 // Equivalent to outer-products between the Form and itself
 // Form^0 = 1.0
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline typename powProduct<Form, 0>::type pow
 (
     const VectorSpace<Form, Cmpt, nCmpt>&,
@@ -293,7 +300,7 @@ inline typename powProduct<Form, 0>::type pow
 }
 
 // Form^1 = Form
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline typename powProduct<Form, 1>::type pow
 (
     const VectorSpace<Form, Cmpt, nCmpt>& v,
@@ -306,7 +313,7 @@ inline typename powProduct<Form, 1>::type pow
 
 
 // Form^2 = sqr(Form)
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline typename powProduct<Form, 2>::type pow
 (
     const VectorSpace<Form, Cmpt, nCmpt>& v,
@@ -318,7 +325,7 @@ inline typename powProduct<Form, 2>::type pow
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline scalar magSqr
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs
@@ -330,7 +337,7 @@ inline scalar magSqr
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline scalar mag
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs
@@ -340,7 +347,7 @@ inline scalar mag
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline VectorSpace<Form, Cmpt, nCmpt> cmptMultiply
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs1,
@@ -353,7 +360,7 @@ inline VectorSpace<Form, Cmpt, nCmpt> cmptMultiply
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline VectorSpace<Form, Cmpt, nCmpt> cmptPow
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs1,
@@ -366,7 +373,7 @@ inline VectorSpace<Form, Cmpt, nCmpt> cmptPow
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline VectorSpace<Form, Cmpt, nCmpt> cmptDivide
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs1,
@@ -379,7 +386,7 @@ inline VectorSpace<Form, Cmpt, nCmpt> cmptDivide
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline VectorSpace<Form, Cmpt, nCmpt> stabilise
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs,
@@ -392,7 +399,7 @@ inline VectorSpace<Form, Cmpt, nCmpt> stabilise
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Cmpt cmptMax
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs
@@ -404,7 +411,7 @@ inline Cmpt cmptMax
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Cmpt cmptMin
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs
@@ -416,7 +423,7 @@ inline Cmpt cmptMin
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Cmpt cmptSum
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs
@@ -428,7 +435,7 @@ inline Cmpt cmptSum
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Cmpt cmptAv
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs
@@ -437,7 +444,7 @@ inline Cmpt cmptAv
     return cmptSum(vs)/nCmpt;
 }
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Cmpt cmptProduct
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs
@@ -449,7 +456,7 @@ inline Cmpt cmptProduct
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Form cmptMag
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs
@@ -461,7 +468,7 @@ inline Form cmptMag
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Form max
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs1,
@@ -474,7 +481,7 @@ inline Form max
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Form min
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs1,
@@ -487,7 +494,7 @@ inline Form min
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Form minMod
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs1,
@@ -516,8 +523,8 @@ inline Type dot(const Type& t, const scalar s)
 
 template
 <
-    class Form1, class Cmpt1, int nCmpt1,
-    class Form2, class Cmpt2, int nCmpt2
+    class Form1, class Cmpt1, direction nCmpt1,
+    class Form2, class Cmpt2, direction nCmpt2
 >
 inline typename innerProduct<Form1, Form2>::type dot
 (
@@ -531,7 +538,7 @@ inline typename innerProduct<Form1, Form2>::type dot
 
 // * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Form operator-
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs
@@ -543,7 +550,7 @@ inline Form operator-
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Form operator+
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs1,
@@ -555,7 +562,7 @@ inline Form operator+
     return v;
 }
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Form operator-
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs1,
@@ -568,7 +575,7 @@ inline Form operator-
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Form operator*
 (
     scalar s,
@@ -581,7 +588,7 @@ inline Form operator*
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Form operator*
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs,
@@ -594,7 +601,7 @@ inline Form operator*
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Form operator/
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs,
@@ -607,7 +614,7 @@ inline Form operator/
 }
 
 /*
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Form operator/
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs1,
@@ -620,7 +627,7 @@ inline Form operator/
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Form operator/
 (
     scalar s,
@@ -634,7 +641,7 @@ inline Form operator/
 */
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline Cmpt operator&&
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs1,
@@ -642,7 +649,7 @@ inline Cmpt operator&&
 )
 {
     Cmpt ddProd = vs1.v_[0]*vs2.v_[0];
-    for (int i=1; i<nCmpt; ++i)
+    for (direction i=1; i<nCmpt; ++i)
     {
         ddProd += vs1.v_[i]*vs2.v_[i];
     }
@@ -650,7 +657,7 @@ inline Cmpt operator&&
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline bool operator==
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs1,
@@ -658,7 +665,7 @@ inline bool operator==
 )
 {
     bool eq = true;
-    for (int i=0; i<nCmpt; ++i)
+    for (direction i=0; i<nCmpt; ++i)
     {
         if (!(eq &= (equal(vs1.v_[i], vs2.v_[i])))) break;
     }
@@ -666,7 +673,7 @@ inline bool operator==
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline bool operator!=
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs1,
@@ -677,7 +684,7 @@ inline bool operator!=
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline bool operator>
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs1,
@@ -685,7 +692,7 @@ inline bool operator>
 )
 {
     bool gt = true;
-    for (int i=0; i<nCmpt; ++i)
+    for (direction i=0; i<nCmpt; ++i)
     {
         if (!(gt &= vs1.v_[i] > vs2.v_[i])) break;
     }
@@ -693,7 +700,7 @@ inline bool operator>
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline bool operator<
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs1,
@@ -701,7 +708,7 @@ inline bool operator<
 )
 {
     bool lt = true;
-    for (int i=0; i<nCmpt; ++i)
+    for (direction i=0; i<nCmpt; ++i)
     {
         if (!(lt &= vs1.v_[i] < vs2.v_[i])) break;
     }
@@ -709,7 +716,7 @@ inline bool operator<
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline bool operator>=
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs1,
@@ -720,7 +727,7 @@ inline bool operator>=
 }
 
 
-template<class Form, class Cmpt, int nCmpt>
+template<class Form, class Cmpt, direction nCmpt>
 inline bool operator<=
 (
     const VectorSpace<Form, Cmpt, nCmpt>& vs1,
diff --git a/src/OpenFOAM/primitives/VectorSpace/VectorSpaceOps.H b/src/OpenFOAM/primitives/VectorSpace/VectorSpaceOps.H
index 7f6d3e1199b..5df70b1e5bf 100644
--- a/src/OpenFOAM/primitives/VectorSpace/VectorSpaceOps.H
+++ b/src/OpenFOAM/primitives/VectorSpace/VectorSpaceOps.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -39,7 +39,7 @@ namespace Foam
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-template<int N, int I>
+template<direction N, direction I>
 class VectorSpaceOps
 {
 public:
diff --git a/src/OpenFOAM/primitives/VectorSpace/products.H b/src/OpenFOAM/primitives/VectorSpace/products.H
index 4d657874aa1..4214f32f0f2 100644
--- a/src/OpenFOAM/primitives/VectorSpace/products.H
+++ b/src/OpenFOAM/primitives/VectorSpace/products.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -41,12 +41,12 @@ namespace Foam
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-template<class Cmpt, int rank>
+template<class Cmpt, direction rank>
 class typeOfRank
 {};
 
 
-template<class Cmpt, int rank>
+template<class Cmpt, direction rank>
 class symmTypeOfRank
 {};
 
@@ -68,7 +68,7 @@ public:
     typedef typename typeOfRank
     <
         typename pTraits<arg1>::cmptType,
-        int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank)
+        direction(pTraits<arg1>::rank) + direction(pTraits<arg2>::rank)
     >::type type;
 };
 
@@ -81,7 +81,7 @@ public:
     typedef typename typeOfRank
     <
         typename pTraits<arg2>::cmptType,
-        int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank) - 1
+        direction(pTraits<arg1>::rank) + direction(pTraits<arg2>::rank) - 1
     >::type type;
 };
 
@@ -93,7 +93,7 @@ public:
     typedef typename typeOfRank
     <
         typename pTraits<arg1>::cmptType,
-        int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank) - 2
+        direction(pTraits<arg1>::rank) + direction(pTraits<arg2>::rank) - 2
     >::type type;
 };
 
@@ -106,7 +106,7 @@ public:
 };
 
 
-template<class arg1, int arg2>
+template<class arg1, direction arg2>
 class powProduct
 {
 public:
@@ -114,7 +114,7 @@ public:
     typedef typename symmTypeOfRank
     <
         typename pTraits<arg1>::cmptType,
-        arg2*int(pTraits<arg1>::rank)
+        arg2*direction(pTraits<arg1>::rank)
     >::type type;
 };
 
diff --git a/src/OpenFOAM/primitives/bools/bool/bool.H b/src/OpenFOAM/primitives/bools/bool/bool.H
index b1638ec0541..19d8fb63de0 100644
--- a/src/OpenFOAM/primitives/bools/bool/bool.H
+++ b/src/OpenFOAM/primitives/bools/bool/bool.H
@@ -56,6 +56,7 @@ bool readBool(Istream&);
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 #include "pTraits.H"
+#include "direction.H"
 
 namespace Foam
 {
@@ -73,12 +74,14 @@ public:
 
     // Member constants
 
-        enum
-        {
-            dim = 3,         //!< Dimensionality of space
-            rank = 0,        //!< Rank of bool is 0
-            nComponents = 1  //!< Number of components in bool is 1
-        };
+        //- Dimensionality of space
+        static const direction dim = 3;
+
+        //- Rank of bool is 0
+        static const direction rank = 0;
+
+        //- Number of components in bool is 1
+        static const direction nComponents = 1;
 
 
     // Static data members
diff --git a/src/OpenFOAM/primitives/ints/int32/int32.H b/src/OpenFOAM/primitives/ints/int32/int32.H
index 0602a8e3458..d2601ad67cb 100644
--- a/src/OpenFOAM/primitives/ints/int32/int32.H
+++ b/src/OpenFOAM/primitives/ints/int32/int32.H
@@ -89,14 +89,17 @@ public:
     //- Component type
     typedef int32_t cmptType;
 
+
     // Member constants
 
-        enum
-        {
-            dim = 3,         //!< Dimensionality of space
-            rank = 0,        //!< Rank of int32_t is 0
-            nComponents = 1  //!< Number of components in int32_t is 1
-        };
+        //- Dimensionality of space
+        static const direction dim = 3;
+
+        //- Rank of int32_t is 0
+        static const direction rank = 0;
+
+        //- Number of components in int32_t is 1
+        static const direction nComponents = 1;
 
 
     // Static data members
diff --git a/src/OpenFOAM/primitives/ints/int64/int64.H b/src/OpenFOAM/primitives/ints/int64/int64.H
index 6006321a288..2bb5a05804f 100644
--- a/src/OpenFOAM/primitives/ints/int64/int64.H
+++ b/src/OpenFOAM/primitives/ints/int64/int64.H
@@ -80,14 +80,17 @@ public:
     //- Component type
     typedef int64_t cmptType;
 
+
     // Member constants
 
-        enum
-        {
-            dim = 3,         //!< Dimensionality of space
-            rank = 0,        //!< Rank of int64_t is 0
-            nComponents = 1  //!< Number of components in int64_t is 1
-        };
+        //- Dimensionality of space
+        static const direction dim = 3;
+
+        //- Rank of int64_t is 0
+        static const direction rank = 0;
+
+        //- Number of components in int64_t is 1
+        static const direction nComponents = 1;
 
 
     // Static data members
diff --git a/src/OpenFOAM/primitives/ints/uint32/uint32.H b/src/OpenFOAM/primitives/ints/uint32/uint32.H
index 9c2a3b6833d..83c3b18c67a 100644
--- a/src/OpenFOAM/primitives/ints/uint32/uint32.H
+++ b/src/OpenFOAM/primitives/ints/uint32/uint32.H
@@ -80,14 +80,17 @@ public:
     //- Component type
     typedef uint32_t cmptType;
 
+
     // Member constants
 
-        enum
-        {
-            dim = 3,         //!< Dimensionality of space
-            rank = 0,        //!< Rank of uint32_t is 0
-            nComponents = 1  //!< Number of components in uint32_t is 1
-        };
+        //- Dimensionality of space
+        static const direction dim = 3;
+
+        //- Rank of uint32_t is 0
+        static const direction rank = 0;
+
+        //- Number of components in uint32_t is 1
+        static const direction nComponents = 1;
 
 
     // Static data members
diff --git a/src/OpenFOAM/primitives/ints/uint64/uint64.H b/src/OpenFOAM/primitives/ints/uint64/uint64.H
index 2d2e31f802f..e1a742b6c22 100644
--- a/src/OpenFOAM/primitives/ints/uint64/uint64.H
+++ b/src/OpenFOAM/primitives/ints/uint64/uint64.H
@@ -80,14 +80,17 @@ public:
     //- Component type
     typedef uint64_t cmptType;
 
+
     // Member constants
 
-        enum
-        {
-            dim = 3,         //!< Dimensionality of space
-            rank = 0,        //!< Rank of uint64_t is 0
-            nComponents = 1  //!< Number of components in uint64_t is 1
-        };
+        //- Dimensionality of space
+        static const direction dim = 3;
+
+        //- Rank of uint64_t is 0
+        static const direction rank = 0;
+
+        //- Number of components in uint64_t is 1
+        static const direction nComponents = 1;
 
 
     // Static data members
diff --git a/src/OpenFOAM/primitives/quaternion/quaternion.H b/src/OpenFOAM/primitives/quaternion/quaternion.H
index 4a4b9f080f3..1e67c9bbcf3 100644
--- a/src/OpenFOAM/primitives/quaternion/quaternion.H
+++ b/src/OpenFOAM/primitives/quaternion/quaternion.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -78,12 +78,11 @@ public:
     //- Component type
     typedef scalar cmptType;
 
+
     // Member constants
 
-        enum
-        {
-            rank = 1 // Rank of quaternion is 1
-        };
+        //- Rank of quaternion is 1
+        static const direction rank = 1;
 
 
     // Static data members
-- 
GitLab