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 | Copyright (C) 2011-2013 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "transformList.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 template<class T>
32 (
33  const tensor& rotTensor,
34  const UList<T>& field
35 )
36 {
37  List<T> newField(field.size());
38 
39  forAll(field, i)
40  {
41  newField[i] = transform(rotTensor, field[i]);
42  }
43 
44  return newField;
45 }
46 
47 
48 template<class T>
49 void Foam::transformList(const tensor& rotTensor, UList<T>& field)
50 {
51  forAll(field, i)
52  {
53  field[i] = transform(rotTensor, field[i]);
54  }
55 }
56 
57 
58 template<class T>
59 void Foam::transformList(const tensorField& rotTensor, UList<T>& field)
60 {
61  if (rotTensor.size() == 1)
62  {
63  forAll(field, i)
64  {
65  field[i] = transform(rotTensor[0], field[i]);
66  }
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  (
79  "transformList(const tensorField&, UList<T>&)"
80  ) << "Sizes of field and transformation not equal. field:"
81  << field.size() << " transformation:" << rotTensor.size()
82  << abort(FatalError);
83  }
84 }
85 
86 
87 template<class T>
88 void Foam::transformList(const tensor& rotTensor, Map<T>& field)
89 {
90  forAllIter(typename Map<T>, field, iter)
91  {
92  iter() = transform(rotTensor[0], iter());
93  }
94 }
95 
96 
97 template<class T>
98 void Foam::transformList(const tensorField& rotTensor, Map<T>& field)
99 {
100  if (rotTensor.size() == 1)
101  {
102  forAllIter(typename Map<T>, field, iter)
103  {
104  iter() = transform(rotTensor[0], iter());
105  }
106  }
107  else
108  {
110  (
111  "transformList(const tensorField&, Map<T>&)"
112  ) << "Multiple transformation tensors not supported. field:"
113  << field.size() << " transformation:" << rotTensor.size()
114  << abort(FatalError);
115  }
116 }
117 
118 
119 template<class T>
120 void Foam::transformList(const tensor& rotTensor, EdgeMap<T>& field)
121 {
122  forAllIter(typename EdgeMap<T>, field, iter)
123  {
124  iter() = transform(rotTensor[0], iter());
125  }
126 }
127 
128 
129 template<class T>
130 void Foam::transformList(const tensorField& rotTensor, EdgeMap<T>& field)
131 {
132  if (rotTensor.size() == 1)
133  {
134  forAllIter(typename EdgeMap<T>, field, iter)
135  {
136  iter() = transform(rotTensor[0], iter());
137  }
138  }
139  else
140  {
142  (
143  "transformList(const tensorField&, EdgeMap<T>&)"
144  ) << "Multiple transformation tensors not supported. field:"
145  << field.size() << " transformation:" << rotTensor.size()
146  << abort(FatalError);
147  }
148 }
149 
150 
151 // ************************************************************************* //
Map from edge (expressed as its endpoints) to value.
Definition: EdgeMap.H:47
Tensor< scalar > tensor
Tensor of scalars.
Definition: tensor.H:51
A HashTable to objects of type <T> with a label key.
Definition: Map.H:49
#define forAllIter(Container, container, iter)
Definition: UList.H:440
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:465
#define forAll(list, i)
Definition: UList.H:421
label size() const
Return the number of elements in the UList.
Definition: UListI.H:299
label size() const
Return number of elements in table.
errorManip< error > abort(error &err)
Definition: errorManip.H:131
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
void transformList(const tensor &, UList< T > &)
Apply transformation to list. Either single transformation tensor.
Definition: transformList.C:49
error FatalError
Spatial transformation functions for primitive fields.
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:60