diff --git a/src/OpenFOAM/fields/FieldFields/transformFieldField/transformFieldField.C b/src/OpenFOAM/fields/FieldFields/transformFieldField/transformFieldField.C index a1069a53fc..950815dead 100644 --- a/src/OpenFOAM/fields/FieldFields/transformFieldField/transformFieldField.C +++ b/src/OpenFOAM/fields/FieldFields/transformFieldField/transformFieldField.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -21,141 +21,260 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Description - Spatial transformation functions for FieldField. - \*---------------------------------------------------------------------------*/ #include "transformFieldField.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * global functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // template class Field, class Type> -void transform +void Foam::transform ( - FieldField& rtf, - const FieldField& trf, - const FieldField& tf + FieldField& result, + const tensor& rot, + const FieldField& fld ) { - forAll(rtf, i) + forAll(result, i) { - transform(rtf[i], trf[i], tf[i]); + transform(result[i], rot, fld[i]); } } template class Field, class Type> -tmp> transform +void Foam::transform ( - const FieldField& trf, - const FieldField& tf + FieldField& result, + const FieldField& rot, + const FieldField& fld ) { - tmp> tranf - ( - FieldField::NewCalculatedType(tf) - ); - transform(tranf(), trf, tf); - return tranf; -} - - -template class Field, class Type> -tmp> transform -( - const FieldField& trf, - const tmp>& ttf -) -{ - tmp> tranf(ttf.ptr()); - transform(tranf(), trf, tranf()); - return tranf; -} - - -template class Field, class Type> -tmp> transform -( - const tmp>& ttrf, - const FieldField& tf -) -{ - tmp> tranf - ( - FieldField::NewCalculatedType(tf) - ); - transform(tranf(), ttrf(), tf); - ttrf.clear(); - return tranf; -} - - -template class Field, class Type> -tmp> transform -( - const tmp>& ttrf, - const tmp>& ttf -) -{ - tmp> tranf(ttf.ptr()); - transform(tranf(), ttrf(), tranf()); - ttrf.clear(); - return tranf; -} - - -template class Field, class Type> -void transform -( - FieldField& rtf, - const tensor& t, - const FieldField& tf -) -{ - forAll(rtf, i) + forAll(result, i) { - transform(rtf[i], t, tf[i]); + transform(result[i], rot[i], fld[i]); } } template class Field, class Type> -tmp> transform +Foam::tmp> +Foam::transform ( - const tensor& t, - const FieldField& tf + const FieldField& rot, + const FieldField& fld ) { tmp> tranf ( - FieldField::NewCalculatedType(tf) + FieldField::NewCalculatedType(fld) ); - transform(tranf(), t, tf); + transform(tranf(), rot, fld); return tranf; } template class Field, class Type> -tmp> transform +Foam::tmp> +Foam::transform ( - const tensor& t, - const tmp>& ttf + const FieldField& rot, + const tmp>& tfld ) { - tmp> tranf(ttf.ptr()); - transform(tranf(), t, tranf()); + tmp> tresult(tfld.ptr()); + transform(tresult(), rot, tresult()); + return tresult; +} + + +template class Field, class Type> +Foam::tmp> +Foam::transform +( + const tmp>& trot, + const FieldField& fld +) +{ + tmp> tresult + ( + FieldField::NewCalculatedType(fld) + ); + transform(tresult(), trot(), fld); + trot.clear(); + return tresult; +} + + +template class Field, class Type> +Foam::tmp> +Foam::transform +( + const tmp>& trot, + const tmp>& tfld +) +{ + tmp> tresult(tfld.ptr()); + transform(tresult(), trot(), tresult()); + trot.clear(); + return tresult; +} + + +template class Field, class Type> +Foam::tmp> +Foam::transform +( + const tensor& rot, + const FieldField& fld +) +{ + tmp> tresult + ( + FieldField::NewCalculatedType(fld) + ); + transform(tresult(), rot, fld); + return tresult; +} + + +template class Field, class Type> +Foam::tmp> +Foam::transform +( + const tensor& rot, + const tmp>& tfld +) +{ + tmp> tresult(tfld.ptr()); + transform(tresult(), rot, tresult()); + return tresult; +} + + +template class Field, class Type> +void Foam::invTransform +( + FieldField& result, + const tensor& rot, + const FieldField& fld +) +{ + forAll(result, i) + { + invTransform(result[i], rot, fld[i]); + } +} + + +template class Field, class Type> +void Foam::invTransform +( + FieldField& result, + const FieldField& rot, + const FieldField& fld +) +{ + forAll(result, i) + { + invTransform(result[i], rot[i], fld[i]); + } +} + + +template class Field, class Type> +Foam::tmp> +Foam::invTransform +( + const FieldField& rot, + const FieldField& fld +) +{ + tmp> tranf + ( + FieldField::NewCalculatedType(fld) + ); + invTransform(tranf(), rot, fld); return tranf; } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +template class Field, class Type> +Foam::tmp> +Foam::invTransform +( + const FieldField& rot, + const tmp>& tfld +) +{ + tmp> tresult(tfld.ptr()); + invTransform(tresult(), rot, tresult()); + return tresult; +} + + +template class Field, class Type> +Foam::tmp> +Foam::invTransform +( + const tmp>& trot, + const FieldField& fld +) +{ + tmp> tresult + ( + FieldField::NewCalculatedType(fld) + ); + invTransform(tresult(), trot(), fld); + trot.clear(); + return tresult; +} + + +template class Field, class Type> +Foam::tmp> +Foam::invTransform +( + const tmp>& trot, + const tmp>& tfld +) +{ + tmp> tresult(tfld.ptr()); + invTransform(tresult(), trot(), tresult()); + trot.clear(); + return tresult; +} + + +template class Field, class Type> +Foam::tmp> +Foam::invTransform +( + const tensor& rot, + const FieldField& fld +) +{ + tmp> tresult + ( + FieldField::NewCalculatedType(fld) + ); + invTransform(tresult(), rot, fld); + return tresult; +} + + +template class Field, class Type> +Foam::tmp> +Foam::invTransform +( + const tensor& rot, + const tmp>& tfld +) +{ + tmp> tresult(tfld.ptr()); + invTransform(tresult(), rot, tresult()); + return tresult; +} -} // End namespace Foam // ************************************************************************* // diff --git a/src/OpenFOAM/fields/FieldFields/transformFieldField/transformFieldField.H b/src/OpenFOAM/fields/FieldFields/transformFieldField/transformFieldField.H index 28cd315077..cd659e05bf 100644 --- a/src/OpenFOAM/fields/FieldFields/transformFieldField/transformFieldField.H +++ b/src/OpenFOAM/fields/FieldFields/transformFieldField/transformFieldField.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,63 +46,127 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -template class Field, class Type> -void transform -( - FieldField&, - const FieldField&, - const FieldField& -); - -template class Field, class Type> -tmp> transform -( - const FieldField&, - const FieldField& -); - -template class Field, class Type> -tmp> transform -( - const FieldField&, - const tmp>& -); - -template class Field, class Type> -tmp> transform -( - const tmp>&, - const FieldField& -); - -template class Field, class Type> -tmp> transform -( - const tmp>&, - const tmp>& -); - +// transform() template class Field, class Type> void transform ( - FieldField&, - const tensor&, - const FieldField& + FieldField& result, + const tensor& rot, + const FieldField& fld +); + +template class Field, class Type> +void transform +( + FieldField& result, + const FieldField& rot, + const FieldField& fld ); template class Field, class Type> tmp> transform ( - const tensor&, - const FieldField& + const FieldField& rot, + const FieldField& fld ); template class Field, class Type> tmp> transform ( - const tensor&, - const tmp>& + const FieldField& rot, + const tmp>& tfld +); + +template class Field, class Type> +tmp> transform +( + const tmp>& trot, + const FieldField& fld +); + +template class Field, class Type> +tmp> transform +( + const tmp>& trot, + const tmp>& tfld +); + + +template class Field, class Type> +tmp> transform +( + const tensor& rot, + const FieldField& fld +); + +template class Field, class Type> +tmp> transform +( + const tensor& rot, + const tmp>& tfld +); + + +// invTransform() + +template class Field, class Type> +void invTransform +( + FieldField& result, + const tensor& rot, + const FieldField& fld +); + +template class Field, class Type> +void invTransform +( + FieldField& result, + const FieldField& rot, + const FieldField& fld +); + +template class Field, class Type> +tmp> invTransform +( + const FieldField& rot, + const FieldField& fld +); + +template class Field, class Type> +tmp> invTransform +( + const FieldField& rot, + const tmp>& tfld +); + +template class Field, class Type> +tmp> invTransform +( + const tmp>& trot, + const FieldField& fld +); + +template class Field, class Type> +tmp> invTransform +( + const tmp>& trot, + const tmp>& tfld +); + + +template class Field, class Type> +tmp> invTransform +( + const tensor& rot, + const FieldField& fld +); + +template class Field, class Type> +tmp> invTransform +( + const tensor& rot, + const tmp>& tfld ); diff --git a/src/OpenFOAM/fields/Fields/transformField/transformField.C b/src/OpenFOAM/fields/Fields/transformField/transformField.C index 564632e1c1..a4730e8ea3 100644 --- a/src/OpenFOAM/fields/Fields/transformField/transformField.C +++ b/src/OpenFOAM/fields/Fields/transformField/transformField.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,59 +36,59 @@ void Foam::transform const vectorField& tf ) { - tensor t = q.R(); - TFOR_ALL_F_OP_FUNC_S_F(vector, rtf, =, transform, tensor, t, vector, tf) + tensor rot = q.R(); + TFOR_ALL_F_OP_FUNC_S_F(vector, rtf, =, transform, tensor, rot, vector, tf) } Foam::tmp Foam::transform ( const quaternion& q, - const vectorField& tf + const vectorField& fld ) { - tmp tranf(new vectorField(tf.size())); - transform(tranf.ref(), q, tf); - return tranf; + auto tresult = tmp::New(fld.size()); + transform(tresult.ref(), q, fld); + return tresult; } Foam::tmp Foam::transform ( const quaternion& q, - const tmp& ttf + const tmp& tfld ) { - tmp tranf = New(ttf); - transform(tranf.ref(), q, ttf()); - ttf.clear(); - return tranf; + tmp tresult = New(tfld); + transform(tresult.ref(), q, tfld()); + tfld.clear(); + return tresult; } void Foam::transformPoints ( - vectorField& rtf, + vectorField& result, const septernion& tr, - const vectorField& tf + const vectorField& fld ) { - vector T = tr.t(); + vector trans = tr.t(); // Check if any translation - if (mag(T) > VSMALL) + if (mag(trans) > VSMALL) { - TFOR_ALL_F_OP_F_OP_S(vector, rtf, =, vector, tf, -, vector, T); + TFOR_ALL_F_OP_F_OP_S(vector, result, =, vector, fld, -, vector, trans); } else { - rtf = tf; + result = fld; } // Check if any rotation if (mag(tr.r().R() - I) > SMALL) { - transform(rtf, tr.r(), rtf); + transform(result, tr.r(), result); } } @@ -96,25 +96,25 @@ void Foam::transformPoints Foam::tmp Foam::transformPoints ( const septernion& tr, - const vectorField& tf + const vectorField& fld ) { - tmp tranf(new vectorField(tf.size())); - transformPoints(tranf.ref(), tr, tf); - return tranf; + auto tresult = tmp::New(fld.size()); + transformPoints(tresult.ref(), tr, fld); + return tresult; } Foam::tmp Foam::transformPoints ( const septernion& tr, - const tmp& ttf + const tmp& tfld ) { - tmp tranf = New(ttf); - transformPoints(tranf.ref(), tr, ttf()); - ttf.clear(); - return tranf; + tmp tresult = New(tfld); + transformPoints(tresult.ref(), tr, tfld()); + tfld.clear(); + return tresult; } diff --git a/src/OpenFOAM/fields/Fields/transformField/transformField.H b/src/OpenFOAM/fields/Fields/transformField/transformField.H index e466ab2021..7d0ed3c854 100644 --- a/src/OpenFOAM/fields/Fields/transformField/transformField.H +++ b/src/OpenFOAM/fields/Fields/transformField/transformField.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,63 +48,157 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -template -void transform(Field&, const tensorField&, const Field&); +// transform() template -tmp> transform(const tensorField&, const Field&); +void transform +( + Field& result, + const tensor& rot, + const Field& fld +); template -tmp> transform(const tensorField&, const tmp>&); - -template -tmp> transform(const tmp&, const Field&); - -template -tmp> transform(const tmp&, const tmp>&); +void transform +( + Field& result, + const tensorField& rot, + const Field& fld +); template -void transform(Field&, const tensor&, const Field&); +tmp> transform +( + const tensorField& rot, + const Field& fld +); template -tmp> transform(const tensor&, const Field&); +tmp> transform +( + const tensorField& rot, + const tmp>& tfld +); template -tmp> transform(const tensor&, const tmp>&); +tmp> transform +( + const tmp& trot, + const Field& fld +); + +template +tmp> transform +( + const tmp& trot, + const tmp>& tfld +); + + +template +tmp> transform +( + const tensor& rot, + const Field& fld +); + +template +tmp> transform +( + const tensor& rot, + const tmp>& tfld +); + + +// invTransform() + +template +void invTransform +( + Field& result, + const tensor& rot, + const Field& fld +); + +template +void invTransform +( + Field& result, + const tensorField& rot, + const Field& fld +); + + +template +tmp> invTransform +( + const tensorField& rot, + const Field& fld +); + +template +tmp> invTransform +( + const tensorField& rot, + const tmp>& tfld +); + +template +tmp> invTransform +( + const tmp& trot, + const Field& fld +); + +template +tmp> invTransform +( + const tmp& trot, + const tmp>& tfld +); + + +template +tmp> invTransform +( + const tensor& rot, + const Field& fld +); + +template +tmp> invTransform +( + const tensor& rot, + const tmp>& tfld +); + template -tmp> transformFieldMask(const Field&); +tmp> transformFieldMask(const Field& fld); template -tmp> transformFieldMask(const tmp>&); +tmp> transformFieldMask(const tmp>& tfld); +// Specializations + template<> -tmp> transformFieldMask -( - const tensorField& -); +tmp> +transformFieldMask(const tensorField&); template<> -tmp> transformFieldMask -( - const tmp& -); - +tmp> +transformFieldMask(const tmp&); template<> -tmp> transformFieldMask -( - const tensorField& -); +tmp> +transformFieldMask(const tensorField&); template<> -tmp> transformFieldMask -( - const tmp& -); +tmp> +transformFieldMask(const tmp&); //- Rotate given vectorField with the given quaternion diff --git a/src/OpenFOAM/fields/Fields/transformField/transformFieldTemplates.C b/src/OpenFOAM/fields/Fields/transformField/transformFieldTemplates.C index 7e87d7af92..2812c56266 100644 --- a/src/OpenFOAM/fields/Fields/transformField/transformFieldTemplates.C +++ b/src/OpenFOAM/fields/Fields/transformField/transformFieldTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,145 +26,269 @@ License #include "transformField.H" #include "FieldM.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * global functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // template -void transform +void Foam::transform ( - Field& rtf, - const tensorField& trf, - const Field& tf + Field& result, + const tensor& rot, + const Field& fld ) { - if (trf.size() == 1) + TFOR_ALL_F_OP_FUNC_S_F + ( + Type, result, =, transform, tensor, rot, Type, fld + ); +} + + +template +void Foam::transform +( + Field& result, + const tensorField& rot, + const Field& fld +) +{ + if (rot.size() == 1) { - return transform(rtf, trf[0], tf); + return transform(result, rot.first(), fld); } - else + + TFOR_ALL_F_OP_FUNC_F_F + ( + Type, result, =, transform, tensor, rot, Type, fld + ); +} + + +template +Foam::tmp> +Foam::transform +( + const tensorField& rot, + const Field& fld +) +{ + auto tresult = tmp>::New(fld.size()); + transform(tresult.ref(), rot, fld); + return tresult; +} + + +template +Foam::tmp> +Foam::transform +( + const tensorField& rot, + const tmp>& tfld +) +{ + tmp> tresult = New(tfld); + transform(tresult.ref(), rot, tfld()); + tfld.clear(); + return tresult; +} + + +template +Foam::tmp> +Foam::transform +( + const tmp& trot, + const Field& fld +) +{ + auto tresult = tmp>::New(fld.size()); + transform(tresult.ref(), trot(), fld); + trot.clear(); + return tresult; +} + + +template +Foam::tmp> +Foam::transform +( + const tmp& trot, + const tmp>& tfld +) +{ + tmp> tresult = New(tfld); + transform(tresult.ref(), trot(), tfld()); + trot.clear(); + tfld.clear(); + return tresult; +} + + +template +Foam::tmp> +Foam::transform +( + const tensor& rot, + const Field& fld +) +{ + auto tresult = tmp>::New(fld.size()); + transform(tresult.ref(), rot, fld); + return tresult; +} + + +template +Foam::tmp> +Foam::transform +( + const tensor& rot, + const tmp>& tfld +) +{ + tmp> tresult = New(tfld); + transform(tresult.ref(), rot, tfld()); + tfld.clear(); + return tresult; +} + + +template +void Foam::invTransform +( + Field& result, + const tensor& rot, + const Field& fld +) +{ + TFOR_ALL_F_OP_FUNC_S_F + ( + Type, result, =, invTransform, tensor, rot, Type, fld + ); +} + + +template +void Foam::invTransform +( + Field& result, + const tensorField& rot, + const Field& fld +) +{ + if (rot.size() == 1) { - TFOR_ALL_F_OP_FUNC_F_F - ( - Type, rtf, =, transform, tensor, trf, Type, tf - ) + return invTransform(result, rot.first(), fld); } + + TFOR_ALL_F_OP_FUNC_F_F + ( + Type, result, =, invTransform, tensor, rot, Type, fld + ); } template -tmp> transform +Foam::tmp> +Foam::invTransform ( - const tensorField& trf, - const Field& tf + const tensorField& rot, + const Field& fld ) { - tmp> tranf(new Field (tf.size())); - transform(tranf.ref(), trf, tf); - return tranf; + auto tresult = tmp>::New(fld.size()); + invTransform(tresult.ref(), rot, fld); + return tresult; } template -tmp> transform +Foam::tmp> +Foam::invTransform ( - const tensorField& trf, - const tmp>& ttf + const tensorField& rot, + const tmp>& tfld ) { - tmp> tranf = New(ttf); - transform(tranf.ref(), trf, ttf()); - ttf.clear(); - return tranf; + tmp> tresult = New(tfld); + invTransform(tresult.ref(), rot, tfld()); + tfld.clear(); + return tresult; } template -tmp> transform +Foam::tmp> +Foam::invTransform ( - const tmp& ttrf, - const Field& tf + const tmp& trot, + const Field& fld ) { - tmp> tranf(new Field (tf.size())); - transform(tranf.ref(), ttrf(), tf); - ttrf.clear(); - return tranf; + auto tresult = tmp>::New(fld.size()); + invTransform(tresult.ref(), trot(), fld); + trot.clear(); + return tresult; } template -tmp> transform +Foam::tmp> +Foam::invTransform ( - const tmp& ttrf, - const tmp>& ttf + const tmp& trot, + const tmp>& tfld ) { - tmp> tranf = New(ttf); - transform(tranf.ref(), ttrf(), ttf()); - ttf.clear(); - ttrf.clear(); - return tranf; + tmp> tresult = New(tfld); + invTransform(tresult.ref(), trot(), tfld()); + trot.clear(); + tfld.clear(); + return tresult; } template -void transform +Foam::tmp> +Foam::invTransform ( - Field& rtf, - const tensor& t, - const Field& tf + const tensor& rot, + const Field& fld ) { - TFOR_ALL_F_OP_FUNC_S_F(Type, rtf, =, transform, tensor, t, Type, tf) + auto tresult = tmp>::New(fld.size()); + invTransform(tresult.ref(), rot, fld); + return tresult; } template -tmp> transform +Foam::tmp> +Foam::invTransform ( - const tensor& t, - const Field& tf + const tensor& rot, + const tmp>& tfld ) { - tmp> tranf(new Field(tf.size())); - transform(tranf.ref(), t, tf); - return tranf; -} - - -template -tmp> transform -( - const tensor& t, - const tmp>& ttf -) -{ - tmp> tranf = New(ttf); - transform(tranf.ref(), t, ttf()); - ttf.clear(); - return tranf; + tmp> tresult = New(tfld); + invTransform(tresult.ref(), rot, tfld()); + tfld.clear(); + return tresult; } template -tmp> transformFieldMask(const Field& f) +Foam::tmp> +Foam::transformFieldMask(const Field& fld) { - return f; + return fld; } template -tmp> transformFieldMask(const tmp>& tf) +Foam::tmp> +Foam::transformFieldMask(const tmp>& tfld) { - return tmp>(tf.ptr()); + return tmp>(tfld.ptr()); } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/fields/GeometricFields/transformGeometricField/transformGeometricField.C b/src/OpenFOAM/fields/GeometricFields/transformGeometricField/transformGeometricField.C index d859f8b5f1..3322be3bce 100644 --- a/src/OpenFOAM/fields/GeometricFields/transformGeometricField/transformGeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/transformGeometricField/transformGeometricField.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,169 +29,328 @@ Description #include "transformGeometricField.H" #include "transformField.H" #include "transformFieldField.H" +#include "GeometricField.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * global functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * Transform Global Functions * * * * * * * * * * * // template class PatchField, class GeoMesh> -void transform +void Foam::transform ( - GeometricField& rtf, - const GeometricField& trf, - const GeometricField& tf + GeometricField& result, + const dimensionedTensor& rot, + const GeometricField& fld ) { transform ( - rtf.primitiveFieldRef(), - trf.primitiveField(), - tf.primitiveField() + result.primitiveFieldRef(), + rot.value(), + fld.primitiveField() ); transform ( - rtf.boundaryFieldRef(), - trf.boundaryField(), - tf.boundaryField() + result.boundaryFieldRef(), + rot.value(), + fld.boundaryField() ); } template class PatchField, class GeoMesh> -tmp> transform +void Foam::transform ( - const GeometricField& trf, - const GeometricField& tf + GeometricField& result, + const GeometricField& rot, + const GeometricField& fld ) { - tmp> tranf + transform ( - new GeometricField - ( - IOobject - ( - "transform(" + trf.name() + ',' + tf.name() + ')', - tf.instance(), - tf.db(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - tf.mesh(), - tf.dimensions() - ) + result.primitiveFieldRef(), + rot.primitiveField(), + fld.primitiveField() ); - - transform(tranf.ref(), trf, tf); - - return tranf; -} - - -template class PatchField, class GeoMesh> -tmp> transform -( - const GeometricField& trf, - const tmp>& ttf -) -{ - tmp> tranf = - transform(trf, ttf()); - ttf.clear(); - return tranf; -} - - -template class PatchField, class GeoMesh> -tmp> transform -( - const tmp>& ttrf, - const GeometricField& tf -) -{ - tmp> tranf = - transform(ttrf(), tf); - ttrf.clear(); - return tranf; -} - - -template class PatchField, class GeoMesh> -tmp> transform -( - const tmp>& ttrf, - const tmp>& ttf -) -{ - tmp> tranf = - transform(ttrf(), ttf()); - ttf.clear(); - ttrf.clear(); - return tranf; -} - - -template class PatchField, class GeoMesh> -void transform -( - GeometricField& rtf, - const dimensionedTensor& t, - const GeometricField& tf -) -{ - transform(rtf.primitiveFieldRef(), t.value(), tf.primitiveField()); - transform(rtf.boundaryFieldRef(), t.value(), tf.boundaryField()); -} - - -template class PatchField, class GeoMesh> -tmp> transform -( - const dimensionedTensor& t, - const GeometricField& tf -) -{ - tmp> tranf + transform ( - new GeometricField - ( - IOobject - ( - "transform(" + t.name() + ',' + tf.name() + ')', - tf.instance(), - tf.db(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - tf.mesh(), - tf.dimensions() - ) + result.boundaryFieldRef(), + rot.boundaryField(), + fld.boundaryField() ); - - transform(tranf.ref(), t, tf); - - return tranf; } template class PatchField, class GeoMesh> -tmp> transform +Foam::tmp> +Foam::transform ( - const dimensionedTensor& t, - const tmp>& ttf + const GeometricField& rot, + const GeometricField& fld ) { - tmp> tranf = - transform(t, ttf()); - ttf.clear(); - return tranf; + auto tresult = tmp>::New + ( + IOobject + ( + "transform(" + rot.name() + ',' + fld.name() + ')', + fld.instance(), + fld.db(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + fld.mesh(), + fld.dimensions() + ); + + transform(tresult.ref(), rot, fld); + + return tresult; } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +template class PatchField, class GeoMesh> +Foam::tmp> +Foam::transform +( + const GeometricField& rot, + const tmp>& tfld +) +{ + auto tresult = transform(rot, tfld()); + tfld.clear(); + return tresult; +} + + +template class PatchField, class GeoMesh> +Foam::tmp> +Foam::transform +( + const tmp>& trot, + const GeometricField& fld +) +{ + auto tresult = transform(trot(), fld); + trot.clear(); + return tresult; +} + + +template class PatchField, class GeoMesh> +Foam::tmp> +Foam::transform +( + const tmp>& trot, + const tmp>& tfld +) +{ + auto tresult = transform(trot(), tfld()); + tfld.clear(); + trot.clear(); + return tresult; +} + + +template class PatchField, class GeoMesh> +Foam::tmp> +Foam::transform +( + const dimensionedTensor& rot, + const GeometricField& fld +) +{ + auto tresult = tmp>::New + ( + IOobject + ( + "transform(" + rot.name() + ',' + fld.name() + ')', + fld.instance(), + fld.db(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + fld.mesh(), + fld.dimensions() + ); + + transform(tresult.ref(), rot, fld); + + return tresult; +} + + +template class PatchField, class GeoMesh> +Foam::tmp> +Foam::transform +( + const dimensionedTensor& rot, + const tmp>& tfld +) +{ + auto tresult = transform(rot, tfld()); + tfld.clear(); + return tresult; +} + + +// * * * * * * * * * * * invTransform Global Functions * * * * * * * * * * * // + +template class PatchField, class GeoMesh> +void Foam::invTransform +( + GeometricField& result, + const dimensionedTensor& rot, + const GeometricField& fld +) +{ + invTransform + ( + result.primitiveFieldRef(), + rot.value(), + fld.primitiveField() + ); + invTransform + ( + result.boundaryFieldRef(), + rot.value(), + fld.boundaryField() + ); +} + + +template class PatchField, class GeoMesh> +void Foam::invTransform +( + GeometricField& result, + const GeometricField& rot, + const GeometricField& fld +) +{ + invTransform + ( + result.primitiveFieldRef(), + rot.primitiveField(), + fld.primitiveField() + ); + invTransform + ( + result.boundaryFieldRef(), + rot.boundaryField(), + fld.boundaryField() + ); +} + + +template class PatchField, class GeoMesh> +Foam::tmp> +Foam::invTransform +( + const GeometricField& rot, + const GeometricField& fld +) +{ + auto tresult = tmp>::New + ( + IOobject + ( + "invTransform(" + rot.name() + ',' + fld.name() + ')', + fld.instance(), + fld.db(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + fld.mesh(), + fld.dimensions() + ); + + invTransform(tresult.ref(), rot, fld); + + return tresult; +} + + +template class PatchField, class GeoMesh> +Foam::tmp> +Foam::invTransform +( + const GeometricField& rot, + const tmp>& tfld +) +{ + auto tresult = invTransform(rot, tfld()); + tfld.clear(); + return tresult; +} + + +template class PatchField, class GeoMesh> +Foam::tmp> +Foam::invTransform +( + const tmp>& trot, + const GeometricField& fld +) +{ + auto tresult = invTransform(trot(), fld); + trot.clear(); + return tresult; +} + + +template class PatchField, class GeoMesh> +Foam::tmp> +Foam::invTransform +( + const tmp>& trot, + const tmp>& tfld +) +{ + auto tresult = invTransform(trot(), tfld()); + tfld.clear(); + trot.clear(); + return tresult; +} + + +template class PatchField, class GeoMesh> +Foam::tmp> +Foam::invTransform +( + const dimensionedTensor& rot, + const GeometricField& fld +) +{ + auto tresult = tmp>::New + ( + IOobject + ( + "invTransform(" + rot.name() + ',' + fld.name() + ')', + fld.instance(), + fld.db(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + fld.mesh(), + fld.dimensions() + ); + + invTransform(tresult.ref(), rot, fld); + + return tresult; +} + + +template class PatchField, class GeoMesh> +Foam::tmp> +Foam::invTransform +( + const dimensionedTensor& rot, + const tmp>& tfld +) +{ + auto tresult = invTransform(rot, tfld()); + tfld.clear(); + return tresult; +} -} // End namespace Foam // ************************************************************************* // diff --git a/src/OpenFOAM/fields/GeometricFields/transformGeometricField/transformGeometricField.H b/src/OpenFOAM/fields/GeometricFields/transformGeometricField/transformGeometricField.H index 77c95e7422..a84cc4b63d 100644 --- a/src/OpenFOAM/fields/GeometricFields/transformGeometricField/transformGeometricField.H +++ b/src/OpenFOAM/fields/GeometricFields/transformGeometricField/transformGeometricField.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,7 +25,7 @@ InClass Foam::transformGeometricField Description - Spatial transformation functions for FieldFields. + Spatial transformation functions for GeometricField SourceFiles transformGeometricField.C @@ -45,63 +45,128 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -template class PatchField, class GeoMesh> -void transform -( - GeometricField&, - const GeometricField&, - const GeometricField& -); - -template class PatchField, class GeoMesh> -tmp> transform -( - const GeometricField&, - const GeometricField& -); - -template class PatchField, class GeoMesh> -tmp> transform -( - const GeometricField&, - const tmp>& -); - -template class PatchField, class GeoMesh> -tmp> transform -( - const tmp>&, - const GeometricField& -); - -template class PatchField, class GeoMesh> -tmp> transform -( - const tmp>&, - const tmp>& -); - +// transform() template class PatchField, class GeoMesh> void transform ( - GeometricField&, - const dimensionedTensor&, - const GeometricField& + GeometricField& result, + const dimensionedTensor& rot, + const GeometricField& fld +); + +template class PatchField, class GeoMesh> +void transform +( + GeometricField& result, + const GeometricField& rot, + const GeometricField& fld +); + + +template class PatchField, class GeoMesh> +tmp> transform +( + const GeometricField& rot, + const GeometricField& fld ); template class PatchField, class GeoMesh> tmp> transform ( - const dimensionedTensor&, - const GeometricField& + const GeometricField& rot, + const tmp>& tfld ); template class PatchField, class GeoMesh> tmp> transform ( - const dimensionedTensor&, - const tmp>& + const tmp>& trot, + const GeometricField& fld +); + +template class PatchField, class GeoMesh> +tmp> transform +( + const tmp>& trot, + const tmp>& tfld +); + +template class PatchField, class GeoMesh> +tmp> transform +( + const dimensionedTensor& rot, + const GeometricField& fld +); + +template class PatchField, class GeoMesh> +tmp> transform +( + const dimensionedTensor& rot, + const tmp>& tfld +); + + + +// invTransform() + +template class PatchField, class GeoMesh> +void invTransform +( + GeometricField& result, + const dimensionedTensor& rot, + const GeometricField& fld +); + +template class PatchField, class GeoMesh> +void invTransform +( + GeometricField& result, + const GeometricField& rot, + const GeometricField& fld +); + +template class PatchField, class GeoMesh> +tmp> invTransform +( + const GeometricField& rot, + const GeometricField& fld +); + +template class PatchField, class GeoMesh> +tmp> invTransform +( + const GeometricField& rot, + const tmp>& tfld +); + +template class PatchField, class GeoMesh> +tmp> invTransform +( + const tmp>& trot, + const GeometricField& fld +); + +template class PatchField, class GeoMesh> +tmp> invTransform +( + const tmp>& trot, + const tmp>& tfld +); + + +template class PatchField, class GeoMesh> +tmp> invTransform +( + const dimensionedTensor& rot, + const GeometricField& fld +); + +template class PatchField, class GeoMesh> +tmp> invTransform +( + const dimensionedTensor& rot, + const tmp>& tfld );