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 FieldReuseFunctions_H
00028 #define FieldReuseFunctions_H
00029
00030
00031
00032 namespace Foam
00033 {
00034
00035
00036
00037 template<class TypeR, class Type1>
00038 class reuseTmp
00039 {
00040 public:
00041
00042 static tmp<Field<TypeR> > New(const tmp<Field<Type1> >& tf1)
00043 {
00044 return tmp<Field<TypeR> >(new Field<TypeR>(tf1().size()));
00045 }
00046
00047 static void clear(const tmp<Field<Type1> >& tf1)
00048 {
00049 tf1.clear();
00050 }
00051 };
00052
00053
00054 template<class TypeR>
00055 class reuseTmp<TypeR, TypeR>
00056 {
00057 public:
00058
00059 static tmp<Field<TypeR> > New(const tmp<Field<TypeR> >& tf1)
00060 {
00061 if (tf1.isTmp())
00062 {
00063 return tf1;
00064 }
00065 else
00066 {
00067 return tmp<Field<TypeR> >(new Field<TypeR>(tf1().size()));
00068 }
00069 }
00070
00071 static void clear(const tmp<Field<TypeR> >& tf1)
00072 {
00073 if (tf1.isTmp())
00074 {
00075 tf1.ptr();
00076 }
00077 }
00078 };
00079
00080
00081 template<class TypeR, class Type1, class Type12, class Type2>
00082 class reuseTmpTmp
00083 {
00084 public:
00085
00086 static tmp<Field<TypeR> > New
00087 (
00088 const tmp<Field<Type1> >& tf1,
00089 const tmp<Field<Type2> >& tf2
00090 )
00091 {
00092 return tmp<Field<TypeR> >(new Field<TypeR>(tf1().size()));
00093 }
00094
00095 static void clear
00096 (
00097 const tmp<Field<Type1> >& tf1,
00098 const tmp<Field<Type2> >& tf2
00099 )
00100 {
00101 tf1.clear();
00102 tf2.clear();
00103 }
00104 };
00105
00106
00107 template<class TypeR, class Type1, class Type12>
00108 class reuseTmpTmp<TypeR, Type1, Type12, TypeR>
00109 {
00110 public:
00111
00112 static tmp<Field<TypeR> > New
00113 (
00114 const tmp<Field<Type1> >& tf1,
00115 const tmp<Field<TypeR> >& tf2
00116 )
00117 {
00118 if (tf2.isTmp())
00119 {
00120 return tf2;
00121 }
00122 else
00123 {
00124 return tmp<Field<TypeR> >(new Field<TypeR>(tf1().size()));
00125 }
00126 }
00127
00128 static void clear
00129 (
00130 const tmp<Field<Type1> >& tf1,
00131 const tmp<Field<TypeR> >& tf2
00132 )
00133 {
00134 tf1.clear();
00135 if (tf2.isTmp())
00136 {
00137 tf2.ptr();
00138 }
00139 }
00140 };
00141
00142
00143 template<class TypeR, class Type2>
00144 class reuseTmpTmp<TypeR, TypeR, TypeR, Type2>
00145 {
00146 public:
00147
00148 static tmp<Field<TypeR> > New
00149 (
00150 const tmp<Field<TypeR> >& tf1,
00151 const tmp<Field<Type2> >& tf2
00152 )
00153 {
00154 if (tf1.isTmp())
00155 {
00156 return tf1;
00157 }
00158 else
00159 {
00160 return tmp<Field<TypeR> >(new Field<TypeR>(tf1().size()));
00161 }
00162 }
00163
00164 static void clear
00165 (
00166 const tmp<Field<TypeR> >& tf1,
00167 const tmp<Field<Type2> >& tf2
00168 )
00169 {
00170 if (tf1.isTmp())
00171 {
00172 tf1.ptr();
00173 }
00174 tf2.clear();
00175 }
00176 };
00177
00178
00179 template<class TypeR>
00180 class reuseTmpTmp<TypeR, TypeR, TypeR, TypeR>
00181 {
00182 public:
00183
00184 static tmp<Field<TypeR> > New
00185 (
00186 const tmp<Field<TypeR> >& tf1,
00187 const tmp<Field<TypeR> >& tf2
00188 )
00189 {
00190 if (tf1.isTmp())
00191 {
00192 return tf1;
00193 }
00194 else if (tf2.isTmp())
00195 {
00196 return tf2;
00197 }
00198 else
00199 {
00200 return tmp<Field<TypeR> >(new Field<TypeR>(tf1().size()));
00201 }
00202 }
00203
00204 static void clear
00205 (
00206 const tmp<Field<TypeR> >& tf1,
00207 const tmp<Field<TypeR> >& tf2
00208 )
00209 {
00210 if (tf1.isTmp())
00211 {
00212 tf1.ptr();
00213 tf2.clear();
00214 }
00215 else if (tf2.isTmp())
00216 {
00217 tf1.clear();
00218 tf2.ptr();
00219 }
00220 }
00221 };
00222
00223
00224
00225
00226 }
00227
00228
00229
00230 #endif
00231
00232
Copyright © 2000-2007 OpenCFD Ltd