diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/cyclicLduInterfaceField/cyclicLduInterfaceField.C b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/cyclicLduInterfaceField/cyclicLduInterfaceField.C index 04b30fbde3..95eb86dce3 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/cyclicLduInterfaceField/cyclicLduInterfaceField.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/cyclicLduInterfaceField/cyclicLduInterfaceField.C @@ -50,7 +50,7 @@ void Foam::cyclicLduInterfaceField::transformCoupleField { if (transforms()) { - f *= pow(diag(transform().R()).component(cmpt), rank()); + f *= pow(diag(transform().T()).component(cmpt), rank()); } } diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/cyclicLduInterfaceField/cyclicLduInterfaceField.H b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/cyclicLduInterfaceField/cyclicLduInterfaceField.H index c8c2d5f61f..74cc665a23 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/cyclicLduInterfaceField/cyclicLduInterfaceField.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/cyclicLduInterfaceField/cyclicLduInterfaceField.H @@ -78,7 +78,7 @@ public: //- Is the transform required bool transforms() const { - return transform().rotates() && rank() != 0; + return transform().transforms() && rank() != 0; } //- Return rank of component for transform diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/processorLduInterfaceField/processorLduInterfaceField.C b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/processorLduInterfaceField/processorLduInterfaceField.C index 1fb768bcdb..e6b622428b 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/processorLduInterfaceField/processorLduInterfaceField.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/processorLduInterfaceField/processorLduInterfaceField.C @@ -50,7 +50,7 @@ void Foam::processorLduInterfaceField::transformCoupleField { if (transforms()) { - f *= pow(diag(transform().R()).component(cmpt), rank()); + f *= pow(diag(transform().T()).component(cmpt), rank()); } } diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/processorLduInterfaceField/processorLduInterfaceField.H b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/processorLduInterfaceField/processorLduInterfaceField.H index 50dcd0eeff..ce79bd8352 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/processorLduInterfaceField/processorLduInterfaceField.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/processorLduInterfaceField/processorLduInterfaceField.H @@ -90,7 +90,7 @@ public: //- Is the transform required bool transforms() const { - return transform().rotates() && rank() != 0; + return transform().transforms() && rank() != 0; } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicTransform.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicTransform.C index 9a9bc61166..6149942914 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicTransform.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicTransform.C @@ -77,13 +77,14 @@ void Foam::cyclicTransform::update() if (mag(rotationCentre_) == 0) { - transform_ = transformer(R); + transform_ = transformer::rotation(R); } else { - const vector t = rotationCentre_ - (R & rotationCentre_); - - transform_ = transformer(t, R); + transform_ = + transformer::translation(rotationCentre_) + & transformer::rotation(R) + & transformer::translation(- rotationCentre_); } } break; @@ -95,7 +96,7 @@ void Foam::cyclicTransform::update() } else { - transform_ = transformer(separation_); + transform_ = transformer::translation(separation_); } break; } @@ -260,7 +261,7 @@ Foam::cyclicTransform::cyclicTransform && (dict.found("separation") || dict.found("separationVector")) ) ), - transform_(vector::uniform(NaN), tensor::uniform(NaN)) + transform_() { if (transformComplete_) { diff --git a/src/OpenFOAM/primitives/Tensor/Tensor.H b/src/OpenFOAM/primitives/Tensor/Tensor.H index 3dcffd2776..ff11b7f932 100644 --- a/src/OpenFOAM/primitives/Tensor/Tensor.H +++ b/src/OpenFOAM/primitives/Tensor/Tensor.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -54,6 +54,9 @@ namespace Foam template class SymmTensor; +template +class DiagTensor; + /*---------------------------------------------------------------------------*\ Class Tensor Declaration \*---------------------------------------------------------------------------*/ @@ -107,6 +110,9 @@ public: //- Construct given SymmTensor inline Tensor(const SymmTensor&); + //- Construct given DiagTensor + inline Tensor(const DiagTensor&); + //- Construct given triad inline Tensor(const Vector>&); @@ -198,6 +204,9 @@ public: //- Assign to a SymmTensor inline void operator=(const SymmTensor&); + //- Assign to a DiagTensor + inline void operator=(const DiagTensor&); + //- Assign to a triad inline void operator=(const Vector>&); }; diff --git a/src/OpenFOAM/primitives/Tensor/TensorI.H b/src/OpenFOAM/primitives/Tensor/TensorI.H index 5b30aa0141..bbb2e94529 100644 --- a/src/OpenFOAM/primitives/Tensor/TensorI.H +++ b/src/OpenFOAM/primitives/Tensor/TensorI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "SymmTensor.H" +#include "DiagTensor.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -79,6 +80,15 @@ inline Foam::Tensor::Tensor(const SymmTensor& st) } +template +inline Foam::Tensor::Tensor(const DiagTensor& 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 inline Foam::Tensor::Tensor(const Vector>& tr) { diff --git a/src/OpenFOAM/primitives/globalIndexAndTransform/globalIndexAndTransform.C b/src/OpenFOAM/primitives/globalIndexAndTransform/globalIndexAndTransform.C index 87556cb91b..c33e27ae50 100644 --- a/src/OpenFOAM/primitives/globalIndexAndTransform/globalIndexAndTransform.C +++ b/src/OpenFOAM/primitives/globalIndexAndTransform/globalIndexAndTransform.C @@ -74,10 +74,10 @@ Foam::label Foam::globalIndexAndTransform::matchTransform scalar tensorDiff = 0; - if (refTransform.rotates() || testTransform.rotates()) + if (refTransform.transforms() || testTransform.transforms()) { tensorDiff = - mag(refTransform.R() - testTransform.R()) + mag(refTransform.T() - testTransform.T()) /sqrt(3.0) /tolerance; } @@ -103,10 +103,10 @@ Foam::label Foam::globalIndexAndTransform::matchTransform tensorDiff = 0; - if (refTransform.rotates() || testTransform.rotates()) + if (refTransform.transforms() || testTransform.transforms()) { tensorDiff = - mag(refTransform.R() - testTransform.R().T()) + mag(refTransform.T() - testTransform.T().T()) /sqrt(3.0) /tolerance; } @@ -360,15 +360,7 @@ Foam::globalIndexAndTransform::globalIndexAndTransform(const polyMesh& mesh) { Info<< '\t' << i << '\t'; const transformer& trafo = transforms_[i]; - if (trafo.rotates()) - { - Info<< trafo.t() << '\t' << trafo.R(); - } - else - { - Info<< trafo.t() << '\t' << "---"; - } - Info<< endl; + Info<< trafo.t() << '\t' << trafo.T() << endl; } Info<< endl; @@ -393,15 +385,7 @@ Foam::globalIndexAndTransform::globalIndexAndTransform(const polyMesh& mesh) { Info<< '\t' << i << '\t'; const transformer& trafo = transformPermutations_[i]; - if (trafo.rotates()) - { - Info<< trafo.t() << '\t' << trafo.R(); - } - else - { - Info<< trafo.t() << '\t' << "---"; - } - Info<< endl; + Info<< trafo.t() << '\t' << trafo.T() << endl; } Info<< "nullTransformIndex:" << nullTransformIndex() << endl << endl; diff --git a/src/OpenFOAM/primitives/globalIndexAndTransform/globalIndexAndTransformI.H b/src/OpenFOAM/primitives/globalIndexAndTransform/globalIndexAndTransformI.H index 452df17fe5..a6a15fbc4d 100644 --- a/src/OpenFOAM/primitives/globalIndexAndTransform/globalIndexAndTransformI.H +++ b/src/OpenFOAM/primitives/globalIndexAndTransform/globalIndexAndTransformI.H @@ -188,11 +188,11 @@ Foam::label Foam::globalIndexAndTransform::addToTransformIndex bool antiCyclic = false; const transformer& vt = transforms_[matchTransI]; - if (!vt.translates() && vt.rotates()) + if (vt.transforms()) { - const tensor& R = vt.R(); - scalar sumDiag = tr(R); - scalar sumMagDiag = mag(R.xx()) + mag(R.yy())+mag(R.zz()); + const tensor& T = vt.T(); + scalar sumDiag = tr(T); + scalar sumMagDiag = mag(T.xx()) + mag(T.yy()) + mag(T.zz()); if (mag(sumMagDiag-3) < tol && mag(sumDiag+1) < tol) { diff --git a/src/OpenFOAM/primitives/transform/transformer/transformer.C b/src/OpenFOAM/primitives/transform/transformer/transformer.C index 2a40b54259..2a998fa187 100644 --- a/src/OpenFOAM/primitives/transform/transformer/transformer.C +++ b/src/OpenFOAM/primitives/transform/transformer/transformer.C @@ -37,6 +37,7 @@ const Foam::transformer Foam::transformer::zero Zero, false, Zero, + false, false ); @@ -45,6 +46,7 @@ const Foam::transformer Foam::transformer::I Zero, false, tensor::I, + false, false ); @@ -65,7 +67,7 @@ Foam::word Foam::name(const transformer& s) { OStringStream buf; - buf << '(' << s.t() << ',' << s.R() << ')'; + buf << '(' << s.t() << ',' << s.T() << ')'; return buf.str(); } @@ -77,17 +79,17 @@ void Foam::transformer::transformPosition const pointField& pts ) const { - if (translates_ && !rotates_) + if (translates_ && !transforms()) { 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::transformer::transformPosition const pointField& pts ) const { - if (translates_ && !rotates_) + if (translates_ && !transforms()) { 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 { @@ -121,17 +123,17 @@ Foam::tmp Foam::transformer::invTransformPosition const pointField& pts ) const { - if (translates_ && !rotates_) + if (translates_ && !transforms()) { 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 { @@ -146,17 +148,17 @@ void Foam::transformer::invTransformPosition const pointField& pts ) const { - if (translates_ && !rotates_) + if (translates_ && !transforms()) { 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 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 is.readEnd("transformer"); @@ -244,7 +246,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const transformer& tr) { os << token::BEGIN_LIST << 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; return os; diff --git a/src/OpenFOAM/primitives/transform/transformer/transformer.H b/src/OpenFOAM/primitives/transform/transformer/transformer.H index f11aac4c50..999298cdd7 100644 --- a/src/OpenFOAM/primitives/transform/transformer/transformer.H +++ b/src/OpenFOAM/primitives/transform/transformer/transformer.H @@ -83,7 +83,7 @@ inline transformer operator&(const transformer& tr1, const transformer& tr2); class transformer { - // private data + // Private data //- Translation vector vector t_; @@ -91,13 +91,30 @@ class transformer //- True if the translation vector is non-zero bool translates_; - //- Rotation tensor - tensor R_; + //- Transformation tensor + 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_; + // 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: // Static Data Members @@ -112,31 +129,23 @@ public: 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 - //- Construct null + //- Construct null (i.e., no transformation) 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 transformer(Istream&); @@ -145,43 +154,42 @@ public: // 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 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; - //- Return the rotation tensor - inline const tensor& R() const; - //- Return true if the transformer transforms a type - // (i.e. rotates) + // (i.e. scales or rotates) inline bool transforms() const; //- Return true if the transformer transforms the given type - // (i.e. rotates) + // (i.e. scales or rotates) template inline bool transforms() const; //- Return true if the transformer transforms a point - // (i.e. translates or rotates) + // (i.e. translates or scales or rotates) 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 the given position @@ -247,13 +255,6 @@ public: 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 @@ -275,24 +276,6 @@ public: 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& ( const transformer& tr1, diff --git a/src/OpenFOAM/primitives/transform/transformer/transformerI.H b/src/OpenFOAM/primitives/transform/transformer/transformerI.H index 947e68c5f4..f3c23d9bdf 100644 --- a/src/OpenFOAM/primitives/transform/transformer/transformerI.H +++ b/src/OpenFOAM/primitives/transform/transformer/transformerI.H @@ -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 * * * * * * * * * * * * * * // inline Foam::transformer::transformer() : t_(Zero), translates_(false), - R_(tensor::I), + T_(tensor::I), + scales_(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 * * * * * * * * * * * * * // -inline bool Foam::transformer::translates() const -{ - return translates_ && !rotates_; -} - - inline const Foam::vector& Foam::transformer::t() const { 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 { - return rotates_; + return scales_ || rotates_; } template inline bool Foam::transformer::transforms() const { - return pTraits::rank != 0 && rotates_; + return pTraits::rank != 0 && transforms(); } inline bool Foam::transformer::transformsPosition() const { - return translates_ || rotates_; -} - - -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_; + return translates_ || transforms(); } @@ -144,17 +154,17 @@ inline Foam::vector Foam::transformer::transformPosition const vector& p ) const { - if (translates_ && !rotates_) + if (translates_ && !transforms()) { 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 { @@ -168,17 +178,17 @@ inline Foam::vector Foam::transformer::invTransformPosition const vector& p ) const { - if (translates_ && !rotates_) + if (translates_ && !transforms()) { 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 { @@ -197,54 +207,13 @@ inline void Foam::transformer::operator&= // If either of the two objects has translates_ as true, then inherit // it, otherwise, these should both be zero vectors. 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 - // it, otherwise, these should both be I tensors. + // If either of the two objects has scales_ or rotates_ as true, then + // inherit it, otherwise, these should both be I tensors. + scales_ = tr.scales_ || scales_; rotates_ = tr.rotates_ || rotates_; - R_ = tr.R_ & R_; -} - - -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_; + T_ = tr.T_ & T_; } @@ -252,22 +221,14 @@ inline void Foam::transformer::operator&=(const tensor& R) inline Foam::transformer Foam::inv(const transformer& tr) { - if (tr.translates_ && !tr.rotates_) - { - return transformer(-tr.t()); - } - else if (!tr.translates_ && tr.rotates_) - { - return transformer(tr.R().T()); - } - else if (tr.translates_ && tr.rotates_) - { - return transformer(tr.R().T() & (-tr.t()), tr.R().T()); - } - else - { - return transformer(); - } + return transformer + ( + tr.invT() & (-tr.t()), + tr.translates_, + tr.invT(), + tr.scales_, + tr.rotates_ + ); } @@ -275,7 +236,7 @@ inline Foam::transformer Foam::inv(const transformer& tr) 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& ( const transformer& tr1, @@ -311,9 +254,10 @@ inline Foam::transformer Foam::operator& { return transformer ( - (tr1.R() & tr2.t()) + tr1.t(), + (tr1.T() & tr2.t()) + tr1.t(), tr1.translates_ || tr2.translates_, - tr1.R() & tr2.R(), + tr1.T() & tr2.T(), + tr1.scales_ || tr2.scales_, tr1.rotates_ || tr2.rotates_ ); } diff --git a/src/OpenFOAM/primitives/transform/transformer/transformerTemplates.C b/src/OpenFOAM/primitives/transform/transformer/transformerTemplates.C index 7a15d85526..4f7f85fbe5 100644 --- a/src/OpenFOAM/primitives/transform/transformer/transformerTemplates.C +++ b/src/OpenFOAM/primitives/transform/transformer/transformerTemplates.C @@ -28,9 +28,9 @@ License template Type Foam::transformer::transform(const Type& x) const { - if (rotates_) + if (transforms()) { - return Foam::transform(R(), x); + return Foam::transform(T(), x); } else { @@ -46,9 +46,9 @@ void Foam::transformer::transform const Field& fld ) const { - if (rotates_) + if (transforms()) { - return Foam::transform(res, R(), fld); + return Foam::transform(res, T(), fld); } } @@ -59,9 +59,9 @@ Foam::tmp> Foam::transformer::transform const Field& fld ) const { - if (rotates_) + if (transforms()) { - return Foam::transform(R(), fld); + return Foam::transform(T(), fld); } else { @@ -76,9 +76,9 @@ Foam::tmp> Foam::transformer::transform const tmp>& tfld ) const { - if (rotates_) + if (transforms()) { - return Foam::transform(R(), tfld); + return Foam::transform(T(), tfld); } else { @@ -90,11 +90,11 @@ Foam::tmp> Foam::transformer::transform template class Container> void Foam::transformer::transformList(Container& l) const { - if (rotates_) + if (transforms()) { forAllIter(typename Container, l, iter) { - *iter = Foam::transform(R(), *iter); + *iter = Foam::transform(T(), *iter); } } } @@ -103,9 +103,9 @@ void Foam::transformer::transformList(Container& l) const template Type Foam::transformer::invTransform(const Type& x) const { - if (rotates_) + if (transforms()) { - return Foam::transform(R().T(), x); + return Foam::transform(invT(), x); } else { @@ -121,9 +121,9 @@ void Foam::transformer::invTransform const Field& fld ) const { - if (rotates_) + if (transforms()) { - Foam::transform(res, R().T(), fld); + Foam::transform(res, invT(), fld); } } @@ -134,9 +134,9 @@ Foam::tmp> Foam::transformer::invTransform const Field& fld ) const { - if (rotates_) + if (transforms()) { - return Foam::transform(R().T(), fld); + return Foam::transform(invT(), fld); } else { @@ -151,9 +151,9 @@ Foam::tmp> Foam::transformer::invTransform const tmp>& tfld ) const { - if (rotates_) + if (transforms()) { - return Foam::transform(R().T(), tfld); + return Foam::transform(invT(), tfld); } else { @@ -165,11 +165,13 @@ Foam::tmp> Foam::transformer::invTransform template class Container> void Foam::transformer::invTransformList(Container& l) const { - if (rotates_) + if (transforms()) { + tensor invT = this->invT(); + forAllIter(typename Container, l, iter) { - *iter = Foam::transform(R().T(), *iter); + *iter = Foam::transform(invT, *iter); } } } diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclic/cyclicFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclic/cyclicFvPatch.C index 5a47f72688..1d3550bbe6 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclic/cyclicFvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclic/cyclicFvPatch.C @@ -80,7 +80,7 @@ Foam::tmp Foam::cyclicFvPatch::delta() const vectorField& pdv = tpdv.ref(); // To the transformation if necessary - if (transform().rotates()) + if (transform().transforms()) { forAll(patchD, facei) { diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C index 111a70c37e..87e0c18040 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C @@ -139,7 +139,7 @@ Foam::tmp Foam::cyclicAMIFvPatch::delta() const vectorField& pdv = tpdv.ref(); // do the transformation if necessary - if (transform().rotates()) + if (transform().transforms()) { forAll(patchD, facei) { diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/processor/processorFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/processor/processorFvPatch.C index 4c4794f775..01e30851f6 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/processor/processorFvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/processor/processorFvPatch.C @@ -93,7 +93,7 @@ Foam::tmp Foam::processorFvPatch::delta() const if (Pstream::parRun()) { // To the transformation if necessary - if (transform().rotates()) + if (transform().transforms()) { return coupledFvPatch::delta() diff --git a/src/lagrangian/basic/particle/particleTemplates.C b/src/lagrangian/basic/particle/particleTemplates.C index 25bd65a2aa..36a9404abe 100644 --- a/src/lagrangian/basic/particle/particleTemplates.C +++ b/src/lagrangian/basic/particle/particleTemplates.C @@ -256,7 +256,7 @@ template void Foam::particle::hitSymmetryPatch(TrackCloudType&, trackingData&) { const vector nf = normal(); - transformProperties(transformer(I - 2.0*nf*nf)); + transformProperties(transformer::rotation(I - 2.0*nf*nf)); } diff --git a/src/lagrangian/molecularDynamics/molecule/molecule/molecule.C b/src/lagrangian/molecularDynamics/molecule/molecule/molecule.C index fd3c551720..d1b636f7ce 100644 --- a/src/lagrangian/molecularDynamics/molecule/molecule/molecule.C +++ b/src/lagrangian/molecularDynamics/molecule/molecule/molecule.C @@ -190,7 +190,7 @@ void Foam::molecule::transformProperties(const transformer& transform) { particle::transformProperties(transform); - Q_ = transform.R() & Q_; + Q_ = transform.T() & Q_; v_ = transform.transform(v_); diff --git a/src/mesh/blockMesh/blockMesh/blockMesh.C b/src/mesh/blockMesh/blockMesh/blockMesh.C index 364cfdcaa0..70be850eb7 100644 --- a/src/mesh/blockMesh/blockMesh/blockMesh.C +++ b/src/mesh/blockMesh/blockMesh/blockMesh.C @@ -134,7 +134,7 @@ Foam::PtrList Foam::blockMesh::patchDicts() const if (isA(ppPtr())) { refCast(ppPtr()) = - transformer(scaleFactor_*tensor::I) + transformer::scaling(scaleFactor_*tensor::I) & refCast(ppPtr()); } diff --git a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C index 7bddae24f6..13be9262e3 100644 --- a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C +++ b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C @@ -113,7 +113,7 @@ void Foam::cyclicAMIGAMGInterfaceField::updateInterfaceMatrix const scalar r = pow ( - inv(thisInterface.AMITransforms()[i]).R()(cmpt, cmpt), + inv(thisInterface.AMITransforms()[i]).T()(cmpt, cmpt), rank() ); @@ -127,7 +127,7 @@ void Foam::cyclicAMIGAMGInterfaceField::updateInterfaceMatrix const scalar r = pow ( - neiInterface.AMITransforms()[i].R()(cmpt, cmpt), + neiInterface.AMITransforms()[i].T()(cmpt, cmpt), rank() ); diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMILduInterfaceField/cyclicAMILduInterfaceField.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMILduInterfaceField/cyclicAMILduInterfaceField.C index 78f2713132..f89295c1dd 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMILduInterfaceField/cyclicAMILduInterfaceField.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMILduInterfaceField/cyclicAMILduInterfaceField.C @@ -50,7 +50,7 @@ void Foam::cyclicAMILduInterfaceField::transformCoupleField { if (transforms()) { - f *= pow(diag(transform().R()).component(cmpt), rank()); + f *= pow(diag(transform().T()).component(cmpt), rank()); } } diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMILduInterfaceField/cyclicAMILduInterfaceField.H b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMILduInterfaceField/cyclicAMILduInterfaceField.H index 4bbfc6570f..bdf69e758f 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMILduInterfaceField/cyclicAMILduInterfaceField.H +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMILduInterfaceField/cyclicAMILduInterfaceField.H @@ -80,7 +80,7 @@ public: //- Is the transform required bool transforms() const { - return transform().rotates() && rank() != 0; + return transform().transforms() && rank() != 0; } diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C index 98aeb2c256..835d25b3eb 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C @@ -553,7 +553,7 @@ Foam::tmp Foam::cyclicAMIPolyPatch::interpolate forAll(AMIs(), i) { const scalar r = - pow(inv(AMITransforms()[i]).R()(cmpt, cmpt), rank); + pow(inv(AMITransforms()[i]).T()(cmpt, cmpt), rank); result.ref() += AMIs()[i].interpolateToSource(r*fld, defaultValues); @@ -564,7 +564,7 @@ Foam::tmp Foam::cyclicAMIPolyPatch::interpolate forAll(nei.AMIs(), i) { const scalar r = - pow(nei.AMITransforms()[i].R()(cmpt, cmpt), rank); + pow(nei.AMITransforms()[i].T()(cmpt, cmpt), rank); result.ref() += nei.AMIs()[i].interpolateToTarget(r*fld, defaultValues); diff --git a/src/meshTools/algorithms/MeshWave/FaceCellWave.C b/src/meshTools/algorithms/MeshWave/FaceCellWave.C index 697093c0c3..8ee87c1c8e 100644 --- a/src/meshTools/algorithms/MeshWave/FaceCellWave.C +++ b/src/meshTools/algorithms/MeshWave/FaceCellWave.C @@ -479,11 +479,11 @@ void Foam::FaceCellWave::transform { // Transform. Implementation referred to Type - if (trans.rotates()) + if (trans.transforms()) { 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::handleProcPatches() } // Apply transform to received data for non-parallel planes - if (procPatch.transform().rotates()) + if (procPatch.transform().transforms()) { transform ( - procPatch.transform().R(), + procPatch.transform().T(), receiveFaces.size(), receiveFacesInfo ); @@ -669,12 +669,12 @@ void Foam::FaceCellWave::handleCyclicPatches() const cyclicPolyPatch& cycPatch = refCast(patch); - if (cycPatch.transform().rotates()) + if (cycPatch.transform().transforms()) { // received data from other half transform ( - cycPatch.transform().R(), + cycPatch.transform().T(), nReceiveFaces, receiveFacesInfo ); @@ -805,11 +805,11 @@ void Foam::FaceCellWave::handleAMICyclicPatches() } // Apply transform to received data for non-parallel planes - if (cycPatch.transform().rotates()) + if (cycPatch.transform().transforms()) { transform ( - cycPatch.transform().R(), + cycPatch.transform().T(), receiveInfo.size(), receiveInfo ); diff --git a/src/meshTools/algorithms/PatchEdgeFaceWave/PatchEdgeFaceWave.H b/src/meshTools/algorithms/PatchEdgeFaceWave/PatchEdgeFaceWave.H index f8a2320235..afe21eed09 100644 --- a/src/meshTools/algorithms/PatchEdgeFaceWave/PatchEdgeFaceWave.H +++ b/src/meshTools/algorithms/PatchEdgeFaceWave/PatchEdgeFaceWave.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -342,14 +342,14 @@ public: { forAll(fld, i) { - fld[i].transform(mesh_, patch_, vt.R(), tol_, td_); + fld[i].transform(mesh_, patch_, vt.T(), tol_, td_); } } else { forAll(fld, i) { - fld[i].transform(mesh_, patch_, vt.R().T(), tol_, td_); + fld[i].transform(mesh_, patch_, vt.T().T(), tol_, td_); } } } diff --git a/src/meshTools/algorithms/PointEdgeWave/PointEdgeWave.C b/src/meshTools/algorithms/PointEdgeWave/PointEdgeWave.C index ed6bf6ac65..12be5e557b 100644 --- a/src/meshTools/algorithms/PointEdgeWave/PointEdgeWave.C +++ b/src/meshTools/algorithms/PointEdgeWave/PointEdgeWave.C @@ -368,9 +368,9 @@ void Foam::PointEdgeWave::handleProcPatches() //} // 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 @@ -453,10 +453,10 @@ void Foam::PointEdgeWave::handleCyclicPatches() // Apply rotation for non-parallel planes - if (cycPatch.transform().rotates()) + if (cycPatch.transform().transforms()) { // received data from half1 - transform(cycPatch, cycPatch.transform().R(), nbrInfo); + transform(cycPatch, cycPatch.transform().T(), nbrInfo); } // if (debug)