transformGeometricField.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-2023 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 Description
28  Spatial transformation functions for FieldFields.
29 
30 \*---------------------------------------------------------------------------*/
31 
33 #include "transformField.H"
34 #include "transformFieldField.H"
35 #include "GeometricField.H"
36 
37 // * * * * * * * * * * * * Transform Global Functions * * * * * * * * * * * //
38 
39 template<class Type, template<class> class PatchField, class GeoMesh>
40 void Foam::transform
41 (
43  const dimensionedTensor& rot,
45 )
46 {
47  transform
48  (
49  result.primitiveFieldRef(),
50  rot.value(),
51  fld.primitiveField()
52  );
53  transform
54  (
55  result.boundaryFieldRef(),
56  rot.value(),
57  fld.boundaryField()
58  );
59 }
60 
61 
62 template<class Type, template<class> class PatchField, class GeoMesh>
63 void Foam::transform
64 (
65  GeometricField<Type, PatchField, GeoMesh>& result,
66  const GeometricField<tensor, PatchField, GeoMesh>& rot,
67  const GeometricField<Type, PatchField, GeoMesh>& fld
68 )
69 {
70  transform
71  (
72  result.primitiveFieldRef(),
73  rot.primitiveField(),
74  fld.primitiveField()
75  );
76  transform
77  (
78  result.boundaryFieldRef(),
79  rot.boundaryField(),
80  fld.boundaryField()
81  );
82 }
83 
84 
85 template<class Type, template<class> class PatchField, class GeoMesh>
88 (
89  const GeometricField<tensor, PatchField, GeoMesh>& rot,
90  const GeometricField<Type, PatchField, GeoMesh>& fld
91 )
92 {
94  (
95  "transform(" + rot.name() + ',' + fld.name() + ')',
96  fld.mesh(),
97  fld.dimensions()
98  );
99 
100  transform(tresult.ref(), rot, fld);
101 
102  return tresult;
103 }
104 
105 
106 template<class Type, template<class> class PatchField, class GeoMesh>
109 (
110  const GeometricField<tensor, PatchField, GeoMesh>& rot,
111  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld
112 )
113 {
114  auto tresult = transform(rot, tfld());
115  tfld.clear();
116  return tresult;
117 }
118 
119 
120 template<class Type, template<class> class PatchField, class GeoMesh>
123 (
124  const tmp<GeometricField<tensor, PatchField, GeoMesh>>& trot,
125  const GeometricField<Type, PatchField, GeoMesh>& fld
126 )
127 {
128  auto tresult = transform(trot(), fld);
129  trot.clear();
130  return tresult;
131 }
132 
133 
134 template<class Type, template<class> class PatchField, class GeoMesh>
137 (
138  const tmp<GeometricField<tensor, PatchField, GeoMesh>>& trot,
139  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld
140 )
141 {
142  auto tresult = transform(trot(), tfld());
143  tfld.clear();
144  trot.clear();
145  return tresult;
146 }
147 
148 
149 template<class Type, template<class> class PatchField, class GeoMesh>
152 (
153  const dimensionedTensor& rot,
154  const GeometricField<Type, PatchField, GeoMesh>& fld
155 )
156 {
158  (
159  "transform(" + rot.name() + ',' + fld.name() + ')',
160  fld.mesh(),
161  fld.dimensions()
162  );
163 
164  transform(tresult.ref(), rot, fld);
165 
166  return tresult;
167 }
168 
169 
170 template<class Type, template<class> class PatchField, class GeoMesh>
173 (
174  const dimensionedTensor& rot,
175  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld
176 )
177 {
178  auto tresult = transform(rot, tfld());
179  tfld.clear();
180  return tresult;
181 }
183 
184 // * * * * * * * * * * * invTransform Global Functions * * * * * * * * * * * //
185 
186 template<class Type, template<class> class PatchField, class GeoMesh>
188 (
190  const dimensionedTensor& rot,
192 )
193 {
195  (
196  result.primitiveFieldRef(),
197  rot.value(),
198  fld.primitiveField()
199  );
201  (
202  result.boundaryFieldRef(),
203  rot.value(),
204  fld.boundaryField()
205  );
206 }
207 
208 
209 template<class Type, template<class> class PatchField, class GeoMesh>
211 (
212  GeometricField<Type, PatchField, GeoMesh>& result,
213  const GeometricField<tensor, PatchField, GeoMesh>& rot,
214  const GeometricField<Type, PatchField, GeoMesh>& fld
215 )
216 {
218  (
219  result.primitiveFieldRef(),
220  rot.primitiveField(),
221  fld.primitiveField()
222  );
224  (
225  result.boundaryFieldRef(),
226  rot.boundaryField(),
227  fld.boundaryField()
228  );
229 }
230 
231 
232 template<class Type, template<class> class PatchField, class GeoMesh>
235 (
236  const GeometricField<tensor, PatchField, GeoMesh>& rot,
237  const GeometricField<Type, PatchField, GeoMesh>& fld
238 )
239 {
241  (
242  "invTransform(" + rot.name() + ',' + fld.name() + ')',
243  fld.mesh(),
244  fld.dimensions()
245  );
246 
247  invTransform(tresult.ref(), rot, fld);
248 
249  return tresult;
250 }
251 
252 
253 template<class Type, template<class> class PatchField, class GeoMesh>
256 (
257  const GeometricField<tensor, PatchField, GeoMesh>& rot,
258  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld
259 )
260 {
261  auto tresult = invTransform(rot, tfld());
262  tfld.clear();
263  return tresult;
264 }
265 
266 
267 template<class Type, template<class> class PatchField, class GeoMesh>
270 (
271  const tmp<GeometricField<tensor, PatchField, GeoMesh>>& trot,
272  const GeometricField<Type, PatchField, GeoMesh>& fld
273 )
274 {
275  auto tresult = invTransform(trot(), fld);
276  trot.clear();
277  return tresult;
278 }
279 
280 
281 template<class Type, template<class> class PatchField, class GeoMesh>
284 (
285  const tmp<GeometricField<tensor, PatchField, GeoMesh>>& trot,
286  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld
287 )
288 {
289  auto tresult = invTransform(trot(), tfld());
290  tfld.clear();
291  trot.clear();
292  return tresult;
293 }
294 
295 
296 template<class Type, template<class> class PatchField, class GeoMesh>
299 (
300  const dimensionedTensor& rot,
301  const GeometricField<Type, PatchField, GeoMesh>& fld
302 )
303 {
305  (
306  "invTransform(" + rot.name() + ',' + fld.name() + ')',
307  fld.mesh(),
308  fld.dimensions()
309  );
310 
311  invTransform(tresult.ref(), rot, fld);
312 
313  return tresult;
314 }
315 
316 
317 template<class Type, template<class> class PatchField, class GeoMesh>
320 (
321  const dimensionedTensor& rot,
322  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld
323 )
324 {
325  auto tresult = invTransform(rot, tfld());
326  tfld.clear();
327  return tresult;
328 }
329 
330 
331 // ************************************************************************* //
const Type & value() const noexcept
Return const reference to value.
dimensionSet invTransform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:527
Spatial transformation functions for GeometricField.
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.
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
Generic dimensioned Type class.
Spatial transformation functions for primitive fields.
dimensioned< tensor > dimensionedTensor
Dimensioned tensor obtained from generic dimensioned type.
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))
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
transformFieldField Spatial transformation functions for FieldField.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:42
A class for managing temporary objects.
Definition: HashPtrTable.H:50
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521