transformFieldField.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 "transformFieldField.H"
30 
31 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
32 
33 template<template<class> class Field, class Type>
34 void Foam::transform
35 (
37  const tensor& rot,
39 )
40 {
41  forAll(result, i)
42  {
43  transform(result[i], rot, fld[i]);
44  }
45 }
46 
47 
48 template<template<class> class Field, class Type>
49 void Foam::transform
50 (
52  const FieldField<Field, tensor>& rot,
54 )
55 {
56  forAll(result, i)
57  {
58  transform(result[i], rot[i], fld[i]);
59  }
60 }
61 
62 
63 template<template<class> class Field, class Type>
66 (
67  const FieldField<Field, tensor>& rot,
68  const FieldField<Field, Type>& fld
69 )
70 {
71  tmp<FieldField<Field, Type>> tranf
72  (
73  FieldField<Field, Type>::NewCalculatedType(fld)
74  );
75  transform(tranf(), rot, fld);
76  return tranf;
77 }
78 
79 
80 template<template<class> class Field, class Type>
83 (
84  const FieldField<Field, tensor>& rot,
85  const tmp<FieldField<Field, Type>>& tfld
86 )
87 {
88  tmp<FieldField<Field, Type>> tresult(tfld.ptr());
89  transform(tresult(), rot, tresult());
90  return tresult;
91 }
92 
93 
94 template<template<class> class Field, class Type>
97 (
98  const tmp<FieldField<Field, tensor>>& trot,
99  const FieldField<Field, Type>& fld
100 )
101 {
102  tmp<FieldField<Field, Type>> tresult
103  (
104  FieldField<Field, Type>::NewCalculatedType(fld)
105  );
106  transform(tresult(), trot(), fld);
107  trot.clear();
108  return tresult;
109 }
110 
111 
112 template<template<class> class Field, class Type>
115 (
116  const tmp<FieldField<Field, tensor>>& trot,
117  const tmp<FieldField<Field, Type>>& tfld
118 )
119 {
120  tmp<FieldField<Field, Type>> tresult(tfld.ptr());
121  transform(tresult(), trot(), tresult());
122  trot.clear();
123  return tresult;
124 }
125 
126 
127 template<template<class> class Field, class Type>
130 (
131  const tensor& rot,
132  const FieldField<Field, Type>& fld
133 )
134 {
135  tmp<FieldField<Field, Type>> tresult
136  (
137  FieldField<Field, Type>::NewCalculatedType(fld)
138  );
139  transform(tresult(), rot, fld);
140  return tresult;
141 }
142 
143 
144 template<template<class> class Field, class Type>
147 (
148  const tensor& rot,
149  const tmp<FieldField<Field, Type>>& tfld
150 )
151 {
152  tmp<FieldField<Field, Type>> tresult(tfld.ptr());
153  transform(tresult(), rot, tresult());
154  return tresult;
155 }
156 
157 
158 template<template<class> class Field, class Type>
160 (
161  FieldField<Field, Type>& result,
162  const tensor& rot,
164 )
165 {
166  forAll(result, i)
167  {
168  invTransform(result[i], rot, fld[i]);
169  }
170 }
171 
172 
173 template<template<class> class Field, class Type>
175 (
176  FieldField<Field, Type>& result,
177  const FieldField<Field, tensor>& rot,
179 )
180 {
181  forAll(result, i)
182  {
183  invTransform(result[i], rot[i], fld[i]);
184  }
185 }
186 
187 
188 template<template<class> class Field, class Type>
191 (
192  const FieldField<Field, tensor>& rot,
193  const FieldField<Field, Type>& fld
194 )
195 {
196  tmp<FieldField<Field, Type>> tranf
197  (
198  FieldField<Field, Type>::NewCalculatedType(fld)
199  );
200  invTransform(tranf(), rot, fld);
201  return tranf;
202 }
203 
204 
205 template<template<class> class Field, class Type>
208 (
209  const FieldField<Field, tensor>& rot,
210  const tmp<FieldField<Field, Type>>& tfld
211 )
212 {
213  tmp<FieldField<Field, Type>> tresult(tfld.ptr());
214  invTransform(tresult(), rot, tresult());
215  return tresult;
216 }
217 
218 
219 template<template<class> class Field, class Type>
222 (
223  const tmp<FieldField<Field, tensor>>& trot,
224  const FieldField<Field, Type>& fld
225 )
226 {
227  tmp<FieldField<Field, Type>> tresult
228  (
229  FieldField<Field, Type>::NewCalculatedType(fld)
230  );
231  invTransform(tresult(), trot(), fld);
232  trot.clear();
233  return tresult;
234 }
235 
236 
237 template<template<class> class Field, class Type>
240 (
241  const tmp<FieldField<Field, tensor>>& trot,
242  const tmp<FieldField<Field, Type>>& tfld
243 )
244 {
245  tmp<FieldField<Field, Type>> tresult(tfld.ptr());
246  invTransform(tresult(), trot(), tresult());
247  trot.clear();
248  return tresult;
249 }
250 
251 
252 template<template<class> class Field, class Type>
255 (
256  const tensor& rot,
257  const FieldField<Field, Type>& fld
258 )
259 {
260  tmp<FieldField<Field, Type>> tresult
261  (
262  FieldField<Field, Type>::NewCalculatedType(fld)
263  );
264  invTransform(tresult(), rot, fld);
265  return tresult;
266 }
267 
268 
269 template<template<class> class Field, class Type>
272 (
273  const tensor& rot,
274  const tmp<FieldField<Field, Type>>& tfld
275 )
276 {
277  tmp<FieldField<Field, Type>> tresult(tfld.ptr());
278  invTransform(tresult(), rot, tresult());
279  return tresult;
280 }
281 
282 
283 // ************************************************************************* //
Foam::Tensor< scalar >
Foam::FieldField
A field of fields is a PtrList of fields with reference counting.
Definition: FieldField.H:53
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:519
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
transformFieldField.H
transformFieldField Spatial transformation functions for FieldField.
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::invTransform
dimensionSet invTransform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:525
Foam::tensor
Tensor< scalar > tensor
Tensor of scalars, i.e. Tensor<scalar>.
Definition: symmTensor.H:61