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 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  List<T> result(field.size());
41 
42  forAll(field, i)
43  {
44  result[i] = transform(rotTensor, field[i]);
45  }
46 
47  return result;
48 }
49 
50 
51 template<class T>
52 void Foam::transformList(const tensor& rotTensor, UList<T>& field)
53 {
54  forAll(field, i)
55  {
56  field[i] = transform(rotTensor, field[i]);
57  }
58 }
59 
60 
61 template<class T>
63 {
64  if (rotTensor.size() == 1)
65  {
66  transformList(rotTensor[0], field);
67  }
68  else if (rotTensor.size() == field.size())
69  {
70  forAll(field, i)
71  {
72  field[i] = transform(rotTensor[i], field[i]);
73  }
74  }
75  else
76  {
78  << "Sizes of field and transformation not equal. field:"
79  << field.size() << " transformation:" << rotTensor.size()
80  << abort(FatalError);
81  }
82 }
83 
84 
85 template<class T>
86 void Foam::transformList(const tensor& rotTensor, Map<T>& field)
87 {
88  forAllIters(field, iter)
89  {
90  T& value = iter.val();
91  value = transform(rotTensor, value);
92  }
93 }
94 
95 
96 template<class T>
97 void Foam::transformList(const tensorField& rotTensor, Map<T>& field)
98 {
99  if (rotTensor.size() == 1)
100  {
101  transformList(rotTensor[0], field);
102  }
103  else
104  {
106  << "Multiple transformation tensors not supported. field:"
107  << field.size() << " transformation:" << rotTensor.size()
108  << abort(FatalError);
109  }
110 }
111 
112 
113 template<class T>
114 void Foam::transformList(const tensor& rotTensor, EdgeMap<T>& field)
115 {
116  forAllIters(field, iter)
117  {
118  T& value = iter.val();
119  value = transform(rotTensor, value);
120  }
121 }
122 
123 
124 template<class T>
126 {
127  if (rotTensor.size() == 1)
128  {
129  transformList(rotTensor[0], field);
130  }
131  else
132  {
134  << "Multiple transformation tensors not supported. field:"
135  << field.size() << " transformation:" << rotTensor.size()
136  << abort(FatalError);
137  }
138 }
139 
140 
141 // ************************************************************************* //
Foam::Tensor< scalar >
Foam::Map
A HashTable to objects of type <T> with a label key.
Definition: lumpedPointController.H:69
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::transformList
void transformList(const tensor &rotTensor, UList< T > &field)
Inplace transform a list of elements.
Definition: transformList.C:52
Foam::Field< tensor >
field
rDeltaTY field()
forAllIters
#define forAllIters(container, iter)
Iterate across all elements in the container object.
Definition: stdFoam.H:223
Foam::FatalError
error FatalError
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
T
const volScalarField & T
Definition: createFieldRefs.H:2
Foam::EdgeMap
Map from edge (expressed as its endpoints) to value. For easier forward declaration it is currently i...
Definition: EdgeMap.H:51
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:103
transformList.H
Spatial transformation functions for list of values and primitive fields.
Foam::tensor
Tensor< scalar > tensor
Tensor of scalars, i.e. Tensor<scalar>.
Definition: symmTensor.H:61