Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
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
27\*---------------------------------------------------------------------------*/
29#include "transformField.H"
30#include "FieldM.H"
31
32// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
33
34template<class Type>
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
50template<class Type>
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
71template<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
85template<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
100template<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
115template<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
131template<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
145template<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
160template<class Type>
162(
163 Field<Type>& result,
164 const tensor& rot,
165 const Field<Type>& fld
166)
167{
168 // std::transform
171 Type, result, =, invTransform, tensor, rot, Type, fld
172 );
173}
174
175
176template<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
197template<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
211template<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
226template<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
241template<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
257template<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
271template<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
286template<class Type1, class Type2>
288Foam::transformFieldMask(const Field<Type2>& fld)
289{
290 return fld;
291}
292
293template<class Type1, class Type2>
295Foam::transformFieldMask(const tmp<Field<Type2>>& tfld)
296{
297 return tmp<Field<Type1>>(tfld.ptr());
298}
299
300
301// ************************************************************************* //
Declaration macros for Field<Type> algebra.
#define TFOR_ALL_F_OP_FUNC_F_F(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3)
Definition FieldM.H:192
#define TFOR_ALL_F_OP_FUNC_S_F(typeF1, f1, OP, FUNC, typeS, s, typeF2, f2)
Definition FieldM.H:277
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 templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
T & front()
Access first element of the list, position [0].
Definition UListI.H:239
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
Tensor of scalars, i.e. Tensor<scalar>.
A class for managing temporary objects.
Definition tmp.H:75
dimensionSet invTransform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
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)
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
Tensor< scalar > tensor
Definition symmTensor.H:57
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
Spatial transformation functions for primitive fields.