Commit 6a5d5e90 by Henry Weller

### septernion: Changed definition of the forward transformation for consistency with spatialTransform

```inline Foam::vector Foam::septernion::transformPoint(const vector& v) const
{
return r().transform(v - t());
}

Now there is a 1:1 correspondence between septernion and
spatialTransform and a septernion constructor from spatialTransform
provided.

Additionally "septernion::transform" has been renamed
"septernion::transformPoint" to clarify that it transforms coordinate
points rather than displacements or other relative vectors.```
parent b66675ed
 ... ... @@ -39,10 +39,10 @@ using namespace Foam; int main(int argc, char *argv[]) { quaternion q(vector(1, 0, 0), 0.7853981); quaternion q(vector(1, 2, 3), 0.7853981); Info<< "q " << q << endl; vector v(0, 1, 0); vector v(0.1, 0.4, 2.1); Info<< "v " << v << endl; Info<< "inv(q)*q " << inv(q)*q << endl; ... ... @@ -50,8 +50,11 @@ int main(int argc, char *argv[]) Info<< "q*quaternion(0, v)*conjugate(q) " << q*quaternion(0, v)*conjugate(q) << endl; Info<< "q.R() " << q.R() << endl; Info<< "q.transform(v) " << q.transform(v) << endl; Info<< "q.R() & v " << (q.R() & v) << endl; Info<< "quaternion(q.R()).transform(v) " << (quaternion(q.R()).transform(v)) << endl; Info<< "q.invTransform(v) " << q.invTransform(v) << endl; ... ... @@ -60,13 +63,16 @@ int main(int argc, char *argv[]) Info<< "inv(tr)*tr " << inv(tr)*tr << endl; Info<< "tr.transform(v) " << tr.transform(v) << endl; Info<< "tr.transform(v) " << tr.transformPoint(v) << endl; Info<< "(septernion(vector(0, -1, 0))*q*septernion(vector(0, 1, 0)))" vector origin(1, 2, 4); Info<< "(septernion(-origin)*q*septernion(origin))" << ".transform(v) " << (septernion(vector(0, -1, 0)) *q *septernion(vector(0, 1, 0))).transform(v) << (septernion(-origin)*q*septernion(origin)).transformPoint(v) << " " << septernion(-origin) .transformPoint(q.transform(septernion(origin).transformPoint(v))) << endl; Info<< "Test conversion from and to Euler-angles" << endl; ... ...
 ... ... @@ -66,7 +66,7 @@ Foam::tmp Foam::transform } void Foam::transform void Foam::transformPoints ( vectorField& rtf, const septernion& tr, ... ... @@ -75,50 +75,44 @@ void Foam::transform { vector T = tr.t(); // Check if any rotation if (mag(tr.r().R() - I) > SMALL) // Check if any translation if (mag(T) > VSMALL) { transform(rtf, tr.r(), tf); if (mag(T) > VSMALL) { rtf += T; } TFOR_ALL_F_OP_F_OP_S(vector, rtf, =, vector, tf, -, vector, T); } else { if (mag(T) > VSMALL) { TFOR_ALL_F_OP_S_OP_F(vector, rtf, =, vector, T, +, vector, tf); } else { rtf = tf; } rtf = tf; } // Check if any rotation if (mag(tr.r().R() - I) > SMALL) { transform(rtf, tr.r(), rtf); } } Foam::tmp Foam::transform Foam::tmp Foam::transformPoints ( const septernion& tr, const vectorField& tf ) { tmp tranf(new vectorField(tf.size())); transform(tranf.ref(), tr, tf); transformPoints(tranf.ref(), tr, tf); return tranf; } Foam::tmp Foam::transform Foam::tmp Foam::transformPoints ( const septernion& tr, const tmp& ttf ) { tmp tranf = New(ttf); transform(tranf.ref(), tr, ttf()); transformPoints(tranf.ref(), tr, ttf()); ttf.clear(); return tranf; } ... ...
 ... ... @@ -117,14 +117,14 @@ tmp transform(const quaternion&, const vectorField&); tmp transform(const quaternion&, const tmp&); //- Transform given vectorField with the given septernion void transform(vectorField&, const septernion&, const vectorField&); //- Transform given vectorField of coordinates with the given septernion void transformPoints(vectorField&, const septernion&, const vectorField&); //- Transform given vectorField with the given septernion tmp transform(const septernion&, const vectorField&); //- Transform given vectorField of coordinates with the given septernion tmp transformPoints(const septernion&, const vectorField&); //- Transform given tmp with the given septernion tmp transform(const septernion&, const tmp&); //- Transform given tmp of coordinates with the given septernion tmp transformPoints(const septernion&, const tmp&); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ... ...
 ... ... @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License ... ... @@ -66,7 +66,7 @@ Foam::septernion Foam::slerp const scalar t ) { return septernion((1.0-t)*qa.t()+t*qb.t(), slerp(qa.r(), qb.r(), t)); return septernion((1 - t)*qa.t() + t*qb.t(), slerp(qa.r(), qb.r(), t)); } ... ...
 ... ... @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License ... ... @@ -43,6 +43,7 @@ SourceFiles #include "vector.H" #include "quaternion.H" #include "spatialTransform.H" #include "word.H" #include "contiguous.H" ... ... @@ -97,6 +98,9 @@ public: //- Construct a pure rotation septernion given a rotation quaternion inline explicit septernion(const quaternion& r); //- Construct a general septernion from the given spatialTransform inline explicit septernion(const spatialTransform& st); //- Construct from Istream septernion(Istream&); ... ... @@ -117,11 +121,11 @@ public: // Transform //- Transform the given vector inline vector transform(const vector& v) const; //- Transform the given coordinate point inline vector transformPoint(const vector& v) const; //- Inverse Transform the given vector inline vector invTransform(const vector& v) const; //- Inverse Transform the given coordinate point inline vector invTransformPoint(const vector& v) const; // Member operators ... ... @@ -153,7 +157,6 @@ public: //- Return the inverse of the given septernion inline septernion inv(const septernion& tr); //- Return a string representation of a septernion word name(const septernion&); ... ...
 ... ... @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License ... ... @@ -42,10 +42,16 @@ inline Foam::septernion::septernion(const vector& t) inline Foam::septernion::septernion(const quaternion& r) : t_(vector::zero), t_(Zero), r_(r) {} inline Foam::septernion::septernion(const spatialTransform& st) : t_(st.r()), r_(st.E()) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // ... ... @@ -73,15 +79,15 @@ inline Foam::quaternion& Foam::septernion::r() } inline Foam::vector Foam::septernion::transform(const vector& v) const inline Foam::vector Foam::septernion::transformPoint(const vector& v) const { return t() + r().transform(v); return r().transform(v - t()); } inline Foam::vector Foam::septernion::invTransform(const vector& v) const inline Foam::vector Foam::septernion::invTransformPoint(const vector& v) const { return r().invTransform(v - t()); return t() + r().invTransform(v); } ... ... @@ -95,7 +101,7 @@ inline void Foam::septernion::operator=(const septernion& tr) inline void Foam::septernion::operator*=(const septernion& tr) { t_ += r().transform(tr.t()); t_ = tr.t() + tr.r().invTransform(t_); r_ *= tr.r(); } ... ... @@ -103,6 +109,7 @@ inline void Foam::septernion::operator*=(const septernion& tr) inline void Foam::septernion::operator=(const vector& t) { t_ = t; r_ = quaternion::I; } inline void Foam::septernion::operator+=(const vector& t) ... ... @@ -118,16 +125,19 @@ inline void Foam::septernion::operator-=(const vector& t) inline void Foam::septernion::operator=(const quaternion& r) { t_ = Zero; r_ = r; } inline void Foam::septernion::operator*=(const quaternion& r) { t_ = r.invTransform(t_); r_ *= r; } inline void Foam::septernion::operator/=(const quaternion& r) { t_ = r.transform(t_); r_ /= r; } ... ... @@ -149,7 +159,7 @@ inline void Foam::septernion::operator/=(const scalar s) inline Foam::septernion Foam::inv(const septernion& tr) { return septernion(-tr.r().invTransform(tr.t()), conjugate(tr.r())); return septernion(-tr.r().transform(tr.t()), conjugate(tr.r())); } ... ... @@ -213,7 +223,7 @@ inline Foam::septernion Foam::operator* const quaternion& r ) { return septernion(tr.t(), tr.r()*r); return septernion(r.invTransform(tr.t()), tr.r()*r); } ... ... @@ -223,7 +233,7 @@ inline Foam::septernion Foam::operator/ const quaternion& r ) { return septernion(tr.t(), tr.r()/r); return septernion(r.transform(tr.t()), tr.r()/r); } ... ... @@ -235,7 +245,7 @@ inline Foam::septernion Foam::operator* { return septernion ( tr1.t() + tr1.r().transform(tr2.t()), tr2.r().invTransform(tr1.t()) + tr2.t(), tr1.r().transform(tr2.r()) ); } ... ...
 ... ... @@ -178,6 +178,10 @@ public: // X.v = (E . vw, E . (vl - r^vw)) inline spatialVector operator&(const spatialVector& v) const; //- Transform position p // X:p = E . (pl - r) inline vector transformPoint(const vector& p) const; //- Transform position p // X:p = (E . pw, E . (vl - r)) inline spatialVector operator&&(const spatialVector& v) const; ... ...
 ... ... @@ -128,7 +128,7 @@ inline Foam::spatialTransform::operator spatialTensor() const inline void Foam::spatialTransform::operator&=(const spatialTransform& X) { E_ &= X.E_; r_ = X.r_ + (r_ & X.E_.T()); r_ = X.r_ + (r_ & X.E_); } ... ... @@ -167,6 +167,15 @@ inline Foam::spatialVector Foam::spatialTransform::operator&& } inline Foam::vector Foam::spatialTransform::transformPoint ( const vector& p ) const { return E_ & (p - r_); } inline Foam::spatialTransform::transpose::operator spatialTensor() const { return spatialTensor ... ...
 ... ... @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License ... ... @@ -185,7 +185,7 @@ bool Foam::multiSolidBodyMotionFvMesh::update() const labelList& zonePoints = pointIDs_[i]; UIndirectList(transformedPts, zonePoints) = transform transformPoints ( SBMFs_[i].transformation(), pointField(transformedPts, zonePoints) ... ...
 ... ... @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License ... ... @@ -63,7 +63,7 @@ solidBodyMotionDisplacementPointPatchVectorField // Determine current local points and offset fixedValuePointPatchVectorField::operator== ( transform(SBMFPtr_().transformation(), localPoints0()) transformPoints(SBMFPtr_().transformation(), localPoints0()) -localPoints0() ); } ... ... @@ -86,7 +86,7 @@ solidBodyMotionDisplacementPointPatchVectorField fixedValuePointPatchVectorField::operator== ( transform(SBMFPtr_().transformation(), localPoints0()) transformPoints(SBMFPtr_().transformation(), localPoints0()) -localPoints0() ); } ... ... @@ -117,7 +117,7 @@ solidBodyMotionDisplacementPointPatchVectorField fixedValuePointPatchVectorField::operator== ( transform(SBMFPtr_().transformation(), localPoints0()) transformPoints(SBMFPtr_().transformation(), localPoints0()) -localPoints0() ); } ... ... @@ -160,7 +160,7 @@ void solidBodyMotionDisplacementPointPatchVectorField::updateCoeffs() // Determine current local points and offset fixedValuePointPatchVectorField::operator== ( transform(SBMFPtr_().transformation(), localPoints0()) transformPoints(SBMFPtr_().transformation(), localPoints0()) -localPoints0() ); ... ...
 ... ... @@ -91,9 +91,9 @@ Foam::septernion Foam::solidBodyMotionFunctions::SDA::transformation() const heaveA_*(sin(wr*time + phh) - sin(phh)) ); quaternion R(quaternion::XYZ, vector(rollA*sin(wr*time + phr), 0, 0)); septernion TR(septernion(CofG_ + T)*R*septernion(-CofG_)); septernion TR(septernion(-CofG_ - T)*R*septernion(CofG_)); InfoInFunction << "Time = " << time << " transformation: " << TR << endl; DebugInFunction << "Time = " << time << " transformation: " << TR << endl; return TR; } ... ...
 ... ... @@ -83,9 +83,9 @@ Foam::solidBodyMotionFunctions::axisRotationMotion::transformation() const scalar magOmega = mag(omega); quaternion R(omega/magOmega, magOmega); septernion TR(septernion(origin_)*R*septernion(-origin_)); septernion TR(septernion(-origin_)*R*septernion(origin_)); InfoInFunction << "Time = " << t << " transformation: " << TR << endl; DebugInFunction << "Time = " << t << " transformation: " << TR << endl; return TR; } ... ...
 ... ... @@ -74,9 +74,9 @@ Foam::solidBodyMotionFunctions::linearMotion::transformation() const const vector displacement = velocity_*t; quaternion R(1); septernion TR(septernion(displacement)*R); septernion TR(septernion(-displacement)*R); InfoInFunction << "Time = " << t << " transformation: " << TR << endl; DebugInFunction << "Time = " << t << " transformation: " << TR << endl; return TR; } ... ...
 ... ... @@ -77,7 +77,7 @@ Foam::solidBodyMotionFunctions::multiMotion::transformation() const TR *= SBMFs_[i].transformation(); } InfoInFunction << "Time = " << t << " transformation: " << TR << endl; DebugInFunction << "Time = " << t << " transformation: " << TR << endl; return TR; } ... ...
 ... ... @@ -74,9 +74,9 @@ Foam::solidBodyMotionFunctions::oscillatingLinearMotion::transformation() const const vector displacement = amplitude_*sin(omega_*t); quaternion R(1); septernion TR(septernion(displacement)*R); septernion TR(septernion(-displacement)*R); InfoInFunction << "Time = " << t << " transformation: " << TR << endl; DebugInFunction << "Time = " << t << " transformation: " << TR << endl; return TR; } ... ...
 ... ... @@ -82,9 +82,9 @@ transformation() const eulerAngles *= pi/180.0; quaternion R(quaternion::XYZ, eulerAngles); septernion TR(septernion(origin_)*R*septernion(-origin_)); septernion TR(septernion(-origin_)*R*septernion(origin_)); InfoInFunction << "Time = " << t << " transformation: " << TR << endl; DebugInFunction << "Time = " << t << " transformation: " << TR << endl; return TR; } ... ...
 ... ... @@ -78,9 +78,9 @@ Foam::solidBodyMotionFunctions::rotatingMotion::transformation() const scalar angle = omega_->integrate(0, t); quaternion R(axis_, angle); septernion TR(septernion(origin_)*R*septernion(-origin_)); septernion TR(septernion(-origin_)*R*septernion(origin_)); InfoInFunction << "Time = " << t << " transformation: " << TR << endl; DebugInFunction << "Time = " << t << " transformation: " << TR << endl; return TR; } ... ...
 ... ... @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License ... ... @@ -29,9 +29,8 @@ License namespace Foam { defineTypeNameAndDebug(solidBodyMotionFunction, 0); defineRunTimeSelectionTable(solidBodyMotionFunction, dictionary); defineTypeNameAndDebug(solidBodyMotionFunction, 0); defineRunTimeSelectionTable(solidBodyMotionFunction, dictionary); } ... ...
 ... ... @@ -105,9 +105,9 @@ Foam::solidBodyMotionFunctions::tabulated6DoFMotion::transformation() const TRV[1] *= pi/180.0; quaternion R(quaternion::XYZ, TRV[1]); septernion TR(septernion(CofG_ + TRV[0])*R*septernion(-CofG_)); septernion TR(septernion(-CofG_ + -TRV[0])*R*septernion(CofG_)); InfoInFunction << "Time = " << t << " transformation: " << TR << endl; DebugInFunction << "Time = " << t << " transformation: " << TR << endl; return TR; } ... ...
 ... ... @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License ... ... @@ -193,7 +193,7 @@ bool Foam::solidBodyMotionFvMesh::update() { fvMesh::movePoints ( transform transformPoints ( SBMFPtr_().transformation(), undisplacedPoints_ ... ... @@ -205,7 +205,7 @@ bool Foam::solidBodyMotionFvMesh::update() pointField transformedPts(undisplacedPoints_); UIndirectList(transformedPts, pointIDs_) = transform transformPoints ( SBMFPtr_().transformation(), pointField(transformedPts, pointIDs_) ... ...
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