DimensionedFieldReuseFunctions.H
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-2019 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\*---------------------------------------------------------------------------*/
28
29#ifndef DimensionedFieldReuseFunctions_H
30#define DimensionedFieldReuseFunctions_H
31
32// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33
34namespace Foam
35{
36
37// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38
39template<class TypeR, class Type1, class GeoMesh>
41{
43 (
45 const word& name,
46 const dimensionSet& dimensions
47 )
48 {
49 const auto& df1 = tdf1();
50
52 (
54 (
55 name,
56 df1.instance(),
57 df1.db()
58 ),
59 df1.mesh(),
60 dimensions
61 );
62 }
63};
64
65
66template<class TypeR, class GeoMesh>
67struct reuseTmpDimensionedField<TypeR, TypeR, GeoMesh>
68{
70 (
72 const word& name,
73 const dimensionSet& dimensions
74 )
75 {
76 if (tdf1.isTmp())
77 {
78 auto& df1 = tdf1.constCast();
79
80 df1.rename(name);
81 df1.dimensions().reset(dimensions);
82 return tdf1;
83 }
84
85 const auto& df1 = tdf1();
86
88 (
90 (
91 name,
92 df1.instance(),
93 df1.db()
94 ),
95 df1.mesh(),
96 dimensions
97 );
98 }
99};
100
101
102//- Global function forwards to reuseTmpDimensionedField::New
103template<class TypeR, class GeoMesh>
105(
107 const word& name,
108 const dimensionSet& dimensions
109)
110{
112 (
113 tdf1,
114 name,
115 dimensions
116 );
117}
118
119
120template<class TypeR, class Type1, class Type12, class Type2, class GeoMesh>
122{
124 (
127 const word& name,
128 const dimensionSet& dimensions
129 )
130 {
131 const auto& df1 = tdf1();
132
134 (
136 (
137 name,
138 df1.instance(),
139 df1.db()
140 ),
141 df1.mesh(),
142 dimensions
143 );
144 }
145};
146
147
148template<class TypeR, class Type1, class Type12, class GeoMesh>
149struct reuseTmpTmpDimensionedField<TypeR, Type1, Type12, TypeR, GeoMesh>
150{
152 (
155 const word& name,
156 const dimensionSet& dimensions
157 )
158 {
159 if (tdf2.isTmp())
160 {
161 auto& df2 = tdf2.constCast();
162
163 df2.rename(name);
164 df2.dimensions().reset(dimensions);
165 return tdf2;
166 }
167
168 const auto& df1 = tdf1();
169
171 (
173 (
174 name,
175 df1.instance(),
176 df1.db()
177 ),
178 df1.mesh(),
179 dimensions
180 );
181 }
182};
183
184
185template<class TypeR, class Type2, class GeoMesh>
186struct reuseTmpTmpDimensionedField<TypeR, TypeR, TypeR, Type2, GeoMesh>
187{
189 (
192 const word& name,
193 const dimensionSet& dimensions
194 )
195 {
196 if (tdf1.isTmp())
197 {
198 auto& df1 = tdf1.constCast();
199
200 df1.rename(name);
201 df1.dimensions().reset(dimensions);
202 return tdf1;
203 }
204
205 const auto& df1 = tdf1();
206
208 (
210 (
211 name,
212 df1.instance(),
213 df1.db()
214 ),
215 df1.mesh(),
216 dimensions
217 );
218 }
219};
220
221
222template<class TypeR, class GeoMesh>
223struct reuseTmpTmpDimensionedField<TypeR, TypeR, TypeR, TypeR, GeoMesh>
224{
226 (
229 const word& name,
230 const dimensionSet& dimensions
231 )
232 {
233 if (tdf1.isTmp())
234 {
235 auto& df1 = tdf1.constCast();
236
237 df1.rename(name);
238 df1.dimensions().reset(dimensions);
239 return tdf1;
240 }
241 else if (tdf2.isTmp())
242 {
243 auto& df2 = tdf2.constCast();
244
245 df2.rename(name);
246 df2.dimensions().reset(dimensions);
247 return tdf2;
248 }
249
250 const auto& df1 = tdf1();
251
253 (
255 (
256 name,
257 df1.instance(),
258 df1.db()
259 ),
260 df1.mesh(),
261 dimensions
262 );
263 }
264};
265
266
267// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268
269} // End namespace Foam
270
271// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272
273#endif
274
275// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:49
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:109
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
Namespace for OpenFOAM.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
static tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
static tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< Type1, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
static tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< Type1, GeoMesh > > &tdf1, const tmp< DimensionedField< TypeR, GeoMesh > > &tdf2, const word &name, const dimensionSet &dimensions)
static tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const tmp< DimensionedField< Type2, GeoMesh > > &tdf2, const word &name, const dimensionSet &dimensions)
static tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const tmp< DimensionedField< TypeR, GeoMesh > > &tdf2, const word &name, const dimensionSet &dimensions)
static tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< Type1, GeoMesh > > &tdf1, const tmp< DimensionedField< Type2, GeoMesh > > &tdf2, const word &name, const dimensionSet &dimensions)