From fa83f2a97d68f86b907a27390f0a16889e35f8e3 Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Thu, 17 Mar 2016 18:05:11 +0000
Subject: [PATCH] primitives/transform: Added functions to generate rotation
 tensors about the individual axes

---
 src/OpenFOAM/primitives/transform/transform.H | 45 ++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/src/OpenFOAM/primitives/transform/transform.H b/src/OpenFOAM/primitives/transform/transform.H
index 3f50d677db8..646ba7734f8 100644
--- a/src/OpenFOAM/primitives/transform/transform.H
+++ b/src/OpenFOAM/primitives/transform/transform.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
@@ -42,6 +42,7 @@ namespace Foam
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+//- Rotational transformation tensor from vector n1 to n2
 inline tensor rotationTensor
 (
     const vector& n1,
@@ -76,6 +77,48 @@ inline tensor rotationTensor
 }
 
 
+//- Rotational transformation tensor about the x-axis by omega radians
+inline tensor Rx(const scalar& omega)
+{
+    const scalar s = sin(omega);
+    const scalar c = cos(omega);
+    return tensor
+    (
+        1,  0,  0,
+        0,  c,  s,
+        0, -s,  c
+    );
+}
+
+
+//- Rotational transformation tensor about the y-axis by omega radians
+inline tensor Ry(const scalar& omega)
+{
+    const scalar s = sin(omega);
+    const scalar c = cos(omega);
+    return tensor
+    (
+        c,  0, -s,
+        0,  1,  0,
+        s,  0,  c
+    );
+}
+
+
+//- Rotational transformation tensor about the z-axis by omega radians
+inline tensor Rz(const scalar& omega)
+{
+    const scalar s = sin(omega);
+    const scalar c = cos(omega);
+    return tensor
+    (
+        c,  s,  0,
+       -s,  c,  0,
+        0,  0,  1
+    );
+}
+
+
 inline label transform(const tensor&, const bool i)
 {
     return i;
-- 
GitLab