transformList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2015 OpenFOAM Foundation
9  Copyright (C) 2018-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "transformList.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 template<class T>
35 (
36  const tensor& rotTensor,
37  const UList<T>& field
38 )
39 {
40  const label loopLen = field.size();
41 
42  List<T> result(loopLen);
43 
44  /* pragmas... */
45  for (label i = 0; i < loopLen; ++i)
46  {
47  result[i] = transform(rotTensor, field[i]);
48  }
49 
50  return result;
51 }
52 
53 
54 template<class T>
55 void Foam::transformList(const tensor& rotTensor, UList<T>& field)
56 {
57  const label loopLen = field.size();
58 
59  /* pragmas... */
60  for (label i = 0; i < loopLen; ++i)
61  {
62  field[i] = transform(rotTensor, field[i]);
63  }
64 }
65 
66 
67 template<class T>
68 void Foam::transformList(const tensorField& rotTensor, UList<T>& field)
69 {
70  if (rotTensor.size() == 1)
71  {
72  transformList(rotTensor.front(), field);
73  }
74  else if (rotTensor.size() == field.size())
75  {
76  const label loopLen = field.size();
77 
78  /* pragmas... */
79  for (label i = 0; i < loopLen; ++i)
80  {
81  field[i] = transform(rotTensor[i], field[i]);
82  }
83  }
84  else
85  {
87  << "Sizes of field and transformation not equal. field:"
88  << field.size() << " transformation:" << rotTensor.size()
89  << abort(FatalError);
90  }
91 }
92 
93 
94 template<class T>
95 void Foam::transformList(const tensor& rotTensor, Map<T>& field)
96 {
97  forAllIters(field, iter)
98  {
99  T& value = iter.val();
100  value = transform(rotTensor, value);
101  }
102 }
103 
104 
105 template<class T>
106 void Foam::transformList(const tensorField& rotTensor, Map<T>& field)
107 {
108  if (rotTensor.size() == 1)
109  {
110  transformList(rotTensor.front(), field);
111  }
112  else
113  {
115  << "Multiple transformation tensors not supported. field:"
116  << field.size() << " transformation:" << rotTensor.size()
117  << abort(FatalError);
118  }
119 }
120 
121 
122 template<class T>
123 void Foam::transformList(const tensor& rotTensor, EdgeMap<T>& field)
124 {
125  forAllIters(field, iter)
126  {
127  T& value = iter.val();
128  value = transform(rotTensor, value);
129  }
130 }
131 
132 
133 template<class T>
134 void Foam::transformList(const tensorField& rotTensor, EdgeMap<T>& field)
135 {
136  if (rotTensor.size() == 1)
137  {
138  transformList(rotTensor.front(), field);
139  }
140  else
141  {
143  << "Multiple transformation tensors not supported. field:"
144  << field.size() << " transformation:" << rotTensor.size()
145  << abort(FatalError);
146  }
147 }
148 
149 
150 // ************************************************************************* //
rDeltaTY field()
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
Tensor< scalar > tensor
Definition: symmTensor.H:57
#define forAllIters(container, iter)
Iterate across all elements in the container object.
Definition: stdFoam.H:336
errorManip< error > abort(error &err)
Definition: errorManip.H:139
const volScalarField & T
Spatial transformation functions for list of values and primitive fields.
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
void transformList(const tensor &rotTensor, UList< T > &field)
Inplace transform a list of elements.
Definition: transformList.C:48
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521