From a50d32b5877cb2d257c7bf85d7c9f0c50a59632d Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 13 Jan 2023 18:15:13 +0100 Subject: [PATCH] ENH: define transform(symmTensor, int/float) as no-op - avoids implicit promotion of label to scalar for no-op, or alternatively promotion of symmTensor to tensor for no-op (ie, ambiguous). - fix incorrect transform(.., symmTensor, ...) declarations. --- .../transformFieldField/transformFieldField.H | 4 +- .../symmTransformField/symmTransformField.C | 137 +++++++++--------- .../symmTransformField/symmTransformField.H | 110 ++++++++------ .../Fields/transformField/transformField.H | 5 +- .../transformField/transformFieldTemplates.C | 4 +- .../Fields/transformList/transformList.C | 25 +++- .../Fields/transformList/transformList.H | 8 +- .../transformGeometricField.H | 4 +- src/OpenFOAM/primitives/complex/complexI.H | 1 + .../primitives/transform/symmTransform.H | 63 +++++--- src/OpenFOAM/primitives/transform/transform.H | 85 +++++++---- 11 files changed, 271 insertions(+), 175 deletions(-) diff --git a/src/OpenFOAM/fields/FieldFields/transformFieldField/transformFieldField.H b/src/OpenFOAM/fields/FieldFields/transformFieldField/transformFieldField.H index 13ab4b87d2..31064780ab 100644 --- a/src/OpenFOAM/fields/FieldFields/transformFieldField/transformFieldField.H +++ b/src/OpenFOAM/fields/FieldFields/transformFieldField/transformFieldField.H @@ -36,8 +36,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef transformFieldField_H -#define transformFieldField_H +#ifndef Foam_transformFieldField_H +#define Foam_transformFieldField_H #include "transform.H" #include "tensorFieldField.H" diff --git a/src/OpenFOAM/fields/Fields/symmTransformField/symmTransformField.C b/src/OpenFOAM/fields/Fields/symmTransformField/symmTransformField.C index 586ff080d0..2149eb8d18 100644 --- a/src/OpenFOAM/fields/Fields/symmTransformField/symmTransformField.C +++ b/src/OpenFOAM/fields/Fields/symmTransformField/symmTransformField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,132 +29,130 @@ License #include "symmTransformField.H" #include "FieldM.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // template -void transform +void Foam::transform ( - Field& rtf, - const symmTensorField& trf, - const Field& tf + Field& result, + const symmTensor& rot, + const Field& fld ) { - if (trf.size() == 1) + TFOR_ALL_F_OP_FUNC_S_F + ( + Type, result, =, transform, symmTensor, rot, Type, fld + ); +} + + +template +void Foam::transform +( + Field& result, + const symmTensorField& rot, + const Field& fld +) +{ + if (rot.size() == 1) { - return transform(rtf, trf[0], tf); - } - else - { - TFOR_ALL_F_OP_FUNC_F_F - ( - Type, rtf, =, transform, symmTensor, trf, Type, tf - ) + return transform(result, rot.front(), fld); } + + TFOR_ALL_F_OP_FUNC_F_F + ( + Type, result, =, transform, symmTensor, rot, Type, fld + ); } template -tmp> transform +Foam::tmp> +Foam::transform ( - const symmTensorField& trf, - const Field& tf + const symmTensorField& rot, + const Field& fld ) { - auto tresult = tmp>::New(tf.size()); - transform(tresult.ref(), trf, tf); + auto tresult = tmp>::New(fld.size()); + transform(tresult.ref(), rot, fld); return tresult; } template -tmp> transform +Foam::tmp> +Foam::transform ( - const symmTensorField& trf, - const tmp>& ttf + const symmTensorField& rot, + const tmp>& tfld ) { - tmp> tresult = New(ttf); - transform(tresult.ref(), trf, ttf()); - ttf.clear(); + tmp> tresult = New(tfld); + transform(tresult.ref(), rot, tfld()); + tfld.clear(); return tresult; } template -tmp> transform +Foam::tmp> +Foam::transform ( - const tmp& ttrf, - const Field& tf + const tmp& trot, + const Field& fld ) { - auto tresult = tmp>::New(tf.size()); - transform(tresult.ref(), ttrf(), tf); - ttrf.clear(); + auto tresult = tmp>::New(fld.size()); + transform(tresult.ref(), trot(), fld); + trot.clear(); return tresult; } template -tmp> transform +Foam::tmp> +Foam::transform ( - const tmp& ttrf, - const tmp>& ttf + const tmp& trot, + const tmp>& tfld ) { - tmp> tresult = New(ttf); - transform(tresult.ref(), ttrf(), ttf()); - ttf.clear(); - ttrf.clear(); + tmp> tresult = New(tfld); + transform(tresult.ref(), trot(), tfld()); + trot.clear(); + tfld.clear(); return tresult; } template -void transform +Foam::tmp> +Foam::transform ( - Field& rtf, - const symmTensor& t, - const Field& tf + const symmTensor& rot, + const Field& fld ) { - TFOR_ALL_F_OP_FUNC_S_F(Type, rtf, =, transform, tensor, t, Type, tf) -} - - -template -tmp> transform -( - const symmTensor& t, - const Field& tf -) -{ - auto tresult = tmp>::New(tf.size()); - transform(tresult.ref(), t, tf); + auto tresult = tmp>::New(fld.size()); + transform(tresult.ref(), rot, fld); return tresult; } template -tmp> transform +Foam::tmp> +Foam::transform ( - const symmTensor& t, - const tmp>& ttf + const symmTensor& rot, + const tmp>& tfld ) { - tmp> tresult = New(ttf); - transform(tresult.ref(), t, ttf()); - ttf.clear(); + tmp> tresult = New(tfld); + transform(tresult.ref(), rot, tfld()); + tfld.clear(); return tresult; } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/fields/Fields/symmTransformField/symmTransformField.H b/src/OpenFOAM/fields/Fields/symmTransformField/symmTransformField.H index 96e534900b..b44686fe1a 100644 --- a/src/OpenFOAM/fields/Fields/symmTransformField/symmTransformField.H +++ b/src/OpenFOAM/fields/Fields/symmTransformField/symmTransformField.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef symmTransformField_H -#define symmTransformField_H +#ifndef Foam_symmTransformField_H +#define Foam_symmTransformField_H #include "symmTransform.H" #include "symmTensorField.H" @@ -48,73 +49,96 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -template -void transform(Field&, const symmTensorField&, const Field&); +// transform() template -tmp> transform(const symmTensorField&, const Field&); +void transform +( + Field& result, + const symmTensor& rot, + const Field& fld +); template -tmp> transform(const symmTensorField&, const tmp>&); +void transform +( + Field& result, + const symmTensorField& rot, + const Field& fld +); -template -tmp> transform(const tmp&, const Field&); template tmp> transform ( - const tmp&, - const tmp>& + const symmTensorField& rot, + const Field& fld +); + +template +tmp> transform +( + const symmTensorField& rot, + const tmp>& tfld +); + +template +tmp> transform +( + const tmp& trot, + const Field& tfld +); + +template +tmp> transform +( + const tmp& trot, + const tmp>& tfld ); template -void transform(Field&, const tensor&, const Field&); +tmp> transform +( + const symmTensor& rot, + const Field& fld +); template -tmp> transform(const tensor&, const Field&); - -template -tmp> transform(const tensor&, const tmp>&); - - -template<> -tmp> transformFieldMask +tmp> transform ( - const symmTensorField& -); - -template<> -tmp> transformFieldMask -( - const tmp& + const symmTensor& rot, + const tmp>& tfld ); -template<> -tmp> transformFieldMask -( - const symmTensorField& -); +// Specializations template<> -tmp> transformFieldMask -( - const tmp& -); +tmp> +transformFieldMask(const symmTensorField&); + +template<> +tmp> +transformFieldMask(const tmp&); template<> -tmp> transformFieldMask -( - const symmTensorField& -); +tmp> +transformFieldMask(const symmTensorField&); template<> -tmp> transformFieldMask -( - const tmp& -); +tmp> +transformFieldMask(const tmp&); + + +template<> +tmp> +transformFieldMask(const symmTensorField&); + +template<> +tmp> +transformFieldMask(const tmp&); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/fields/Fields/transformField/transformField.H b/src/OpenFOAM/fields/Fields/transformField/transformField.H index 99ad5e7c24..eb8de48f9c 100644 --- a/src/OpenFOAM/fields/Fields/transformField/transformField.H +++ b/src/OpenFOAM/fields/Fields/transformField/transformField.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef transformField_H -#define transformField_H +#ifndef Foam_transformField_H +#define Foam_transformField_H #include "transform.H" #include "quaternion.H" @@ -177,6 +177,7 @@ tmp> invTransform ); +// transformFieldMask() template tmp> transformFieldMask(const Field& fld); diff --git a/src/OpenFOAM/fields/Fields/transformField/transformFieldTemplates.C b/src/OpenFOAM/fields/Fields/transformField/transformFieldTemplates.C index 4078c0f3b5..f603625483 100644 --- a/src/OpenFOAM/fields/Fields/transformField/transformFieldTemplates.C +++ b/src/OpenFOAM/fields/Fields/transformField/transformFieldTemplates.C @@ -56,7 +56,7 @@ void Foam::transform { if (rot.size() == 1) { - return transform(result, rot.first(), fld); + return transform(result, rot.front(), fld); } TFOR_ALL_F_OP_FUNC_F_F @@ -180,7 +180,7 @@ void Foam::invTransform { if (rot.size() == 1) { - return invTransform(result, rot.first(), fld); + return invTransform(result, rot.front(), fld); } TFOR_ALL_F_OP_FUNC_F_F diff --git a/src/OpenFOAM/fields/Fields/transformList/transformList.C b/src/OpenFOAM/fields/Fields/transformList/transformList.C index 3de5a9b886..4ed8482718 100644 --- a/src/OpenFOAM/fields/Fields/transformList/transformList.C +++ b/src/OpenFOAM/fields/Fields/transformList/transformList.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,9 +37,12 @@ Foam::List Foam::transform const UList& field ) { - List result(field.size()); + const label loopLen = field.size(); - forAll(field, i) + List result(loopLen); + + /* pragmas... */ + for (label i = 0; i < loopLen; ++i) { result[i] = transform(rotTensor, field[i]); } @@ -51,7 +54,10 @@ Foam::List Foam::transform template void Foam::transformList(const tensor& rotTensor, UList& field) { - forAll(field, i) + const label loopLen = field.size(); + + /* pragmas... */ + for (label i = 0; i < loopLen; ++i) { field[i] = transform(rotTensor, field[i]); } @@ -63,11 +69,14 @@ void Foam::transformList(const tensorField& rotTensor, UList& field) { if (rotTensor.size() == 1) { - transformList(rotTensor[0], field); + transformList(rotTensor.front(), field); } else if (rotTensor.size() == field.size()) { - forAll(field, i) + const label loopLen = field.size(); + + /* pragmas... */ + for (label i = 0; i < loopLen; ++i) { field[i] = transform(rotTensor[i], field[i]); } @@ -98,7 +107,7 @@ void Foam::transformList(const tensorField& rotTensor, Map& field) { if (rotTensor.size() == 1) { - transformList(rotTensor[0], field); + transformList(rotTensor.front(), field); } else { @@ -126,7 +135,7 @@ void Foam::transformList(const tensorField& rotTensor, EdgeMap& field) { if (rotTensor.size() == 1) { - transformList(rotTensor[0], field); + transformList(rotTensor.front(), field); } else { diff --git a/src/OpenFOAM/fields/Fields/transformList/transformList.H b/src/OpenFOAM/fields/Fields/transformList/transformList.H index 062b749e47..a963589dfd 100644 --- a/src/OpenFOAM/fields/Fields/transformList/transformList.H +++ b/src/OpenFOAM/fields/Fields/transformList/transformList.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef transformList_H -#define transformList_H +#ifndef Foam_transformList_H +#define Foam_transformList_H #include "transform.H" #include "List.H" @@ -67,7 +67,7 @@ void transformList(const tensorField& rotTensor, UList& field); template void transformList(const tensor& rotTensor, Map& field); -//- Inplace transform a Map of elements using one tensor per element. +//- Inplace transform a Map of elements. // Using multiple tensors is ill-defined (Fatal). template void transformList(const tensorField& rotTensor, Map& field); @@ -77,7 +77,7 @@ void transformList(const tensorField& rotTensor, Map& field); template void transformList(const tensor& rotTensor, EdgeMap& field); -//- Inplace transform a Map of elements using one tensor per element. +//- Inplace transform a Map of elements. // Using multiple tensors is ill-defined (Fatal). template void transformList(const tensorField& rotTensor, EdgeMap& field); diff --git a/src/OpenFOAM/fields/GeometricFields/transformGeometricField/transformGeometricField.H b/src/OpenFOAM/fields/GeometricFields/transformGeometricField/transformGeometricField.H index 71982b137b..d7406bbfb6 100644 --- a/src/OpenFOAM/fields/GeometricFields/transformGeometricField/transformGeometricField.H +++ b/src/OpenFOAM/fields/GeometricFields/transformGeometricField/transformGeometricField.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef transformGeometricField_H -#define transformGeometricField_H +#ifndef Foam_transformGeometricField_H +#define Foam_transformGeometricField_H #include "transform.H" #include "GeometricField.H" diff --git a/src/OpenFOAM/primitives/complex/complexI.H b/src/OpenFOAM/primitives/complex/complexI.H index bba3e4a738..428849021d 100644 --- a/src/OpenFOAM/primitives/complex/complexI.H +++ b/src/OpenFOAM/primitives/complex/complexI.H @@ -274,6 +274,7 @@ inline const complex& sum(const complex& c) template class Tensor; +//- No-op rotational transform for complex inline complex transform(const Tensor&, const complex c) { return c; diff --git a/src/OpenFOAM/primitives/transform/symmTransform.H b/src/OpenFOAM/primitives/transform/symmTransform.H index ac4a86c6a7..f463e57632 100644 --- a/src/OpenFOAM/primitives/transform/symmTransform.H +++ b/src/OpenFOAM/primitives/transform/symmTransform.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,8 +32,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef symmTransform_H -#define symmTransform_H +#ifndef Foam_symmTransform_H +#define Foam_symmTransform_H #include "transform.H" @@ -43,57 +44,84 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -inline scalar transform(const symmTensor&, const scalar s) +//- No-op rotational transform for base types +template +constexpr typename std::enable_if::value, T>::type +transform(const symmTensor&, const T val) { - return s; + return val; } +//- No-op rotational transform for spherical tensor template -inline Vector transform(const symmTensor& stt, const Vector& v) +inline SphericalTensor transform +( + const symmTensor&, + const SphericalTensor& val +) { - return stt & v; + return val; } +//- Use rotational tensor to transform a vector +// Same as (rot & v) +template +inline Vector transform(const symmTensor& tt, const Vector& v) +{ + return tt & v; +} + + +//- Use rotational tensor to transform a tensor. +// Same as (rot & input & rot.T()) template inline Tensor transform(const symmTensor& stt, const Tensor& t) { - //return stt & t & stt.T(); return Tensor ( + // xx: (stt.xx()*t.xx() + stt.xy()*t.yx() + stt.xz()*t.zx())*stt.xx() + (stt.xx()*t.xy() + stt.xy()*t.yy() + stt.xz()*t.zy())*stt.xy() + (stt.xx()*t.xz() + stt.xy()*t.yz() + stt.xz()*t.zz())*stt.xz(), + // xy: (stt.xx()*t.xx() + stt.xy()*t.yx() + stt.xz()*t.zx())*stt.xy() + (stt.xx()*t.xy() + stt.xy()*t.yy() + stt.xz()*t.zy())*stt.yy() + (stt.xx()*t.xz() + stt.xy()*t.yz() + stt.xz()*t.zz())*stt.yz(), + // xz: (stt.xx()*t.xx() + stt.xy()*t.yx() + stt.xz()*t.zx())*stt.xz() + (stt.xx()*t.xy() + stt.xy()*t.yy() + stt.xz()*t.zy())*stt.yz() + (stt.xx()*t.xz() + stt.xy()*t.yz() + stt.xz()*t.zz())*stt.zz(), + // yx: (stt.xy()*t.xx() + stt.yy()*t.yx() + stt.yz()*t.zx())*stt.xx() + (stt.xy()*t.xy() + stt.yy()*t.yy() + stt.yz()*t.zy())*stt.xy() + (stt.xy()*t.xz() + stt.yy()*t.yz() + stt.yz()*t.zz())*stt.xz(), + // yy: (stt.xy()*t.xx() + stt.yy()*t.yx() + stt.yz()*t.zx())*stt.xy() + (stt.xy()*t.xy() + stt.yy()*t.yy() + stt.yz()*t.zy())*stt.yy() + (stt.xy()*t.xz() + stt.yy()*t.yz() + stt.yz()*t.zz())*stt.yz(), + // yz: (stt.xy()*t.xx() + stt.yy()*t.yx() + stt.yz()*t.zx())*stt.xz() + (stt.xy()*t.xy() + stt.yy()*t.yy() + stt.yz()*t.zy())*stt.yz() + (stt.xy()*t.xz() + stt.yy()*t.yz() + stt.yz()*t.zz())*stt.zz(), + // zx: (stt.xz()*t.xx() + stt.yz()*t.yx() + stt.zz()*t.zx())*stt.xx() + (stt.xz()*t.xy() + stt.yz()*t.yy() + stt.zz()*t.zy())*stt.xy() + (stt.xz()*t.xz() + stt.yz()*t.yz() + stt.zz()*t.zz())*stt.xz(), + // zy: (stt.xz()*t.xx() + stt.yz()*t.yx() + stt.zz()*t.zx())*stt.xy() + (stt.xz()*t.xy() + stt.yz()*t.yy() + stt.zz()*t.zy())*stt.yy() + (stt.xz()*t.xz() + stt.yz()*t.yz() + stt.zz()*t.zz())*stt.yz(), + // zz: (stt.xz()*t.xx() + stt.yz()*t.yx() + stt.zz()*t.zx())*stt.xz() + (stt.xz()*t.xy() + stt.yz()*t.yy() + stt.zz()*t.zy())*stt.yz() + (stt.xz()*t.xz() + stt.yz()*t.yz() + stt.zz()*t.zz())*stt.zz() @@ -101,17 +129,8 @@ inline Tensor transform(const symmTensor& stt, const Tensor& t) } -template -inline SphericalTensor transform -( - const symmTensor& stt, - const SphericalTensor& st -) -{ - return st; -} - - +//- Use rotational tensor to transform a symmTensor +// Same as (rot & input & rot.T()) template inline SymmTensor transform ( @@ -121,26 +140,32 @@ inline SymmTensor transform { return SymmTensor ( + // xx: (stt.xx()*st.xx() + stt.xy()*st.xy() + stt.xz()*st.xz())*stt.xx() + (stt.xx()*st.xy() + stt.xy()*st.yy() + stt.xz()*st.yz())*stt.xy() + (stt.xx()*st.xz() + stt.xy()*st.yz() + stt.xz()*st.zz())*stt.xz(), + // xy: (stt.xx()*st.xx() + stt.xy()*st.xy() + stt.xz()*st.xz())*stt.xy() + (stt.xx()*st.xy() + stt.xy()*st.yy() + stt.xz()*st.yz())*stt.yy() + (stt.xx()*st.xz() + stt.xy()*st.yz() + stt.xz()*st.zz())*stt.yz(), + // xz: (stt.xx()*st.xx() + stt.xy()*st.xy() + stt.xz()*st.xz())*stt.xz() + (stt.xx()*st.xy() + stt.xy()*st.yy() + stt.xz()*st.yz())*stt.yz() + (stt.xx()*st.xz() + stt.xy()*st.yz() + stt.xz()*st.zz())*stt.zz(), + // yy: (stt.xy()*st.xx() + stt.yy()*st.xy() + stt.yz()*st.xz())*stt.xy() + (stt.xy()*st.xy() + stt.yy()*st.yy() + stt.yz()*st.yz())*stt.yy() + (stt.xy()*st.xz() + stt.yy()*st.yz() + stt.yz()*st.zz())*stt.yz(), + // yz: (stt.xy()*st.xx() + stt.yy()*st.xy() + stt.yz()*st.xz())*stt.xz() + (stt.xy()*st.xy() + stt.yy()*st.yy() + stt.yz()*st.yz())*stt.yz() + (stt.xy()*st.xz() + stt.yy()*st.yz() + stt.yz()*st.zz())*stt.zz(), + // zz: (stt.xz()*st.xx() + stt.yz()*st.xy() + stt.zz()*st.xz())*stt.xz() + (stt.xz()*st.xy() + stt.yz()*st.yy() + stt.zz()*st.yz())*stt.yz() + (stt.xz()*st.xz() + stt.yz()*st.yz() + stt.zz()*st.zz())*stt.zz() @@ -148,6 +173,8 @@ inline SymmTensor transform } +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + template<> inline sphericalTensor transformMask(const symmTensor& st) { diff --git a/src/OpenFOAM/primitives/transform/transform.H b/src/OpenFOAM/primitives/transform/transform.H index fd52c65553..cc921ef038 100644 --- a/src/OpenFOAM/primitives/transform/transform.H +++ b/src/OpenFOAM/primitives/transform/transform.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -146,6 +146,8 @@ inline tensor Ra(const vector& a, const scalar omega) } +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + //- No-op rotational transform for base types template constexpr typename std::enable_if::value, T>::type @@ -154,6 +156,19 @@ transform(const tensor&, const T val) return val; } + +//- No-op rotational transform for spherical tensor +template +inline SphericalTensor transform +( + const tensor&, + const SphericalTensor& val +) +{ + return val; +} + + //- No-op inverse rotational transform for base types template constexpr typename std::enable_if::value, T>::type @@ -163,6 +178,18 @@ invTransform(const tensor&, const T val) } +//- No-op inverse rotational transform for spherical tensor +template +inline SphericalTensor invTransform +( + const tensor&, + const SphericalTensor& val +) +{ + return val; +} + + //- Use rotational tensor to transform a vector. // Same as (rot & v) template @@ -188,38 +215,47 @@ inline Tensor transform(const tensor& tt, const Tensor& t) { return Tensor ( + // xx: (tt.xx()*t.xx() + tt.xy()*t.yx() + tt.xz()*t.zx())*tt.xx() + (tt.xx()*t.xy() + tt.xy()*t.yy() + tt.xz()*t.zy())*tt.xy() + (tt.xx()*t.xz() + tt.xy()*t.yz() + tt.xz()*t.zz())*tt.xz(), + // xy: (tt.xx()*t.xx() + tt.xy()*t.yx() + tt.xz()*t.zx())*tt.yx() + (tt.xx()*t.xy() + tt.xy()*t.yy() + tt.xz()*t.zy())*tt.yy() + (tt.xx()*t.xz() + tt.xy()*t.yz() + tt.xz()*t.zz())*tt.yz(), + // xz: (tt.xx()*t.xx() + tt.xy()*t.yx() + tt.xz()*t.zx())*tt.zx() + (tt.xx()*t.xy() + tt.xy()*t.yy() + tt.xz()*t.zy())*tt.zy() + (tt.xx()*t.xz() + tt.xy()*t.yz() + tt.xz()*t.zz())*tt.zz(), + // yx: (tt.yx()*t.xx() + tt.yy()*t.yx() + tt.yz()*t.zx())*tt.xx() + (tt.yx()*t.xy() + tt.yy()*t.yy() + tt.yz()*t.zy())*tt.xy() + (tt.yx()*t.xz() + tt.yy()*t.yz() + tt.yz()*t.zz())*tt.xz(), + // yy: (tt.yx()*t.xx() + tt.yy()*t.yx() + tt.yz()*t.zx())*tt.yx() + (tt.yx()*t.xy() + tt.yy()*t.yy() + tt.yz()*t.zy())*tt.yy() + (tt.yx()*t.xz() + tt.yy()*t.yz() + tt.yz()*t.zz())*tt.yz(), + // yz: (tt.yx()*t.xx() + tt.yy()*t.yx() + tt.yz()*t.zx())*tt.zx() + (tt.yx()*t.xy() + tt.yy()*t.yy() + tt.yz()*t.zy())*tt.zy() + (tt.yx()*t.xz() + tt.yy()*t.yz() + tt.yz()*t.zz())*tt.zz(), + // zx: (tt.zx()*t.xx() + tt.zy()*t.yx() + tt.zz()*t.zx())*tt.xx() + (tt.zx()*t.xy() + tt.zy()*t.yy() + tt.zz()*t.zy())*tt.xy() + (tt.zx()*t.xz() + tt.zy()*t.yz() + tt.zz()*t.zz())*tt.xz(), + // zy: (tt.zx()*t.xx() + tt.zy()*t.yx() + tt.zz()*t.zx())*tt.yx() + (tt.zx()*t.xy() + tt.zy()*t.yy() + tt.zz()*t.zy())*tt.yy() + (tt.zx()*t.xz() + tt.zy()*t.yz() + tt.zz()*t.zz())*tt.yz(), + // zz: (tt.zx()*t.xx() + tt.zy()*t.yx() + tt.zz()*t.zx())*tt.zx() + (tt.zx()*t.xy() + tt.zy()*t.yy() + tt.zz()*t.zy())*tt.zy() + (tt.zx()*t.xz() + tt.zy()*t.yz() + tt.zz()*t.zz())*tt.zz() @@ -234,38 +270,47 @@ inline Tensor invTransform(const tensor& tt, const Tensor& t) { return Tensor ( + // xx: (tt.xx()*t.xx() + tt.yx()*t.yx() + tt.zx()*t.zx())*tt.xx() + (tt.xx()*t.xy() + tt.yx()*t.yy() + tt.zx()*t.zy())*tt.yx() + (tt.xx()*t.xz() + tt.yx()*t.yz() + tt.zx()*t.zz())*tt.zx(), + // xy: (tt.xx()*t.xx() + tt.yx()*t.yx() + tt.zx()*t.zx())*tt.xy() + (tt.xx()*t.xy() + tt.yx()*t.yy() + tt.zx()*t.zy())*tt.yy() + (tt.xx()*t.xz() + tt.yx()*t.yz() + tt.zx()*t.zz())*tt.zy(), + // xz: (tt.xx()*t.xx() + tt.yx()*t.yx() + tt.zx()*t.zx())*tt.xz() + (tt.xx()*t.xy() + tt.yx()*t.yy() + tt.zx()*t.zy())*tt.yz() + (tt.xx()*t.xz() + tt.yx()*t.yz() + tt.zx()*t.zz())*tt.zz(), + // yx: (tt.xy()*t.xx() + tt.yy()*t.yx() + tt.zy()*t.zx())*tt.xx() + (tt.xy()*t.xy() + tt.yy()*t.yy() + tt.zy()*t.zy())*tt.yx() + (tt.xy()*t.xz() + tt.yy()*t.yz() + tt.zy()*t.zz())*tt.zx(), + // yy: (tt.xy()*t.xx() + tt.yy()*t.yx() + tt.zy()*t.zx())*tt.xy() + (tt.xy()*t.xy() + tt.yy()*t.yy() + tt.zy()*t.zy())*tt.yy() + (tt.xy()*t.xz() + tt.yy()*t.yz() + tt.zy()*t.zz())*tt.zy(), + // yz: (tt.xy()*t.xx() + tt.yy()*t.yx() + tt.zy()*t.zx())*tt.xz() + (tt.xy()*t.xy() + tt.yy()*t.yy() + tt.zy()*t.zy())*tt.yz() + (tt.xy()*t.xz() + tt.yy()*t.yz() + tt.zy()*t.zz())*tt.zz(), + // zx: (tt.xz()*t.xx() + tt.yz()*t.yx() + tt.zz()*t.zx())*tt.xx() + (tt.xz()*t.xy() + tt.yz()*t.yy() + tt.zz()*t.zy())*tt.yx() + (tt.xz()*t.xz() + tt.yz()*t.yz() + tt.zz()*t.zz())*tt.zx(), + // zy: (tt.xz()*t.xx() + tt.yz()*t.yx() + tt.zz()*t.zx())*tt.xy() + (tt.xz()*t.xy() + tt.yz()*t.yy() + tt.zz()*t.zy())*tt.yy() + (tt.xz()*t.xz() + tt.yz()*t.yz() + tt.zz()*t.zz())*tt.zy(), + // zz: (tt.xz()*t.xx() + tt.yz()*t.yx() + tt.zz()*t.zx())*tt.xz() + (tt.xz()*t.xy() + tt.yz()*t.yy() + tt.zz()*t.zy())*tt.yz() + (tt.xz()*t.xz() + tt.yz()*t.yz() + tt.zz()*t.zz())*tt.zz() @@ -273,30 +318,6 @@ inline Tensor invTransform(const tensor& tt, const Tensor& t) } -//- Use rotational tensor to transform a spherical tensor (no-op). -template -inline SphericalTensor transform -( - const tensor& tt, - const SphericalTensor& st -) -{ - return st; -} - - -//- Use rotational tensor to inverse transform a spherical tensor (no-op). -template -inline SphericalTensor invTransform -( - const tensor& tt, - const SphericalTensor& st -) -{ - return st; -} - - //- Use rotational tensor to transform a symmetrical tensor. // Same as (rot & input & rot.T()) template @@ -304,26 +325,32 @@ inline SymmTensor transform(const tensor& tt, const SymmTensor& st) { return SymmTensor ( + // xx: (tt.xx()*st.xx() + tt.xy()*st.xy() + tt.xz()*st.xz())*tt.xx() + (tt.xx()*st.xy() + tt.xy()*st.yy() + tt.xz()*st.yz())*tt.xy() + (tt.xx()*st.xz() + tt.xy()*st.yz() + tt.xz()*st.zz())*tt.xz(), + // xy: (tt.xx()*st.xx() + tt.xy()*st.xy() + tt.xz()*st.xz())*tt.yx() + (tt.xx()*st.xy() + tt.xy()*st.yy() + tt.xz()*st.yz())*tt.yy() + (tt.xx()*st.xz() + tt.xy()*st.yz() + tt.xz()*st.zz())*tt.yz(), + // xz: (tt.xx()*st.xx() + tt.xy()*st.xy() + tt.xz()*st.xz())*tt.zx() + (tt.xx()*st.xy() + tt.xy()*st.yy() + tt.xz()*st.yz())*tt.zy() + (tt.xx()*st.xz() + tt.xy()*st.yz() + tt.xz()*st.zz())*tt.zz(), + // yy: (tt.yx()*st.xx() + tt.yy()*st.xy() + tt.yz()*st.xz())*tt.yx() + (tt.yx()*st.xy() + tt.yy()*st.yy() + tt.yz()*st.yz())*tt.yy() + (tt.yx()*st.xz() + tt.yy()*st.yz() + tt.yz()*st.zz())*tt.yz(), + // yz: (tt.yx()*st.xx() + tt.yy()*st.xy() + tt.yz()*st.xz())*tt.zx() + (tt.yx()*st.xy() + tt.yy()*st.yy() + tt.yz()*st.yz())*tt.zy() + (tt.yx()*st.xz() + tt.yy()*st.yz() + tt.yz()*st.zz())*tt.zz(), + // zz: (tt.zx()*st.xx() + tt.zy()*st.xy() + tt.zz()*st.xz())*tt.zx() + (tt.zx()*st.xy() + tt.zy()*st.yy() + tt.zz()*st.yz())*tt.zy() + (tt.zx()*st.xz() + tt.zy()*st.yz() + tt.zz()*st.zz())*tt.zz() @@ -339,26 +366,32 @@ invTransform(const tensor& tt, const SymmTensor& st) { return SymmTensor ( + // xx: (tt.xx()*st.xx() + tt.yx()*st.xy() + tt.zx()*st.xz())*tt.xx() + (tt.xx()*st.xy() + tt.yx()*st.yy() + tt.zx()*st.yz())*tt.yx() + (tt.xx()*st.xz() + tt.yx()*st.yz() + tt.zx()*st.zz())*tt.zx(), + // xy: (tt.xx()*st.xx() + tt.yx()*st.xy() + tt.zx()*st.xz())*tt.xy() + (tt.xx()*st.xy() + tt.yx()*st.yy() + tt.zx()*st.yz())*tt.yy() + (tt.xx()*st.xz() + tt.yx()*st.yz() + tt.zx()*st.zz())*tt.zy(), + // xz: (tt.xx()*st.xx() + tt.yx()*st.xy() + tt.zx()*st.xz())*tt.xz() + (tt.xx()*st.xy() + tt.yx()*st.yy() + tt.zx()*st.yz())*tt.yz() + (tt.xx()*st.xz() + tt.yx()*st.yz() + tt.zx()*st.zz())*tt.zz(), + // yy: (tt.xy()*st.xx() + tt.yy()*st.xy() + tt.zy()*st.xz())*tt.xy() + (tt.xy()*st.xy() + tt.yy()*st.yy() + tt.zy()*st.yz())*tt.yy() + (tt.xy()*st.xz() + tt.yy()*st.yz() + tt.zy()*st.zz())*tt.zy(), + // yz: (tt.xy()*st.xx() + tt.yy()*st.xy() + tt.zy()*st.xz())*tt.xz() + (tt.xy()*st.xy() + tt.yy()*st.yy() + tt.zy()*st.yz())*tt.yz() + (tt.xy()*st.xz() + tt.yy()*st.yz() + tt.zy()*st.zz())*tt.zz(), + // zz: (tt.xz()*st.xx() + tt.yz()*st.xy() + tt.zz()*st.xz())*tt.xz() + (tt.xz()*st.xy() + tt.yz()*st.yy() + tt.zz()*st.yz())*tt.yz() + (tt.xz()*st.xz() + tt.yz()*st.yz() + tt.zz()*st.zz())*tt.zz() @@ -366,6 +399,8 @@ invTransform(const tensor& tt, const SymmTensor& st) } +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + template inline Type1 transformMask(const Type2& t) {