Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
11License
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
27Description
28 Spatial transformation functions for FieldFields.
29
30\*---------------------------------------------------------------------------*/
31
33#include "transformField.H"
35#include "GeometricField.H"
36
37// * * * * * * * * * * * * Transform Global Functions * * * * * * * * * * * //
38
39template<class Type, template<class> class PatchField, class GeoMesh>
41(
43 const dimensionedTensor& rot,
45)
46{
48 (
49 result.primitiveFieldRef(),
50 rot.value(),
51 fld.primitiveField()
52 );
54 (
55 result.boundaryFieldRef(),
56 rot.value(),
57 fld.boundaryField()
58 );
59}
60
61
62template<class Type, template<class> class PatchField, class GeoMesh>
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
85template<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 = GeometricField<Type, PatchField, GeoMesh>::New
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
106template<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
120template<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
134template<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
149template<class Type, template<class> class PatchField, class GeoMesh>
152(
153 const dimensionedTensor& rot,
154 const GeometricField<Type, PatchField, GeoMesh>& fld
155)
156{
157 auto tresult = GeometricField<Type, PatchField, GeoMesh>::New
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
170template<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;
182
183
184// * * * * * * * * * * * invTransform Global Functions * * * * * * * * * * * //
185
186template<class Type, template<class> class PatchField, class GeoMesh>
188(
189 GeometricField<Type, PatchField, GeoMesh>& result,
190 const dimensionedTensor& rot,
191 const GeometricField<Type, PatchField, GeoMesh>& fld
192)
193{
194 invTransform
195 (
196 result.primitiveFieldRef(),
197 rot.value(),
198 fld.primitiveField()
199 );
200 invTransform
201 (
202 result.boundaryFieldRef(),
203 rot.value(),
204 fld.boundaryField()
205 );
206}
207
208
209template<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{
217 invTransform
218 (
219 result.primitiveFieldRef(),
220 rot.primitiveField(),
221 fld.primitiveField()
222 );
223 invTransform
224 (
225 result.boundaryFieldRef(),
226 rot.boundaryField(),
227 fld.boundaryField()
228 );
229}
230
231
232template<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{
240 auto tresult = GeometricField<Type, PatchField, GeoMesh>::New
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
253template<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
267template<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
281template<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
296template<class Type, template<class> class PatchField, class GeoMesh>
299(
300 const dimensionedTensor& rot,
301 const GeometricField<Type, PatchField, GeoMesh>& fld
302)
303{
304 auto tresult = GeometricField<Type, PatchField, GeoMesh>::New
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
317template<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// ************************************************************************* //
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition GeoMesh.H:46
Generic GeometricField class.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
const Type & value() const noexcept
Return const reference to value.
A class for managing temporary objects.
Definition tmp.H:75
dimensionSet invTransform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
dimensioned< tensor > dimensionedTensor
Dimensioned tensor obtained from generic dimensioned type.
transformFieldField Spatial transformation functions for FieldField.
Spatial transformation functions for primitive fields.
Spatial transformation functions for GeometricField.