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 {
42  // std::transform
44  (
45  Type, result, =, transform, tensor, rot, Type, fld
46  );
47 }
48 
49 
50 template<class Type>
51 void Foam::transform
52 (
53  Field<Type>& result,
54  const tensorField& rot,
55  const Field<Type>& fld
56 )
57 {
58  if (rot.size() == 1)
59  {
60  return transform(result, rot.front(), fld);
61  }
62 
63  // std::transform
65  (
66  Type, result, =, transform, tensor, rot, Type, fld
67  );
68 }
69 
70 
71 template<class Type>
74 (
75  const tensorField& rot,
76  const Field<Type>& fld
77 )
78 {
79  auto tresult = tmp<Field<Type>>::New(fld.size());
80  transform(tresult.ref(), rot, fld);
81  return tresult;
82 }
83 
84 
85 template<class Type>
88 (
89  const tensorField& rot,
90  const tmp<Field<Type>>& tfld
91 )
92 {
93  tmp<Field<Type>> tresult = New(tfld);
94  transform(tresult.ref(), rot, tfld());
95  tfld.clear();
96  return tresult;
97 }
98 
99 
100 template<class Type>
103 (
104  const tmp<tensorField>& trot,
105  const Field<Type>& fld
106 )
107 {
108  auto tresult = tmp<Field<Type>>::New(fld.size());
109  transform(tresult.ref(), trot(), fld);
110  trot.clear();
111  return tresult;
112 }
113 
114 
115 template<class Type>
118 (
119  const tmp<tensorField>& trot,
120  const tmp<Field<Type>>& tfld
121 )
122 {
123  tmp<Field<Type>> tresult = New(tfld);
124  transform(tresult.ref(), trot(), tfld());
125  trot.clear();
126  tfld.clear();
127  return tresult;
128 }
129 
130 
131 template<class Type>
134 (
135  const tensor& rot,
136  const Field<Type>& fld
137 )
138 {
139  auto tresult = tmp<Field<Type>>::New(fld.size());
140  transform(tresult.ref(), rot, fld);
141  return tresult;
142 }
143 
144 
145 template<class Type>
148 (
149  const tensor& rot,
150  const tmp<Field<Type>>& tfld
151 )
152 {
153  tmp<Field<Type>> tresult = New(tfld);
154  transform(tresult.ref(), rot, tfld());
155  tfld.clear();
156  return tresult;
157 }
158 
159 
160 template<class Type>
162 (
163  Field<Type>& result,
164  const tensor& rot,
165  const Field<Type>& fld
166 )
167 {
168  // std::transform
170  (
171  Type, result, =, invTransform, tensor, rot, Type, fld
172  );
173 }
174 
175 
176 template<class Type>
178 (
179  Field<Type>& result,
180  const tensorField& rot,
181  const Field<Type>& fld
182 )
183 {
184  if (rot.size() == 1)
185  {
186  return invTransform(result, rot.front(), fld);
187  }
188 
189  // std::transform
191  (
192  Type, result, =, invTransform, tensor, rot, Type, fld
193  );
194 }
195 
196 
197 template<class Type>
200 (
201  const tensorField& rot,
202  const Field<Type>& fld
203 )
204 {
205  auto tresult = tmp<Field<Type>>::New(fld.size());
206  invTransform(tresult.ref(), rot, fld);
207  return tresult;
208 }
209 
210 
211 template<class Type>
214 (
215  const tensorField& rot,
216  const tmp<Field<Type>>& tfld
217 )
218 {
219  tmp<Field<Type>> tresult = New(tfld);
220  invTransform(tresult.ref(), rot, tfld());
221  tfld.clear();
222  return tresult;
223 }
224 
225 
226 template<class Type>
229 (
230  const tmp<tensorField>& trot,
231  const Field<Type>& fld
232 )
233 {
234  auto tresult = tmp<Field<Type>>::New(fld.size());
235  invTransform(tresult.ref(), trot(), fld);
236  trot.clear();
237  return tresult;
238 }
239 
240 
241 template<class Type>
244 (
245  const tmp<tensorField>& trot,
246  const tmp<Field<Type>>& tfld
247 )
248 {
249  tmp<Field<Type>> tresult = New(tfld);
250  invTransform(tresult.ref(), trot(), tfld());
251  trot.clear();
252  tfld.clear();
253  return tresult;
254 }
255 
256 
257 template<class Type>
260 (
261  const tensor& rot,
262  const Field<Type>& fld
263 )
264 {
265  auto tresult = tmp<Field<Type>>::New(fld.size());
266  invTransform(tresult.ref(), rot, fld);
267  return tresult;
268 }
269 
270 
271 template<class Type>
274 (
275  const tensor& rot,
276  const tmp<Field<Type>>& tfld
277 )
278 {
279  tmp<Field<Type>> tresult = New(tfld);
280  invTransform(tresult.ref(), rot, tfld());
281  tfld.clear();
282  return tresult;
283 }
284 
285 
286 template<class Type1, class Type2>
288 Foam::transformFieldMask(const Field<Type2>& fld)
289 {
290  return fld;
291 }
292 
293 template<class Type1, class Type2>
295 Foam::transformFieldMask(const tmp<Field<Type2>>& tfld)
296 {
297  return tmp<Field<Type1>>(tfld.ptr());
298 }
299 
300 
301 // ************************************************************************* //
#define TFOR_ALL_F_OP_FUNC_F_F(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3)
Definition: FieldM.H:192
dimensionSet invTransform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:527
Tensor< scalar > tensor
Definition: symmTensor.H:57
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
tmp< Field< Type1 > > transformFieldMask(const Field< Type2 > &fld)
Spatial transformation functions for primitive fields.
Generic templated field type.
Definition: Field.H:62
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))
#define TFOR_ALL_F_OP_FUNC_S_F(typeF1, f1, OP, FUNC, typeS, s, typeF2, f2)
Definition: FieldM.H:277
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
void clear()
Clear exponents - resets to be dimensionless.
Definition: dimensionSet.C:136
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Declaration macros for Field<Type> algebra.
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521
Tensor of scalars, i.e. Tensor<scalar>.