From a465e4db858d48196a4a144960ee674ef2a9517c Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 1 Jun 2022 13:38:49 +0200 Subject: [PATCH] ENH: support Euler rotation rollPitchYaw/yawPitchRoll ordering - can be more intuitive to specify for some cases: rotation { type euler; order rollPitchYaw; angles (0 20 45); } - refactor starcd rotation to reuse Euler ZXY ordering (code reduction) ENH: add -rotate-x, -rotate-y, -rotate-z for transformPoints etc - easier to specify for simple rotations --- .../transformPoints/transformPoints.C | 105 ++++++++++++------ .../surfaceTransformPoints.C | 83 +++++++++++--- .../rotation/EulerCoordinateRotation.C | 57 +++++----- .../rotation/EulerCoordinateRotation.H | 21 ++-- .../rotation/STARCDCoordinateRotation.C | 71 +++++------- .../rotation/STARCDCoordinateRotation.H | 9 +- .../coordinate/rotation/axesRotation.C | 44 ++++---- .../coordinate/rotation/axesRotation.H | 4 +- .../coordinate/rotation/axisAngleRotation.C | 40 +++++-- .../coordinate/rotation/axisAngleRotation.H | 26 +++-- .../coordinate/rotation/coordinateRotation.H | 6 +- .../coordinate/rotation/cylindricalRotation.C | 24 ++-- .../coordinate/rotation/cylindricalRotation.H | 12 +- .../coordinate/rotation/identityRotation.C | 24 ++-- .../coordinate/rotation/identityRotation.H | 8 +- .../coordinate/rotation/specifiedRotation.C | 4 +- .../coordinate/rotation/specifiedRotation.H | 4 +- .../coordinate/systems/coordinateSystem.H | 4 +- .../cylinder/cylinderAndBackground/Allrun.pre | 2 +- .../cylinderAndBackground/Allrun.pre | 2 +- .../rhoPimpleFoam/RAS/aerofoilNACA0012/Allrun | 2 +- .../rhoSimpleFoam/aerofoilNACA0012/Allrun.pre | 2 +- .../cylinder/cylinderAndBackground/Allrun.pre | 2 +- .../system/snappyHexMeshDict | 4 +- .../RAS/electrostaticDeposition/Allrun.pre | 2 +- .../decompositionConstraints/geometric/Allrun | 2 +- 26 files changed, 336 insertions(+), 228 deletions(-) diff --git a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C index dd82546f4e..0022525ad4 100644 --- a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C +++ b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2021 OpenCFD Ltd. + Copyright (C) 2017-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -53,6 +53,15 @@ Usage -rotate-angle (vector angle) Rotate angle degrees about vector axis. + -rotate-x angle + Rotate (degrees) about x-axis. + + -rotate-y angle + Rotate (degrees) about y-axis. + + -rotate-z angle + Rotate (degrees) about z-axis. + or -yawPitchRoll (yawdegrees pitchdegrees rolldegrees) or -rollPitchYaw (rolldegrees pitchdegrees yawdegrees) @@ -277,10 +286,25 @@ int main(int argc, char *argv[]) argList::addOption ( "rotate-angle", - "(vector scalar)", + "(vector angle)", "Rotate degrees about - eg, '((1 0 0) 45)'" ); argList::addOption + ( + "rotate-x", "deg", + "Rotate (degrees) about x-axis" + ); + argList::addOption + ( + "rotate-y", "deg", + "Rotate (degrees) about y-axis" + ); + argList::addOption + ( + "rotate-z", "deg", + "Rotate (degrees) about z-axis" + ); + argList::addOption ( "rollPitchYaw", "vector", @@ -316,15 +340,18 @@ int main(int argc, char *argv[]) // Verify that an operation has been specified { const List operationNames - { + ({ "recentre", "translate", "rotate", "rotate-angle", + "rotate-x", + "rotate-y", + "rotate-z", "rollPitchYaw", "yawPitchRoll", "scale" - }; + }); if (!args.count(operationNames)) { @@ -424,6 +451,12 @@ int main(int argc, char *argv[]) points -= origin; } + + // Get a rotation specification + + tensor rot(Zero); + bool useRotation(false); + if (args.found("rotate")) { Pair n1n2 @@ -433,15 +466,8 @@ int main(int argc, char *argv[]) n1n2[0].normalise(); n1n2[1].normalise(); - const tensor rot(rotationTensor(n1n2[0], n1n2[1])); - - Info<< "Rotating points by " << rot << endl; - points = transform(rot, points); - - if (doRotateFields) - { - rotateFields(regionName, runTime, rot); - } + rot = rotationTensor(n1n2[0], n1n2[1]); + useRotation = true; } else if (args.found("rotate-angle")) { @@ -457,15 +483,35 @@ int main(int argc, char *argv[]) << " about " << axis << nl << " angle " << angle << nl; - const tensor rot(axisAngle::rotation(axis, angle, true)); + rot = axisAngle::rotation(axis, angle, true); + useRotation = true; + } + else if (args.found("rotate-x")) + { + const scalar angle = args.get("rotate-x"); - Info<< "Rotating points by " << rot << endl; - points = transform(rot, points); + Info<< "Rotating points about x-axis: " << angle << nl; - if (doRotateFields) - { - rotateFields(regionName, runTime, rot); - } + rot = axisAngle::rotation(vector::X, angle, true); + useRotation = true; + } + else if (args.found("rotate-y")) + { + const scalar angle = args.get("rotate-y"); + + Info<< "Rotating points about y-axis: " << angle << nl; + + rot = axisAngle::rotation(vector::Y, angle, true); + useRotation = true; + } + else if (args.found("rotate-z")) + { + const scalar angle = args.get("rotate-z"); + + Info<< "Rotating points about z-axis: " << angle << nl; + + rot = axisAngle::rotation(vector::Z, angle, true); + useRotation = true; } else if (args.readIfPresent("rollPitchYaw", v)) { @@ -474,15 +520,8 @@ int main(int argc, char *argv[]) << " pitch " << v.y() << nl << " yaw " << v.z() << nl; - const tensor rot(euler::rotation(euler::eulerOrder::XYZ, v, true)); - - Info<< "Rotating points by " << rot << endl; - points = transform(rot, points); - - if (doRotateFields) - { - rotateFields(regionName, runTime, rot); - } + rot = euler::rotation(euler::eulerOrder::ROLL_PITCH_YAW, v, true); + useRotation = true; } else if (args.readIfPresent("yawPitchRoll", v)) { @@ -491,10 +530,14 @@ int main(int argc, char *argv[]) << " pitch " << v.y() << nl << " roll " << v.z() << nl; - const tensor rot(euler::rotation(euler::eulerOrder::ZYX, v, true)); + rot = euler::rotation(euler::eulerOrder::YAW_PITCH_ROLL, v, true); + useRotation = true; + } + if (useRotation) + { Info<< "Rotating points by " << rot << endl; - points = transform(rot, points); + transform(points, rot, points); if (doRotateFields) { diff --git a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C index 4322a0a530..dcee32d3d4 100644 --- a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C +++ b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2021 OpenCFD Ltd. + Copyright (C) 2017-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -206,10 +206,25 @@ int main(int argc, char *argv[]) argList::addOption ( "rotate-angle", - "(vector scalar)", + "(vector angle)", "Rotate degrees about - eg, '((1 0 0) 45)'" ); argList::addOption + ( + "rotate-x", "deg", + "Rotate (degrees) about x-axis" + ); + argList::addOption + ( + "rotate-y", "deg", + "Rotate (degrees) about y-axis" + ); + argList::addOption + ( + "rotate-z", "deg", + "Rotate (degrees) about z-axis" + ); + argList::addOption ( "rollPitchYaw", "vector", @@ -254,16 +269,19 @@ int main(int argc, char *argv[]) // Verify that an operation has been specified { const List operationNames - { + ({ "recentre", "translate", "rotate", "rotate-angle", + "rotate-x", + "rotate-y", + "rotate-z", "rollPitchYaw", "yawPitchRoll", "read-scale", "write-scale" - }; + }); if (!args.count(operationNames)) { @@ -348,6 +366,12 @@ int main(int argc, char *argv[]) points -= origin; } + + // Get a rotation specification + + tensor rot(Zero); + bool useRotation(false); + if (args.found("rotate")) { Pair n1n2 @@ -357,10 +381,8 @@ int main(int argc, char *argv[]) n1n2[0].normalise(); n1n2[1].normalise(); - const tensor rot(rotationTensor(n1n2[0], n1n2[1])); - - Info<< "Rotating points by " << rot << endl; - points = transform(rot, points); + rot = rotationTensor(n1n2[0], n1n2[1]); + useRotation = true; } else if (args.found("rotate-angle")) { @@ -376,10 +398,35 @@ int main(int argc, char *argv[]) << " about " << axis << nl << " angle " << angle << nl; - const tensor rot(axisAngle::rotation(axis, angle, true)); + rot = axisAngle::rotation(axis, angle, true); + useRotation = true; + } + else if (args.found("rotate-x")) + { + const scalar angle = args.get("rotate-x"); - Info<< "Rotating points by " << rot << endl; - points = transform(rot, points); + Info<< "Rotating points about x-axis: " << angle << nl; + + rot = axisAngle::rotation(vector::X, angle, true); + useRotation = true; + } + else if (args.found("rotate-y")) + { + const scalar angle = args.get("rotate-y"); + + Info<< "Rotating points about y-axis: " << angle << nl; + + rot = axisAngle::rotation(vector::Y, angle, true); + useRotation = true; + } + else if (args.found("rotate-z")) + { + const scalar angle = args.get("rotate-z"); + + Info<< "Rotating points about z-axis: " << angle << nl; + + rot = axisAngle::rotation(vector::Z, angle, true); + useRotation = true; } else if (args.readIfPresent("rollPitchYaw", v)) { @@ -388,10 +435,8 @@ int main(int argc, char *argv[]) << " pitch " << v.y() << nl << " yaw " << v.z() << nl; - const tensor rot(euler::rotation(euler::eulerOrder::XYZ, v, true)); - - Info<< "Rotating points by " << rot << endl; - points = transform(rot, points); + rot = euler::rotation(euler::eulerOrder::ROLL_PITCH_YAW, v, true); + useRotation = true; } else if (args.readIfPresent("yawPitchRoll", v)) { @@ -400,10 +445,14 @@ int main(int argc, char *argv[]) << " pitch " << v.y() << nl << " roll " << v.z() << nl; - const tensor rot(euler::rotation(euler::eulerOrder::ZYX, v, true)); + rot = euler::rotation(euler::eulerOrder::YAW_PITCH_ROLL, v, true); + useRotation = true; + } + if (useRotation) + { Info<< "Rotating points by " << rot << endl; - points = transform(rot, points); + transform(points, rot, points); } // Output scaling diff --git a/src/OpenFOAM/primitives/coordinate/rotation/EulerCoordinateRotation.C b/src/OpenFOAM/primitives/coordinate/rotation/EulerCoordinateRotation.C index ec1785386c..7e74e48475 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/EulerCoordinateRotation.C +++ b/src/OpenFOAM/primitives/coordinate/rotation/EulerCoordinateRotation.C @@ -34,29 +34,31 @@ License namespace Foam { - namespace coordinateRotations - { - defineTypeName(euler); +namespace coordinateRotations +{ - // Standard short name - addNamedToRunTimeSelectionTable - ( - coordinateRotation, - euler, - dictionary, - euler - ); + defineTypeName(euler); - // Longer name - Compat 1806 - addNamedToRunTimeSelectionTable - ( - coordinateRotation, - euler, - dictionary, - EulerRotation - ); - } -} + // Standard short name + addNamedToRunTimeSelectionTable + ( + coordinateRotation, + euler, + dictionary, + euler + ); + + // Longer name - Compat 1806 + addNamedToRunTimeSelectionTable + ( + coordinateRotation, + euler, + dictionary, + EulerRotation + ); + +} // End namespace coordinateRotations +} // End namespace Foam // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // @@ -68,9 +70,9 @@ Foam::tensor Foam::coordinateRotations::euler::rotation bool degrees ) { - scalar angle1(angles.component(vector::X)); // Rotation #1 - scalar angle2(angles.component(vector::Y)); // Rotation #2 - scalar angle3(angles.component(vector::Z)); // Rotation #3 + scalar angle1(angles.x()); // Rotation #1 + scalar angle2(angles.y()); // Rotation #2 + scalar angle3(angles.z()); // Rotation #3 if (degrees) { @@ -156,7 +158,7 @@ Foam::tensor Foam::coordinateRotations::euler::rotation } - // Tait-Bryan angles + // Tait-Bryan angles case eulerOrder::XZY: // X1-Z2-Y3 rotation { @@ -228,10 +230,9 @@ Foam::tensor Foam::coordinateRotations::euler::rotation FatalErrorInFunction << "Unknown euler rotation order " << int(order) << abort(FatalError); - break; } - return tensor::I; + return sphericalTensor::I; // identity rotation } @@ -321,7 +322,7 @@ void Foam::coordinateRotations::euler::clear() Foam::tensor Foam::coordinateRotations::euler::R() const { - return euler::rotation(angles_, degrees_); + return euler::rotation(order_, angles_, degrees_); } diff --git a/src/OpenFOAM/primitives/coordinate/rotation/EulerCoordinateRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/EulerCoordinateRotation.H index 2dbe8fec74..d60af6e32d 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/EulerCoordinateRotation.H +++ b/src/OpenFOAM/primitives/coordinate/rotation/EulerCoordinateRotation.H @@ -47,19 +47,24 @@ Description \heading Dictionary entries \table - Property | Description | Required | Default - type | Type name: euler (or EulerRotation) | yes | - angles | The z-x-z rotation angles | yes | - degrees | Angles are in degrees | no | true + Property | Description | Reqd | Default + type | Type name: euler (or EulerRotation) | yes | + angles | Rotation angles (usually z-x-z order) | yes | + degrees | Angles are in degrees | no | true + order | Rotation order | no | zxz \endtable +Note + The rotation order is usually z-x-z, but can also be something like + "rollPitchYaw" etc. + SourceFiles EulerCoordinateRotation.C \*---------------------------------------------------------------------------*/ -#ifndef coordinateRotations_euler_H -#define coordinateRotations_euler_H +#ifndef Foam_coordinateRotations_euler_H +#define Foam_coordinateRotations_euler_H #include "coordinateRotation.H" #include "quaternion.H" @@ -139,11 +144,11 @@ public: // Static Member Functions - //- The rotation tensor calculated for the intrinsic Euler + //- Rotation tensor calculated for the intrinsic Euler //- angles in z-x-z order static tensor rotation(const vector& angles, bool degrees=false); - //- The rotation tensor calculated for given angles and order + //- Rotation tensor calculated for given order and angles static tensor rotation ( const eulerOrder order, diff --git a/src/OpenFOAM/primitives/coordinate/rotation/STARCDCoordinateRotation.C b/src/OpenFOAM/primitives/coordinate/rotation/STARCDCoordinateRotation.C index e19f304f3d..17ac50c30b 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/STARCDCoordinateRotation.C +++ b/src/OpenFOAM/primitives/coordinate/rotation/STARCDCoordinateRotation.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2021 OpenCFD Ltd. + Copyright (C) 2017-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,36 +27,38 @@ License \*---------------------------------------------------------------------------*/ #include "STARCDCoordinateRotation.H" -#include "unitConversion.H" +#include "EulerCoordinateRotation.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - namespace coordinateRotations - { - defineTypeName(starcd); +namespace coordinateRotations +{ - // Standard short name - addNamedToRunTimeSelectionTable - ( - coordinateRotation, - starcd, - dictionary, - starcd - ); + defineTypeName(starcd); - // Longer name - Compat 1806 - addNamedToRunTimeSelectionTable - ( - coordinateRotation, - starcd, - dictionary, - STARCDRotation - ); - } -} + // Standard short name + addNamedToRunTimeSelectionTable + ( + coordinateRotation, + starcd, + dictionary, + starcd + ); + + // Longer name - Compat 1806 + addNamedToRunTimeSelectionTable + ( + coordinateRotation, + starcd, + dictionary, + STARCDRotation + ); + +} // End namespace coordinateRotation +} // End namespace Foam // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // @@ -67,28 +69,7 @@ Foam::tensor Foam::coordinateRotations::starcd::rotation bool degrees ) { - scalar z = angles.component(vector::X); // 1. Rotate about Z - scalar x = angles.component(vector::Y); // 2. Rotate about X - scalar y = angles.component(vector::Z); // 3. Rotate about Y - - if (degrees) - { - x *= degToRad(); - y *= degToRad(); - z *= degToRad(); - } - - const scalar cx = cos(x); const scalar sx = sin(x); - const scalar cy = cos(y); const scalar sy = sin(y); - const scalar cz = cos(z); const scalar sz = sin(z); - - return - tensor - ( - cy*cz - sx*sy*sz, -cx*sz, sx*cy*sz + sy*cz, - cy*sz + sx*sy*cz, cx*cz, sy*sz - sx*cy*cz, - -cx*sy, sx, cx*cy - ); + return euler::rotation(euler::eulerOrder::ZXY, angles, degrees); } diff --git a/src/OpenFOAM/primitives/coordinate/rotation/STARCDCoordinateRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/STARCDCoordinateRotation.H index f72f510267..fd005e7384 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/STARCDCoordinateRotation.H +++ b/src/OpenFOAM/primitives/coordinate/rotation/STARCDCoordinateRotation.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2017-2021 OpenCFD Ltd. + Copyright (C) 2017-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -57,8 +57,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef coordinateRotations_starcd_H -#define coordinateRotations_starcd_H +#ifndef Foam_coordinateRotations_starcd_H +#define Foam_coordinateRotations_starcd_H #include "coordinateRotation.H" @@ -124,7 +124,7 @@ public: // Static Member Functions - //- The rotation tensor calculated for the specified STARCD angles + //- Rotation tensor calculated for the specified STARCD angles //- interpreted as rotate-Z, rotate-X, rotate-Y static tensor rotation(const vector& angles, bool degrees); @@ -142,7 +142,6 @@ public: //- Write dictionary entry virtual void writeEntry(const word& keyword, Ostream& os) const; - }; diff --git a/src/OpenFOAM/primitives/coordinate/rotation/axesRotation.C b/src/OpenFOAM/primitives/coordinate/rotation/axesRotation.C index 459b0d7b5f..5aa1393fe4 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/axesRotation.C +++ b/src/OpenFOAM/primitives/coordinate/rotation/axesRotation.C @@ -34,29 +34,31 @@ License namespace Foam { - namespace coordinateRotations - { - defineTypeName(axes); +namespace coordinateRotations +{ - // Standard short name - addNamedToRunTimeSelectionTable - ( - coordinateRotation, - axes, - dictionary, - axes - ); + defineTypeName(axes); - // Longer name - Compat 1806 - addNamedToRunTimeSelectionTable - ( - coordinateRotation, - axes, - dictionary, - axesRotation - ); - } -} + // Standard short name + addNamedToRunTimeSelectionTable + ( + coordinateRotation, + axes, + dictionary, + axes + ); + + // Longer name - Compat 1806 + addNamedToRunTimeSelectionTable + ( + coordinateRotation, + axes, + dictionary, + axesRotation + ); + +} // End namespace coordinateRotations +} // End namespace Foam // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/coordinate/rotation/axesRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/axesRotation.H index 2459c67fa6..37bd4a419f 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/axesRotation.H +++ b/src/OpenFOAM/primitives/coordinate/rotation/axesRotation.H @@ -61,8 +61,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef coordinateRotations_axes_H -#define coordinateRotations_axes_H +#ifndef Foam_coordinateRotations_axes_H +#define Foam_coordinateRotations_axes_H #include "coordinateRotation.H" diff --git a/src/OpenFOAM/primitives/coordinate/rotation/axisAngleRotation.C b/src/OpenFOAM/primitives/coordinate/rotation/axisAngleRotation.C index d965376c1f..8b311d822a 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/axisAngleRotation.C +++ b/src/OpenFOAM/primitives/coordinate/rotation/axisAngleRotation.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,17 +35,19 @@ License namespace Foam { - namespace coordinateRotations - { - defineTypeName(axisAngle); - addToRunTimeSelectionTable - ( - coordinateRotation, - axisAngle, - dictionary - ); - } -} +namespace coordinateRotations +{ + + defineTypeName(axisAngle); + addToRunTimeSelectionTable + ( + coordinateRotation, + axisAngle, + dictionary + ); + +} // End namespace coordinateRotation +} // End namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -77,6 +79,20 @@ Foam::tensor Foam::coordinateRotations::axisAngle::rotation } +Foam::tensor Foam::coordinateRotations::axisAngle::rotation +( + const vector::components axis, + const scalar angle, + bool degrees +) +{ + vector rotAxis(Zero); + rotAxis[axis] = 1; + + return axisAngle::rotation(rotAxis, angle, degrees); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::coordinateRotations::axisAngle::axisAngle() diff --git a/src/OpenFOAM/primitives/coordinate/rotation/axisAngleRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/axisAngleRotation.H index 03a5660e95..0914d4b1c2 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/axisAngleRotation.H +++ b/src/OpenFOAM/primitives/coordinate/rotation/axisAngleRotation.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,23 +41,23 @@ Description \heading Dictionary entries \table - Property | Description | Required | Default - type | Type name: axisAngle | yes | - axis | Axis of rotation (vector) | yes | - angle | Rotation angle | yes | - degrees | The angle is in degrees | no | true + Property | Description | Reqd | Default + type | Type name: axisAngle | yes | + axis | Axis of rotation (vector) | yes | + angle | Rotation angle | yes | + degrees | The angle is in degrees | no | true \endtable Note - The rotation axis will be normalized internally. + The rotation axis is normalized internally. SourceFiles axisAngleRotation.C \*---------------------------------------------------------------------------*/ -#ifndef coordinateRotations_axisAngle_H -#define coordinateRotations_axisAngle_H +#ifndef Foam_coordinateRotations_axisAngle_H +#define Foam_coordinateRotations_axisAngle_H #include "coordinateRotation.H" @@ -140,6 +140,14 @@ public: bool degrees=false ); + //- Rotation tensor calculated for given axis and angle + static tensor rotation + ( + const vector::components axis, + const scalar angle, + bool degrees=false + ); + // Member Functions diff --git a/src/OpenFOAM/primitives/coordinate/rotation/coordinateRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/coordinateRotation.H index 48ea6c972b..c15461d416 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/coordinateRotation.H +++ b/src/OpenFOAM/primitives/coordinate/rotation/coordinateRotation.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,8 +58,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef coordinateRotation_H -#define coordinateRotation_H +#ifndef Foam_coordinateRotation_H +#define Foam_coordinateRotation_H #include "autoPtr.H" #include "vector.H" diff --git a/src/OpenFOAM/primitives/coordinate/rotation/cylindricalRotation.C b/src/OpenFOAM/primitives/coordinate/rotation/cylindricalRotation.C index 89848a084e..2e7e52d401 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/cylindricalRotation.C +++ b/src/OpenFOAM/primitives/coordinate/rotation/cylindricalRotation.C @@ -32,17 +32,19 @@ License namespace Foam { - namespace coordinateRotations - { - defineTypeName(cylindrical); - addToRunTimeSelectionTable - ( - coordinateRotation, - cylindrical, - dictionary - ); - } -} +namespace coordinateRotations +{ + + defineTypeName(cylindrical); + addToRunTimeSelectionTable + ( + coordinateRotation, + cylindrical, + dictionary + ); + +} // End namespace coordinateRotations +} // End namespace Foam // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/coordinate/rotation/cylindricalRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/cylindricalRotation.H index c4e3c8d2a0..59a1acd0fb 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/cylindricalRotation.H +++ b/src/OpenFOAM/primitives/coordinate/rotation/cylindricalRotation.H @@ -34,10 +34,10 @@ Description \heading Dictionary entries \table - Property | Description | Required | Default - type | Type name: cylindrical | yes | - axis | The z-axis | yes | - e3 | Alias for 'axis' | no | + Property | Description | Reqd | Default + type | Type name: cylindrical | yes | + axis | The z-axis | yes | + e3 | Alias for 'axis' | no | \endtable SourceFiles @@ -45,8 +45,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef coordinateRotations_cylindrical_H -#define coordinateRotations_cylindrical_H +#ifndef Foam_coordinateRotations_cylindrical_H +#define Foam_coordinateRotations_cylindrical_H #include "axesRotation.H" diff --git a/src/OpenFOAM/primitives/coordinate/rotation/identityRotation.C b/src/OpenFOAM/primitives/coordinate/rotation/identityRotation.C index 6396c68fe1..82fa14bb67 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/identityRotation.C +++ b/src/OpenFOAM/primitives/coordinate/rotation/identityRotation.C @@ -33,17 +33,19 @@ License namespace Foam { - namespace coordinateRotations - { - defineTypeName(identity); - addToRunTimeSelectionTable - ( - coordinateRotation, - identity, - dictionary - ); - } -} +namespace coordinateRotations +{ + + defineTypeName(identity); + addToRunTimeSelectionTable + ( + coordinateRotation, + identity, + dictionary + ); + +} // End namespace coordinateRotations +} // End namespace Foam // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/coordinate/rotation/identityRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/identityRotation.H index 54c7b284dd..80fe1efec6 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/identityRotation.H +++ b/src/OpenFOAM/primitives/coordinate/rotation/identityRotation.H @@ -38,8 +38,8 @@ Description \heading Dictionary entries \table - Property | Description | Required | Default - type | Type name: none | yes | + Property | Description | Reqd | Default + type | Type name: none | yes | \endtable SourceFiles @@ -47,8 +47,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef coordinateRotations_identity_H -#define coordinateRotations_identity_H +#ifndef Foam_coordinateRotations_identity_H +#define Foam_coordinateRotations_identity_H #include "coordinateRotation.H" diff --git a/src/OpenFOAM/primitives/coordinate/rotation/specifiedRotation.C b/src/OpenFOAM/primitives/coordinate/rotation/specifiedRotation.C index 06117a99f1..1db73bb6c2 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/specifiedRotation.C +++ b/src/OpenFOAM/primitives/coordinate/rotation/specifiedRotation.C @@ -39,8 +39,8 @@ namespace coordinateRotations defineTypeName(specified); //FUTURE addToRunTimeSelectionTable(coordinateRotation, specified, dictionary); -} -} +} // End namespace coordinateRotations +} // End namespace Foam // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/coordinate/rotation/specifiedRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/specifiedRotation.H index 8c27a65330..6d41c8ce55 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/specifiedRotation.H +++ b/src/OpenFOAM/primitives/coordinate/rotation/specifiedRotation.H @@ -43,8 +43,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef coordinateRotations_specified_H -#define coordinateRotations_specified_H +#ifndef Foam_coordinateRotations_specified_H +#define Foam_coordinateRotations_specified_H #include "coordinateRotation.H" diff --git a/src/OpenFOAM/primitives/coordinate/systems/coordinateSystem.H b/src/OpenFOAM/primitives/coordinate/systems/coordinateSystem.H index 34f7aac188..9b5aa423e4 100644 --- a/src/OpenFOAM/primitives/coordinate/systems/coordinateSystem.H +++ b/src/OpenFOAM/primitives/coordinate/systems/coordinateSystem.H @@ -97,8 +97,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef coordinateSystem_H -#define coordinateSystem_H +#ifndef Foam_coordinateSystem_H +#define Foam_coordinateSystem_H #include "vector.H" #include "point.H" diff --git a/tutorials/basic/overPotentialFoam/cylinder/cylinderAndBackground/Allrun.pre b/tutorials/basic/overPotentialFoam/cylinder/cylinderAndBackground/Allrun.pre index dcf0a0a3a0..79f6c5de3c 100755 --- a/tutorials/basic/overPotentialFoam/cylinder/cylinderAndBackground/Allrun.pre +++ b/tutorials/basic/overPotentialFoam/cylinder/cylinderAndBackground/Allrun.pre @@ -10,7 +10,7 @@ runApplication blockMesh runApplication mergeMeshes . ../cylinderMesh -overwrite ## Make it a bit smaller to keep it laminar -#runApplication transformPoints -scale '(0.001 0.001 0.001)' +#runApplication transformPoints -scale 0.001 # Select cellSets for the different zones runApplication topoSet diff --git a/tutorials/compressible/overRhoSimpleFoam/hotCylinder/cylinderAndBackground/Allrun.pre b/tutorials/compressible/overRhoSimpleFoam/hotCylinder/cylinderAndBackground/Allrun.pre index dcf0a0a3a0..79f6c5de3c 100755 --- a/tutorials/compressible/overRhoSimpleFoam/hotCylinder/cylinderAndBackground/Allrun.pre +++ b/tutorials/compressible/overRhoSimpleFoam/hotCylinder/cylinderAndBackground/Allrun.pre @@ -10,7 +10,7 @@ runApplication blockMesh runApplication mergeMeshes . ../cylinderMesh -overwrite ## Make it a bit smaller to keep it laminar -#runApplication transformPoints -scale '(0.001 0.001 0.001)' +#runApplication transformPoints -scale 0.001 # Select cellSets for the different zones runApplication topoSet diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/aerofoilNACA0012/Allrun b/tutorials/compressible/rhoPimpleFoam/RAS/aerofoilNACA0012/Allrun index 97c3b0d0c8..2cfd929f0b 100755 --- a/tutorials/compressible/rhoPimpleFoam/RAS/aerofoilNACA0012/Allrun +++ b/tutorials/compressible/rhoPimpleFoam/RAS/aerofoilNACA0012/Allrun @@ -13,7 +13,7 @@ restore0Dir runApplication blockMesh -runApplication transformPoints -scale "(1 0 1)" +runApplication transformPoints -scale '(1 0 1)' runApplication extrudeMesh diff --git a/tutorials/compressible/rhoSimpleFoam/aerofoilNACA0012/Allrun.pre b/tutorials/compressible/rhoSimpleFoam/aerofoilNACA0012/Allrun.pre index 102703e969..c2367e643e 100755 --- a/tutorials/compressible/rhoSimpleFoam/aerofoilNACA0012/Allrun.pre +++ b/tutorials/compressible/rhoSimpleFoam/aerofoilNACA0012/Allrun.pre @@ -13,7 +13,7 @@ restore0Dir runApplication blockMesh -runApplication transformPoints -scale "(1 0 1)" +runApplication transformPoints -scale '(1 0 1)' runApplication extrudeMesh diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun.pre b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun.pre index dcf0a0a3a0..79f6c5de3c 100755 --- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun.pre +++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun.pre @@ -10,7 +10,7 @@ runApplication blockMesh runApplication mergeMeshes . ../cylinderMesh -overwrite ## Make it a bit smaller to keep it laminar -#runApplication transformPoints -scale '(0.001 0.001 0.001)' +#runApplication transformPoints -scale 0.001 # Select cellSets for the different zones runApplication topoSet diff --git a/tutorials/mesh/snappyHexMesh/iglooWithFridgesDirectionalRefinement/system/snappyHexMeshDict b/tutorials/mesh/snappyHexMesh/iglooWithFridgesDirectionalRefinement/system/snappyHexMeshDict index 83e7804d59..1901c39878 100644 --- a/tutorials/mesh/snappyHexMesh/iglooWithFridgesDirectionalRefinement/system/snappyHexMeshDict +++ b/tutorials/mesh/snappyHexMesh/iglooWithFridgesDirectionalRefinement/system/snappyHexMeshDict @@ -60,9 +60,9 @@ geometry { type cartesian; origin (2 2 0); - coordinateRotation + rotation { - type axesRotation; + type axes; e1 (1 0 0); e3 (0 0 1); } diff --git a/tutorials/multiphase/interFoam/RAS/electrostaticDeposition/Allrun.pre b/tutorials/multiphase/interFoam/RAS/electrostaticDeposition/Allrun.pre index 838bd0b7b9..5ee318a496 100755 --- a/tutorials/multiphase/interFoam/RAS/electrostaticDeposition/Allrun.pre +++ b/tutorials/multiphase/interFoam/RAS/electrostaticDeposition/Allrun.pre @@ -13,7 +13,7 @@ restore0Dir runApplication setFields -runApplication transformPoints -rollPitchYaw "(0 -90 0)" +runApplication transformPoints -rotate-y -90 runApplication checkMesh -allGeometry -allTopology diff --git a/tutorials/preProcessing/decompositionConstraints/geometric/Allrun b/tutorials/preProcessing/decompositionConstraints/geometric/Allrun index 5f0d114e42..442127d2d8 100755 --- a/tutorials/preProcessing/decompositionConstraints/geometric/Allrun +++ b/tutorials/preProcessing/decompositionConstraints/geometric/Allrun @@ -9,7 +9,7 @@ mkdir -p constant/triSurface runApplication surfaceTransformPoints \ -translate '(0 0 5)' \ -origin '(0 0 5)' \ - -rotate-angle '((1 0 0) 45)' \ + -rotate-x 45 \ "$FOAM_TUTORIALS"/resources/geometry/blob.stl.gz \ constant/triSurface/blob.obj