Skip to content
Snippets Groups Projects
Commit 9a04ebae authored by Henry Weller's avatar Henry Weller
Browse files

spatialTransform: Compact representation of the Plücker spatial transformation tensor

in terms of the rotation tensor \c E and translation vector \c r .

  See Chapter 2 and Appendix A in reference:
     Featherstone, R. (2008).
     Rigid body dynamics algorithms.
     Springer.

    This work is sponsored by Carnegie Wave Energy Ltd

Henry G. Weller
CFD Direct
parent 07041365
Branches
Tags
No related merge requests found
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::spatialTransform
Description
Compact representation of the Plücker spatial transformation tensor
in terms of the rotation tensor \c E and translation vector \c r .
See Chapter 2 and Appendix A in reference:
\verbatim
Featherstone, R. (2008).
Rigid body dynamics algorithms.
Springer.
\endverbatim
SourceFiles
spatialTransformI.H
\*---------------------------------------------------------------------------*/
#ifndef spatialTransform_H
#define spatialTransform_H
#include "tensor.H"
#include "spatialVector.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class Istream;
class Ostream;
// Forward declaration of friend functions and operators
class spatialTransform;
Istream& operator>>(Istream&, spatialTransform&);
Ostream& operator<<(Ostream&, const spatialTransform&);
/*---------------------------------------------------------------------------*\
Class spatialTransform Declaration
\*---------------------------------------------------------------------------*/
class spatialTransform
{
// Private data
//- Rotation tensor
tensor E_;
//- Translation vector
vector r_;
// Private member functions
//- Return E . *r
inline tensor Erx() const;
public:
//- Wrapper-class to provide transpose functions and operators
class transpose
{
const spatialTransform& X_;
public:
//- Construct from a spatialTransform
inline transpose(const spatialTransform& X);
//- Return the transpose transformation tensor ^A{X^*}_B
// X^T
inline operator spatialTensor() const;
//- Transpose transform dual f: ^A{X^*}_B & f
// X^T . f = (E^T . fl + r ^ E^T . fw, E^T . fl)
inline spatialVector operator&(const spatialVector& f) const;
};
//- Wrapper-class to provide dual functions and operators
class dual
{
const spatialTransform& X_;
public:
//- Construct from a spatialTransform
inline dual(const spatialTransform& X);
//- Return dual transformation tensor ^B{X^*}_A
inline operator spatialTensor() const;
//- Transform dual f: ^B{X^*}_A & f
// X^* . f = (E . fw - r ^ fl, E . fl)
inline spatialVector operator&(const spatialVector& f) const;
};
// Constructors
//- Construct null
inline spatialTransform();
//- Construct from components
inline spatialTransform(const tensor& E, const vector& r);
//- Construct from Istream
inline spatialTransform(Istream&);
// Member Functions
//- Return the rotation tensor
inline const tensor& E() const;
//- Return non-const access to the rotation tensor
inline tensor& E();
//- Return the translation vector
inline const vector& r() const;
//- Return non-const access to the translation vector
inline vector& r();
//- Return the transpose transformation tensor ^A{X^*}_B
// X^T
inline transpose T() const;
//- Return the inverse transformation tensor: X^-1
// X^-1 = (E^T, −E.r)
inline spatialTransform inv() const;
// Member Operators
//- Return the dual transformation tensor ^B{X^*}_A
inline dual operator*() const;
//- Return transformation tensor ^BX_A
// X
inline operator spatialTensor() const;
//- Inner-product multiply with a transformation tensor
inline void operator&=(const spatialTransform& X);
//- Return the inner-product of two transformation tensors
inline spatialTransform operator&(const spatialTransform& X) const;
//- Transform v: ^BX_A . v
// X.v = (E . vw, E . (vl - r^vw))
inline spatialVector operator&(const spatialVector& v) const;
// IOstream Operators
friend Istream& operator>>(Istream&, spatialTransform&);
friend Ostream& operator<<(Ostream&, const spatialTransform&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "spatialTransformI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "transform.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::tensor Foam::spatialTransform::Erx() const
{
return E_ & *r_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::spatialTransform::spatialTransform()
:
E_(tensor::I),
r_(vector::zero)
{}
inline Foam::spatialTransform::spatialTransform
(
const tensor& E,
const vector& r
)
:
E_(E),
r_(r)
{}
inline Foam::spatialTransform::spatialTransform(Istream& is)
:
E_(is),
r_(is)
{}
inline Foam::spatialTransform::transpose::transpose(const spatialTransform& X)
:
X_(X)
{}
inline Foam::spatialTransform::dual::dual(const spatialTransform& X)
:
X_(X)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::tensor& Foam::spatialTransform::E() const
{
return E_;
}
inline Foam::tensor& Foam::spatialTransform::E()
{
return E_;
}
inline const Foam::vector& Foam::spatialTransform::r() const
{
return r_;
}
inline Foam::vector& Foam::spatialTransform::r()
{
return r_;
}
inline Foam::spatialTransform::transpose Foam::spatialTransform::T() const
{
return transpose(*this);
}
inline Foam::spatialTransform Foam::spatialTransform::inv() const
{
return spatialTransform(E_.T(), -(E_ & r_));
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline Foam::spatialTransform::dual Foam::spatialTransform::operator*() const
{
return dual(*this);
}
inline Foam::spatialTransform::operator spatialTensor() const
{
return spatialTensor
(
E_, tensor::zero,
-Erx(), E_
);
}
inline void Foam::spatialTransform::operator&=(const spatialTransform& X)
{
E_ &= X.E_;
r_ = X.r_ + (r_ & X.E_.T());
}
inline Foam::spatialTransform Foam::spatialTransform::operator&
(
const spatialTransform& X
) const
{
return spatialTransform(E_ & X.E_, X.r_ + (r_ & X.E_));
}
inline Foam::spatialVector Foam::spatialTransform::operator&
(
const spatialVector& v
) const
{
return spatialVector
(
E_ & v.angular(),
E_ & (v.linear() - (r_ ^ v.angular()))
);
}
inline Foam::spatialTransform::transpose::operator spatialTensor() const
{
return spatialTensor
(
X_.E().T(), -X_.Erx().T(),
tensor::zero, X_.E().T()
);
}
inline Foam::spatialVector Foam::spatialTransform::transpose::operator&
(
const spatialVector& f
) const
{
vector ETfl(X_.E().T() & f.linear());
return spatialVector
(
(X_.E().T() & f.angular()) + (X_.r() ^ ETfl),
ETfl
);
}
inline Foam::spatialTransform::dual::operator spatialTensor() const
{
return spatialTensor
(
X_.E(), -X_.Erx(),
tensor::zero, X_.E()
);
}
inline Foam::spatialVector Foam::spatialTransform::dual::operator&
(
const spatialVector& f
) const
{
return spatialVector
(
X_.E() & (f.angular() - (X_.r() ^ f.linear())),
X_.E() & f.linear()
);
}
// * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
inline Foam::Istream& Foam::operator>>(Foam::Istream& is, spatialTransform& X)
{
is >> X.E() >> X.r();
return is;
}
inline Foam::Ostream& Foam::operator<<
(
Foam::Ostream& os,
const spatialTransform& X
)
{
os << X.E() << token::SPACE << X.r() << endl;
return os;
}
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Rotational spatial transformation tensor about the x-axis by omega radians
inline spatialTransform Xrx(const scalar& omega)
{
return spatialTransform(Rx(omega), vector::zero);
}
//- Rotational spatial transformation tensor about the x-axis by omega radians
inline spatialTransform Xry(const scalar& omega)
{
return spatialTransform(Ry(omega), vector::zero);
}
//- Rotational spatial transformation tensor about the z-axis by omega radians
inline spatialTransform Xrz(const scalar& omega)
{
return spatialTransform(Rz(omega), vector::zero);
}
//- Rotational spatial transformation tensor about axis a by omega radians
inline spatialTransform Xr(const vector& a, const scalar omega)
{
return spatialTransform(Ra(a, omega), vector::zero);
}
//- Translational spatial transformation tensor about axis a by omega radians
inline spatialTransform Xt(const vector& r)
{
return spatialTransform(tensor::I, r);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
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