00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef GeometricFieldReuseFunctions_H
00028 #define GeometricFieldReuseFunctions_H
00029
00030
00031
00032 namespace Foam
00033 {
00034
00035
00036
00037 template
00038 <
00039 class TypeR,
00040 class Type1,
00041 template<class> class PatchField,
00042 class GeoMesh
00043 >
00044 class reuseTmpGeometricField
00045 {
00046 public:
00047
00048 static tmp<GeometricField<TypeR, PatchField, GeoMesh> > New
00049 (
00050 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tdf1,
00051 const word& name,
00052 const dimensionSet& dimensions
00053 )
00054 {
00055 const GeometricField<Type1, PatchField, GeoMesh>& df1 = tdf1();
00056
00057 return tmp<GeometricField<TypeR, PatchField, GeoMesh> >
00058 (
00059 new GeometricField<TypeR, PatchField, GeoMesh>
00060 (
00061 IOobject
00062 (
00063 name,
00064 df1.instance(),
00065 df1.db()
00066 ),
00067 df1.mesh(),
00068 dimensions
00069 )
00070 );
00071 }
00072
00073 static void clear
00074 (
00075 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tdf1
00076 )
00077 {
00078 tdf1.clear();
00079 }
00080 };
00081
00082
00083 template<class TypeR, template<class> class PatchField, class GeoMesh>
00084 class reuseTmpGeometricField<TypeR, TypeR, PatchField, GeoMesh>
00085 {
00086 public:
00087
00088 static tmp<GeometricField<TypeR, PatchField, GeoMesh> > New
00089 (
00090 const tmp<GeometricField<TypeR, PatchField, GeoMesh> >& tdf1,
00091 const word& name,
00092 const dimensionSet& dimensions
00093 )
00094 {
00095 GeometricField<TypeR, PatchField, GeoMesh>& df1 =
00096 const_cast<GeometricField<TypeR, PatchField, GeoMesh>& >(tdf1());
00097
00098 if (tdf1.isTmp())
00099 {
00100 df1.rename(name);
00101 df1.dimensions().reset(dimensions);
00102 return tdf1;
00103 }
00104 else
00105 {
00106 return tmp<GeometricField<TypeR, PatchField, GeoMesh> >
00107 (
00108 new GeometricField<TypeR, PatchField, GeoMesh>
00109 (
00110 IOobject
00111 (
00112 name,
00113 df1.instance(),
00114 df1.db()
00115 ),
00116 df1.mesh(),
00117 dimensions
00118 )
00119 );
00120 }
00121 }
00122
00123 static void clear
00124 (
00125 const tmp<GeometricField<TypeR, PatchField, GeoMesh> >& tdf1
00126 )
00127 {
00128 if (tdf1.isTmp())
00129 {
00130 tdf1.ptr();
00131 }
00132 }
00133 };
00134
00135
00136 template
00137 <
00138 class TypeR,
00139 class Type1,
00140 class Type12,
00141 class Type2,
00142 template<class> class PatchField,
00143 class GeoMesh
00144 >
00145 class reuseTmpTmpGeometricField
00146 {
00147 public:
00148
00149 static tmp<GeometricField<TypeR, PatchField, GeoMesh> > New
00150 (
00151 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tdf1,
00152 const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tdf2,
00153 const word& name,
00154 const dimensionSet& dimensions
00155 )
00156 {
00157 const GeometricField<Type1, PatchField, GeoMesh>& df1 = tdf1();
00158
00159 return tmp<GeometricField<TypeR, PatchField, GeoMesh> >
00160 (
00161 new GeometricField<TypeR, PatchField, GeoMesh>
00162 (
00163 IOobject
00164 (
00165 name,
00166 df1.instance(),
00167 df1.db()
00168 ),
00169 df1.mesh(),
00170 dimensions
00171 )
00172 );
00173 }
00174
00175 static void clear
00176 (
00177 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tdf1,
00178 const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tdf2
00179 )
00180 {
00181 tdf1.clear();
00182 tdf2.clear();
00183 }
00184 };
00185
00186
00187 template
00188 <
00189 class TypeR,
00190 class Type1,
00191 class Type12,
00192 template<class> class PatchField,
00193 class GeoMesh
00194 >
00195 class reuseTmpTmpGeometricField
00196 <TypeR, Type1, Type12, TypeR, PatchField, GeoMesh>
00197 {
00198 public:
00199
00200 static tmp<GeometricField<TypeR, PatchField, GeoMesh> > New
00201 (
00202 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tdf1,
00203 const tmp<GeometricField<TypeR, PatchField, GeoMesh> >& tdf2,
00204 const word& name,
00205 const dimensionSet& dimensions
00206 )
00207 {
00208 const GeometricField<Type1, PatchField, GeoMesh>& df1 = tdf1();
00209 GeometricField<TypeR, PatchField, GeoMesh>& df2 =
00210 const_cast<GeometricField<TypeR, PatchField, GeoMesh>& >(tdf2());
00211
00212 if (tdf2.isTmp())
00213 {
00214 df2.rename(name);
00215 df2.dimensions().reset(dimensions);
00216 return tdf2;
00217 }
00218 else
00219 {
00220 return tmp<GeometricField<TypeR, PatchField, GeoMesh> >
00221 (
00222 new GeometricField<TypeR, PatchField, GeoMesh>
00223 (
00224 IOobject
00225 (
00226 name,
00227 df1.instance(),
00228 df1.db()
00229 ),
00230 df1.mesh(),
00231 dimensions
00232 )
00233 );
00234 }
00235 }
00236
00237 static void clear
00238 (
00239 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tdf1,
00240 const tmp<GeometricField<TypeR, PatchField, GeoMesh> >& tdf2
00241 )
00242 {
00243 tdf1.clear();
00244 if (tdf2.isTmp())
00245 {
00246 tdf2.ptr();
00247 }
00248 }
00249 };
00250
00251
00252 template
00253 <
00254 class TypeR,
00255 class Type2,
00256 template<class> class PatchField,
00257 class GeoMesh
00258 >
00259 class reuseTmpTmpGeometricField<TypeR, TypeR, TypeR, Type2, PatchField, GeoMesh>
00260 {
00261 public:
00262
00263 static tmp<GeometricField<TypeR, PatchField, GeoMesh> > New
00264 (
00265 const tmp<GeometricField<TypeR, PatchField, GeoMesh> >& tdf1,
00266 const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tdf2,
00267 const word& name,
00268 const dimensionSet& dimensions
00269 )
00270 {
00271 GeometricField<TypeR, PatchField, GeoMesh>& df1 =
00272 const_cast<GeometricField<TypeR, PatchField, GeoMesh>& >(tdf1());
00273
00274 if (tdf1.isTmp())
00275 {
00276 df1.rename(name);
00277 df1.dimensions().reset(dimensions);
00278 return tdf1;
00279 }
00280 else
00281 {
00282 return tmp<GeometricField<TypeR, PatchField, GeoMesh> >
00283 (
00284 new GeometricField<TypeR, PatchField, GeoMesh>
00285 (
00286 IOobject
00287 (
00288 name,
00289 df1.instance(),
00290 df1.db()
00291 ),
00292 df1.mesh(),
00293 dimensions
00294 )
00295 );
00296 }
00297 }
00298
00299 static void clear
00300 (
00301 const tmp<GeometricField<TypeR, PatchField, GeoMesh> >& tdf1,
00302 const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tdf2
00303 )
00304 {
00305 if (tdf1.isTmp())
00306 {
00307 tdf1.ptr();
00308 }
00309 tdf2.clear();
00310 }
00311 };
00312
00313
00314 template<class TypeR, template<class> class PatchField, class GeoMesh>
00315 class reuseTmpTmpGeometricField<TypeR, TypeR, TypeR, TypeR, PatchField, GeoMesh>
00316 {
00317 public:
00318
00319 static tmp<GeometricField<TypeR, PatchField, GeoMesh> > New
00320 (
00321 const tmp<GeometricField<TypeR, PatchField, GeoMesh> >& tdf1,
00322 const tmp<GeometricField<TypeR, PatchField, GeoMesh> >& tdf2,
00323 const word& name,
00324 const dimensionSet& dimensions
00325 )
00326 {
00327 GeometricField<TypeR, PatchField, GeoMesh>& df1 =
00328 const_cast<GeometricField<TypeR, PatchField, GeoMesh>& >(tdf1());
00329 GeometricField<TypeR, PatchField, GeoMesh>& df2 =
00330 const_cast<GeometricField<TypeR, PatchField, GeoMesh>& >(tdf2());
00331
00332 if (tdf1.isTmp())
00333 {
00334 df1.rename(name);
00335 df1.dimensions().reset(dimensions);
00336 return tdf1;
00337 }
00338 else if (tdf2.isTmp())
00339 {
00340 df2.rename(name);
00341 df2.dimensions().reset(dimensions);
00342 return tdf2;
00343 }
00344 else
00345 {
00346 return tmp<GeometricField<TypeR, PatchField, GeoMesh> >
00347 (
00348 new GeometricField<TypeR, PatchField, GeoMesh>
00349 (
00350 IOobject
00351 (
00352 name,
00353 df1.instance(),
00354 df1.db()
00355 ),
00356 df1.mesh(),
00357 dimensions
00358 )
00359 );
00360 }
00361 }
00362
00363 static void clear
00364 (
00365 const tmp<GeometricField<TypeR, PatchField, GeoMesh> >& tdf1,
00366 const tmp<GeometricField<TypeR, PatchField, GeoMesh> >& tdf2
00367 )
00368 {
00369 if (tdf1.isTmp())
00370 {
00371 tdf1.ptr();
00372 tdf2.clear();
00373 }
00374 else if (tdf2.isTmp())
00375 {
00376 tdf1.clear();
00377 tdf2.ptr();
00378 }
00379 }
00380 };
00381
00382
00383
00384
00385 }
00386
00387
00388
00389 #endif
00390
00391