diff --git a/src/OpenFOAM/fields/Fields/transformList/transformList.C b/src/OpenFOAM/fields/Fields/transformList/transformList.C index f4db4cc6f8..7088bcd7e0 100644 --- a/src/OpenFOAM/fields/Fields/transformList/transformList.C +++ b/src/OpenFOAM/fields/Fields/transformList/transformList.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,14 +34,14 @@ Foam::List Foam::transform const UList& field ) { - List newField(field.size()); + List result(field.size()); forAll(field, i) { - newField[i] = transform(rotTensor, field[i]); + result[i] = transform(rotTensor, field[i]); } - return newField; + return result; } @@ -60,10 +60,7 @@ void Foam::transformList(const tensorField& rotTensor, UList& field) { if (rotTensor.size() == 1) { - forAll(field, i) - { - field[i] = transform(rotTensor[0], field[i]); - } + transformList(rotTensor[0], field); } else if (rotTensor.size() == field.size()) { @@ -87,7 +84,8 @@ void Foam::transformList(const tensor& rotTensor, Map& field) { forAllIters(field, iter) { - iter() = transform(rotTensor, iter()); + T& value = iter.object(); + value = transform(rotTensor, value); } } @@ -97,10 +95,7 @@ void Foam::transformList(const tensorField& rotTensor, Map& field) { if (rotTensor.size() == 1) { - forAllIter(typename Map, field, iter) - { - iter() = transform(rotTensor[0], iter()); - } + transformList(rotTensor[0], field); } else { @@ -117,7 +112,8 @@ void Foam::transformList(const tensor& rotTensor, EdgeMap& field) { forAllIters(field, iter) { - iter() = transform(rotTensor, iter()); + T& value = iter.object(); + value = transform(rotTensor, value); } } @@ -127,10 +123,7 @@ void Foam::transformList(const tensorField& rotTensor, EdgeMap& field) { if (rotTensor.size() == 1) { - forAllIter(typename EdgeMap, field, iter) - { - iter() = transform(rotTensor[0], iter()); - } + transformList(rotTensor[0], field); } else { diff --git a/src/OpenFOAM/fields/Fields/transformList/transformList.H b/src/OpenFOAM/fields/Fields/transformList/transformList.H index 8b485bec41..9f827d0928 100644 --- a/src/OpenFOAM/fields/Fields/transformList/transformList.H +++ b/src/OpenFOAM/fields/Fields/transformList/transformList.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 Description - Spatial transformation functions for primitive fields. + Spatial transformation functions for list of values and primitive fields. SourceFiles transformList.C @@ -41,7 +41,6 @@ SourceFiles #include "edgeHashes.H" #include "tensorField.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -49,93 +48,63 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -//- Extend transform to work on list. +//- Apply transform to a list of elements, returning a copy. template -List transform -( - const tensor& rotTensor, - const UList& field -); +List transform(const tensor& rotTensor, const UList& field); -//- Apply transformation to list. Either single transformation tensor -// or one tensor per element. +//- Inplace transform a list of elements. template -void transformList(const tensor&, UList&); +void transformList(const tensor& rotTensor, UList& field); + +//- Inplace transform a list of elements using one tensor per element. template -void transformList(const tensorField&, UList&); +void transformList(const tensorField& rotTensor, UList& field); +//- Inplace transform a Map of elements. template -void transformList(const tensor&, Map&); +void transformList(const tensor& rotTensor, Map& field); + +//- Inplace transform a Map of elements using one tensor per element. +// Using multiple tensors is ill-defined (Fatal). template -void transformList(const tensorField&, Map&); +void transformList(const tensorField& rotTensor, Map& field); +//- Inplace transform a Map of elements. +// Using multiple tensors is ill-defined (Fatal). template -void transformList(const tensor&, EdgeMap&); +void transformList(const tensor& rotTensor, EdgeMap& field); + +//- Inplace transform a Map of elements using one tensor per element. +// Using multiple tensors is ill-defined (Fatal). template -void transformList(const tensorField&, EdgeMap&); +void transformList(const tensorField& rotTensor, EdgeMap& field); -// Specialisations for bool -template<> -inline void transformList(const tensor&, UList&) -{} -template<> -inline void transformList(const tensorField&, UList&) -{} -template<> -inline void transformList(const tensor&, Map&) -{} -template<> -inline void transformList(const tensorField&, Map&) -{} -template<> -inline void transformList(const tensor&, EdgeMap&) -{} -template<> -inline void transformList(const tensorField&, EdgeMap&) -{} +// Specialisations for bool (no-op) +template<> inline void transformList(const tensor&, UList&) {} +template<> inline void transformList(const tensorField&, UList&) {} +template<> inline void transformList(const tensor&, Map&) {} +template<> inline void transformList(const tensorField&, Map&) {} +template<> inline void transformList(const tensor&, EdgeMap&) {} +template<> inline void transformList(const tensorField&, EdgeMap&) {} -// Specialisations for label -template<> -inline void transformList(const tensor&, labelUList&) -{} -template<> -inline void transformList(const tensorField&, labelUList&) -{} -template<> -inline void transformList(const tensor&, Map