Loading...
Searching...
No Matches
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-2023 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 const label loopLen = field.size();
41
42 List<T> result(loopLen);
43
44 /* pragmas... */
45 for (label i = 0; i < loopLen; ++i)
46 {
47 result[i] = transform(rotTensor, field[i]);
48 }
49
50 return result;
51}
52
53
54template<class T>
55void Foam::transformList(const tensor& rotTensor, UList<T>& field)
56{
57 const label loopLen = field.size();
58
59 /* pragmas... */
60 for (label i = 0; i < loopLen; ++i)
61 {
62 field[i] = transform(rotTensor, field[i]);
63 }
64}
65
66
67template<class T>
68void Foam::transformList(const tensorField& rotTensor, UList<T>& field)
69{
70 if (rotTensor.size() == 1)
71 {
72 transformList(rotTensor.front(), field);
73 }
74 else if (rotTensor.size() == field.size())
75 {
76 const label loopLen = field.size();
77
78 /* pragmas... */
79 for (label i = 0; i < loopLen; ++i)
80 {
81 field[i] = transform(rotTensor[i], field[i]);
82 }
83 }
84 else
85 {
87 << "Sizes of field and transformation not equal. field:"
88 << field.size() << " transformation:" << rotTensor.size()
89 << abort(FatalError);
90 }
91}
92
93
94template<class T>
95void Foam::transformList(const tensor& rotTensor, Map<T>& field)
96{
97 forAllIters(field, iter)
98 {
99 T& value = iter.val();
100 value = transform(rotTensor, value);
101 }
102}
103
104
105template<class T>
106void Foam::transformList(const tensorField& rotTensor, Map<T>& field)
107{
108 if (rotTensor.size() == 1)
109 {
110 transformList(rotTensor.front(), field);
111 }
112 else
113 {
115 << "Multiple transformation tensors not supported. field:"
116 << field.size() << " transformation:" << rotTensor.size()
117 << abort(FatalError);
118 }
119}
120
121
122template<class T>
123void Foam::transformList(const tensor& rotTensor, EdgeMap<T>& field)
124{
125 forAllIters(field, iter)
126 {
127 T& value = iter.val();
128 value = transform(rotTensor, value);
129 }
130}
131
132
133template<class T>
134void Foam::transformList(const tensorField& rotTensor, EdgeMap<T>& field)
135{
136 if (rotTensor.size() == 1)
137 {
138 transformList(rotTensor.front(), field);
139 }
140 else
141 {
143 << "Multiple transformation tensors not supported. field:"
144 << field.size() << " transformation:" << rotTensor.size()
145 << abort(FatalError);
146 }
147}
148
149
150// ************************************************************************* //
Map from edge (expressed as its endpoints) to value. Hashing (and ==) on an edge is symmetric.
Definition edgeHashes.H:59
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
A HashTable to objects of type <T> with a label key.
Definition Map.H:54
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:89
T & front()
Access first element of the list, position [0].
Definition UListI.H:239
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
Tensor of scalars, i.e. Tensor<scalar>.
rDeltaTY field()
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
Tensor< scalar > tensor
Definition symmTensor.H:57
errorManip< error > abort(error &err)
Definition errorManip.H:139
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
void transformList(const tensor &rotTensor, UList< T > &field)
Inplace transform a list of elements.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
#define forAllIters(container, iter)
Iterate across all elements in the container object.
Definition stdFoam.H:214
Spatial transformation functions for list of values and primitive fields.