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