diff --git a/src/OpenFOAM/primitives/quaternion/quaternion.H b/src/OpenFOAM/primitives/quaternion/quaternion.H index 4e3ecc5fcc3a0731d382aa4ff8815bcdb6a8d049..b7b69bbc836e1f4107d449ab2504117dace6e4a3 100644 --- a/src/OpenFOAM/primitives/quaternion/quaternion.H +++ b/src/OpenFOAM/primitives/quaternion/quaternion.H @@ -182,7 +182,7 @@ public: //- Vector part of the quaternion ( = axis of rotation) inline const vector& v() const; - //- The rotation tensor corresponding the quaternion + //- The rotation tensor corresponding to the quaternion inline tensor R() const; //- Return the Euler rotation angles corresponding to the diff --git a/src/lumpedPointMotion/lumpedPointState.C b/src/lumpedPointMotion/lumpedPointState.C index 1d38c4ad22a8434faa18ba50c3d9b129244dc0a6..c7a7b96f8ef2a47dfe3eb7c80af70d5ab19377b3 100644 --- a/src/lumpedPointMotion/lumpedPointState.C +++ b/src/lumpedPointMotion/lumpedPointState.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,10 +25,8 @@ License #include "lumpedPointState.H" #include "demandDrivenData.H" -#include "EulerCoordinateRotation.H" #include "unitConversion.H" - -#include "ISstream.H" +#include "EulerCoordinateRotation.H" #include "IFstream.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -70,13 +68,15 @@ static Foam::string getLineNoComment void Foam::lumpedPointState::calcRotations() const { rotationPtr_ = new tensorField(angles_.size()); - forAll(angles_, itemi) + + auto rotIter = rotationPtr_->begin(); + + for (const vector& angles : angles_) { - rotationPtr_->operator[](itemi) = EulerCoordinateRotation - ( - angles_[itemi], - degrees_ // true=degrees, false=radians - ).R(); + *rotIter = + coordinateRotations::euler::rotation(order_, angles, degrees_); + + ++rotIter; } } @@ -85,7 +85,15 @@ void Foam::lumpedPointState::readDict(const dictionary& dict) { dict.readEntry("points", points_); dict.readEntry("angles", angles_); + order_ = + quaternion::eulerOrderNames.getOrDefault + ( + "order", + dict, + quaternion::eulerOrder::ZXZ + ); degrees_ = dict.lookupOrDefault("degrees", false); + deleteDemandDrivenData(rotationPtr_); } @@ -96,6 +104,7 @@ Foam::lumpedPointState::lumpedPointState() : points_(), angles_(), + order_(quaternion::eulerOrder::ZXZ), degrees_(false), rotationPtr_(nullptr) {} @@ -105,6 +114,7 @@ Foam::lumpedPointState::lumpedPointState(const lumpedPointState& rhs) : points_(rhs.points_), angles_(rhs.angles_), + order_(rhs.order_), degrees_(rhs.degrees_), rotationPtr_(nullptr) {} @@ -114,6 +124,7 @@ Foam::lumpedPointState::lumpedPointState(const pointField& pts) : points_(pts), angles_(points_.size(), Zero), + order_(quaternion::eulerOrder::ZXZ), degrees_(false), rotationPtr_(nullptr) {} @@ -123,6 +134,7 @@ Foam::lumpedPointState::lumpedPointState(tmp<pointField>& pts) : points_(pts), angles_(points_.size(), Zero), + order_(quaternion::eulerOrder::ZXZ), degrees_(false), rotationPtr_(nullptr) {} @@ -132,6 +144,7 @@ Foam::lumpedPointState::lumpedPointState(const dictionary& dict) : points_(), angles_(), + order_(quaternion::eulerOrder::ZXZ), degrees_(false), rotationPtr_(nullptr) { @@ -153,6 +166,7 @@ void Foam::lumpedPointState::operator=(const lumpedPointState& rhs) { points_ = rhs.points_; angles_ = rhs.angles_; + order_ = rhs.order_; degrees_ = rhs.degrees_; deleteDemandDrivenData(rotationPtr_); @@ -228,6 +242,7 @@ bool Foam::lumpedPointState::readPlain(Istream& is) points_.setSize(count); angles_.setSize(count); + order_ = quaternion::eulerOrder::ZXZ; degrees_ = false; deleteDemandDrivenData(rotationPtr_); @@ -256,9 +271,13 @@ void Foam::lumpedPointState::writeDict(Ostream& os) const { os.writeEntry("points", points_); os.writeEntry("angles", angles_); + if (order_ != quaternion::eulerOrder::ZXZ) + { + os.writeEntry("order", quaternion::eulerOrderNames[order_]); + } if (degrees_) { - os.writeEntry("degrees", word("true")); + os.writeEntry("degrees", "true"); } } diff --git a/src/lumpedPointMotion/lumpedPointState.H b/src/lumpedPointMotion/lumpedPointState.H index b0117ef41241ee00ab276d738103cfe909e700a6..764e3126c942a9d48ee2eaa2cfe0303d3e5c5d1e 100644 --- a/src/lumpedPointMotion/lumpedPointState.H +++ b/src/lumpedPointMotion/lumpedPointState.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,6 +35,7 @@ Description Property | Description | Required | Default points | List of points | yes | angles | List of Euler rotation angles | yes | + order | The Euler-angle rotation order | no | zxz degrees | Rotation angles in degrees | no | false \endtable @@ -49,10 +50,11 @@ Description \endverbatim SeeAlso - EulerCoordinateRotation + Foam::coordinateRotations::euler, Foam::quaternion SourceFiles lumpedPointState.C + lumpedPointStateI.H \*---------------------------------------------------------------------------*/ @@ -65,6 +67,7 @@ SourceFiles #include "scalarField.H" #include "vectorField.H" #include "tensorField.H" +#include "quaternion.H" #include "Enum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -98,7 +101,7 @@ public: private: - // Private data + // Private Data //- Positions of lumped points pointField points_; @@ -106,7 +109,10 @@ private: //- Orientation of lumped points (as Euler angles) vectorField angles_; - //- Euler angles in degrees instead radians + //- The Euler-angle rotation order (default: zxz) + quaternion::eulerOrder order_; + + //- Euler angles measured in degrees bool degrees_; //- Tensor rotation of lumped points