Blockstructured Adaptive Mesh Refinement in object-oriented C++
00001 #ifndef _included_GridDataOps_3_h 00002 #define _included_GridDataOps_3_h 00003 00009 template <class Type> 00010 void GridData(3)<Type>::lin_interp (GridData(3)<Type> const &gd1, double const frac1, 00011 GridData(3)<Type> const &gd2, double const frac2, 00012 BBox const &where) 00013 { 00014 BBox intersection = _bbox * gd1._bbox * gd2._bbox * where; 00015 if (!intersection.empty()) 00016 { 00017 //int max_step = (_step > gd1._step) ? _step : 00018 // (gd1._step > gd2._step) ? gd1._step : gd2._step; 00019 00020 Coords max_step = _step.getmax(gd1._step); 00021 max_step.max(gd2._step); 00022 00023 GridData(3)<Type> &dst = *this; 00024 00025 BeginFastIndex3(src1, gd1._bbox, gd1._data, const Type); 00026 BeginFastIndex3(src2, gd2._bbox, gd2._data, const Type); 00027 BeginFastIndex3(dst, dst._bbox, dst._data, Type); 00028 00029 for_3(i, j, k, intersection, max_step) 00030 FastIndex3(dst,i,j,k) = (Type) ((FastIndex3(src1,i,j,k) * frac1) 00031 + (FastIndex3(src2,i,j,k) * frac2)); 00032 end_for 00033 00034 EndFastIndex3(dst); 00035 EndFastIndex3(src1); 00036 EndFastIndex3(src2); 00037 } 00038 } 00039 00040 /**************************************************************************/ 00041 00042 template <class Type> 00043 void GridData(3)<Type>::equals (Type const &val, BBox const &where) 00044 { 00045 BBox intersection = _bbox * where; 00046 if (!intersection.empty()) 00047 { 00048 Coords max_step = _step.getmax(where.stepsize()); 00049 BBox to(intersection); to.setstepsize(_step); 00050 BBox from(intersection); from.setstepsize(where.stepsize()); 00051 gd_OperateRegion(equal)(val, to, from, max_step); 00052 } 00053 } 00054 00055 template <class Type> 00056 void GridData(3)<Type>::equals (GridData(3)<Type> const &gd, BBox const &to, 00057 BBox const &from) 00058 { 00059 const Coords toshift = from.lower() - to.lower(); 00060 BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift); 00061 if (!newfrom.empty()) 00062 { 00063 BBox newto = shiftabs(newfrom, -toshift); 00064 // Coords max_step = max(_step, gd._step); 00065 Coords max_step = _step.getmax(gd._step); 00066 newto.setstepsize(_step); 00067 newfrom.setstepsize(gd._step); 00068 gd_OperateRegion(equal)(gd, newto, newfrom, max_step); 00069 } 00070 } 00071 00072 template <class Type> 00073 void GridData(3)<Type>::plus (Type const &val, BBox const &where) 00074 { 00075 BBox intersection = _bbox * where; 00076 if (!intersection.empty()) 00077 { 00078 Coords max_step = _step.getmax(where.stepsize()); 00079 BBox to(intersection); to.setstepsize(_step); 00080 BBox from(intersection); from.setstepsize(where.stepsize()); 00081 gd_OperateRegion(plus)(val, to, from, max_step); 00082 } 00083 } 00084 00085 template <class Type> 00086 void GridData(3)<Type>::plus (GridData(3)<Type> const &gd, BBox const &to, 00087 BBox const &from) 00088 { 00089 const Coords toshift = from.lower() - to.lower(); 00090 BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift); 00091 if (!newfrom.empty()) 00092 { 00093 BBox newto = shiftabs(newfrom, -toshift); 00094 Coords max_step = _step.getmax(gd._step); 00095 newto.setstepsize(_step); 00096 newfrom.setstepsize(gd._step); 00097 gd_OperateRegion(plus)(gd, newto, newfrom, max_step); 00098 } 00099 } 00100 00101 template <class Type> 00102 void GridData(3)<Type>::minus (Type const &val, BBox const &where) 00103 { 00104 BBox intersection = _bbox * where; 00105 if (!intersection.empty()) 00106 { 00107 Coords max_step = _step.getmax(where.stepsize()); 00108 BBox to(intersection); to.setstepsize(_step); 00109 BBox from(intersection); from.setstepsize(where.stepsize()); 00110 gd_OperateRegion(minus)(val, to, from, max_step); 00111 } 00112 } 00113 00114 template <class Type> 00115 void GridData(3)<Type>::minus (GridData(3)<Type> const &gd, BBox const &to, 00116 BBox const &from) 00117 { 00118 const Coords toshift = from.lower() - to.lower(); 00119 BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift); 00120 if (!newfrom.empty()) 00121 { 00122 BBox newto = shiftabs(newfrom, -toshift); 00123 Coords max_step = _step.getmax(gd._step); 00124 newto.setstepsize(_step); 00125 newfrom.setstepsize(gd._step); 00126 gd_OperateRegion(minus)(gd, newto, newfrom, max_step); 00127 } 00128 } 00129 00130 template <class Type> 00131 void GridData(3)<Type>::multiply (Type const &val, BBox const &where) 00132 { 00133 BBox intersection = _bbox * where; 00134 if (!intersection.empty()) 00135 { 00136 Coords max_step = _step.getmax(where.stepsize()); 00137 BBox to(intersection); to.setstepsize(_step); 00138 BBox from(intersection); from.setstepsize(where.stepsize()); 00139 gd_OperateRegion(mult)(val, to, from, max_step); 00140 } 00141 } 00142 00143 template <class Type> 00144 void GridData(3)<Type>::multiply (GridData(3)<Type> const &gd, BBox const &to, 00145 BBox const &from) 00146 { 00147 const Coords toshift = from.lower() - to.lower(); 00148 BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift); 00149 if (!newfrom.empty()) 00150 { 00151 BBox newto = shiftabs(newfrom, -toshift); 00152 Coords max_step = _step.getmax(gd._step); 00153 newto.setstepsize(_step); 00154 newfrom.setstepsize(gd._step); 00155 gd_OperateRegion(mult)(gd, newto, newfrom, max_step); 00156 } 00157 } 00158 00159 template <class Type> 00160 void GridData(3)<Type>::divide (Type const &val, BBox const &where) 00161 { 00162 BBox intersection = _bbox * where; 00163 if (!intersection.empty()) 00164 { 00165 Coords max_step = _step.getmax(where.stepsize()); 00166 BBox to(intersection); to.setstepsize(_step); 00167 BBox from(intersection); from.setstepsize(where.stepsize()); 00168 gd_OperateRegion(div)(val, to, from, max_step); 00169 } 00170 } 00171 00172 template <class Type> 00173 void GridData(3)<Type>::divide (GridData(3)<Type> const &gd, BBox const &to, 00174 BBox const &from) 00175 { 00176 const Coords toshift = from.lower() - to.lower(); 00177 BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift); 00178 if (!newfrom.empty()) 00179 { 00180 BBox newto = shiftabs(newfrom, -toshift); 00181 Coords max_step = _step.getmax(gd._step); 00182 newto.setstepsize(_step); 00183 newfrom.setstepsize(gd._step); 00184 gd_OperateRegion(div)(gd, newto, newfrom, max_step); 00185 } 00186 } 00187 00188 /****************************** = ***************************************/ 00189 00190 template <class Type> 00191 void GridData(3)<Type>::gd_OperateRegion(equal) (Type const &val, 00192 BBox const &to, BBox const &from, Coords const &step) 00193 { 00194 GridData(3)<Type> &dst = *this; 00195 00196 BeginFastIndex3(dst, dst._bbox, dst._data, Type); 00197 00198 for_3(i, j, k, to, step) 00199 FastIndex3(dst,i,j,k) = val; 00200 end_for 00201 00202 EndFastIndex3(dst); 00203 } 00204 00205 template <class Type> 00206 void GridData(3)<Type>::gd_OperateRegion(equal) (GridData(3)<Type> const &src, 00207 BBox const &to, BBox const &from, Coords const &step) 00208 { 00209 GridData(3)<Type> &dst = *this; 00210 const int di = from.lower(0)-to.lower(0); 00211 const int dj = from.lower(1)-to.lower(1); 00212 const int dk = from.lower(2)-to.lower(2); 00213 00214 BeginFastIndex3(src, src._bbox, src._data, const Type); 00215 BeginFastIndex3(dst, dst._bbox, dst._data, Type); 00216 00217 for_3(i, j, k, to, step) 00218 FastIndex3(dst,i,j,k) = FastIndex3(src,i+di,j+dj,k+dk); 00219 end_for 00220 00221 EndFastIndex3(dst); 00222 EndFastIndex3(src); 00223 } 00224 00225 /************************************************************************/ 00226 00227 /****************************** + ***************************************/ 00228 00229 template <class Type> 00230 void GridData(3)<Type>::gd_OperateRegion(plus)(Type const &val, 00231 BBox const &to, BBox const &from, Coords const &step) 00232 { 00233 GridData(3)<Type> &dst = *this; 00234 00235 BeginFastIndex3(dst, dst._bbox, dst._data, Type); 00236 00237 for_3(i, j, k, to, step) 00238 FastIndex3(dst,i,j,k) += val; 00239 end_for 00240 00241 EndFastIndex3(dst); 00242 } 00243 00244 template <class Type> 00245 void GridData(3)<Type>::gd_OperateRegion(plus)(GridData(3)<Type> const &src, 00246 BBox const &to, BBox const &from, Coords const &step) 00247 { 00248 GridData(3)<Type> &dst = *this; 00249 const int di = from.lower(0)-to.lower(0); 00250 const int dj = from.lower(1)-to.lower(1); 00251 const int dk = from.lower(2)-to.lower(2); 00252 00253 BeginFastIndex3(src, src._bbox, src._data, const Type); 00254 BeginFastIndex3(dst, dst._bbox, dst._data, Type); 00255 00256 for_3(i, j, k, to, step) 00257 FastIndex3(dst,i,j,k) += FastIndex3(src,i+di,j+dj,k+dk); 00258 end_for 00259 00260 EndFastIndex3(dst); 00261 EndFastIndex3(src); 00262 } 00263 00264 /************************************************************************/ 00265 00266 /****************************** - ***************************************/ 00267 00268 template <class Type> 00269 void GridData(3)<Type>::gd_OperateRegion(minus)(Type const &val, 00270 BBox const &to, BBox const &from, Coords const &step) 00271 { 00272 GridData(3)<Type> &dst = *this; 00273 00274 BeginFastIndex3(dst, dst._bbox, dst._data, Type); 00275 00276 for_3(i, j, k, to, step) 00277 FastIndex3(dst,i,j,k) -= val; 00278 end_for 00279 00280 EndFastIndex3(dst); 00281 } 00282 00283 template <class Type> 00284 void GridData(3)<Type>::gd_OperateRegion(minus)(GridData(3)<Type> const &src, 00285 BBox const &to, BBox const &from, Coords const &step) 00286 { 00287 GridData(3)<Type> &dst = *this; 00288 const int di = from.lower(0)-to.lower(0); 00289 const int dj = from.lower(1)-to.lower(1); 00290 const int dk = from.lower(2)-to.lower(2); 00291 00292 BeginFastIndex3(src, src._bbox, src._data, const Type); 00293 BeginFastIndex3(dst, dst._bbox, dst._data, Type); 00294 00295 for_3(i, j, k, to, step) 00296 FastIndex3(dst,i,j,k) -= FastIndex3(src,i+di,j+dj,k+dk); 00297 end_for 00298 00299 EndFastIndex3(dst); 00300 EndFastIndex3(src); 00301 } 00302 00303 /************************************************************************/ 00304 00305 /****************************** * ***************************************/ 00306 00307 template <class Type> 00308 void GridData(3)<Type>::gd_OperateRegion(mult)(Type const &val, 00309 BBox const &to, BBox const &from, Coords const &step) 00310 { 00311 GridData(3)<Type> &dst = *this; 00312 00313 BeginFastIndex3(dst, dst._bbox, dst._data, Type); 00314 00315 for_3(i, j, k, to, step) 00316 FastIndex3(dst,i,j,k) *= val; 00317 end_for 00318 00319 EndFastIndex3(dst); 00320 } 00321 00322 template <class Type> 00323 void GridData(3)<Type>::gd_OperateRegion(mult)(GridData(3)<Type> const &src, 00324 BBox const &to, BBox const &from, Coords const &step) 00325 { 00326 GridData(3)<Type> &dst = *this; 00327 const int di = from.lower(0)-to.lower(0); 00328 const int dj = from.lower(1)-to.lower(1); 00329 const int dk = from.lower(2)-to.lower(2); 00330 00331 BeginFastIndex3(src, src._bbox, src._data, const Type); 00332 BeginFastIndex3(dst, dst._bbox, dst._data, Type); 00333 00334 for_3(i, j, k, to, step) 00335 FastIndex3(dst,i,j,k) *= FastIndex3(src,i+di,j+dj,k+dk); 00336 end_for 00337 00338 EndFastIndex3(dst); 00339 EndFastIndex3(src); 00340 } 00341 00342 /************************************************************************/ 00343 00344 /****************************** / ***************************************/ 00345 00346 template <class Type> 00347 void GridData(3)<Type>::gd_OperateRegion(div)(Type const &val, 00348 BBox const &to, BBox const &from, Coords const &step) 00349 { 00350 assert (val != (Type)0); 00351 GridData(3)<Type> &dst = *this; 00352 00353 BeginFastIndex3(dst, dst._bbox, dst._data, Type); 00354 00355 for_3(i, j, k, to, step) 00356 FastIndex3(dst,i,j,k) /= val; 00357 end_for 00358 00359 EndFastIndex3(dst); 00360 } 00361 00362 template <class Type> 00363 void GridData(3)<Type>::gd_OperateRegion(div)(GridData(3)<Type> const &src, 00364 BBox const &to, BBox const &from, Coords const &step) 00365 { 00366 GridData(3)<Type> &dst = *this; 00367 const int di = from.lower(0)-to.lower(0); 00368 const int dj = from.lower(1)-to.lower(1); 00369 const int dk = from.lower(2)-to.lower(2); 00370 00371 BeginFastIndex3(src, src._bbox, src._data, const Type); 00372 BeginFastIndex3(dst, dst._bbox, dst._data, Type); 00373 00374 for_3(i, j, k, to, step) 00375 FastIndex3(dst,i,j,k) /= FastIndex3(src,i+di,j+dj,k+dk); 00376 end_for 00377 00378 EndFastIndex3(dst); 00379 EndFastIndex3(src); 00380 } 00381 /************************************************************************/ 00382 00383 #endif
Quickstart Users Guide Programmers Reference Installation Examples Download
AMROC Main Home Contactlast update: 06/01/04