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>
62 void Foam::transformList(const tensorField& rotTensor, UList<T>& field)
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>
125 void Foam::transformList(const tensorField& rotTensor, EdgeMap<T>& field)
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
A templated (3 x 3) tensor of objects of <T> derived from MatrixSpace.
Definition: complexI.H:268
Foam::tensorField
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
Definition: primitiveFieldsFwd.H:51
Foam::Map< T >
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Definition: dimensionSet.C:514
forAll
#define forAll(list, i)
Definition: stdFoam.H:349
Foam::transformList
void transformList(const tensor &rotTensor, UList< T > &field)
Definition: transformList.C:45
Foam::Field
Generic templated field type.
Definition: Field.H:59
field
rDeltaTY field()
forAllIters
#define forAllIters(container, iter)
Definition: stdFoam.H:264
Foam::FatalError
error FatalError
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:139
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:45
FatalErrorInFunction
#define FatalErrorInFunction
Definition: error.H:465
Foam::List< T >
Foam::UList< T >
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:57