transformFieldTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "transformField.H"
27 #include "FieldM.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * * * global functions * * * * * * * * * * * * * //
35 
36 template<class Type>
37 List<Type> transform(const tensor& t, const UList<Type>& list)
38 {
39  List<Type> newList(list.size());
40 
41  forAll(list, i)
42  {
43  newList[i] = transform(t, list[i]);
44  }
45 
46  return newList;
47 }
48 
49 
50 template<class Type>
51 void transform
52 (
53  Field<Type>& rtf,
54  const tensorField& trf,
55  const Field<Type>& tf
56 )
57 {
58  if (trf.size() == 1)
59  {
60  return transform(rtf, trf[0], tf);
61  }
62  else
63  {
65  (
66  Type, rtf, =, transform, tensor, trf, Type, tf
67  )
68  }
69 }
70 
71 
72 template<class Type>
74 (
75  const tensorField& trf,
76  const Field<Type>& tf
77 )
78 {
79  tmp<Field<Type>> tranf(new Field<Type> (tf.size()));
80  transform(tranf.ref(), trf, tf);
81  return tranf;
82 }
83 
84 
85 template<class Type>
87 (
88  const tensorField& trf,
89  const tmp<Field<Type>>& ttf
90 )
91 {
92  tmp<Field<Type>> tranf = New(ttf);
93  transform(tranf.ref(), trf, ttf());
94  ttf.clear();
95  return tranf;
96 }
97 
98 
99 template<class Type>
101 (
102  const tmp<tensorField>& ttrf,
103  const Field<Type>& tf
104 )
105 {
106  tmp<Field<Type>> tranf(new Field<Type> (tf.size()));
107  transform(tranf.ref(), ttrf(), tf);
108  ttrf.clear();
109  return tranf;
110 }
111 
112 
113 template<class Type>
115 (
116  const tmp<tensorField>& ttrf,
117  const tmp<Field<Type>>& ttf
118 )
119 {
120  tmp<Field<Type>> tranf = New(ttf);
121  transform(tranf.ref(), ttrf(), ttf());
122  ttf.clear();
123  ttrf.clear();
124  return tranf;
125 }
126 
127 
128 template<class Type>
129 void transform
130 (
131  Field<Type>& rtf,
132  const tensor& t,
133  const Field<Type>& tf
134 )
135 {
136  TFOR_ALL_F_OP_FUNC_S_F(Type, rtf, =, transform, tensor, t, Type, tf)
137 }
138 
139 
140 template<class Type>
142 (
143  const tensor& t,
144  const Field<Type>& tf
145 )
146 {
147  tmp<Field<Type>> tranf(new Field<Type>(tf.size()));
148  transform(tranf.ref(), t, tf);
149  return tranf;
150 }
151 
152 
153 template<class Type>
155 (
156  const tensor& t,
157  const tmp<Field<Type>>& ttf
158 )
159 {
160  tmp<Field<Type>> tranf = New(ttf);
161  transform(tranf.ref(), t, ttf());
162  ttf.clear();
163  return tranf;
164 }
165 
166 
167 template<class Type1, class Type2>
169 {
170  return f;
171 }
172 
173 template<class Type1, class Type2>
175 {
176  return tmp<Field<Type1>>(tf.ptr());
177 }
178 
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 } // End namespace Foam
183 
184 // ************************************************************************* //
#define TFOR_ALL_F_OP_FUNC_F_F(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3)
Definition: FieldM.H:144
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
void clear() const
If object pointer points to valid object:
Definition: tmpI.H:237
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
const tensorField & tf
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Spatial transformation functions for primitive fields.
Pre-declare SubField and related Field type.
Definition: Field.H:56
labelList f(nPoints)
tmp< Field< Type1 > > transformFieldMask(const Field< Type2 > &)
#define TFOR_ALL_F_OP_FUNC_S_F(typeF1, f1, OP, FUNC, typeS, s, typeF2, f2)
Definition: FieldM.H:210
A class for managing temporary objects.
Definition: PtrList.H:53
label size() const
Return the number of elements in the UList.
Definition: UListI.H:311
High performance macro functions for Field<Type> algebra. These expand using either array element acc...
Namespace for OpenFOAM.
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:477