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 -------------------------------------------------------------------------------
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 "transformField.H"
30 #include "FieldM.H"
31 
32 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
33 
34 template<class Type>
35 void Foam::transform
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 
49 template<class Type>
50 void Foam::transform
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 
69 template<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 
83 template<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 
98 template<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 
113 template<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 
129 template<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 
143 template<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 
158 template<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 
173 template<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 
193 template<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 
207 template<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 
222 template<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 
237 template<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 
253 template<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 
267 template<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 
282 template<class Type1, class Type2>
284 Foam::transformFieldMask(const Field<Type2>& fld)
285 {
286  return fld;
287 }
288 
289 template<class Type1, class Type2>
291 Foam::transformFieldMask(const tmp<Field<Type2>>& tfld)
292 {
293  return tmp<Field<Type1>>(tfld.ptr());
294 }
295 
296 
297 // ************************************************************************* //
Foam::Tensor< scalar >
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
FieldM.H
High performance macro functions for Field<Type> algebra. These expand using either array element acc...
Foam::tensorField
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
Definition: primitiveFieldsFwd.H:57
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:519
transformField.H
Spatial transformation functions for primitive fields.
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::dimensionSet::clear
void clear()
Reset exponents to be dimensionless.
Definition: dimensionSet.C:141
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::transformFieldMask
tmp< Field< Type1 > > transformFieldMask(const Field< Type2 > &fld)
TFOR_ALL_F_OP_FUNC_S_F
#define TFOR_ALL_F_OP_FUNC_S_F(typeF1, f1, OP, FUNC, typeS, s, typeF2, f2)
Definition: FieldM.H:219
Foam::invTransform
dimensionSet invTransform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:525
TFOR_ALL_F_OP_FUNC_F_F
#define TFOR_ALL_F_OP_FUNC_F_F(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3)
Definition: FieldM.H:150
Foam::tensor
Tensor< scalar > tensor
Tensor of scalars, i.e. Tensor<scalar>.
Definition: symmTensor.H:61