Commit a6473dca authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: minor coding/comments cleanup for transform, transformList

parent dde9ef47
......@@ -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<T> Foam::transform
const UList<T>& field
)
{
List<T> newField(field.size());
List<T> 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<T>& 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<T>& 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<T>& field)
{
if (rotTensor.size() == 1)
{
forAllIter(typename Map<T>, field, iter)
{
iter() = transform(rotTensor[0], iter());
}
transformList(rotTensor[0], field);
}
else
{
......@@ -117,7 +112,8 @@ void Foam::transformList(const tensor& rotTensor, EdgeMap<T>& 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<T>& field)
{
if (rotTensor.size() == 1)
{
forAllIter(typename EdgeMap<T>, field, iter)
{
iter() = transform(rotTensor[0], iter());
}
transformList(rotTensor[0], field);
}
else
{
......
......@@ -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<class T>
List<T> transform
(
const tensor& rotTensor,
const UList<T>& field
);
//- Apply transformation to list. Either single transformation tensor
// or one tensor per element.
List<T> transform(const tensor& rotTensor, const UList<T>& field);
//- Inplace transform a list of elements.
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>
void transformList(const tensorField&, UList<T>&);
void transformList(const tensorField& rotTensor, UList<T>& field);
//- Inplace transform a Map of elements.
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>
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>
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>
void transformList(const tensorField&, EdgeMap<T>&);
// Specialisations for bool
template<>
inline void transformList(const tensor&, UList<bool>&)
{}
template<>
inline void transformList(const tensorField&, UList<bool>&)
{}
template<>
inline void transformList(const tensor&, Map<bool>&)
{}
template<>
inline void transformList(const tensorField&, Map<bool>&)
{}
template<>
inline void transformList(const tensor&, EdgeMap<bool>&)
{}
template<>
inline void transformList(const tensorField&, EdgeMap<bool>&)
{}
// Specialisations for label
template<>
inline void transformList(const tensor&, labelUList&)
{}
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>&)
{}
void transformList(const tensorField& rotTensor, EdgeMap<T>& field);
// Specialisations for bool (no-op)
template<> inline void transformList(const tensor&, UList<bool>&) {}
template<> inline void transformList(const tensorField&, UList<bool>&) {}
template<> inline void transformList(const tensor&, Map<bool>&) {}
template<> inline void transformList(const tensorField&, Map<bool>&) {}
template<> inline void transformList(const tensor&, EdgeMap<bool>&) {}
template<> inline void transformList(const tensorField&, EdgeMap<bool>&) {}
// Specialisations for label (no-op)
template<> inline void transformList(const tensor&, labelUList&) {}
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 (no-op)
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)
}
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)
{
return i;
}
//- No-op rotational transform of a label
inline scalar transform(const tensor&, const scalar s)
{
return s;
}
//- Use rotational tensor to transform a vector.
// Same as (rot & v)
template<class Cmpt>
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>
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>
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>
inline SymmTensor<Cmpt> transform(const tensor& tt, const SymmTensor<Cmpt>& st)
{
......@@ -292,16 +302,16 @@ inline scalar pseudoAngle
const vector& vec
)
{
scalar cos = vec & e0;
scalar sin = vec & e1;
const scalar cos_angle = vec & e0;
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
{
return (1.0 - cos)*constant::mathematical::piByTwo;
return (1.0 - cos_angle)*constant::mathematical::piByTwo;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment