FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/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>
50 (
51  const tensorField& rotTensor,
52  UList<T>& field
53 )
54 {
55  if (rotTensor.size() == 1)
56  {
57  forAll(field, i)
58  {
59  field[i] = transform(rotTensor[0], field[i]);
60  }
61  }
62  else if (rotTensor.size() == field.size())
63  {
64  forAll(field, i)
65  {
66  field[i] = transform(rotTensor[i], field[i]);
67  }
68  }
69  else
70  {
72  (
73  "transformList(const tensorField&, UList<T>&)"
74  ) << "Sizes of field and transformation not equal. field:"
75  << field.size() << " transformation:" << rotTensor.size()
76  << abort(FatalError);
77  }
78 }
79 
80 
81 template <class T>
83 (
84  const tensorField& rotTensor,
85  Map<T>& field
86 )
87 {
88  if (rotTensor.size() == 1)
89  {
90  forAllIter(typename Map<T>, field, iter)
91  {
92  iter() = transform(rotTensor[0], iter());
93  }
94  }
95  else
96  {
98  (
99  "transformList(const tensorField&, Map<T>&)"
100  ) << "Multiple transformation tensors not supported. field:"
101  << field.size() << " transformation:" << rotTensor.size()
102  << abort(FatalError);
103  }
104 }
105 
106 
107 template <class T>
109 (
110  const tensorField& rotTensor,
111  EdgeMap<T>& field
112 )
113 {
114  if (rotTensor.size() == 1)
115  {
116  forAllIter(typename EdgeMap<T>, field, iter)
117  {
118  iter() = transform(rotTensor[0], iter());
119  }
120  }
121  else
122  {
124  (
125  "transformList(const tensorField&, EdgeMap<T>&)"
126  ) << "Multiple transformation tensors not supported. field:"
127  << field.size() << " transformation:" << rotTensor.size()
128  << abort(FatalError);
129  }
130 }
131 
132 
133 // ************************ vim: set sw=4 sts=4 et: ************************ //