1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #ifndef DimensionedFieldReuseFunctions_H
28 #define DimensionedFieldReuseFunctions_H
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 template<class TypeR, class Type1, class GeoMesh>
38 class reuseTmpDimensionedField
42 static tmp<DimensionedField<TypeR, GeoMesh> > New
44 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,
46 const dimensionSet& dimensions
49 const DimensionedField<Type1, GeoMesh>& df1 = tdf1();
51 return tmp<DimensionedField<TypeR, GeoMesh> >
53 new DimensionedField<TypeR, GeoMesh>
67 static void clear(const tmp<DimensionedField<Type1, GeoMesh> >& tdf1)
74 template<class TypeR, class GeoMesh>
75 class reuseTmpDimensionedField<TypeR, TypeR, GeoMesh>
79 static tmp<DimensionedField<TypeR, GeoMesh> > New
81 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf1,
83 const dimensionSet& dimensions
86 DimensionedField<TypeR, GeoMesh>& df1 =
87 const_cast<DimensionedField<TypeR, GeoMesh>& >(tdf1());
92 df1.dimensions().reset(dimensions);
97 return tmp<DimensionedField<TypeR, GeoMesh> >
99 new DimensionedField<TypeR, GeoMesh>
114 static void clear(const tmp<DimensionedField<TypeR, GeoMesh> >& tdf1)
124 template<class TypeR, class Type1, class Type12, class Type2, class GeoMesh>
125 class reuseTmpTmpDimensionedField
129 static tmp<DimensionedField<TypeR, GeoMesh> > New
131 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,
132 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2,
134 const dimensionSet& dimensions
137 const DimensionedField<Type1, GeoMesh>& df1 = tdf1();
139 return tmp<DimensionedField<TypeR, GeoMesh> >
141 new DimensionedField<TypeR, GeoMesh>
157 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,
158 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2
167 template<class TypeR, class Type1, class Type12, class GeoMesh>
168 class reuseTmpTmpDimensionedField<TypeR, Type1, Type12, TypeR, GeoMesh>
172 static tmp<DimensionedField<TypeR, GeoMesh> > New
174 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,
175 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf2,
177 const dimensionSet& dimensions
180 const DimensionedField<Type1, GeoMesh>& df1 = tdf1();
181 DimensionedField<TypeR, GeoMesh>& df2 =
182 const_cast<DimensionedField<TypeR, GeoMesh>& >(tdf2());
187 df2.dimensions().reset(dimensions);
192 return tmp<DimensionedField<TypeR, GeoMesh> >
194 new DimensionedField<TypeR, GeoMesh>
211 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,
212 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf2
224 template<class TypeR, class Type2, class GeoMesh>
225 class reuseTmpTmpDimensionedField<TypeR, TypeR, TypeR, Type2, GeoMesh>
229 static tmp<DimensionedField<TypeR, GeoMesh> > New
231 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf1,
232 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2,
234 const dimensionSet& dimensions
237 DimensionedField<TypeR, GeoMesh>& df1 =
238 const_cast<DimensionedField<TypeR, GeoMesh>& >(tdf1());
243 df1.dimensions().reset(dimensions);
248 return tmp<DimensionedField<TypeR, GeoMesh> >
250 new DimensionedField<TypeR, GeoMesh>
267 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf1,
268 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2
280 template<class TypeR, class GeoMesh>
281 class reuseTmpTmpDimensionedField<TypeR, TypeR, TypeR, TypeR, GeoMesh>
285 static tmp<DimensionedField<TypeR, GeoMesh> > New
287 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf1,
288 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf2,
290 const dimensionSet& dimensions
293 DimensionedField<TypeR, GeoMesh>& df1 =
294 const_cast<DimensionedField<TypeR, GeoMesh>& >(tdf1());
295 DimensionedField<TypeR, GeoMesh>& df2 =
296 const_cast<DimensionedField<TypeR, GeoMesh>& >(tdf2());
301 df1.dimensions().reset(dimensions);
304 else if (tdf2.isTmp())
307 df2.dimensions().reset(dimensions);
312 return tmp<DimensionedField<TypeR, GeoMesh> >
314 new DimensionedField<TypeR, GeoMesh>
331 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf1,
332 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf2
340 else if (tdf2.isTmp())
349 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
351 } // End namespace Foam
353 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
357 // ************************************************************************* //