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-------------------------------------------------------------------------------
11License
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
33template<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
51template<class T>
52void 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
61template<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
85template<class T>
86void 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
96template<class T>
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
113template<class T>
115{
116 forAllIters(field, iter)
117 {
118 T& value = iter.val();
119 value = transform(rotTensor, value);
120 }
121}
122
123
124template<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// ************************************************************************* //
Map from edge (expressed as its endpoints) to value. For easier forward declaration it is currently i...
Definition: EdgeMap.H:54
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Tensor of scalars, i.e. Tensor<scalar>.
const volScalarField & T
rDeltaTY field()
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:536
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
void transformList(const tensor &rotTensor, UList< T > &field)
Inplace transform a list of elements.
Definition: transformList.C:52
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
#define forAllIters(container, iter)
Iterate across all elements in the container object.
Definition: stdFoam.H:260
Spatial transformation functions for list of values and primitive fields.