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
This commit is contained in:
Mark Olesen
2022-06-01 13:38:49 +02:00
parent eba7a485ba
commit a465e4db85
26 changed files with 336 additions and 228 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd. Copyright (C) 2017-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -53,6 +53,15 @@ Usage
-rotate-angle (vector angle) -rotate-angle (vector angle)
Rotate angle degrees about vector axis. 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 -yawPitchRoll (yawdegrees pitchdegrees rolldegrees)
or -rollPitchYaw (rolldegrees pitchdegrees yawdegrees) or -rollPitchYaw (rolldegrees pitchdegrees yawdegrees)
@ -277,10 +286,25 @@ int main(int argc, char *argv[])
argList::addOption argList::addOption
( (
"rotate-angle", "rotate-angle",
"(vector scalar)", "(vector angle)",
"Rotate <angle> degrees about <vector> - eg, '((1 0 0) 45)'" "Rotate <angle> degrees about <vector> - eg, '((1 0 0) 45)'"
); );
argList::addOption 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", "rollPitchYaw",
"vector", "vector",
@ -316,15 +340,18 @@ int main(int argc, char *argv[])
// Verify that an operation has been specified // Verify that an operation has been specified
{ {
const List<word> operationNames const List<word> operationNames
{ ({
"recentre", "recentre",
"translate", "translate",
"rotate", "rotate",
"rotate-angle", "rotate-angle",
"rotate-x",
"rotate-y",
"rotate-z",
"rollPitchYaw", "rollPitchYaw",
"yawPitchRoll", "yawPitchRoll",
"scale" "scale"
}; });
if (!args.count(operationNames)) if (!args.count(operationNames))
{ {
@ -424,6 +451,12 @@ int main(int argc, char *argv[])
points -= origin; points -= origin;
} }
// Get a rotation specification
tensor rot(Zero);
bool useRotation(false);
if (args.found("rotate")) if (args.found("rotate"))
{ {
Pair<vector> n1n2 Pair<vector> n1n2
@ -433,15 +466,8 @@ int main(int argc, char *argv[])
n1n2[0].normalise(); n1n2[0].normalise();
n1n2[1].normalise(); n1n2[1].normalise();
const tensor rot(rotationTensor(n1n2[0], n1n2[1])); rot = rotationTensor(n1n2[0], n1n2[1]);
useRotation = true;
Info<< "Rotating points by " << rot << endl;
points = transform(rot, points);
if (doRotateFields)
{
rotateFields(regionName, runTime, rot);
}
} }
else if (args.found("rotate-angle")) else if (args.found("rotate-angle"))
{ {
@ -457,15 +483,35 @@ int main(int argc, char *argv[])
<< " about " << axis << nl << " about " << axis << nl
<< " angle " << angle << 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<scalar>("rotate-x");
Info<< "Rotating points by " << rot << endl; Info<< "Rotating points about x-axis: " << angle << nl;
points = transform(rot, points);
if (doRotateFields) rot = axisAngle::rotation(vector::X, angle, true);
{ useRotation = true;
rotateFields(regionName, runTime, rot); }
} else if (args.found("rotate-y"))
{
const scalar angle = args.get<scalar>("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<scalar>("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)) else if (args.readIfPresent("rollPitchYaw", v))
{ {
@ -474,15 +520,8 @@ int main(int argc, char *argv[])
<< " pitch " << v.y() << nl << " pitch " << v.y() << nl
<< " yaw " << v.z() << nl; << " yaw " << v.z() << nl;
const tensor rot(euler::rotation(euler::eulerOrder::XYZ, v, true)); rot = euler::rotation(euler::eulerOrder::ROLL_PITCH_YAW, v, true);
useRotation = true;
Info<< "Rotating points by " << rot << endl;
points = transform(rot, points);
if (doRotateFields)
{
rotateFields(regionName, runTime, rot);
}
} }
else if (args.readIfPresent("yawPitchRoll", v)) else if (args.readIfPresent("yawPitchRoll", v))
{ {
@ -491,10 +530,14 @@ int main(int argc, char *argv[])
<< " pitch " << v.y() << nl << " pitch " << v.y() << nl
<< " roll " << v.z() << 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; Info<< "Rotating points by " << rot << endl;
points = transform(rot, points); transform(points, rot, points);
if (doRotateFields) if (doRotateFields)
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd. Copyright (C) 2017-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -206,10 +206,25 @@ int main(int argc, char *argv[])
argList::addOption argList::addOption
( (
"rotate-angle", "rotate-angle",
"(vector scalar)", "(vector angle)",
"Rotate <angle> degrees about <vector> - eg, '((1 0 0) 45)'" "Rotate <angle> degrees about <vector> - eg, '((1 0 0) 45)'"
); );
argList::addOption 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", "rollPitchYaw",
"vector", "vector",
@ -254,16 +269,19 @@ int main(int argc, char *argv[])
// Verify that an operation has been specified // Verify that an operation has been specified
{ {
const List<word> operationNames const List<word> operationNames
{ ({
"recentre", "recentre",
"translate", "translate",
"rotate", "rotate",
"rotate-angle", "rotate-angle",
"rotate-x",
"rotate-y",
"rotate-z",
"rollPitchYaw", "rollPitchYaw",
"yawPitchRoll", "yawPitchRoll",
"read-scale", "read-scale",
"write-scale" "write-scale"
}; });
if (!args.count(operationNames)) if (!args.count(operationNames))
{ {
@ -348,6 +366,12 @@ int main(int argc, char *argv[])
points -= origin; points -= origin;
} }
// Get a rotation specification
tensor rot(Zero);
bool useRotation(false);
if (args.found("rotate")) if (args.found("rotate"))
{ {
Pair<vector> n1n2 Pair<vector> n1n2
@ -357,10 +381,8 @@ int main(int argc, char *argv[])
n1n2[0].normalise(); n1n2[0].normalise();
n1n2[1].normalise(); n1n2[1].normalise();
const tensor rot(rotationTensor(n1n2[0], n1n2[1])); rot = rotationTensor(n1n2[0], n1n2[1]);
useRotation = true;
Info<< "Rotating points by " << rot << endl;
points = transform(rot, points);
} }
else if (args.found("rotate-angle")) else if (args.found("rotate-angle"))
{ {
@ -376,10 +398,35 @@ int main(int argc, char *argv[])
<< " about " << axis << nl << " about " << axis << nl
<< " angle " << angle << 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<scalar>("rotate-x");
Info<< "Rotating points by " << rot << endl; Info<< "Rotating points about x-axis: " << angle << nl;
points = transform(rot, points);
rot = axisAngle::rotation(vector::X, angle, true);
useRotation = true;
}
else if (args.found("rotate-y"))
{
const scalar angle = args.get<scalar>("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<scalar>("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)) else if (args.readIfPresent("rollPitchYaw", v))
{ {
@ -388,10 +435,8 @@ int main(int argc, char *argv[])
<< " pitch " << v.y() << nl << " pitch " << v.y() << nl
<< " yaw " << v.z() << nl; << " yaw " << v.z() << nl;
const tensor rot(euler::rotation(euler::eulerOrder::XYZ, v, true)); rot = euler::rotation(euler::eulerOrder::ROLL_PITCH_YAW, v, true);
useRotation = true;
Info<< "Rotating points by " << rot << endl;
points = transform(rot, points);
} }
else if (args.readIfPresent("yawPitchRoll", v)) else if (args.readIfPresent("yawPitchRoll", v))
{ {
@ -400,10 +445,14 @@ int main(int argc, char *argv[])
<< " pitch " << v.y() << nl << " pitch " << v.y() << nl
<< " roll " << v.z() << 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; Info<< "Rotating points by " << rot << endl;
points = transform(rot, points); transform(points, rot, points);
} }
// Output scaling // Output scaling

View File

@ -34,29 +34,31 @@ License
namespace Foam namespace Foam
{ {
namespace coordinateRotations namespace coordinateRotations
{ {
defineTypeName(euler);
// Standard short name defineTypeName(euler);
addNamedToRunTimeSelectionTable
(
coordinateRotation,
euler,
dictionary,
euler
);
// Longer name - Compat 1806 // Standard short name
addNamedToRunTimeSelectionTable addNamedToRunTimeSelectionTable
( (
coordinateRotation, coordinateRotation,
euler, euler,
dictionary, dictionary,
EulerRotation euler
); );
}
} // Longer name - Compat 1806
addNamedToRunTimeSelectionTable
(
coordinateRotation,
euler,
dictionary,
EulerRotation
);
} // End namespace coordinateRotations
} // End namespace Foam
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
@ -68,9 +70,9 @@ Foam::tensor Foam::coordinateRotations::euler::rotation
bool degrees bool degrees
) )
{ {
scalar angle1(angles.component(vector::X)); // Rotation #1 scalar angle1(angles.x()); // Rotation #1
scalar angle2(angles.component(vector::Y)); // Rotation #2 scalar angle2(angles.y()); // Rotation #2
scalar angle3(angles.component(vector::Z)); // Rotation #3 scalar angle3(angles.z()); // Rotation #3
if (degrees) 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 case eulerOrder::XZY: // X1-Z2-Y3 rotation
{ {
@ -228,10 +230,9 @@ Foam::tensor Foam::coordinateRotations::euler::rotation
FatalErrorInFunction FatalErrorInFunction
<< "Unknown euler rotation order " << "Unknown euler rotation order "
<< int(order) << abort(FatalError); << 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 Foam::tensor Foam::coordinateRotations::euler::R() const
{ {
return euler::rotation(angles_, degrees_); return euler::rotation(order_, angles_, degrees_);
} }

View File

@ -47,19 +47,24 @@ Description
\heading Dictionary entries \heading Dictionary entries
\table \table
Property | Description | Required | Default Property | Description | Reqd | Default
type | Type name: euler (or EulerRotation) | yes | type | Type name: euler (or EulerRotation) | yes |
angles | The z-x-z rotation angles | yes | angles | Rotation angles (usually z-x-z order) | yes |
degrees | Angles are in degrees | no | true degrees | Angles are in degrees | no | true
order | Rotation order | no | zxz
\endtable \endtable
Note
The rotation order is usually z-x-z, but can also be something like
"rollPitchYaw" etc.
SourceFiles SourceFiles
EulerCoordinateRotation.C EulerCoordinateRotation.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef coordinateRotations_euler_H #ifndef Foam_coordinateRotations_euler_H
#define coordinateRotations_euler_H #define Foam_coordinateRotations_euler_H
#include "coordinateRotation.H" #include "coordinateRotation.H"
#include "quaternion.H" #include "quaternion.H"
@ -139,11 +144,11 @@ public:
// Static Member Functions // Static Member Functions
//- The rotation tensor calculated for the intrinsic Euler //- Rotation tensor calculated for the intrinsic Euler
//- angles in z-x-z order //- angles in z-x-z order
static tensor rotation(const vector& angles, bool degrees=false); 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 static tensor rotation
( (
const eulerOrder order, const eulerOrder order,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd. Copyright (C) 2017-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,36 +27,38 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "STARCDCoordinateRotation.H" #include "STARCDCoordinateRotation.H"
#include "unitConversion.H" #include "EulerCoordinateRotation.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
namespace coordinateRotations namespace coordinateRotations
{ {
defineTypeName(starcd);
// Standard short name defineTypeName(starcd);
addNamedToRunTimeSelectionTable
(
coordinateRotation,
starcd,
dictionary,
starcd
);
// Longer name - Compat 1806 // Standard short name
addNamedToRunTimeSelectionTable addNamedToRunTimeSelectionTable
( (
coordinateRotation, coordinateRotation,
starcd, starcd,
dictionary, dictionary,
STARCDRotation starcd
); );
}
} // Longer name - Compat 1806
addNamedToRunTimeSelectionTable
(
coordinateRotation,
starcd,
dictionary,
STARCDRotation
);
} // End namespace coordinateRotation
} // End namespace Foam
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
@ -67,28 +69,7 @@ Foam::tensor Foam::coordinateRotations::starcd::rotation
bool degrees bool degrees
) )
{ {
scalar z = angles.component(vector::X); // 1. Rotate about Z return euler::rotation(euler::eulerOrder::ZXY, angles, degrees);
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
);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd. Copyright (C) 2017-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -57,8 +57,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef coordinateRotations_starcd_H #ifndef Foam_coordinateRotations_starcd_H
#define coordinateRotations_starcd_H #define Foam_coordinateRotations_starcd_H
#include "coordinateRotation.H" #include "coordinateRotation.H"
@ -124,7 +124,7 @@ public:
// Static Member Functions // 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 //- interpreted as rotate-Z, rotate-X, rotate-Y
static tensor rotation(const vector& angles, bool degrees); static tensor rotation(const vector& angles, bool degrees);
@ -142,7 +142,6 @@ public:
//- Write dictionary entry //- Write dictionary entry
virtual void writeEntry(const word& keyword, Ostream& os) const; virtual void writeEntry(const word& keyword, Ostream& os) const;
}; };

View File

@ -34,29 +34,31 @@ License
namespace Foam namespace Foam
{ {
namespace coordinateRotations namespace coordinateRotations
{ {
defineTypeName(axes);
// Standard short name defineTypeName(axes);
addNamedToRunTimeSelectionTable
(
coordinateRotation,
axes,
dictionary,
axes
);
// Longer name - Compat 1806 // Standard short name
addNamedToRunTimeSelectionTable addNamedToRunTimeSelectionTable
( (
coordinateRotation, coordinateRotation,
axes, axes,
dictionary, dictionary,
axesRotation axes
); );
}
} // Longer name - Compat 1806
addNamedToRunTimeSelectionTable
(
coordinateRotation,
axes,
dictionary,
axesRotation
);
} // End namespace coordinateRotations
} // End namespace Foam
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //

View File

@ -61,8 +61,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef coordinateRotations_axes_H #ifndef Foam_coordinateRotations_axes_H
#define coordinateRotations_axes_H #define Foam_coordinateRotations_axes_H
#include "coordinateRotation.H" #include "coordinateRotation.H"

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -35,17 +35,19 @@ License
namespace Foam namespace Foam
{ {
namespace coordinateRotations namespace coordinateRotations
{ {
defineTypeName(axisAngle);
addToRunTimeSelectionTable defineTypeName(axisAngle);
( addToRunTimeSelectionTable
coordinateRotation, (
axisAngle, coordinateRotation,
dictionary axisAngle,
); dictionary
} );
}
} // End namespace coordinateRotation
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * 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 * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::coordinateRotations::axisAngle::axisAngle() Foam::coordinateRotations::axisAngle::axisAngle()

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -41,23 +41,23 @@ Description
\heading Dictionary entries \heading Dictionary entries
\table \table
Property | Description | Required | Default Property | Description | Reqd | Default
type | Type name: axisAngle | yes | type | Type name: axisAngle | yes |
axis | Axis of rotation (vector) | yes | axis | Axis of rotation (vector) | yes |
angle | Rotation angle | yes | angle | Rotation angle | yes |
degrees | The angle is in degrees | no | true degrees | The angle is in degrees | no | true
\endtable \endtable
Note Note
The rotation axis will be normalized internally. The rotation axis is normalized internally.
SourceFiles SourceFiles
axisAngleRotation.C axisAngleRotation.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef coordinateRotations_axisAngle_H #ifndef Foam_coordinateRotations_axisAngle_H
#define coordinateRotations_axisAngle_H #define Foam_coordinateRotations_axisAngle_H
#include "coordinateRotation.H" #include "coordinateRotation.H"
@ -140,6 +140,14 @@ public:
bool degrees=false 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 // Member Functions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -58,8 +58,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef coordinateRotation_H #ifndef Foam_coordinateRotation_H
#define coordinateRotation_H #define Foam_coordinateRotation_H
#include "autoPtr.H" #include "autoPtr.H"
#include "vector.H" #include "vector.H"

View File

@ -32,17 +32,19 @@ License
namespace Foam namespace Foam
{ {
namespace coordinateRotations namespace coordinateRotations
{ {
defineTypeName(cylindrical);
addToRunTimeSelectionTable defineTypeName(cylindrical);
( addToRunTimeSelectionTable
coordinateRotation, (
cylindrical, coordinateRotation,
dictionary cylindrical,
); dictionary
} );
}
} // End namespace coordinateRotations
} // End namespace Foam
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //

View File

@ -34,10 +34,10 @@ Description
\heading Dictionary entries \heading Dictionary entries
\table \table
Property | Description | Required | Default Property | Description | Reqd | Default
type | Type name: cylindrical | yes | type | Type name: cylindrical | yes |
axis | The z-axis | yes | axis | The z-axis | yes |
e3 | Alias for 'axis' | no | e3 | Alias for 'axis' | no |
\endtable \endtable
SourceFiles SourceFiles
@ -45,8 +45,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef coordinateRotations_cylindrical_H #ifndef Foam_coordinateRotations_cylindrical_H
#define coordinateRotations_cylindrical_H #define Foam_coordinateRotations_cylindrical_H
#include "axesRotation.H" #include "axesRotation.H"

View File

@ -33,17 +33,19 @@ License
namespace Foam namespace Foam
{ {
namespace coordinateRotations namespace coordinateRotations
{ {
defineTypeName(identity);
addToRunTimeSelectionTable defineTypeName(identity);
( addToRunTimeSelectionTable
coordinateRotation, (
identity, coordinateRotation,
dictionary identity,
); dictionary
} );
}
} // End namespace coordinateRotations
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

View File

@ -38,8 +38,8 @@ Description
\heading Dictionary entries \heading Dictionary entries
\table \table
Property | Description | Required | Default Property | Description | Reqd | Default
type | Type name: none | yes | type | Type name: none | yes |
\endtable \endtable
SourceFiles SourceFiles
@ -47,8 +47,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef coordinateRotations_identity_H #ifndef Foam_coordinateRotations_identity_H
#define coordinateRotations_identity_H #define Foam_coordinateRotations_identity_H
#include "coordinateRotation.H" #include "coordinateRotation.H"

View File

@ -39,8 +39,8 @@ namespace coordinateRotations
defineTypeName(specified); defineTypeName(specified);
//FUTURE addToRunTimeSelectionTable(coordinateRotation, specified, dictionary); //FUTURE addToRunTimeSelectionTable(coordinateRotation, specified, dictionary);
} } // End namespace coordinateRotations
} } // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

View File

@ -43,8 +43,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef coordinateRotations_specified_H #ifndef Foam_coordinateRotations_specified_H
#define coordinateRotations_specified_H #define Foam_coordinateRotations_specified_H
#include "coordinateRotation.H" #include "coordinateRotation.H"

View File

@ -97,8 +97,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef coordinateSystem_H #ifndef Foam_coordinateSystem_H
#define coordinateSystem_H #define Foam_coordinateSystem_H
#include "vector.H" #include "vector.H"
#include "point.H" #include "point.H"

View File

@ -10,7 +10,7 @@ runApplication blockMesh
runApplication mergeMeshes . ../cylinderMesh -overwrite runApplication mergeMeshes . ../cylinderMesh -overwrite
## Make it a bit smaller to keep it laminar ## 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 # Select cellSets for the different zones
runApplication topoSet runApplication topoSet

View File

@ -10,7 +10,7 @@ runApplication blockMesh
runApplication mergeMeshes . ../cylinderMesh -overwrite runApplication mergeMeshes . ../cylinderMesh -overwrite
## Make it a bit smaller to keep it laminar ## 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 # Select cellSets for the different zones
runApplication topoSet runApplication topoSet

View File

@ -13,7 +13,7 @@ restore0Dir
runApplication blockMesh runApplication blockMesh
runApplication transformPoints -scale "(1 0 1)" runApplication transformPoints -scale '(1 0 1)'
runApplication extrudeMesh runApplication extrudeMesh

View File

@ -13,7 +13,7 @@ restore0Dir
runApplication blockMesh runApplication blockMesh
runApplication transformPoints -scale "(1 0 1)" runApplication transformPoints -scale '(1 0 1)'
runApplication extrudeMesh runApplication extrudeMesh

View File

@ -10,7 +10,7 @@ runApplication blockMesh
runApplication mergeMeshes . ../cylinderMesh -overwrite runApplication mergeMeshes . ../cylinderMesh -overwrite
## Make it a bit smaller to keep it laminar ## 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 # Select cellSets for the different zones
runApplication topoSet runApplication topoSet

View File

@ -60,9 +60,9 @@ geometry
{ {
type cartesian; type cartesian;
origin (2 2 0); origin (2 2 0);
coordinateRotation rotation
{ {
type axesRotation; type axes;
e1 (1 0 0); e1 (1 0 0);
e3 (0 0 1); e3 (0 0 1);
} }

View File

@ -13,7 +13,7 @@ restore0Dir
runApplication setFields runApplication setFields
runApplication transformPoints -rollPitchYaw "(0 -90 0)" runApplication transformPoints -rotate-y -90
runApplication checkMesh -allGeometry -allTopology runApplication checkMesh -allGeometry -allTopology

View File

@ -9,7 +9,7 @@ mkdir -p constant/triSurface
runApplication surfaceTransformPoints \ runApplication surfaceTransformPoints \
-translate '(0 0 5)' \ -translate '(0 0 5)' \
-origin '(0 0 5)' \ -origin '(0 0 5)' \
-rotate-angle '((1 0 0) 45)' \ -rotate-x 45 \
"$FOAM_TUTORIALS"/resources/geometry/blob.stl.gz \ "$FOAM_TUTORIALS"/resources/geometry/blob.stl.gz \
constant/triSurface/blob.obj constant/triSurface/blob.obj