transformer: Generalised to permit scaling and improved abstraction

Transformer now supports scaling matrices. The number of ways in which
transformer can be constructed has also been reduced to null (i.e.,
identity), pure translation, pure scaling and pure rotation. Compound
translations must be constructed by combining transformers with the
dot-product (&) operator. In this way, the details of in what order the
different parts of the transformation are applied have been abstracted.
This commit is contained in:
Will Bainbridge
2020-01-24 15:40:25 +00:00
parent ea3e891dab
commit 55b982eeea
26 changed files with 281 additions and 346 deletions

View File

@ -50,7 +50,7 @@ void Foam::cyclicLduInterfaceField::transformCoupleField
{ {
if (transforms()) if (transforms())
{ {
f *= pow(diag(transform().R()).component(cmpt), rank()); f *= pow(diag(transform().T()).component(cmpt), rank());
} }
} }

View File

@ -78,7 +78,7 @@ public:
//- Is the transform required //- Is the transform required
bool transforms() const bool transforms() const
{ {
return transform().rotates() && rank() != 0; return transform().transforms() && rank() != 0;
} }
//- Return rank of component for transform //- Return rank of component for transform

View File

@ -50,7 +50,7 @@ void Foam::processorLduInterfaceField::transformCoupleField
{ {
if (transforms()) if (transforms())
{ {
f *= pow(diag(transform().R()).component(cmpt), rank()); f *= pow(diag(transform().T()).component(cmpt), rank());
} }
} }

View File

@ -90,7 +90,7 @@ public:
//- Is the transform required //- Is the transform required
bool transforms() const bool transforms() const
{ {
return transform().rotates() && rank() != 0; return transform().transforms() && rank() != 0;
} }

View File

@ -77,13 +77,14 @@ void Foam::cyclicTransform::update()
if (mag(rotationCentre_) == 0) if (mag(rotationCentre_) == 0)
{ {
transform_ = transformer(R); transform_ = transformer::rotation(R);
} }
else else
{ {
const vector t = rotationCentre_ - (R & rotationCentre_); transform_ =
transformer::translation(rotationCentre_)
transform_ = transformer(t, R); & transformer::rotation(R)
& transformer::translation(- rotationCentre_);
} }
} }
break; break;
@ -95,7 +96,7 @@ void Foam::cyclicTransform::update()
} }
else else
{ {
transform_ = transformer(separation_); transform_ = transformer::translation(separation_);
} }
break; break;
} }
@ -260,7 +261,7 @@ Foam::cyclicTransform::cyclicTransform
&& (dict.found("separation") || dict.found("separationVector")) && (dict.found("separation") || dict.found("separationVector"))
) )
), ),
transform_(vector::uniform(NaN), tensor::uniform(NaN)) transform_()
{ {
if (transformComplete_) if (transformComplete_)
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -54,6 +54,9 @@ namespace Foam
template<class Cmpt> template<class Cmpt>
class SymmTensor; class SymmTensor;
template<class Cmpt>
class DiagTensor;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class Tensor Declaration Class Tensor Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -107,6 +110,9 @@ public:
//- Construct given SymmTensor //- Construct given SymmTensor
inline Tensor(const SymmTensor<Cmpt>&); inline Tensor(const SymmTensor<Cmpt>&);
//- Construct given DiagTensor
inline Tensor(const DiagTensor<Cmpt>&);
//- Construct given triad //- Construct given triad
inline Tensor(const Vector<Vector<Cmpt>>&); inline Tensor(const Vector<Vector<Cmpt>>&);
@ -198,6 +204,9 @@ public:
//- Assign to a SymmTensor //- Assign to a SymmTensor
inline void operator=(const SymmTensor<Cmpt>&); inline void operator=(const SymmTensor<Cmpt>&);
//- Assign to a DiagTensor
inline void operator=(const DiagTensor<Cmpt>&);
//- Assign to a triad //- Assign to a triad
inline void operator=(const Vector<Vector<Cmpt>>&); inline void operator=(const Vector<Vector<Cmpt>>&);
}; };

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "SymmTensor.H" #include "SymmTensor.H"
#include "DiagTensor.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -79,6 +80,15 @@ inline Foam::Tensor<Cmpt>::Tensor(const SymmTensor<Cmpt>& st)
} }
template<class Cmpt>
inline Foam::Tensor<Cmpt>::Tensor(const DiagTensor<Cmpt>& st)
{
this->v_[XX] = st.xx(); this->v_[XY] = 0; this->v_[XZ] = 0;
this->v_[YX] = 0; this->v_[YY] = st.yy(); this->v_[YZ] = 0;
this->v_[ZX] = 0; this->v_[ZY] = 0; this->v_[ZZ] = st.zz();
}
template<class Cmpt> template<class Cmpt>
inline Foam::Tensor<Cmpt>::Tensor(const Vector<Vector<Cmpt>>& tr) inline Foam::Tensor<Cmpt>::Tensor(const Vector<Vector<Cmpt>>& tr)
{ {

View File

@ -74,10 +74,10 @@ Foam::label Foam::globalIndexAndTransform::matchTransform
scalar tensorDiff = 0; scalar tensorDiff = 0;
if (refTransform.rotates() || testTransform.rotates()) if (refTransform.transforms() || testTransform.transforms())
{ {
tensorDiff = tensorDiff =
mag(refTransform.R() - testTransform.R()) mag(refTransform.T() - testTransform.T())
/sqrt(3.0) /sqrt(3.0)
/tolerance; /tolerance;
} }
@ -103,10 +103,10 @@ Foam::label Foam::globalIndexAndTransform::matchTransform
tensorDiff = 0; tensorDiff = 0;
if (refTransform.rotates() || testTransform.rotates()) if (refTransform.transforms() || testTransform.transforms())
{ {
tensorDiff = tensorDiff =
mag(refTransform.R() - testTransform.R().T()) mag(refTransform.T() - testTransform.T().T())
/sqrt(3.0) /sqrt(3.0)
/tolerance; /tolerance;
} }
@ -360,15 +360,7 @@ Foam::globalIndexAndTransform::globalIndexAndTransform(const polyMesh& mesh)
{ {
Info<< '\t' << i << '\t'; Info<< '\t' << i << '\t';
const transformer& trafo = transforms_[i]; const transformer& trafo = transforms_[i];
if (trafo.rotates()) Info<< trafo.t() << '\t' << trafo.T() << endl;
{
Info<< trafo.t() << '\t' << trafo.R();
}
else
{
Info<< trafo.t() << '\t' << "---";
}
Info<< endl;
} }
Info<< endl; Info<< endl;
@ -393,15 +385,7 @@ Foam::globalIndexAndTransform::globalIndexAndTransform(const polyMesh& mesh)
{ {
Info<< '\t' << i << '\t'; Info<< '\t' << i << '\t';
const transformer& trafo = transformPermutations_[i]; const transformer& trafo = transformPermutations_[i];
if (trafo.rotates()) Info<< trafo.t() << '\t' << trafo.T() << endl;
{
Info<< trafo.t() << '\t' << trafo.R();
}
else
{
Info<< trafo.t() << '\t' << "---";
}
Info<< endl;
} }
Info<< "nullTransformIndex:" << nullTransformIndex() << endl Info<< "nullTransformIndex:" << nullTransformIndex() << endl
<< endl; << endl;

View File

@ -188,11 +188,11 @@ Foam::label Foam::globalIndexAndTransform::addToTransformIndex
bool antiCyclic = false; bool antiCyclic = false;
const transformer& vt = transforms_[matchTransI]; const transformer& vt = transforms_[matchTransI];
if (!vt.translates() && vt.rotates()) if (vt.transforms())
{ {
const tensor& R = vt.R(); const tensor& T = vt.T();
scalar sumDiag = tr(R); scalar sumDiag = tr(T);
scalar sumMagDiag = mag(R.xx()) + mag(R.yy())+mag(R.zz()); scalar sumMagDiag = mag(T.xx()) + mag(T.yy()) + mag(T.zz());
if (mag(sumMagDiag-3) < tol && mag(sumDiag+1) < tol) if (mag(sumMagDiag-3) < tol && mag(sumDiag+1) < tol)
{ {

View File

@ -37,6 +37,7 @@ const Foam::transformer Foam::transformer::zero
Zero, Zero,
false, false,
Zero, Zero,
false,
false false
); );
@ -45,6 +46,7 @@ const Foam::transformer Foam::transformer::I
Zero, Zero,
false, false,
tensor::I, tensor::I,
false,
false false
); );
@ -65,7 +67,7 @@ Foam::word Foam::name(const transformer& s)
{ {
OStringStream buf; OStringStream buf;
buf << '(' << s.t() << ',' << s.R() << ')'; buf << '(' << s.t() << ',' << s.T() << ')';
return buf.str(); return buf.str();
} }
@ -77,17 +79,17 @@ void Foam::transformer::transformPosition
const pointField& pts const pointField& pts
) const ) const
{ {
if (translates_ && !rotates_) if (translates_ && !transforms())
{ {
res = pts + t(); res = pts + t();
} }
else if (!translates_ && rotates_) else if (!translates_ && transforms())
{ {
res = R() & pts; res = T() & pts;
} }
else if (translates_ && rotates_) else if (translates_ && transforms())
{ {
res = (R() & pts) + t(); res = (T() & pts) + t();
} }
} }
@ -97,17 +99,17 @@ Foam::tmp<Foam::pointField> Foam::transformer::transformPosition
const pointField& pts const pointField& pts
) const ) const
{ {
if (translates_ && !rotates_) if (translates_ && !transforms())
{ {
return pts + t(); return pts + t();
} }
else if (!translates_ && rotates_) else if (!translates_ && transforms())
{ {
return R() & pts; return T() & pts;
} }
else if (translates_ && rotates_) else if (translates_ && transforms())
{ {
return (R() & pts) + t(); return (T() & pts) + t();
} }
else else
{ {
@ -121,17 +123,17 @@ Foam::tmp<Foam::pointField> Foam::transformer::invTransformPosition
const pointField& pts const pointField& pts
) const ) const
{ {
if (translates_ && !rotates_) if (translates_ && !transforms())
{ {
return pts - t(); return pts - t();
} }
else if (!translates_ && rotates_) else if (!translates_ && transforms())
{ {
return R().T() & pts; return T().T() & pts;
} }
else if (translates_ && rotates_) else if (translates_ && transforms())
{ {
return (R().T() & (pts - t())); return (T().T() & (pts - t()));
} }
else else
{ {
@ -146,17 +148,17 @@ void Foam::transformer::invTransformPosition
const pointField& pts const pointField& pts
) const ) const
{ {
if (translates_ && !rotates_) if (translates_ && !transforms())
{ {
res = pts - t(); res = pts - t();
} }
else if (!translates_ && rotates_) else if (!translates_ && transforms())
{ {
res = R().T() & pts; res = T().T() & pts;
} }
else if (translates_ && rotates_) else if (translates_ && transforms())
{ {
res = (R().T() & (pts - t())); res = (T().T() & (pts - t()));
} }
} }
@ -228,7 +230,7 @@ Foam::Istream& Foam::operator>>(Istream& is, transformer& tr)
// Read beginning of transformer // Read beginning of transformer
is.readBegin("transformer"); is.readBegin("transformer");
is >> tr.translates_ >> tr.t_ >> tr.rotates_ >> tr.R_; is >> tr.translates_ >> tr.t_ >> tr.scales_ >> tr.rotates_ >> tr.T_;
// Read end of transformer // Read end of transformer
is.readEnd("transformer"); is.readEnd("transformer");
@ -244,7 +246,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const transformer& tr)
{ {
os << token::BEGIN_LIST os << token::BEGIN_LIST
<< tr.translates_ << token::SPACE << tr.t_ << token::SPACE << tr.translates_ << token::SPACE << tr.t_ << token::SPACE
<< tr.rotates_ << token::SPACE << tr.R_ << tr.scales_ << token::SPACE << tr.rotates_ << token::SPACE << tr.T_
<< token::END_LIST; << token::END_LIST;
return os; return os;

View File

@ -83,7 +83,7 @@ inline transformer operator&(const transformer& tr1, const transformer& tr2);
class transformer class transformer
{ {
// private data // Private data
//- Translation vector //- Translation vector
vector t_; vector t_;
@ -91,13 +91,30 @@ class transformer
//- True if the translation vector is non-zero //- True if the translation vector is non-zero
bool translates_; bool translates_;
//- Rotation tensor //- Transformation tensor
tensor R_; tensor T_;
//- True if the rotation tensor is non-I //- True if the transformation tensor has component vectors of
// differing magnitudes
bool scales_;
//- True if the transformation tensor has off-diagonal terms
bool rotates_; bool rotates_;
// Private constructors
//- Construct given a translation vector and transformation tensor
inline transformer
(
const vector& t,
const bool translates,
const tensor& T,
const bool scales,
const bool rotates
);
public: public:
// Static Data Members // Static Data Members
@ -112,31 +129,23 @@ public:
static const transformer null; static const transformer null;
// Static Member Functions
//- Construct a pure translation transformer
inline static transformer translation(const vector& t);
//- Construct a pure scaling transformer
inline static transformer scaling(const tensor& T);
//- Construct a pure rotation transformer
inline static transformer rotation(const tensor& T);
// Constructors // Constructors
//- Construct null //- Construct null (i.e., no transformation)
inline transformer(); inline transformer();
//- Construct a pure translation transformer given a
// translation vector
inline explicit transformer(const vector& t);
//- Construct a pure rotation transformer given a
// rotation tensor
inline explicit transformer(const tensor& R);
//- Construct given a translation vector and rotation tensor
inline transformer(const vector& t, const tensor& R);
//- Construct given a translation vector and rotation tensor
inline transformer
(
const vector& t,
const bool translates,
const tensor& R,
const bool rotates
);
//- Construct from Istream //- Construct from Istream
transformer(Istream&); transformer(Istream&);
@ -145,43 +154,42 @@ public:
// Access // Access
//- Return true if the transformer performs pure translation
// i.e. the translation vector is non-zero and the rotation tensor
// is I
inline bool translates() const;
//- Return the translation vector //- Return the translation vector
inline const vector& t() const; inline const vector& t() const;
//- Return true if the rotation tensor is non-I //- Return true if the transformer performs pure translation
// (i.e. the translation vector is non-zero and the transformation
// tensor is I)
inline bool translates() const;
//- Return the transformation tensor
inline const tensor& T() const;
//- Return the inverse transformation tensor
inline tensor invT() const;
//- Return true if the transformer performs pure scaling
// (i.e. the transformation tensor is diagonal)
inline bool scales() const;
//- Return true if the transformer performs pure rotation
// (i.e. the transformation tensor is orthogonal)
inline bool rotates() const; inline bool rotates() const;
//- Return the rotation tensor
inline const tensor& R() const;
//- Return true if the transformer transforms a type //- Return true if the transformer transforms a type
// (i.e. rotates) // (i.e. scales or rotates)
inline bool transforms() const; inline bool transforms() const;
//- Return true if the transformer transforms the given type //- Return true if the transformer transforms the given type
// (i.e. rotates) // (i.e. scales or rotates)
template<typename Type> template<typename Type>
inline bool transforms() const; inline bool transforms() const;
//- Return true if the transformer transforms a point //- Return true if the transformer transforms a point
// (i.e. translates or rotates) // (i.e. translates or scales or rotates)
inline bool transformsPosition() const; inline bool transformsPosition() const;
// Edit
//- Return non-const access to the translation vector
inline vector& t();
//- Return non-const access to the rotation tensor
inline tensor& R();
// Transform // Transform
//- Transform the given position //- Transform the given position
@ -247,13 +255,6 @@ public:
inline void operator&=(const transformer&); inline void operator&=(const transformer&);
inline void operator=(const vector&);
inline void operator+=(const vector&);
inline void operator-=(const vector&);
inline void operator=(const tensor&);
inline void operator&=(const tensor&);
// Global Functions // Global Functions
@ -275,24 +276,6 @@ public:
const transformer& tr2 const transformer& tr2
); );
friend inline transformer operator+
(
const transformer& tr,
const vector& t
);
friend inline transformer operator+
(
const vector& t,
const transformer& tr
);
friend inline transformer operator-
(
const transformer& tr,
const vector& t
);
friend inline transformer operator& friend inline transformer operator&
( (
const transformer& tr1, const transformer& tr1,

View File

@ -23,119 +23,129 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "transformer.H"
#include "diagTensor.H"
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
inline Foam::transformer Foam::transformer::translation(const vector& t)
{
return transformer(t, true, tensor::I, false, false);
}
inline Foam::transformer Foam::transformer::scaling(const tensor& T)
{
return transformer(vector::zero, false, T, true, false);
}
inline Foam::transformer Foam::transformer::rotation(const tensor& T)
{
return transformer(vector::zero, false, T, false, true);
}
// * * * * * * * * * * * * * * Private Constructors * * * * * * * * * * * * //
inline Foam::transformer::transformer
(
const vector& t,
const bool translates,
const tensor& T,
const bool scales,
const bool rotates
)
:
t_(t),
translates_(translates),
T_(T),
scales_(scales),
rotates_(rotates)
{}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::transformer::transformer() inline Foam::transformer::transformer()
: :
t_(Zero), t_(Zero),
translates_(false), translates_(false),
R_(tensor::I), T_(tensor::I),
scales_(false),
rotates_(false) rotates_(false)
{} {}
inline Foam::transformer::transformer(const vector& t)
:
t_(t),
translates_(true),
R_(tensor::I),
rotates_(false)
{}
inline Foam::transformer::transformer(const tensor& R)
:
t_(Zero),
translates_(false),
R_(R),
rotates_(true)
{}
inline Foam::transformer::transformer(const vector& t, const tensor& R)
:
t_(t),
translates_(true),
R_(R),
rotates_(true)
{}
inline Foam::transformer::transformer
(
const vector& t,
const bool translates,
const tensor& R,
const bool rotates
)
:
t_(t),
translates_(translates),
R_(R),
rotates_(rotates)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline bool Foam::transformer::translates() const
{
return translates_ && !rotates_;
}
inline const Foam::vector& Foam::transformer::t() const inline const Foam::vector& Foam::transformer::t() const
{ {
return t_; return t_;
} }
inline bool Foam::transformer::rotates() const inline bool Foam::transformer::translates() const
{ {
return rotates_; return translates_ && !transforms();
} }
inline const Foam::tensor& Foam::transformer::R() const inline const Foam::tensor& Foam::transformer::T() const
{ {
return R_; return T_;
}
inline Foam::tensor Foam::transformer::invT() const
{
if (scales_ && rotates_)
{
return inv(T());
}
else if (scales_)
{
return inv(diag(T()));
}
else if (rotates_)
{
return T().T();
}
else
{
return tensor::I;
}
}
inline bool Foam::transformer::scales() const
{
return scales_ && !rotates_;
}
inline bool Foam::transformer::rotates() const
{
return !scales_ && rotates_;
} }
inline bool Foam::transformer::transforms() const inline bool Foam::transformer::transforms() const
{ {
return rotates_; return scales_ || rotates_;
} }
template<typename Type> template<typename Type>
inline bool Foam::transformer::transforms() const inline bool Foam::transformer::transforms() const
{ {
return pTraits<Type>::rank != 0 && rotates_; return pTraits<Type>::rank != 0 && transforms();
} }
inline bool Foam::transformer::transformsPosition() const inline bool Foam::transformer::transformsPosition() const
{ {
return translates_ || rotates_; return translates_ || transforms();
}
inline Foam::vector& Foam::transformer::t()
{
// Assume that non-const access to t changes it from zero
translates_ = true;
return t_;
}
inline Foam::tensor& Foam::transformer::R()
{
// Assume that non-const access to R changes it from I
rotates_ = true;
return R_;
} }
@ -144,17 +154,17 @@ inline Foam::vector Foam::transformer::transformPosition
const vector& p const vector& p
) const ) const
{ {
if (translates_ && !rotates_) if (translates_ && !transforms())
{ {
return p + t(); return p + t();
} }
else if (!translates_ && rotates_) else if (!translates_ && transforms())
{ {
return R() & p; return T() & p;
} }
else if (translates_ && rotates_) else if (translates_ && transforms())
{ {
return (R() & p) + t(); return (T() & p) + t();
} }
else else
{ {
@ -168,17 +178,17 @@ inline Foam::vector Foam::transformer::invTransformPosition
const vector& p const vector& p
) const ) const
{ {
if (translates_ && !rotates_) if (translates_ && !transforms())
{ {
return p - t(); return p - t();
} }
else if (!translates_ && rotates_) else if (!translates_ && transforms())
{ {
return R().T() & p; return invT() & p;
} }
else if (translates_ && rotates_) else if (translates_ && transforms())
{ {
return (R().T() & (p - t())); return invT() & (p - t());
} }
else else
{ {
@ -197,54 +207,13 @@ inline void Foam::transformer::operator&=
// If either of the two objects has translates_ as true, then inherit // If either of the two objects has translates_ as true, then inherit
// it, otherwise, these should both be zero vectors. // it, otherwise, these should both be zero vectors.
translates_ = tr.translates_ || translates_; translates_ = tr.translates_ || translates_;
t_ = (tr.R_ & t_) + tr.t_; t_ = (tr.T_ & t_) + tr.t_;
// If either of the two objects has rotates_ as true, then inherit // If either of the two objects has scales_ or rotates_ as true, then
// it, otherwise, these should both be I tensors. // inherit it, otherwise, these should both be I tensors.
scales_ = tr.scales_ || scales_;
rotates_ = tr.rotates_ || rotates_; rotates_ = tr.rotates_ || rotates_;
R_ = tr.R_ & R_; T_ = tr.T_ & T_;
}
inline void Foam::transformer::operator=(const vector& t)
{
translates_ = true;
t_ = t;
rotates_ = false;
R_ = tensor::I;
}
inline void Foam::transformer::operator+=(const vector& t)
{
translates_ = true;
t_ += t;
}
inline void Foam::transformer::operator-=(const vector& t)
{
translates_ = true;
t_ -= t;
}
inline void Foam::transformer::operator=(const tensor& R)
{
translates_ = false;
t_ = Zero;
rotates_ = true;
R_ = R;
}
inline void Foam::transformer::operator&=(const tensor& R)
{
rotates_ = true;
t_ = R & t_;
R_ = R & R_;
} }
@ -252,22 +221,14 @@ inline void Foam::transformer::operator&=(const tensor& R)
inline Foam::transformer Foam::inv(const transformer& tr) inline Foam::transformer Foam::inv(const transformer& tr)
{ {
if (tr.translates_ && !tr.rotates_) return transformer
{ (
return transformer(-tr.t()); tr.invT() & (-tr.t()),
} tr.translates_,
else if (!tr.translates_ && tr.rotates_) tr.invT(),
{ tr.scales_,
return transformer(tr.R().T()); tr.rotates_
} );
else if (tr.translates_ && tr.rotates_)
{
return transformer(tr.R().T() & (-tr.t()), tr.R().T());
}
else
{
return transformer();
}
} }
@ -275,7 +236,7 @@ inline Foam::transformer Foam::inv(const transformer& tr)
inline bool Foam::operator==(const transformer& tr1, const transformer& tr2) inline bool Foam::operator==(const transformer& tr1, const transformer& tr2)
{ {
return (tr1.t() == tr2.t() && tr1.R() == tr2.R()); return (tr1.t() == tr2.t() && tr1.T() == tr2.T());
} }
@ -285,24 +246,6 @@ inline bool Foam::operator!=(const transformer& tr1, const transformer& tr2)
} }
inline Foam::transformer Foam::operator+(const transformer& tr, const vector& t)
{
return transformer(tr.t() + t, true, tr.R(), tr.rotates_);
}
inline Foam::transformer Foam::operator+(const vector& t, const transformer& tr)
{
return transformer(t + tr.t(), true, tr.R(), tr.rotates_);
}
inline Foam::transformer Foam::operator-(const transformer& tr, const vector& t)
{
return transformer(tr.t() - t, true, tr.R(), tr.rotates_);
}
inline Foam::transformer Foam::operator& inline Foam::transformer Foam::operator&
( (
const transformer& tr1, const transformer& tr1,
@ -311,9 +254,10 @@ inline Foam::transformer Foam::operator&
{ {
return transformer return transformer
( (
(tr1.R() & tr2.t()) + tr1.t(), (tr1.T() & tr2.t()) + tr1.t(),
tr1.translates_ || tr2.translates_, tr1.translates_ || tr2.translates_,
tr1.R() & tr2.R(), tr1.T() & tr2.T(),
tr1.scales_ || tr2.scales_,
tr1.rotates_ || tr2.rotates_ tr1.rotates_ || tr2.rotates_
); );
} }

View File

@ -28,9 +28,9 @@ License
template<class Type> template<class Type>
Type Foam::transformer::transform(const Type& x) const Type Foam::transformer::transform(const Type& x) const
{ {
if (rotates_) if (transforms())
{ {
return Foam::transform(R(), x); return Foam::transform(T(), x);
} }
else else
{ {
@ -46,9 +46,9 @@ void Foam::transformer::transform
const Field<Type>& fld const Field<Type>& fld
) const ) const
{ {
if (rotates_) if (transforms())
{ {
return Foam::transform(res, R(), fld); return Foam::transform(res, T(), fld);
} }
} }
@ -59,9 +59,9 @@ Foam::tmp<Foam::Field<Type>> Foam::transformer::transform
const Field<Type>& fld const Field<Type>& fld
) const ) const
{ {
if (rotates_) if (transforms())
{ {
return Foam::transform(R(), fld); return Foam::transform(T(), fld);
} }
else else
{ {
@ -76,9 +76,9 @@ Foam::tmp<Foam::Field<Type>> Foam::transformer::transform
const tmp<Field<Type>>& tfld const tmp<Field<Type>>& tfld
) const ) const
{ {
if (rotates_) if (transforms())
{ {
return Foam::transform(R(), tfld); return Foam::transform(T(), tfld);
} }
else else
{ {
@ -90,11 +90,11 @@ Foam::tmp<Foam::Field<Type>> Foam::transformer::transform
template<class Type, template<class> class Container> template<class Type, template<class> class Container>
void Foam::transformer::transformList(Container<Type>& l) const void Foam::transformer::transformList(Container<Type>& l) const
{ {
if (rotates_) if (transforms())
{ {
forAllIter(typename Container<Type>, l, iter) forAllIter(typename Container<Type>, l, iter)
{ {
*iter = Foam::transform(R(), *iter); *iter = Foam::transform(T(), *iter);
} }
} }
} }
@ -103,9 +103,9 @@ void Foam::transformer::transformList(Container<Type>& l) const
template<class Type> template<class Type>
Type Foam::transformer::invTransform(const Type& x) const Type Foam::transformer::invTransform(const Type& x) const
{ {
if (rotates_) if (transforms())
{ {
return Foam::transform(R().T(), x); return Foam::transform(invT(), x);
} }
else else
{ {
@ -121,9 +121,9 @@ void Foam::transformer::invTransform
const Field<Type>& fld const Field<Type>& fld
) const ) const
{ {
if (rotates_) if (transforms())
{ {
Foam::transform(res, R().T(), fld); Foam::transform(res, invT(), fld);
} }
} }
@ -134,9 +134,9 @@ Foam::tmp<Foam::Field<Type>> Foam::transformer::invTransform
const Field<Type>& fld const Field<Type>& fld
) const ) const
{ {
if (rotates_) if (transforms())
{ {
return Foam::transform(R().T(), fld); return Foam::transform(invT(), fld);
} }
else else
{ {
@ -151,9 +151,9 @@ Foam::tmp<Foam::Field<Type>> Foam::transformer::invTransform
const tmp<Field<Type>>& tfld const tmp<Field<Type>>& tfld
) const ) const
{ {
if (rotates_) if (transforms())
{ {
return Foam::transform(R().T(), tfld); return Foam::transform(invT(), tfld);
} }
else else
{ {
@ -165,11 +165,13 @@ Foam::tmp<Foam::Field<Type>> Foam::transformer::invTransform
template<class Type, template<class> class Container> template<class Type, template<class> class Container>
void Foam::transformer::invTransformList(Container<Type>& l) const void Foam::transformer::invTransformList(Container<Type>& l) const
{ {
if (rotates_) if (transforms())
{ {
tensor invT = this->invT();
forAllIter(typename Container<Type>, l, iter) forAllIter(typename Container<Type>, l, iter)
{ {
*iter = Foam::transform(R().T(), *iter); *iter = Foam::transform(invT, *iter);
} }
} }
} }

View File

@ -80,7 +80,7 @@ Foam::tmp<Foam::vectorField> Foam::cyclicFvPatch::delta() const
vectorField& pdv = tpdv.ref(); vectorField& pdv = tpdv.ref();
// To the transformation if necessary // To the transformation if necessary
if (transform().rotates()) if (transform().transforms())
{ {
forAll(patchD, facei) forAll(patchD, facei)
{ {

View File

@ -139,7 +139,7 @@ Foam::tmp<Foam::vectorField> Foam::cyclicAMIFvPatch::delta() const
vectorField& pdv = tpdv.ref(); vectorField& pdv = tpdv.ref();
// do the transformation if necessary // do the transformation if necessary
if (transform().rotates()) if (transform().transforms())
{ {
forAll(patchD, facei) forAll(patchD, facei)
{ {

View File

@ -93,7 +93,7 @@ Foam::tmp<Foam::vectorField> Foam::processorFvPatch::delta() const
if (Pstream::parRun()) if (Pstream::parRun())
{ {
// To the transformation if necessary // To the transformation if necessary
if (transform().rotates()) if (transform().transforms())
{ {
return return
coupledFvPatch::delta() coupledFvPatch::delta()

View File

@ -256,7 +256,7 @@ template<class TrackCloudType>
void Foam::particle::hitSymmetryPatch(TrackCloudType&, trackingData&) void Foam::particle::hitSymmetryPatch(TrackCloudType&, trackingData&)
{ {
const vector nf = normal(); const vector nf = normal();
transformProperties(transformer(I - 2.0*nf*nf)); transformProperties(transformer::rotation(I - 2.0*nf*nf));
} }

View File

@ -190,7 +190,7 @@ void Foam::molecule::transformProperties(const transformer& transform)
{ {
particle::transformProperties(transform); particle::transformProperties(transform);
Q_ = transform.R() & Q_; Q_ = transform.T() & Q_;
v_ = transform.transform(v_); v_ = transform.transform(v_);

View File

@ -134,7 +134,7 @@ Foam::PtrList<Foam::dictionary> Foam::blockMesh::patchDicts() const
if (isA<cyclicTransform>(ppPtr())) if (isA<cyclicTransform>(ppPtr()))
{ {
refCast<cyclicTransform>(ppPtr()) = refCast<cyclicTransform>(ppPtr()) =
transformer(scaleFactor_*tensor::I) transformer::scaling(scaleFactor_*tensor::I)
& refCast<cyclicTransform>(ppPtr()); & refCast<cyclicTransform>(ppPtr());
} }

View File

@ -113,7 +113,7 @@ void Foam::cyclicAMIGAMGInterfaceField::updateInterfaceMatrix
const scalar r = const scalar r =
pow pow
( (
inv(thisInterface.AMITransforms()[i]).R()(cmpt, cmpt), inv(thisInterface.AMITransforms()[i]).T()(cmpt, cmpt),
rank() rank()
); );
@ -127,7 +127,7 @@ void Foam::cyclicAMIGAMGInterfaceField::updateInterfaceMatrix
const scalar r = const scalar r =
pow pow
( (
neiInterface.AMITransforms()[i].R()(cmpt, cmpt), neiInterface.AMITransforms()[i].T()(cmpt, cmpt),
rank() rank()
); );

View File

@ -50,7 +50,7 @@ void Foam::cyclicAMILduInterfaceField::transformCoupleField
{ {
if (transforms()) if (transforms())
{ {
f *= pow(diag(transform().R()).component(cmpt), rank()); f *= pow(diag(transform().T()).component(cmpt), rank());
} }
} }

View File

@ -80,7 +80,7 @@ public:
//- Is the transform required //- Is the transform required
bool transforms() const bool transforms() const
{ {
return transform().rotates() && rank() != 0; return transform().transforms() && rank() != 0;
} }

View File

@ -553,7 +553,7 @@ Foam::tmp<Foam::scalarField> Foam::cyclicAMIPolyPatch::interpolate
forAll(AMIs(), i) forAll(AMIs(), i)
{ {
const scalar r = const scalar r =
pow(inv(AMITransforms()[i]).R()(cmpt, cmpt), rank); pow(inv(AMITransforms()[i]).T()(cmpt, cmpt), rank);
result.ref() += result.ref() +=
AMIs()[i].interpolateToSource(r*fld, defaultValues); AMIs()[i].interpolateToSource(r*fld, defaultValues);
@ -564,7 +564,7 @@ Foam::tmp<Foam::scalarField> Foam::cyclicAMIPolyPatch::interpolate
forAll(nei.AMIs(), i) forAll(nei.AMIs(), i)
{ {
const scalar r = const scalar r =
pow(nei.AMITransforms()[i].R()(cmpt, cmpt), rank); pow(nei.AMITransforms()[i].T()(cmpt, cmpt), rank);
result.ref() += result.ref() +=
nei.AMIs()[i].interpolateToTarget(r*fld, defaultValues); nei.AMIs()[i].interpolateToTarget(r*fld, defaultValues);

View File

@ -479,11 +479,11 @@ void Foam::FaceCellWave<Type, TrackingData>::transform
{ {
// Transform. Implementation referred to Type // Transform. Implementation referred to Type
if (trans.rotates()) if (trans.transforms())
{ {
for (label facei = 0; facei < nFaces; facei++) for (label facei = 0; facei < nFaces; facei++)
{ {
faceInfo[facei].transform(mesh_, trans.R(), td_); faceInfo[facei].transform(mesh_, trans.T(), td_);
} }
} }
} }
@ -597,11 +597,11 @@ void Foam::FaceCellWave<Type, TrackingData>::handleProcPatches()
} }
// Apply transform to received data for non-parallel planes // Apply transform to received data for non-parallel planes
if (procPatch.transform().rotates()) if (procPatch.transform().transforms())
{ {
transform transform
( (
procPatch.transform().R(), procPatch.transform().T(),
receiveFaces.size(), receiveFaces.size(),
receiveFacesInfo receiveFacesInfo
); );
@ -669,12 +669,12 @@ void Foam::FaceCellWave<Type, TrackingData>::handleCyclicPatches()
const cyclicPolyPatch& cycPatch = const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(patch); refCast<const cyclicPolyPatch>(patch);
if (cycPatch.transform().rotates()) if (cycPatch.transform().transforms())
{ {
// received data from other half // received data from other half
transform transform
( (
cycPatch.transform().R(), cycPatch.transform().T(),
nReceiveFaces, nReceiveFaces,
receiveFacesInfo receiveFacesInfo
); );
@ -805,11 +805,11 @@ void Foam::FaceCellWave<Type, TrackingData>::handleAMICyclicPatches()
} }
// Apply transform to received data for non-parallel planes // Apply transform to received data for non-parallel planes
if (cycPatch.transform().rotates()) if (cycPatch.transform().transforms())
{ {
transform transform
( (
cycPatch.transform().R(), cycPatch.transform().T(),
receiveInfo.size(), receiveInfo.size(),
receiveInfo receiveInfo
); );

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -342,14 +342,14 @@ public:
{ {
forAll(fld, i) forAll(fld, i)
{ {
fld[i].transform(mesh_, patch_, vt.R(), tol_, td_); fld[i].transform(mesh_, patch_, vt.T(), tol_, td_);
} }
} }
else else
{ {
forAll(fld, i) forAll(fld, i)
{ {
fld[i].transform(mesh_, patch_, vt.R().T(), tol_, td_); fld[i].transform(mesh_, patch_, vt.T().T(), tol_, td_);
} }
} }
} }

View File

@ -368,9 +368,9 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleProcPatches()
//} //}
// Apply transform to received data for non-parallel planes // Apply transform to received data for non-parallel planes
if (procPatch.transform().rotates()) if (procPatch.transform().transforms())
{ {
transform(procPatch, procPatch.transform().R(), patchInfo); transform(procPatch, procPatch.transform().T(), patchInfo);
} }
// Adapt for entering domain // Adapt for entering domain
@ -453,10 +453,10 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleCyclicPatches()
// Apply rotation for non-parallel planes // Apply rotation for non-parallel planes
if (cycPatch.transform().rotates()) if (cycPatch.transform().transforms())
{ {
// received data from half1 // received data from half1
transform(cycPatch, cycPatch.transform().R(), nbrInfo); transform(cycPatch, cycPatch.transform().T(), nbrInfo);
} }
// if (debug) // if (debug)