1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #ifndef DimensionedFieldReuseFunctions_H
27 #define DimensionedFieldReuseFunctions_H
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 template<class TypeR, class Type1, class GeoMesh>
37 class reuseTmpDimensionedField
41 static tmp<DimensionedField<TypeR, GeoMesh> > New
43 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,
45 const dimensionSet& dimensions
48 const DimensionedField<Type1, GeoMesh>& df1 = tdf1();
50 return tmp<DimensionedField<TypeR, GeoMesh> >
52 new DimensionedField<TypeR, GeoMesh>
66 static void clear(const tmp<DimensionedField<Type1, GeoMesh> >& tdf1)
73 template<class TypeR, class GeoMesh>
74 class reuseTmpDimensionedField<TypeR, TypeR, GeoMesh>
78 static tmp<DimensionedField<TypeR, GeoMesh> > New
80 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf1,
82 const dimensionSet& dimensions
85 DimensionedField<TypeR, GeoMesh>& df1 =
86 const_cast<DimensionedField<TypeR, GeoMesh>& >(tdf1());
91 df1.dimensions().reset(dimensions);
96 return tmp<DimensionedField<TypeR, GeoMesh> >
98 new DimensionedField<TypeR, GeoMesh>
113 static void clear(const tmp<DimensionedField<TypeR, GeoMesh> >& tdf1)
123 template<class TypeR, class Type1, class Type12, class Type2, class GeoMesh>
124 class reuseTmpTmpDimensionedField
128 static tmp<DimensionedField<TypeR, GeoMesh> > New
130 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,
131 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2,
133 const dimensionSet& dimensions
136 const DimensionedField<Type1, GeoMesh>& df1 = tdf1();
138 return tmp<DimensionedField<TypeR, GeoMesh> >
140 new DimensionedField<TypeR, GeoMesh>
156 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,
157 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2
166 template<class TypeR, class Type1, class Type12, class GeoMesh>
167 class reuseTmpTmpDimensionedField<TypeR, Type1, Type12, TypeR, GeoMesh>
171 static tmp<DimensionedField<TypeR, GeoMesh> > New
173 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,
174 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf2,
176 const dimensionSet& dimensions
179 const DimensionedField<Type1, GeoMesh>& df1 = tdf1();
180 DimensionedField<TypeR, GeoMesh>& df2 =
181 const_cast<DimensionedField<TypeR, GeoMesh>& >(tdf2());
186 df2.dimensions().reset(dimensions);
191 return tmp<DimensionedField<TypeR, GeoMesh> >
193 new DimensionedField<TypeR, GeoMesh>
210 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,
211 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf2
223 template<class TypeR, class Type2, class GeoMesh>
224 class reuseTmpTmpDimensionedField<TypeR, TypeR, TypeR, Type2, GeoMesh>
228 static tmp<DimensionedField<TypeR, GeoMesh> > New
230 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf1,
231 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2,
233 const dimensionSet& dimensions
236 DimensionedField<TypeR, GeoMesh>& df1 =
237 const_cast<DimensionedField<TypeR, GeoMesh>& >(tdf1());
242 df1.dimensions().reset(dimensions);
247 return tmp<DimensionedField<TypeR, GeoMesh> >
249 new DimensionedField<TypeR, GeoMesh>
266 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf1,
267 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2
279 template<class TypeR, class GeoMesh>
280 class reuseTmpTmpDimensionedField<TypeR, TypeR, TypeR, TypeR, GeoMesh>
284 static tmp<DimensionedField<TypeR, GeoMesh> > New
286 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf1,
287 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf2,
289 const dimensionSet& dimensions
292 DimensionedField<TypeR, GeoMesh>& df1 =
293 const_cast<DimensionedField<TypeR, GeoMesh>& >(tdf1());
294 DimensionedField<TypeR, GeoMesh>& df2 =
295 const_cast<DimensionedField<TypeR, GeoMesh>& >(tdf2());
300 df1.dimensions().reset(dimensions);
303 else if (tdf2.isTmp())
306 df2.dimensions().reset(dimensions);
311 return tmp<DimensionedField<TypeR, GeoMesh> >
313 new DimensionedField<TypeR, GeoMesh>
330 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf1,
331 const tmp<DimensionedField<TypeR, GeoMesh> >& tdf2
339 else if (tdf2.isTmp())
348 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
350 } // End namespace Foam
352 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
356 // ************************************************************************* //