transformFieldTemplates.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-2016 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 "transformField.H"
30#include "FieldM.H"
31
32// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
33
34template<class Type>
36(
37 Field<Type>& result,
38 const tensor& rot,
39 const Field<Type>& fld
40)
41{
43 (
44 Type, result, =, transform, tensor, rot, Type, fld
45 );
46}
47
48
49template<class Type>
51(
52 Field<Type>& result,
53 const tensorField& rot,
54 const Field<Type>& fld
55)
56{
57 if (rot.size() == 1)
58 {
59 return transform(result, rot.first(), fld);
60 }
61
63 (
64 Type, result, =, transform, tensor, rot, Type, fld
65 );
66}
67
68
69template<class Type>
72(
73 const tensorField& rot,
74 const Field<Type>& fld
75)
76{
77 auto tresult = tmp<Field<Type>>::New(fld.size());
78 transform(tresult.ref(), rot, fld);
79 return tresult;
80}
81
82
83template<class Type>
86(
87 const tensorField& rot,
88 const tmp<Field<Type>>& tfld
89)
90{
91 tmp<Field<Type>> tresult = New(tfld);
92 transform(tresult.ref(), rot, tfld());
93 tfld.clear();
94 return tresult;
95}
96
97
98template<class Type>
101(
102 const tmp<tensorField>& trot,
103 const Field<Type>& fld
104)
105{
106 auto tresult = tmp<Field<Type>>::New(fld.size());
107 transform(tresult.ref(), trot(), fld);
108 trot.clear();
109 return tresult;
110}
111
112
113template<class Type>
116(
117 const tmp<tensorField>& trot,
118 const tmp<Field<Type>>& tfld
119)
120{
121 tmp<Field<Type>> tresult = New(tfld);
122 transform(tresult.ref(), trot(), tfld());
123 trot.clear();
124 tfld.clear();
125 return tresult;
126}
127
128
129template<class Type>
132(
133 const tensor& rot,
134 const Field<Type>& fld
135)
136{
137 auto tresult = tmp<Field<Type>>::New(fld.size());
138 transform(tresult.ref(), rot, fld);
139 return tresult;
140}
141
142
143template<class Type>
146(
147 const tensor& rot,
148 const tmp<Field<Type>>& tfld
149)
150{
151 tmp<Field<Type>> tresult = New(tfld);
152 transform(tresult.ref(), rot, tfld());
153 tfld.clear();
154 return tresult;
155}
156
157
158template<class Type>
160(
161 Field<Type>& result,
162 const tensor& rot,
163 const Field<Type>& fld
164)
165{
167 (
168 Type, result, =, invTransform, tensor, rot, Type, fld
169 );
170}
171
172
173template<class Type>
175(
176 Field<Type>& result,
177 const tensorField& rot,
178 const Field<Type>& fld
179)
180{
181 if (rot.size() == 1)
182 {
183 return invTransform(result, rot.first(), fld);
184 }
185
187 (
188 Type, result, =, invTransform, tensor, rot, Type, fld
189 );
190}
191
192
193template<class Type>
196(
197 const tensorField& rot,
198 const Field<Type>& fld
199)
200{
201 auto tresult = tmp<Field<Type>>::New(fld.size());
202 invTransform(tresult.ref(), rot, fld);
203 return tresult;
204}
205
206
207template<class Type>
210(
211 const tensorField& rot,
212 const tmp<Field<Type>>& tfld
213)
214{
215 tmp<Field<Type>> tresult = New(tfld);
216 invTransform(tresult.ref(), rot, tfld());
217 tfld.clear();
218 return tresult;
219}
220
221
222template<class Type>
225(
226 const tmp<tensorField>& trot,
227 const Field<Type>& fld
228)
229{
230 auto tresult = tmp<Field<Type>>::New(fld.size());
231 invTransform(tresult.ref(), trot(), fld);
232 trot.clear();
233 return tresult;
234}
235
236
237template<class Type>
240(
241 const tmp<tensorField>& trot,
242 const tmp<Field<Type>>& tfld
243)
244{
245 tmp<Field<Type>> tresult = New(tfld);
246 invTransform(tresult.ref(), trot(), tfld());
247 trot.clear();
248 tfld.clear();
249 return tresult;
250}
251
252
253template<class Type>
256(
257 const tensor& rot,
258 const Field<Type>& fld
259)
260{
261 auto tresult = tmp<Field<Type>>::New(fld.size());
262 invTransform(tresult.ref(), rot, fld);
263 return tresult;
264}
265
266
267template<class Type>
270(
271 const tensor& rot,
272 const tmp<Field<Type>>& tfld
273)
274{
275 tmp<Field<Type>> tresult = New(tfld);
276 invTransform(tresult.ref(), rot, tfld());
277 tfld.clear();
278 return tresult;
279}
280
281
282template<class Type1, class Type2>
284Foam::transformFieldMask(const Field<Type2>& fld)
285{
286 return fld;
287}
288
289template<class Type1, class Type2>
291Foam::transformFieldMask(const tmp<Field<Type2>>& tfld)
292{
293 return tmp<Field<Type1>>(tfld.ptr());
294}
295
296
297// ************************************************************************* //
High performance macro functions for Field<Type> algebra. These expand using either array element acc...
#define TFOR_ALL_F_OP_FUNC_F_F(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3)
Definition: FieldM.H:150
#define TFOR_ALL_F_OP_FUNC_S_F(typeF1, f1, OP, FUNC, typeS, s, typeF2, f2)
Definition: FieldM.H:219
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Generic templated field type.
Definition: Field.H:82
T & first()
Return the first element of the list.
Definition: UListI.H:202
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Tensor of scalars, i.e. Tensor<scalar>.
A class for managing temporary objects.
Definition: tmp.H:65
dimensionSet invTransform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:542
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:536
tmp< Field< Type1 > > transformFieldMask(const Field< Type2 > &fld)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Spatial transformation functions for primitive fields.