Commit f7f08fce authored by Mark Olesen's avatar Mark Olesen Committed by Andrew Heather
Browse files

ENH: alternative Euler rotation orders for lumpedPointState (#1341)

parent 17de75b0
......@@ -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
......
......@@ -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");
}
}
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment