Skip to content
Snippets Groups Projects
Commit a6473dca authored by Mark OLESEN's avatar Mark OLESEN
Browse files

STYLE: minor coding/comments cleanup for transform, transformList

parent dde9ef47
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -34,14 +34,14 @@ Foam::List<T> Foam::transform ...@@ -34,14 +34,14 @@ Foam::List<T> Foam::transform
const UList<T>& field const UList<T>& field
) )
{ {
List<T> newField(field.size()); List<T> result(field.size());
forAll(field, i) 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<T>& field) ...@@ -60,10 +60,7 @@ void Foam::transformList(const tensorField& rotTensor, UList<T>& field)
{ {
if (rotTensor.size() == 1) if (rotTensor.size() == 1)
{ {
forAll(field, i) transformList(rotTensor[0], field);
{
field[i] = transform(rotTensor[0], field[i]);
}
} }
else if (rotTensor.size() == field.size()) else if (rotTensor.size() == field.size())
{ {
...@@ -87,7 +84,8 @@ void Foam::transformList(const tensor& rotTensor, Map<T>& field) ...@@ -87,7 +84,8 @@ void Foam::transformList(const tensor& rotTensor, Map<T>& field)
{ {
forAllIters(field, iter) 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<T>& field) ...@@ -97,10 +95,7 @@ void Foam::transformList(const tensorField& rotTensor, Map<T>& field)
{ {
if (rotTensor.size() == 1) if (rotTensor.size() == 1)
{ {
forAllIter(typename Map<T>, field, iter) transformList(rotTensor[0], field);
{
iter() = transform(rotTensor[0], iter());
}
} }
else else
{ {
...@@ -117,7 +112,8 @@ void Foam::transformList(const tensor& rotTensor, EdgeMap<T>& field) ...@@ -117,7 +112,8 @@ void Foam::transformList(const tensor& rotTensor, EdgeMap<T>& field)
{ {
forAllIters(field, iter) 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<T>& field) ...@@ -127,10 +123,7 @@ void Foam::transformList(const tensorField& rotTensor, EdgeMap<T>& field)
{ {
if (rotTensor.size() == 1) if (rotTensor.size() == 1)
{ {
forAllIter(typename EdgeMap<T>, field, iter) transformList(rotTensor[0], field);
{
iter() = transform(rotTensor[0], iter());
}
} }
else else
{ {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -25,7 +25,7 @@ InClass ...@@ -25,7 +25,7 @@ InClass
Foam Foam
Description Description
Spatial transformation functions for primitive fields. Spatial transformation functions for list of values and primitive fields.
SourceFiles SourceFiles
transformList.C transformList.C
...@@ -41,7 +41,6 @@ SourceFiles ...@@ -41,7 +41,6 @@ SourceFiles
#include "edgeHashes.H" #include "edgeHashes.H"
#include "tensorField.H" #include "tensorField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
...@@ -49,93 +48,63 @@ 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<class T> template<class T>
List<T> transform List<T> transform(const tensor& rotTensor, const UList<T>& field);
(
const tensor& rotTensor, //- Inplace transform a list of elements.
const UList<T>& field
);
//- Apply transformation to list. Either single transformation tensor
// or one tensor per element.
template<class T> template<class T>
void transformList(const tensor&, UList<T>&); void transformList(const tensor& rotTensor, UList<T>& field);
//- Inplace transform a list of elements using one tensor per element.
template<class T> template<class T>
void transformList(const tensorField&, UList<T>&); void transformList(const tensorField& rotTensor, UList<T>& field);
//- Inplace transform a Map of elements.
template<class T> template<class T>
void transformList(const tensor&, Map<T>&); void transformList(const tensor& rotTensor, Map<T>& field);
//- Inplace transform a Map of elements using one tensor per element.
// Using multiple tensors is ill-defined (Fatal).
template<class T> template<class T>
void transformList(const tensorField&, Map<T>&); void transformList(const tensorField& rotTensor, Map<T>& field);
//- Inplace transform a Map of elements.
// Using multiple tensors is ill-defined (Fatal).
template<class T> template<class T>
void transformList(const tensor&, EdgeMap<T>&); void transformList(const tensor& rotTensor, EdgeMap<T>& field);
//- Inplace transform a Map of elements using one tensor per element.
// Using multiple tensors is ill-defined (Fatal).
template<class T> template<class T>
void transformList(const tensorField&, EdgeMap<T>&); void transformList(const tensorField& rotTensor, EdgeMap<T>& field);
// Specialisations for bool // Specialisations for bool (no-op)
template<> template<> inline void transformList(const tensor&, UList<bool>&) {}
inline void transformList(const tensor&, UList<bool>&) template<> inline void transformList(const tensorField&, UList<bool>&) {}
{} template<> inline void transformList(const tensor&, Map<bool>&) {}
template<> template<> inline void transformList(const tensorField&, Map<bool>&) {}
inline void transformList(const tensorField&, UList<bool>&) template<> inline void transformList(const tensor&, EdgeMap<bool>&) {}
{} template<> inline void transformList(const tensorField&, EdgeMap<bool>&) {}
template<>
inline void transformList(const tensor&, Map<bool>&)
{} // Specialisations for label (no-op)
template<> template<> inline void transformList(const tensor&, labelUList&) {}
inline void transformList(const tensorField&, Map<bool>&) template<> inline void transformList(const tensorField&, labelUList&) {}
{} template<> inline void transformList(const tensor&, Map<label>&) {}
template<> template<> inline void transformList(const tensorField&, Map<label>&) {}
inline void transformList(const tensor&, EdgeMap<bool>&) template<> inline void transformList(const tensor&, EdgeMap<label>&) {}
{} template<> inline void transformList(const tensorField&, EdgeMap<label>&) {}
template<>
inline void transformList(const tensorField&, EdgeMap<bool>&)
{} // Specialisations for scalar (no-op)
template<> inline void transformList(const tensor&, UList<scalar>&) {}
template<> inline void transformList(const tensorField&, UList<scalar>&) {}
// Specialisations for label template<> inline void transformList(const tensor&, Map<scalar>&) {}
template<> template<> inline void transformList(const tensorField&, Map<scalar>&) {}
inline void transformList(const tensor&, labelUList&) template<> inline void transformList(const tensor&, EdgeMap<scalar>&) {}
{} template<> inline void transformList(const tensorField&, EdgeMap<scalar>&) {}
template<>
inline void transformList(const tensorField&, labelUList&)
{}
template<>
inline void transformList(const tensor&, Map<label>&)
{}
template<>
inline void transformList(const tensorField&, Map<label>&)
{}
template<>
inline void transformList(const tensor&, EdgeMap<label>&)
{}
template<>
inline void transformList(const tensorField&, EdgeMap<label>&)
{}
// Specialisations for scalar
template<>
inline void transformList(const tensor&, UList<scalar>&)
{}
template<>
inline void transformList(const tensorField&, UList<scalar>&)
{}
template<>
inline void transformList(const tensor&, Map<scalar>&)
{}
template<>
inline void transformList(const tensorField&, Map<scalar>&)
{}
template<>
inline void transformList(const tensor&, EdgeMap<scalar>&)
{}
template<>
inline void transformList(const tensorField&, EdgeMap<scalar>&)
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
...@@ -142,31 +142,38 @@ inline tensor Ra(const vector& a, const scalar omega) ...@@ -142,31 +142,38 @@ inline tensor Ra(const vector& a, const scalar omega)
} }
inline label transform(const tensor&, const bool i) //- No-op rotational transform of a bool
inline bool transform(const tensor&, const bool b)
{ {
return i; return b;
} }
//- No-op rotational transform of a label
inline label transform(const tensor&, const label i) inline label transform(const tensor&, const label i)
{ {
return i; return i;
} }
//- No-op rotational transform of a label
inline scalar transform(const tensor&, const scalar s) inline scalar transform(const tensor&, const scalar s)
{ {
return s; return s;
} }
//- Use rotational tensor to transform a vector.
// Same as (rot & v)
template<class Cmpt> template<class Cmpt>
inline Vector<Cmpt> transform(const tensor& tt, const Vector<Cmpt>& v) inline Vector<Cmpt> transform(const tensor& tt, const Vector<Cmpt>& v)
{ {
return tt & v; return (tt & v);
} }
//- Use rotational tensor to transform a tensor.
// Same as (rot & input & rot.T())
template<class Cmpt> template<class Cmpt>
inline Tensor<Cmpt> transform(const tensor& tt, const Tensor<Cmpt>& t) inline Tensor<Cmpt> transform(const tensor& tt, const Tensor<Cmpt>& t)
{ {
...@@ -211,6 +218,7 @@ inline Tensor<Cmpt> transform(const tensor& tt, const Tensor<Cmpt>& t) ...@@ -211,6 +218,7 @@ inline Tensor<Cmpt> transform(const tensor& tt, const Tensor<Cmpt>& t)
} }
//- Use rotational tensor to transform a spherical tensor (no-op).
template<class Cmpt> template<class Cmpt>
inline SphericalTensor<Cmpt> transform inline SphericalTensor<Cmpt> transform
( (
...@@ -222,6 +230,8 @@ inline SphericalTensor<Cmpt> transform ...@@ -222,6 +230,8 @@ inline SphericalTensor<Cmpt> transform
} }
//- Use rotational tensor to transform a symmetrical tensor.
// Same as (rot & input & rot.T())
template<class Cmpt> template<class Cmpt>
inline SymmTensor<Cmpt> transform(const tensor& tt, const SymmTensor<Cmpt>& st) inline SymmTensor<Cmpt> transform(const tensor& tt, const SymmTensor<Cmpt>& st)
{ {
...@@ -292,16 +302,16 @@ inline scalar pseudoAngle ...@@ -292,16 +302,16 @@ inline scalar pseudoAngle
const vector& vec const vector& vec
) )
{ {
scalar cos = vec & e0; const scalar cos_angle = vec & e0;
scalar sin = vec & e1; const scalar sin_angle = vec & e1;
if (sin < -SMALL) if (sin_angle < -SMALL)
{ {
return (3.0 + cos)*constant::mathematical::piByTwo; return (3.0 + cos_angle)*constant::mathematical::piByTwo;
} }
else else
{ {
return (1.0 - cos)*constant::mathematical::piByTwo; return (1.0 - cos_angle)*constant::mathematical::piByTwo;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment