From 227734ddf8b82106754903e659331d64aa34904c Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Tue, 30 Mar 2021 13:11:48 +0100 Subject: [PATCH] transform: Standardised the Rx, Ry, Rz and Ra rotational tranformations so that they operate in the conventional manner in a right-handed coordinate system: //- Rotational transformation tensor about the x-axis by omega radians // The rotation is defined in a right-handed coordinate system // i.e. clockwise with respect to the axis from -ve to +ve // (looking along the axis). inline tensor Rx(const scalar& omega) //- Rotational transformation tensor about the y-axis by omega radians // The rotation is defined in a right-handed coordinate system // i.e. clockwise with respect to the axis from -ve to +ve // (looking along the axis). inline tensor Ry(const scalar& omega) //- Rotational transformation tensor about the z-axis by omega radians // The rotation is defined in a right-handed coordinate system // i.e. clockwise with respect to the axis from -ve to +ve // (looking along the axis). inline tensor Rz(const scalar& omega) //- Rotational transformation tensor about axis a by omega radians // The rotation is defined in a right-handed coordinate system // i.e. clockwise with respect to the axis from -ve to +ve // (looking along the axis). inline tensor Ra(const vector& a, const scalar omega) --- src/OpenFOAM/primitives/transform/transform.H | 40 ++++++++++++------- .../rotor2D/system/blockMeshDict | 2 +- .../interFoam/RAS/planingHullW3/Allmesh.1 | 2 +- .../interFoam/RAS/planingHullW3/Allmesh.2 | 2 +- tutorials/resources/blockMesh/angledDuct | 2 +- tutorials/resources/blockMesh/mixerVessel2D | 2 +- 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/OpenFOAM/primitives/transform/transform.H b/src/OpenFOAM/primitives/transform/transform.H index 94337c608a..19da63bc19 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 | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -83,6 +83,9 @@ inline tensor rotationTensor //- Rotational transformation tensor about the x-axis by omega radians +// The rotation is defined in a right-handed coordinate system +// i.e. clockwise with respect to the axis from -ve to +ve +// (looking along the axis). inline tensor Rx(const scalar& omega) { const scalar s = sin(omega); @@ -90,41 +93,50 @@ inline tensor Rx(const scalar& omega) return tensor ( 1, 0, 0, - 0, c, s, - 0, -s, c + 0, c, -s, + 0, s, c ); } //- Rotational transformation tensor about the y-axis by omega radians +// The rotation is defined in a right-handed coordinate system +// i.e. clockwise with respect to the axis from -ve to +ve +// (looking along the axis). inline tensor Ry(const scalar& omega) { const scalar s = sin(omega); const scalar c = cos(omega); return tensor ( - c, 0, -s, + c, 0, s, 0, 1, 0, - s, 0, c + -s, 0, c ); } //- Rotational transformation tensor about the z-axis by omega radians +// The rotation is defined in a right-handed coordinate system +// i.e. clockwise with respect to the axis from -ve to +ve +// (looking along the axis). inline tensor Rz(const scalar& omega) { const scalar s = sin(omega); const scalar c = cos(omega); return tensor ( - c, s, 0, - -s, c, 0, + c, -s, 0, + s, c, 0, 0, 0, 1 ); } //- Rotational transformation tensor about axis a by omega radians +// The rotation is defined in a right-handed coordinate system +// i.e. clockwise with respect to the axis from -ve to +ve +// (looking along the axis). inline tensor Ra(const vector& a, const scalar omega) { const scalar s = sin(omega); @@ -133,15 +145,15 @@ inline tensor Ra(const vector& a, const scalar omega) return tensor ( sqr(a.x())*(1 - c) + c, - a.y()*a.x()*(1 - c) + a.z()*s, - a.x()*a.z()*(1 - c) - a.y()*s, - - a.x()*a.y()*(1 - c) - a.z()*s, - sqr(a.y())*(1 - c) + c, - a.y()*a.z()*(1 - c) + a.x()*s, - + a.y()*a.x()*(1 - c) - a.z()*s, a.x()*a.z()*(1 - c) + a.y()*s, + + a.x()*a.y()*(1 - c) + a.z()*s, + sqr(a.y())*(1 - c) + c, a.y()*a.z()*(1 - c) - a.x()*s, + + a.x()*a.z()*(1 - c) - a.y()*s, + a.y()*a.z()*(1 - c) + a.x()*s, sqr(a.z())*(1 - c) + c ); } diff --git a/tutorials/incompressible/SRFPimpleFoam/rotor2D/system/blockMeshDict b/tutorials/incompressible/SRFPimpleFoam/rotor2D/system/blockMeshDict index c298159809..b2723ecba7 100644 --- a/tutorials/incompressible/SRFPimpleFoam/rotor2D/system/blockMeshDict +++ b/tutorials/incompressible/SRFPimpleFoam/rotor2D/system/blockMeshDict @@ -51,7 +51,7 @@ vertices #codeStream // Rotate points around z-axis and append for (label i = 0; i < 4; i++) { - points.append(transform(Rz(-degToRad(i*$angle)), initPoints)); + points.append(transform(Rz(degToRad(i*$angle)), initPoints)); } // Duplicate z points diff --git a/tutorials/multiphase/interFoam/RAS/planingHullW3/Allmesh.1 b/tutorials/multiphase/interFoam/RAS/planingHullW3/Allmesh.1 index deb81a2e05..bb901d2e7b 100755 --- a/tutorials/multiphase/interFoam/RAS/planingHullW3/Allmesh.1 +++ b/tutorials/multiphase/interFoam/RAS/planingHullW3/Allmesh.1 @@ -6,7 +6,7 @@ cd ${0%/*} || exit 1 # Run from this directory runApplication surfaceTransformPoints \ "translate=(-0.586 0 -0.156), \ - Ry=3.485, \ + Ry=-3.485, \ translate=(0.586 0 0.156)" \ constant/geometry/w3_orig.stl constant/geometry/w3.stl diff --git a/tutorials/multiphase/interFoam/RAS/planingHullW3/Allmesh.2 b/tutorials/multiphase/interFoam/RAS/planingHullW3/Allmesh.2 index 6a21486828..3ffd810e10 100755 --- a/tutorials/multiphase/interFoam/RAS/planingHullW3/Allmesh.2 +++ b/tutorials/multiphase/interFoam/RAS/planingHullW3/Allmesh.2 @@ -6,7 +6,7 @@ cd ${0%/*} || exit 1 # Run from this directory runApplication surfaceTransformPoints \ "translate=(-0.586 0 -0.156), \ - Ry=3.485, \ + Ry=-3.485, \ translate=(0.586 0 0.156)" \ constant/geometry/w3_orig.stl constant/geometry/w3.stl diff --git a/tutorials/resources/blockMesh/angledDuct b/tutorials/resources/blockMesh/angledDuct index 6f3fd8ced8..16bec827b4 100644 --- a/tutorials/resources/blockMesh/angledDuct +++ b/tutorials/resources/blockMesh/angledDuct @@ -56,7 +56,7 @@ vertices #codeStream }); // Rotate points around z-axis - points = transform(Rz(-degToRad($angle)), points); + points = transform(Rz(degToRad($angle)), points); // Append points 6 and 7 points.append(points[0]); // pt 6 diff --git a/tutorials/resources/blockMesh/mixerVessel2D b/tutorials/resources/blockMesh/mixerVessel2D index f20a1937b4..dbcfc460e0 100644 --- a/tutorials/resources/blockMesh/mixerVessel2D +++ b/tutorials/resources/blockMesh/mixerVessel2D @@ -56,7 +56,7 @@ vertices #codeStream // Rotate points around z-axis and append for (label i = 0; i < 8; i++) { - points.append(transform(Rz(-degToRad(i*$angle)), initPoints)); + points.append(transform(Rz(degToRad(i*$angle)), initPoints)); } // Duplicate z points