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 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 (
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 {
93  auto tresult = tmp<GeometricField<Type, PatchField, GeoMesh>>::New
94  (
95  IOobject
96  (
97  "transform(" + rot.name() + ',' + fld.name() + ')',
98  fld.instance(),
99  fld.db(),
100  IOobject::NO_READ,
101  IOobject::NO_WRITE
102  ),
103  fld.mesh(),
104  fld.dimensions()
105  );
106 
107  transform(tresult.ref(), rot, fld);
108 
109  return tresult;
110 }
111 
112 
113 template<class Type, template<class> class PatchField, class GeoMesh>
116 (
117  const GeometricField<tensor, PatchField, GeoMesh>& rot,
118  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld
119 )
120 {
121  auto tresult = transform(rot, tfld());
122  tfld.clear();
123  return tresult;
124 }
125 
126 
127 template<class Type, template<class> class PatchField, class GeoMesh>
130 (
131  const tmp<GeometricField<tensor, PatchField, GeoMesh>>& trot,
132  const GeometricField<Type, PatchField, GeoMesh>& fld
133 )
134 {
135  auto tresult = transform(trot(), fld);
136  trot.clear();
137  return tresult;
138 }
139 
140 
141 template<class Type, template<class> class PatchField, class GeoMesh>
144 (
145  const tmp<GeometricField<tensor, PatchField, GeoMesh>>& trot,
146  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld
147 )
148 {
149  auto tresult = transform(trot(), tfld());
150  tfld.clear();
151  trot.clear();
152  return tresult;
153 }
154 
155 
156 template<class Type, template<class> class PatchField, class GeoMesh>
159 (
160  const dimensionedTensor& rot,
161  const GeometricField<Type, PatchField, GeoMesh>& fld
162 )
163 {
164  auto tresult = tmp<GeometricField<Type, PatchField, GeoMesh>>::New
165  (
166  IOobject
167  (
168  "transform(" + rot.name() + ',' + fld.name() + ')',
169  fld.instance(),
170  fld.db(),
171  IOobject::NO_READ,
172  IOobject::NO_WRITE
173  ),
174  fld.mesh(),
175  fld.dimensions()
176  );
177 
178  transform(tresult.ref(), rot, fld);
179 
180  return tresult;
181 }
182 
183 
184 template<class Type, template<class> class PatchField, class GeoMesh>
187 (
188  const dimensionedTensor& rot,
189  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld
190 )
191 {
192  auto tresult = transform(rot, tfld());
193  tfld.clear();
194  return tresult;
195 }
196 
197 
198 // * * * * * * * * * * * invTransform Global Functions * * * * * * * * * * * //
199 
200 template<class Type, template<class> class PatchField, class GeoMesh>
202 (
204  const dimensionedTensor& rot,
206 )
207 {
209  (
210  result.primitiveFieldRef(),
211  rot.value(),
212  fld.primitiveField()
213  );
215  (
216  result.boundaryFieldRef(),
217  rot.value(),
218  fld.boundaryField()
219  );
220 }
221 
222 
223 template<class Type, template<class> class PatchField, class GeoMesh>
225 (
229 )
230 {
232  (
233  result.primitiveFieldRef(),
234  rot.primitiveField(),
235  fld.primitiveField()
236  );
238  (
239  result.boundaryFieldRef(),
240  rot.boundaryField(),
241  fld.boundaryField()
242  );
243 }
244 
245 
246 template<class Type, template<class> class PatchField, class GeoMesh>
249 (
250  const GeometricField<tensor, PatchField, GeoMesh>& rot,
251  const GeometricField<Type, PatchField, GeoMesh>& fld
252 )
253 {
254  auto tresult = tmp<GeometricField<Type, PatchField, GeoMesh>>::New
255  (
256  IOobject
257  (
258  "invTransform(" + rot.name() + ',' + fld.name() + ')',
259  fld.instance(),
260  fld.db(),
261  IOobject::NO_READ,
262  IOobject::NO_WRITE
263  ),
264  fld.mesh(),
265  fld.dimensions()
266  );
267 
268  invTransform(tresult.ref(), rot, fld);
269 
270  return tresult;
271 }
272 
273 
274 template<class Type, template<class> class PatchField, class GeoMesh>
277 (
278  const GeometricField<tensor, PatchField, GeoMesh>& rot,
279  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld
280 )
281 {
282  auto tresult = invTransform(rot, tfld());
283  tfld.clear();
284  return tresult;
285 }
286 
287 
288 template<class Type, template<class> class PatchField, class GeoMesh>
291 (
292  const tmp<GeometricField<tensor, PatchField, GeoMesh>>& trot,
293  const GeometricField<Type, PatchField, GeoMesh>& fld
294 )
295 {
296  auto tresult = invTransform(trot(), fld);
297  trot.clear();
298  return tresult;
299 }
300 
301 
302 template<class Type, template<class> class PatchField, class GeoMesh>
305 (
306  const tmp<GeometricField<tensor, PatchField, GeoMesh>>& trot,
307  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld
308 )
309 {
310  auto tresult = invTransform(trot(), tfld());
311  tfld.clear();
312  trot.clear();
313  return tresult;
314 }
315 
316 
317 template<class Type, template<class> class PatchField, class GeoMesh>
320 (
321  const dimensionedTensor& rot,
322  const GeometricField<Type, PatchField, GeoMesh>& fld
323 )
324 {
325  auto tresult = tmp<GeometricField<Type, PatchField, GeoMesh>>::New
326  (
327  IOobject
328  (
329  "invTransform(" + rot.name() + ',' + fld.name() + ')',
330  fld.instance(),
331  fld.db(),
332  IOobject::NO_READ,
333  IOobject::NO_WRITE
334  ),
335  fld.mesh(),
336  fld.dimensions()
337  );
338 
339  invTransform(tresult.ref(), rot, fld);
340 
341  return tresult;
342 }
343 
344 
345 template<class Type, template<class> class PatchField, class GeoMesh>
348 (
349  const dimensionedTensor& rot,
350  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld
351 )
352 {
353  auto tresult = invTransform(rot, tfld());
354  tfld.clear();
355  return tresult;
356 }
357 
358 
359 // ************************************************************************* //
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
transformGeometricField.H
Spatial transformation functions for GeometricField.
Foam::GeometricField::primitiveField
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
Definition: GeometricFieldI.H:53
Foam::dimensioned::value
const Type & value() const
Return const reference to value.
Definition: dimensionedType.C:434
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521
transformField.H
Spatial transformation functions for primitive fields.
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::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:42
Foam::GeometricField::primitiveFieldRef
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Definition: GeometricField.C:766
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
GeometricField.H
Foam::GeometricField::boundaryFieldRef
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
Definition: GeometricField.C:783
Foam::invTransform
dimensionSet invTransform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:527
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::dimensionedTensor
dimensioned< tensor > dimensionedTensor
Dimensioned tensor obtained from generic dimensioned type.
Definition: dimensionedTensor.H:52
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62