mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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;
|
||||||
Info<< "Rotating points by " << rot << endl;
|
|
||||||
points = transform(rot, points);
|
|
||||||
|
|
||||||
if (doRotateFields)
|
|
||||||
{
|
|
||||||
rotateFields(regionName, runTime, rot);
|
|
||||||
}
|
}
|
||||||
|
else if (args.found("rotate-x"))
|
||||||
|
{
|
||||||
|
const scalar angle = args.get<scalar>("rotate-x");
|
||||||
|
|
||||||
|
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<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)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -34,8 +34,9 @@ License
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
namespace coordinateRotations
|
namespace coordinateRotations
|
||||||
{
|
{
|
||||||
|
|
||||||
defineTypeName(euler);
|
defineTypeName(euler);
|
||||||
|
|
||||||
// Standard short name
|
// Standard short name
|
||||||
@ -55,8 +56,9 @@ namespace Foam
|
|||||||
dictionary,
|
dictionary,
|
||||||
EulerRotation
|
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)
|
||||||
{
|
{
|
||||||
@ -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_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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,15 +27,16 @@ 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);
|
defineTypeName(starcd);
|
||||||
|
|
||||||
// Standard short name
|
// Standard short name
|
||||||
@ -55,8 +56,9 @@ namespace Foam
|
|||||||
dictionary,
|
dictionary,
|
||||||
STARCDRotation
|
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
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -34,8 +34,9 @@ License
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
namespace coordinateRotations
|
namespace coordinateRotations
|
||||||
{
|
{
|
||||||
|
|
||||||
defineTypeName(axes);
|
defineTypeName(axes);
|
||||||
|
|
||||||
// Standard short name
|
// Standard short name
|
||||||
@ -55,8 +56,9 @@ namespace Foam
|
|||||||
dictionary,
|
dictionary,
|
||||||
axesRotation
|
axesRotation
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
} // End namespace coordinateRotations
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -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"
|
||||||
|
|
||||||
|
|||||||
@ -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,8 +35,9 @@ License
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
namespace coordinateRotations
|
namespace coordinateRotations
|
||||||
{
|
{
|
||||||
|
|
||||||
defineTypeName(axisAngle);
|
defineTypeName(axisAngle);
|
||||||
addToRunTimeSelectionTable
|
addToRunTimeSelectionTable
|
||||||
(
|
(
|
||||||
@ -44,8 +45,9 @@ namespace Foam
|
|||||||
axisAngle,
|
axisAngle,
|
||||||
dictionary
|
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()
|
||||||
|
|||||||
@ -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,7 +41,7 @@ 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 |
|
||||||
@ -49,15 +49,15 @@ Description
|
|||||||
\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
|
||||||
|
|
||||||
|
|||||||
@ -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"
|
||||||
|
|||||||
@ -32,8 +32,9 @@ License
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
namespace coordinateRotations
|
namespace coordinateRotations
|
||||||
{
|
{
|
||||||
|
|
||||||
defineTypeName(cylindrical);
|
defineTypeName(cylindrical);
|
||||||
addToRunTimeSelectionTable
|
addToRunTimeSelectionTable
|
||||||
(
|
(
|
||||||
@ -41,8 +42,9 @@ namespace Foam
|
|||||||
cylindrical,
|
cylindrical,
|
||||||
dictionary
|
dictionary
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
} // End namespace coordinateRotations
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -34,7 +34,7 @@ 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 |
|
||||||
@ -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"
|
||||||
|
|
||||||
|
|||||||
@ -33,8 +33,9 @@ License
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
namespace coordinateRotations
|
namespace coordinateRotations
|
||||||
{
|
{
|
||||||
|
|
||||||
defineTypeName(identity);
|
defineTypeName(identity);
|
||||||
addToRunTimeSelectionTable
|
addToRunTimeSelectionTable
|
||||||
(
|
(
|
||||||
@ -42,8 +43,9 @@ namespace Foam
|
|||||||
identity,
|
identity,
|
||||||
dictionary
|
dictionary
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
} // End namespace coordinateRotations
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -38,7 +38,7 @@ 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
|
||||||
|
|
||||||
@ -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"
|
||||||
|
|
||||||
|
|||||||
@ -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 * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -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"
|
||||||
|
|
||||||
|
|||||||
@ -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"
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user